/* ===========================================================================
   CCVC design system — single source of styling for the whole application.
   Translated from the approved mockups. Light + dark mode.
   =========================================================================== */
:root {
  --bg-page: #f4f6f8;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f3f5;
  --bg-rail: #ffffff;
  --border: rgba(20, 28, 40, 0.10);
  --border-strong: rgba(20, 28, 40, 0.18);
  --text: #1a1d21;
  --text-secondary: #586273;
  --text-tertiary: #8a929c;

  --primary: #1f5fa8;
  --primary-bg: #e8f1fb;
  --primary-text: #0c447c;

  --success: #0f6e56;
  --success-bg: #e1f5ee;
  --success-text: #085041;

  --warning: #9a6212;
  --warning-bg: #faeeda;
  --warning-text: #854f0b;

  --danger: #a32d2d;
  --danger-bg: #fcebeb;
  --danger-text: #791f1f;

  --accent: #534ab7;
  --accent-bg: #eeedfe;
  --accent-text: #3c3489;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --rail-w: 56px;
  --topbar-h: 52px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --shadow-pop: 0 6px 24px rgba(20, 28, 40, 0.14);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #14171c;
    --bg-surface: #1d2229;
    --bg-subtle: #232a33;
    --bg-rail: #1a1f25;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text: #e9edf2;
    --text-secondary: #a7b0bd;
    --text-tertiary: #79828f;
    --primary: #6ea8e6;
    --primary-bg: #16314c;
    --primary-text: #b5d4f4;
    --success: #5dcaa5;
    --success-bg: #103f33;
    --success-text: #9fe1cb;
    --warning: #e6a94e;
    --warning-bg: #3f2f12;
    --warning-text: #f5d49a;
    --danger: #ea8a8a;
    --danger-bg: #3f1c1c;
    --danger-text: #f3b2b2;
    --accent: #9b94e8;
    --accent-bg: #272150;
    --accent-text: #cecbf6;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-weight: 500; color: var(--text); margin: 0; }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 15px; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.rail {
  width: var(--rail-w); background: var(--bg-rail); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 3px;
  position: sticky; top: 0; height: 100vh;
}
.rail .brand {
  width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; margin-bottom: 6px;
}
.rail a.ic {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md); color: var(--text-secondary); font-size: 20px; position: relative;
}
.rail a.ic:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.rail a.ic.active { background: var(--primary-bg); color: var(--primary-text); }
.rail .spacer { flex: 1; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); background: var(--bg-surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 18px; position: sticky; top: 0; z-index: 20;
}
.topbar .search {
  flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px;
  background: var(--bg-subtle); border: 1px solid transparent; border-radius: var(--radius-md);
  padding: 7px 12px; color: var(--text-tertiary); font-size: 13px; cursor: text;
}
.content { padding: 20px 22px; max-width: 1280px; width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.card.tight { padding: 12px 14px; }
.card.subtle { background: var(--bg-subtle); border-color: transparent; }
.card-title { font-weight: 500; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-2-wide { grid-template-columns: 1.4fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-2-wide, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Metric tiles ---------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.metric { background: var(--bg-subtle); border-radius: var(--radius-md); padding: 12px 14px; }
.metric .label { font-size: 12px; color: var(--text-secondary); }
.metric .value { font-size: 24px; font-weight: 600; margin-top: 2px; }
.metric .value.warning { color: var(--warning); }
.metric .value.success { color: var(--success); }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 500;
  padding: 2px 9px; border-radius: 20px; white-space: nowrap;
}
.pill.neutral { background: var(--bg-subtle); color: var(--text-secondary); }
.pill.info { background: var(--primary-bg); color: var(--primary-text); }
.pill.success { background: var(--success-bg); color: var(--success-text); }
.pill.warning { background: var(--warning-bg); color: var(--warning-text); }
.pill.danger { background: var(--danger-bg); color: var(--danger-text); }
.pill.accent { background: var(--accent-bg); color: var(--accent-text); }

/* ---------- Avatar ---------- */
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--primary-bg); color: var(--primary-text);
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar.warning { background: var(--warning-bg); color: var(--warning-text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; font-family: inherit; font-size: 13px; font-weight: 500;
  padding: 7px 13px; border-radius: var(--radius-md); border: 1px solid var(--border-strong);
  background: var(--bg-surface); color: var(--text); cursor: pointer; transition: background .12s, transform .05s;
}
.btn:hover { background: var(--bg-subtle); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); background: var(--primary); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-secondary); }
.btn.ghost:hover { background: var(--bg-subtle); }
.btn.danger { color: var(--danger); }
.btn.sm { font-size: 12px; padding: 5px 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-tertiary);
  text-align: left; font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
