:root {
  --bg: oklch(0.97 0.004 90);
  --surface: #fff;
  --ink: oklch(0.24 0.015 250);
  --ink-2: oklch(0.28 0.015 250);
  --ink-3: oklch(0.42 0.015 250);
  --mute: oklch(0.55 0.012 250);
  --mute-2: oklch(0.58 0.012 250);
  --rule: oklch(0.9 0.006 90);
  --rule-2: oklch(0.93 0.006 90);
  --rule-3: oklch(0.95 0.006 90);
  --accent: oklch(0.32 0.07 195);
  --accent-hover: oklch(0.28 0.08 195);
  --accent-ink: oklch(0.28 0.06 195);
  --accent-soft: oklch(0.94 0.03 195);
  --accent-softer: oklch(0.97 0.02 195);
  --ok-fg: oklch(0.36 0.09 150);
  --ok-bg: oklch(0.95 0.04 150);
  --warn-fg: oklch(0.46 0.12 70);
  --warn-bg: oklch(0.96 0.05 80);
  --alert-fg: oklch(0.46 0.14 25);
  --alert-bg: oklch(0.95 0.04 25);
  --draft-fg: oklch(0.4 0.015 250);
  --draft-bg: oklch(0.93 0.006 90);
  --radius: 12px;
  --radius-sm: 9px;
  --radius-xs: 8px;
  --sidebar: 252px;
  --font: Inter, "Segoe UI", Helvetica, Arial, sans-serif;
  --shadow-drawer: -8px 0 24px oklch(0.15 0.01 250 / 0.12);
  --shadow-modal: 0 16px 40px oklch(0.15 0.01 250 / 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
}

img { max-width: 100%; height: auto; }

button, input, select, textarea { font-family: inherit; }

button { color: inherit; }

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

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

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  z-index: 80;
}
.skip:focus { left: 8px; }

/* ---- App shell ---- */
.app {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  overflow-x: clip;
}

.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 14px;
  z-index: 12;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 22px;
  min-width: 0;
}
.brand img {
  height: 26px;
  width: auto;
  display: block;
}
.brand-kicker {
  font-size: 11px;
  font-weight: 600;
  color: var(--mute);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-xs);
  color: var(--ink-3);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border: 0;
  background: transparent;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: oklch(0.97 0.006 90);
  color: var(--ink-2);
  text-decoration: none;
}
.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
}
.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-top: 1px solid var(--rule-2);
  min-width: 0;
  position: relative;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: oklch(0.28 0.02 250);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
