/* Owner reports demo
   Glass layers (Apple) + large-title, grouped-list and thumb-reach patterns (One UI).
   Light theme only for the demo. */

:root {
  color-scheme: light;

  /* Base palette */
  --sky: #e9f1f9;
  --mist: #f4f2ee;
  --ridge: #8ea6bf;
  --ink: #132131;
  --ink-2: #556373;
  --ink-3: #7c8794;
  --action: #1f5fd1;
  --action-press: #194eae;

  /* Chart roles (validated: blue ordinal ramp, steps 250-600) */
  --series-1: #2a78d6;
  --ramp-1: #86b6ef;
  --ramp-2: #5598e7;
  --ramp-3: #2a78d6;
  --ramp-4: #184f95;
  --grid: rgba(19, 33, 49, 0.08);

  /* Status: only for flags, always with icon + label */
  --good: #0ca30c;
  --warning: #b97800;   /* darkened from #fab219 for text on glass */
  --serious: #c45a2f;
  --critical: #d03b3b;

  /* Glass */
  --glass-fill: linear-gradient(160deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.46));
  --glass-edge: rgba(255, 255, 255, 0.75);
  --glass-blur: 24px;

  /* Radii follow hierarchy: slab > panel > row > pill */
  --r-sheet: 34px;
  --r-slab: 30px;
  --r-panel: 26px;
  --r-row: 16px;
  --r-pill: 999px;

  --font: "Manrope", -apple-system, "SF Pro Text", system-ui, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky) 0, #eef3f8 360px, var(--mist) 760px) no-repeat, var(--mist);
  overflow-x: hidden;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, p { margin: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.icon { width: 18px; height: 18px; flex: none; }

/* ---------- Backdrop ---------- */

.backdrop {
  position: absolute;
  inset: 0 0 auto 0;
  height: 560px;
  z-index: -1;
  overflow: hidden;
  /* fade the ridge into the mist so there is no hard edge */
  -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 62%, transparent 100%);
}
.backdrop::before {
  /* low sun behind the ridge */
  content: "";
  position: absolute;
  width: 520px; height: 520px;
  right: 8%; top: 40px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 226, 196, 0.85), rgba(255, 226, 196, 0) 62%);
}
.ridge {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 100%;
}

/* ---------- Glass ---------- */

.glass {
  position: relative;
  background: var(--glass-fill);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(170%);
  backdrop-filter: blur(var(--glass-blur)) saturate(170%);
  border: 1px solid var(--glass-edge);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1px 0 rgba(255, 255, 255, 0.35);
}
/* specular sheen along the top edge */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 38%);
  mix-blend-mode: soft-light;
}
.glass > * { position: relative; }

.glass--slab {
  border-radius: var(--r-slab);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 24px 48px -28px rgba(29, 54, 86, 0.45);
}
.glass--panel {
  border-radius: var(--r-panel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 12px 32px -24px rgba(29, 54, 86, 0.35);
}
.glass--bar { border-radius: var(--r-pill); }
.glass--sheet {
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  --glass-fill: linear-gradient(170deg, rgba(255, 255, 255, 0.9), rgba(247, 250, 253, 0.82));
  box-shadow: 0 -20px 60px -20px rgba(19, 33, 49, 0.35);
}
/* Slightly denser glass for the mobile FAB so it stays readable over page content */
.glass--tint {
  --glass-fill: linear-gradient(160deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.62));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 10px 28px -12px rgba(29, 54, 86, 0.4);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { --glass-fill: rgba(255, 255, 255, 0.92); }
}

/* ---------- Page ---------- */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

/* One UI: generous top space so the title sits in the upper third */
.title-area {
  padding: clamp(64px, 14vh, 140px) 4px 28px;
}
.title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.large-title {
  font-size: clamp(36px, 5.2vw, 54px);
  line-height: 1.02;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.subtitle {
  margin-top: 10px;
  font-size: 17px;
  color: var(--ink-2);
  font-weight: 500;
}
.demo-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  font-size: 13px;
  color: var(--ink-2);
}