table.data td { font-size: 13px; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:hover { background: var(--bg-subtle); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-link { cursor: pointer; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 5px; }
.input, .select, .textarea {
  width: 100%; font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--bg-surface); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  padding: 9px 11px; height: 38px;
}
.textarea { height: auto; min-height: 70px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }

/* ---------- Status rail (claim stepper) ---------- */
.steprail { display: flex; align-items: center; gap: 7px; overflow-x: auto; padding: 4px 0; }
.steprail .step { display: flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; color: var(--text-tertiary); }
.steprail .step.current { font-weight: 500; color: var(--text); }
.steprail .step.done { color: var(--text-secondary); }
.steprail .dot {
  width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; flex-shrink: 0; background: var(--bg-subtle); color: var(--text-secondary);
}
.steprail .step.done .dot { background: var(--success-bg); color: var(--success-text); }
.steprail .step.current .dot { background: var(--primary); color: #fff; }
.steprail .sep { color: var(--text-tertiary); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs .tab { font-size: 13px; padding: 10px 2px; color: var(--text-secondary); border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer; background: none; border-top: none; border-left: none; border-right: none; font-family: inherit; }
.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 500; }

/* ---------- Segmented control ---------- */
.segments { display: flex; gap: 5px; overflow-x: auto; }
.segment { font-size: 12.5px; padding: 7px 12px; border-radius: var(--radius-md); color: var(--text-secondary); white-space: nowrap; display: flex; align-items: center; gap: 7px; cursor: pointer; background: none; border: none; font-family: inherit; }
.segment:hover { background: var(--bg-subtle); }
.segment.active { background: var(--primary-bg); color: var(--primary-text); font-weight: 500; }
.segment .count { font-size: 11px; background: var(--bg-surface); border-radius: 9px; padding: 0 7px; }

/* ---------- Misc ---------- */
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.muted { color: var(--text-secondary); }
.tertiary { color: var(--text-tertiary); }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 6px 0; border-top: 1px solid var(--border); }
.kv .k { color: var(--text-secondary); }
.kv.strong { font-weight: 600; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.stack > * + * { margin-top: 12px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.checkbox { width: 17px; height: 17px; border-radius: 4px; border: 1.5px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: transparent; }
.checkbox.on { background: var(--primary); border-color: var(--primary); color: #fff; font-size: 11px; }
.actionbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 16px; position: sticky; bottom: 14px; box-shadow: var(--shadow-pop); }
.empty { text-align: center; padding: 40px 20px; color: var(--text-tertiary); }
.loading { padding: 30px; text-align: center; color: var(--text-tertiary); }
.callout { display: flex; gap: 10px; padding: 11px 13px; border-radius: var(--radius-md); font-size: 12.5px; line-height: 1.5; }
.callout.info { background: var(--primary-bg); color: var(--primary-text); }
.callout.warning { background: var(--warning-bg); color: var(--warning-text); }

/* user menu dropdown */
.usermenu { position: relative; }
.usermenu .menu { position: absolute; right: 0; top: 40px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); padding: 6px; width: 250px; z-index: 50; }
.usermenu .menu .item { display: flex; align-items: center; gap: 9px; padding: 8px 9px; border-radius: var(--radius-md); cursor: pointer; font-size: 13px; }
.usermenu .menu .item:hover { background: var(--bg-subtle); }
.usermenu .menu .item.sel { background: var(--primary-bg); color: var(--primary-text); }

/* blazor error ui */
#blazor-error-ui { background: var(--warning-bg); color: var(--warning-text); bottom: 0; display: none; left: 0; padding: 0.8rem 1.2rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.blazor-error-boundary { background: var(--danger-bg); padding: 1rem; color: var(--danger-text); border-radius: var(--radius-md); }