button.avatar {
  border: 0;
  padding: 0;
  cursor: pointer;
}
button.avatar:hover {
  filter: brightness(1.12);
}
.profile-menu {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px oklch(0.2 0.02 250 / 0.14);
  padding: 6px;
  z-index: 20;
}
.profile-menu-item {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.profile-menu-item:hover {
  background: var(--accent-softer);
  color: var(--ink);
  text-decoration: none;
}
.sidebar-user .who {
  min-width: 0;
}
.sidebar-user .who-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user .who-role {
  font-size: 11.5px;
  color: var(--mute-2);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  background: oklch(0.97 0.004 90 / 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
  padding: 14px 40px;
}
.topbar h1 {
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}
.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
  min-width: 0;
}
#topbar-action:empty { display: none; }

.nav-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: var(--radius-xs);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.nav-toggle svg {
  width: 18px;
  height: 18px;
  stroke: var(--ink);
  fill: none;
  stroke-width: 1.8;
}

.search-wrap {
  width: 240px;
  flex: 0 1 240px;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  stroke: var(--mute);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  pointer-events: none;
}
.search-wrap input[type="search"] {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: 999px;
  border: 1px solid oklch(0.88 0.006 90);
  background: var(--surface);
  font-size: 13px;
  color: var(--ink-2);
}
.search-wrap input[type="search"]:hover { border-color: oklch(0.82 0.008 90); }
.search-wrap input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(0.32 0.07 195 / 0.15);
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  width: min(360px, 70vw);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-modal);
  z-index: 20;
  max-height: 320px;
  overflow: auto;
}
.search-hit {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--rule-3);
}
.search-hit:hover, .search-hit:focus { background: var(--accent-softer); }
.search-hit .k { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.search-hit .s { font-size: 12px; color: var(--mute); margin-top: 2px; }

.content {
  flex: 1;
  padding: 32px 40px 56px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}

.stack { display: flex; flex-direction: column; gap: 28px; }
.stack-sm { display: flex; flex-direction: column; gap: 18px; }

/* ---- Type ---- */
.page-lead {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.page-sub {
  font-size: 14px;
  color: var(--mute);
  margin-top: 4px;
}
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid oklch(0.85 0.006 90);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover:not(:disabled) {
  background: oklch(0.985 0.004 90);
  text-decoration: none;
  color: var(--ink);
}
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn--primary {
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  color: #fff;
}
.btn--primary:disabled {
  opacity: 1;
  background: oklch(0.9 0.006 90);
  color: oklch(0.65 0.008 90);
}
.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--mute);
  padding: 8px 10px;
}
.btn--ghost:hover:not(:disabled) { color: var(--ink); background: oklch(0.96 0.006 90); }
.btn--sm { padding: 6px 12px; font-size: 12.5px; border-radius: var(--radius-xs); }
.btn--danger { color: var(--alert-fg); }
.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.linkish:hover { color: var(--accent-hover); text-decoration: underline; }
.linkish:disabled { color: var(--mute); cursor: default; text-decoration: none; }

/* ---- Cards / metrics ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px oklch(0.2 0.01 250 / 0.04);
}
.card:has(> .table-scroll) {
  overflow: hidden;
}
.card--pad { padding: 24px 26px; }
.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.metric .label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.metric .value {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* ---- Chips ---- */
.chip {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  background: var(--draft-bg);
  color: var(--draft-fg);
}
.chip--attention, .chip--failed { background: var(--alert-bg); color: var(--alert-fg); }
.chip--awaiting, .chip--awaiting_review, .chip--progress { background: var(--warn-bg); color: var(--warn-fg); }
.chip--ready { background: var(--accent-soft); color: var(--accent-ink); }
.chip--completed, .chip--success, .chip--connected, .chip--active, .chip--ok {
  background: var(--ok-bg); color: var(--ok-fg);
}
.chip--detected { background: var(--accent-soft); color: var(--accent-ink); }
.chip--draft, .chip--inactive, .chip--none { background: var(--draft-bg); color: var(--draft-fg); }