/* pill select */
.pill-select {
  position: relative;
  display: inline-flex;
}
.pill-select select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  padding: 11px 42px 11px 18px;
  border-radius: var(--r-pill);
  border: 1px solid var(--glass-edge);
  background: rgba(255, 255, 255, 0.6);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  cursor: pointer;
}
.pill-select::after {
  content: "";
  position: absolute;
  right: 18px; top: 50%;
  width: 8px; height: 8px;
  border-right: 2px solid var(--ink-2);
  border-bottom: 2px solid var(--ink-2);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* ---------- Compact bar ---------- */

.compact-bar {
  position: fixed;
  top: 12px; left: 50%;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  transform: translate(-50%, -140%);
  opacity: 0;
  transition: transform 0.4s var(--ease), opacity 0.3s var(--ease);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 10px 30px -14px rgba(29, 54, 86, 0.4);
}
.compact-bar.is-visible { transform: translate(-50%, 0); opacity: 1; }
.compact-title { font-weight: 800; font-size: 15px; }
.compact-month { color: var(--ink-2); font-weight: 600; font-size: 14px; }

/* ---------- KPIs ---------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px;
}
.kpi {
  padding: 18px 22px 20px;
  border-left: 1px solid rgba(19, 33, 49, 0.07);
}
.kpi:first-child { border-left: 0; }
.kpi-label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.kpi-value {
  display: block;
  margin-top: 6px;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.kpi-delta svg { width: 12px; height: 12px; }

/* ---------- Workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}

.panel-head, .detail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 22px 24px 10px;
}
.detail-head { display: block; }
h2 { font-size: 21px; font-weight: 800; letter-spacing: -0.015em; }
.panel-hint { font-size: 13.5px; color: var(--ink-2); font-weight: 500; }

/* Property table as a One UI grouped list */
.table-wrap { padding: 4px 10px 12px; overflow-x: auto; }
.prop-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
}
.prop-table th {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  text-align: left;
  padding: 6px 14px;
}
.prop-table .num { text-align: right; white-space: nowrap; }
.prop-table td {
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.0);
  transition: background 0.2s var(--ease);
}
.prop-table td:first-child { border-radius: var(--r-row) 0 0 var(--r-row); }
.prop-table td:last-child { border-radius: 0 var(--r-row) var(--r-row) 0; }
.prop-table tbody tr { cursor: pointer; }
.prop-table tbody tr:hover td { background: rgba(255, 255, 255, 0.45); }
.prop-table tbody tr[aria-selected="true"] td {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 1px 0 rgba(19, 33, 49, 0.04);
}
.prop-table tbody tr:focus-visible { outline: none; }
.prop-table tbody tr:focus-visible td { box-shadow: inset 0 0 0 2px var(--action); }
.prop-table tbody tr:focus-visible td:not(:first-child) { box-shadow: inset 0 2px 0 var(--action), inset 0 -2px 0 var(--action); }
.prop-table tbody tr:focus-visible td:first-child { box-shadow: inset 2px 2px 0 var(--action), inset 0 -2px 0 var(--action); }
.prop-table tbody tr:focus-visible td:last-child { box-shadow: inset -2px 2px 0 var(--action), inset 0 -2px 0 var(--action); }
.prop-name { display: block; font-weight: 700; }
.prop-meta { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin-top: 2px; }

.cell-flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.cell-flag svg { width: 14px; height: 14px; }
.tone-warning { color: var(--warning); }
.tone-serious { color: var(--serious); }
.tone-critical { color: var(--critical); }
.tone-good { color: var(--good); }

/* ---------- Detail ---------- */

.detail { padding-bottom: 22px; }

.flag-list {
  list-style: none;
  margin: 8px 24px 4px;
  padding: 0;
  display: grid;
  gap: 8px;
}
.flag {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  border-radius: var(--r-row);
  background: rgba(255, 255, 255, 0.62);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}
.flag svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.flag small { display: block; font-weight: 500; color: var(--ink-2); font-size: 13px; }
.flag--clear { color: var(--ink-2); }

.chart-block { margin: 18px 24px 0; }
.chart-block figcaption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.chart-title { font-size: 14px; font-weight: 700; }
.chart-sub { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); font-size: 12px; fill: var(--ink-3); font-weight: 600; }
.chart .label-strong { fill: var(--ink); font-weight: 700; }

.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 18px 24px 0;
  border-radius: var(--r-row);
  overflow: hidden;
  background: rgba(19, 33, 49, 0.06);
}
.facts div { background: rgba(255, 255, 255, 0.66); padding: 12px 14px; }
.facts dt { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.facts dd { margin: 2px 0 0; font-size: 17px; font-weight: 800; }

/* ---------- Buttons ---------- */

.btn {
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  border-radius: var(--r-pill);
  padding: 13px 22px;
  border: 0;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.2s var(--ease), opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn--primary {
  color: #fff;
  background: linear-gradient(180deg, #3576e6, var(--action));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 22px -12px rgba(31, 95, 209, 0.9);
}
.btn--primary:hover:not(:disabled) { background: linear-gradient(180deg, #2d6ce0, var(--action-press)); }
.btn--quiet {
  color: var(--ink);
  background: rgba(19, 33, 49, 0.06);
}
.btn--quiet:hover:not(:disabled) { background: rgba(19, 33, 49, 0.1); }
.btn--wide { display: block; width: calc(100% - 48px); margin: 22px 24px 0; }

:focus-visible { outline: 2px solid var(--action); outline-offset: 3px; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--ink-2);
  background: rgba(19, 33, 49, 0.06);
  cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Log ---------- */

.log { margin-top: 20px; }
.log-list { list-style: none; margin: 0; padding: 4px 14px 18px; display: grid; gap: 6px; }
.log-list li { padding: 12px 12px; border-radius: var(--r-row); }
.log-item { background: rgba(255, 255, 255, 0.55); display: grid; gap: 4px; }
.log-item strong { font-weight: 700; }
.log-item .log-meta { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.log-item .log-text { font-size: 14px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.log-empty { color: var(--ink-2); font-size: 14px; }

.foot { padding: 28px 4px 0; font-size: 13px; color: var(--ink-3); }

/* ---------- Sheet ---------- */

.scrim {
  position: fixed; inset: 0;
  background: rgba(19, 33, 49, 0.28);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.scrim.is-open { opacity: 1; }

.sheet {
  position: fixed;
  left: 50%; bottom: 0;
  z-index: 50;
  width: min(760px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  transform: translate(-50%, 104%);
  transition: transform 0.45s var(--ease);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.is-open { transform: translate(-50%, 0); }
.sheet-handle {
  width: 40px; height: 5px;
  border-radius: 3px;
  background: rgba(19, 33, 49, 0.18);
  margin: 10px auto 0;
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 26px 6px;
}
.sheet-body { padding: 10px 26px 4px; overflow-y: auto; }
.sheet-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 26px 22px;
}

.draft-state {
  display: flex; align-items: center; gap: 12px;
  padding: 36px 4px;
  color: var(--ink-2);
  font-weight: 600;
}
.spinner {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2.5px solid rgba(31, 95, 209, 0.2);
  border-top-color: var(--action);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.check-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 700;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(19, 33, 49, 0.08);
}
.chip svg { width: 14px; height: 14px; }

.field { display: grid; gap: 8px; }
.field-label { font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
textarea {
  font: inherit;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  width: 100%;
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid rgba(19, 33, 49, 0.1);
  background: rgba(255, 255, 255, 0.9);
  resize: vertical;
  max-width: 100%;
}
textarea:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px rgba(31, 95, 209, 0.18); }
.field-help { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); }

/* ---------- Toast & tooltip ---------- */

.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  z-index: 60;
  transform: translateX(-50%);
  padding: 12px 20px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 14px 36px -14px rgba(19, 33, 49, 0.45);
}

.tooltip {
  position: fixed;
  z-index: 70;
  pointer-events: none;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(19, 33, 49, 0.92);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 12px));
}
.tooltip span { display: block; font-weight: 500; opacity: 0.75; font-size: 12px; }

/* ---------- Responsive ---------- */

.mobile-only { display: none; }

@media (max-width: 960px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n + 3) { border-top: 1px solid rgba(19, 33, 49, 0.07); }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .page { padding: 0 12px 120px; }
  .title-area { padding-top: 16vh; }
  .kpi-delta .vs { display: none; }
  .kpi-label { font-size: 13px; }
  .kpi { padding: 14px 16px 16px; }
  .kpi-value { font-size: 26px; }
  .panel-head, .detail-head { padding: 18px 18px 8px; }
  .flag-list, .chart-block, .facts { margin-left: 18px; margin-right: 18px; }
  .facts { grid-template-columns: 1fr 1fr; }
  /* rows become stacked list items: name on top, four figures below */
  .table-wrap { overflow: visible; padding: 4px 8px 10px; }
  .prop-table, .prop-table tbody { display: block; }
  .prop-table thead { display: none; }
  .prop-table tbody tr {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px 6px;
    padding: 14px 12px;
    border-radius: var(--r-row);
    margin-bottom: 4px;
  }
  .prop-table td, .prop-table td:first-child, .prop-table td:last-child {
    padding: 0; border-radius: 0; background: none; text-align: left; font-size: 14px;
  }
  .prop-table td:first-child { grid-column: 1 / -1; }
  .prop-table td.num { text-align: left; white-space: normal; }
  .prop-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11.5px; font-weight: 600; color: var(--ink-3);
    margin-bottom: 1px;
  }
  .prop-table tbody tr:hover td { background: none; }
  .prop-table tbody tr:hover { background: rgba(255, 255, 255, 0.45); }
  .prop-table tbody tr[aria-selected="true"] td { background: none; box-shadow: none; }
  .prop-table tbody tr[aria-selected="true"] { background: rgba(255, 255, 255, 0.85); }
  .prop-table tbody tr:focus-visible td { box-shadow: none !important; }
  .prop-table tbody tr:focus-visible { outline: 2px solid var(--action); outline-offset: -2px; }
  .desktop-only { display: none; }
  .mobile-only { display: block; }
  .fab-dock {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  }
  .btn--fab { width: 100%; padding: 16px 22px; font-size: 16px; }
  .sheet { max-height: 94vh; }
  .sheet-head, .sheet-body, .sheet-foot { padding-left: 18px; padding-right: 18px; }
  .sheet-foot .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