/* ---- Tables ---- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 720px;
}
table.data th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 12px 22px;
  background: oklch(0.975 0.004 90);
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
table.data td {
  padding: 14px 22px;
  border-bottom: 1px solid var(--rule-3);
  font-size: 13px;
  color: oklch(0.45 0.015 250);
  vertical-align: middle;
}
table.data td.strong {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.is-clickable { cursor: pointer; }
table.data tbody tr.is-clickable:hover td { background: oklch(0.985 0.004 90); }
table.data tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.muted { color: var(--mute); }
.sub {
  display: block;
  font-size: 12px;
  color: var(--mute-2);
  font-weight: 400;
  margin-top: 2px;
}

.card-list { display: none; flex-direction: column; }
.item-card {
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule-3);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.item-card:last-child { border-bottom: 0; }
.item-card.is-clickable { cursor: pointer; }
.item-card.is-clickable:hover { background: oklch(0.985 0.004 90); }
.item-card .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 12.5px;
  color: var(--mute);
}

/* ---- Filters ---- */
.seg, .pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.seg button, .pill-btn {
  border: 1px solid oklch(0.88 0.006 90);
  background: #fff;
  color: oklch(0.45 0.015 250);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-xs);
  cursor: pointer;
}
.seg button:hover, .pill-btn:hover { border-color: oklch(0.8 0.01 90); }
.seg button.is-on, .pill-btn.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="date"],
input[type="number"],
input[type="url"],
input[type="tel"],
input:not([type]),
select,
textarea {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  background: var(--surface);
  font-size: 14px;
  color: var(--ink);
  line-height: 1.35;
  box-shadow: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 32px;
}
input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="search"]:hover,
input[type="date"]:hover,
input[type="number"]:hover,
input[type="url"]:hover,
input[type="tel"]:hover,
input:not([type]):hover,
select:hover,
textarea:hover {
  border-color: oklch(0.82 0.01 90);
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
input:not([type]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px oklch(0.32 0.07 195 / 0.12);
}
input:disabled, select:disabled, textarea:disabled {
  background: oklch(0.96 0.004 90);
  color: var(--mute);
  cursor: not-allowed;
  box-shadow: none;
}
input[type="date"] {
  appearance: auto;
  -webkit-appearance: auto;
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  box-shadow: 0 0 0 1000px #fff inset;
  transition: background-color 9999s ease-out;
}
label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}
.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.fields .span2 { grid-column: 1 / -1; }

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
}
.tab {
  padding: 10px 4px;
  margin-right: 22px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--mute);
  border: 0;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--ink-2); }
.tab.is-on {
  font-weight: 700;
  color: var(--accent-ink);
  border-bottom-color: var(--accent);
}

/* ---- States ---- */
.empty, .error-box, .ok-box, .loading {
  padding: 32px 28px;
  text-align: center;
  font-size: 13.5px;
  color: var(--mute);
}
.error-box {
  text-align: left;
  color: var(--alert-fg);
  background: var(--alert-bg);
  border: 1px solid oklch(0.86 0.06 25);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.ok-box {
  text-align: left;
  color: var(--ok-fg);
  background: var(--ok-bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.warn-box {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
}
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 240px;
  font-size: 14px;
  color: var(--ink-3);
}
.spinner {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--rule);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.setup {
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--mute);
  font-size: 14px;
}
.setup code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--ink);
}

/* ---- Activity feed ---- */
.feed-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 22px;
  border-bottom: 1px solid var(--rule-3);
}
.feed-item:last-child { border-bottom: 0; }
.feed-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: oklch(0.55 0.1 150);
  flex-shrink: 0;
}
.feed-text { font-size: 13.5px; color: oklch(0.32 0.015 250); }
.feed-when { font-size: 12.5px; color: var(--mute-2); white-space: nowrap; }

/* ---- Settings list ---- */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--rule-3);
}
.settings-row:last-child { border-bottom: 0; }
.settings-row h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
}
.settings-row p {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--mute-2);
}

/* ---- Wizard ---- */
.steps {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.step {
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  background: oklch(0.95 0.006 90);
  color: oklch(0.6 0.012 250);
}
.step.is-on {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.step.is-done {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.choice {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--rule);
  cursor: pointer;
  background: #fff;
  text-align: left;
  width: 100%;
}
.choice:hover { border-color: oklch(0.8 0.01 195); }
.choice.is-on {
  border-color: var(--accent);
  background: var(--accent-softer);
}
.choice .n { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.choice .c { font-size: 12px; color: var(--mute-2); margin-top: 2px; }

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 16px;
  border: 1.5px dashed oklch(0.85 0.008 90);
  border-radius: var(--radius);
  background: oklch(0.985 0.004 90);
  cursor: pointer;
}
.drop:hover, .drop.is-over {
  border-color: var(--accent);
  background: var(--accent-softer);
}
.drop.is-ready {
  border-color: oklch(0.55 0.1 150);
  background: oklch(0.97 0.03 150);
}
.drop input { display: none; }
.drop-title { font-size: 13.5px; font-weight: 600; color: oklch(0.4 0.015 250); }
.drop-hint { font-size: 12px; color: oklch(0.6 0.012 250); margin-top: 4px; }

.file-list { list-style: none; margin: 14px 0 0; padding: 0; }
.file-list li {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 2px 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule-3);
  font-size: 13px;
}
.file-list .slot {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  grid-row: span 2;
}
.file-list .fname { font-weight: 600; color: var(--ink-2); }
.file-list .ftitle { color: var(--mute); }

.issue-list { list-style: none; margin: 14px 0 0; padding: 0; }
.issue-list li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule-3);
}
.issue-list .issue-status {
  flex: 0 0 5.5rem;
  padding-top: 1px;
}
.issue-list .issue-body {
  flex: 1 1 auto;
  min-width: 0;
}
.issue-list .issue-title {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  line-height: 1.35;
}
.issue-list .issue-detail {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--mute);
  line-height: 1.45;
}
.issue-list .issue-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding-top: 1px;
}

table.edit { width: 100%; border-collapse: collapse; font-size: 13px; }
table.edit th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 0 8px 8px 0;
}
table.edit td { padding: 4px 8px 4px 0; vertical-align: top; }
table.edit input, table.edit textarea {
  width: 100%;
}

.extract h3 { font-size: 15px; margin: 14px 0 4px; }
.extract p { margin: 0 0 6px; font-size: 14px; color: var(--ink-3); }

.wizard-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* ---- Drawer / modal / toast ---- */
.backdrop {
  position: fixed;
  inset: 0;
  background: oklch(0.15 0.01 250 / 0.35);
  z-index: 30;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(440px, 100vw);
  background: #fff;
  box-shadow: var(--shadow-drawer);
  z-index: 31;
  padding: 28px;
  overflow-y: auto;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}
.drawer-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.icon-btn {
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--mute);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.icon-btn:hover { color: var(--ink); background: oklch(0.96 0.006 90); }

.timeline { display: flex; flex-direction: column; }
.tl-row { display: flex; gap: 12px; padding: 8px 0; }
.tl-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
  background: oklch(0.55 0.1 150);
}
.tl-dot.is-fail { background: oklch(0.55 0.15 25); }
.tl-dot.is-wait { background: oklch(0.78 0.01 90); }
.tl-label { font-size: 13px; font-weight: 600; color: oklch(0.32 0.015 250); }
.tl-note { font-size: 12px; color: var(--mute); margin-top: 2px; }

.modal-wrap {
  position: fixed;
  inset: 0;
  background: oklch(0.15 0.01 250 / 0.4);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 26px;
  width: min(400px, 100%);
  box-shadow: var(--shadow-modal);
}
.modal h2 { margin: 0 0 8px; font-size: 15px; font-weight: 700; }
.modal p { margin: 0 0 22px; font-size: 13.5px; color: oklch(0.5 0.012 250); line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  background: oklch(0.24 0.015 250);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  max-width: min(360px, calc(100vw - 32px));
}
.toast.is-error { background: oklch(0.42 0.14 25); }

.facts {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 6px 12px;
  margin: 0 0 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule-2);
  font-size: 13px;
}
.facts dt { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--mute); }
.facts dd { margin: 0; color: var(--ink-2); }
.body-frame {
  display: block;
  width: 100%;
  min-height: 360px;
  height: 50vh;
  border: 1px solid var(--rule);
  background: #fff;
  border-radius: var(--radius-xs);
}
.body-text {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: var(--radius-xs);
}

.profile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi .label {
  font-size: 11px;
  font-weight: 700;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.kpi .value {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-top: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: oklch(0.15 0.01 250 / 0.4);
  z-index: 11;
}

@media (max-width: 1100px) {
  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: none;
  }
  .app.nav-open .sidebar { transform: translateX(0); box-shadow: 8px 0 24px oklch(0.15 0.01 250 / 0.12); }
  .nav-toggle { display: inline-flex; }
  .app.nav-open .nav-backdrop { display: block; }
  .topbar-inner, .content { padding-left: 20px; padding-right: 20px; }
  .choice-grid { grid-template-columns: 1fr 1fr; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .metrics { grid-template-columns: 1fr; }
  .fields { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; }
  .topbar-right { flex: 1 1 100%; }
  .search-wrap { width: 100%; flex: 1 1 100%; }
  .choice-grid { grid-template-columns: 1fr; }
  .profile-head { flex-direction: column; }
}

@media (max-width: 720px) {
  .table-scroll { display: none; }
  .card-list { display: flex; }
  table.data { min-width: 0; }
  .kpi-row { grid-template-columns: 1fr; }
  .feed-item { flex-direction: column; align-items: flex-start; gap: 4px; }
  .settings-row { flex-direction: column; align-items: flex-start; }
  .content { padding: 20px 16px 40px; }
  .topbar-inner { padding: 14px 16px; }
  .drawer { width: 100vw; }
}

/* ---- Valuation workspace ---- */
.ws { display: flex; flex-direction: column; gap: 14px; }
.ws-rail {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
}
.ws-rail-item {
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: var(--radius-xs);
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--mute);
  cursor: pointer;
}
.ws-rail-item:hover { background: var(--accent-softer); color: var(--accent-ink); }
.ws-rail-item.is-on { background: var(--accent-soft); color: var(--accent-ink); }
.ws-rail-item.is-locked { font-weight: 500; }
.ws-lock {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--mute-2);
}
.ws-meta {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto 1.4fr;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  color: var(--ink-2);
}
.ws-meta .mute, .mute { color: var(--mute); }
.doc-table select, .doc-table input[type=text], .doc-table input.app-label, .doc-table input.app-title {
  width: 100%;
  max-width: 260px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  background: var(--surface);
  color: inherit;
}
.row-actions { white-space: nowrap; }
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.plain-list { margin: 8px 0 16px; padding-left: 18px; color: var(--ink-2); }
.plain-list li { margin: 4px 0; }
.facts { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--mute); font-size: 12px; }
.facts dd { margin: 0; }
.calc-amt {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}
.calc-amt:hover { color: var(--accent-ink); }
.section-draft p { margin: 0 0 10px; max-width: 72ch; }
.extract-sec {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}
.extract-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.extract-sec-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}
.extract-sec-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.req-sel {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  background: var(--surface);
}
@media (max-width: 720px) {
  .ws-rail { flex-wrap: nowrap; overflow-x: auto; }
  .ws-rail-item { flex: 0 0 auto; }
  .facts { grid-template-columns: 1fr; }
  .issue-list li { flex-wrap: wrap; }
  .issue-list .issue-actions { width: 100%; padding-top: 6px; }
}

@media (max-width: 860px) {
  .ws-meta { grid-template-columns: 1fr 1fr; }
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  background:
    radial-gradient(1200px 480px at 50% -10%, oklch(0.94 0.03 195), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 36px 32px 32px;
  box-shadow: 0 18px 50px oklch(0.2 0.02 250 / 0.08);
}
.login-card img {
  height: 34px;
  width: auto;
}
.login-card h1 {
  margin: 20px 0 6px;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.login-card > p {
  margin: 0 0 24px;
  color: var(--mute);
  font-size: 14px;
}
.login-card form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-card input[type="email"],
.login-card input[type="password"] {
  height: 44px;
  padding: 0 14px;
  font-size: 15px;
  border-radius: 10px;
  background: oklch(0.985 0.004 90);
}
.login-card input[type="email"]:focus,
.login-card input[type="password"]:focus {
  background: #fff;
}
.login-card .btn {
  width: 100%;
  height: 44px;
  justify-content: center;
  margin-top: 6px;
  font-size: 14px;
  border-radius: 10px;
}
.login-card .error-box { margin-bottom: 0; }
