/* =========================================================
   锦辰机电 · LiftOps
   Precision Editorial / Operate
   Warm canvas · Carbon navigation · Cobalt signal
   ========================================================= */

:root {
  --canvas: #f4f5f0;
  --canvas-deep: #ebede5;
  --bg: var(--canvas);
  --panel: #ffffff;
  --panel-soft: #fafbf7;
  --surface-soft: #f5f6f1;
  --ink: #121513;
  --ink-soft: #343a33;
  --muted: #666d64;
  --soft: #8b9187;
  --line: #e2e5dd;
  --line-strong: #d2d7cc;
  --brand: #2f5cff;
  --brand-2: #6d88ff;
  --brand-deep: #13265d;
  --brand-soft: #e9eeff;
  --accent: #d9f36a;
  --accent-ink: #3d4b00;
  --nav: #161a17;
  --nav-2: #1d221e;
  --nav-line: rgba(255, 255, 255, 0.08);
  --amber: #a96800;
  --amber-soft: #fff4d6;
  --red: #c9362b;
  --red-soft: #fff0ed;
  --green: #187a54;
  --green-soft: #e7f5ee;
  --blue: #2457d6;
  --blue-soft: #e9efff;
  --purple: #6550bf;
  --purple-soft: #efedff;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 18px 48px rgba(20, 26, 20, 0.08);
  --shadow-soft: 0 8px 24px rgba(20, 26, 20, 0.055);
  --focus: 0 0 0 4px rgba(47, 92, 255, 0.15);
  --font: Aptos, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(18, 21, 19, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 21, 19, 0.018) 1px, transparent 1px),
    var(--canvas);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body, button, input, select, textarea { font-family: var(--font); }
button, input, select, textarea { font-size: inherit; }
button { color: inherit; cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; }
::selection { background: #dfe6ff; color: var(--ink); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
input, select, textarea { caret-color: var(--brand); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }
input[type="date"] { min-width: 0; }
hr { border: 0; border-top: 1px solid var(--line); }

* { scrollbar-width: thin; scrollbar-color: #c6cbc0 transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: #c6cbc0;
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: #aeb4a8; background-clip: padding-box; }

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

/* ---------- Login ---------- */

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(420px, 0.86fr) minmax(0, 1.14fr);
  background: var(--canvas);
}

.login-panel {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 54px;
  border-right: 1px solid var(--line);
  background: var(--canvas);
}

.login-card {
  width: min(410px, 100%);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  backdrop-filter: none;
}

.login-brand-mobile { display: none; }

.login-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  margin-bottom: 28px;
}

.login-kicker::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.login-card h2 {
  margin: 0;
  max-width: 390px;
  font-size: clamp(32px, 3.2vw, 43px);
  line-height: 1.08;
  letter-spacing: -0.055em;
  font-weight: 780;
}

.login-card .sub {
  color: var(--muted);
  margin: 13px 0 30px;
  line-height: 1.72;
  font-size: 14px;
}

.login-form .field { margin-bottom: 16px; }
.login-form .field label {
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.login-form .input { height: 48px; background: #fbfcf8; }
.login-form .btn.primary { height: 48px; margin-top: 5px; font-size: 14px; }

.login-security {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 18px;
  color: var(--soft);
  font-size: 11px;
  line-height: 1.55;
}
.login-security svg { width: 16px; height: 16px; flex: 0 0 16px; color: var(--green); margin-top: 1px; }

.demo-accounts {
  margin-top: 32px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.demo-accounts p {
  margin: 0 0 10px;
  color: var(--soft);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.13em;
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.demo-account {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: left;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.35;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.demo-account:hover {
  border-color: var(--brand-2);
  background: var(--brand-soft);
  color: var(--brand-deep);
}
.demo-account small {
  display: block;
  color: var(--soft);
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.login-brand {
  min-height: 100vh;
  padding: 42px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  color: #f4f6f0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    var(--nav);
  background-size: 56px 56px;
}

.login-brand::after {
  content: "";
  position: absolute;
  width: 380px;
  height: 380px;
  right: -116px;
  bottom: -150px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 54px rgba(255, 255, 255, 0.025), 0 0 0 108px rgba(255, 255, 255, 0.016);
  pointer-events: none;
}

.login-brand > * { position: relative; z-index: 1; }

.login-brand-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup > div:last-child { display: grid; gap: 2px; }
.brand-lockup strong { font-size: 15px; letter-spacing: -0.02em; }
.brand-lockup small {
  color: #8f978c;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.login-version {
  color: #858d82;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.04em;
  position: relative;
  overflow: hidden;
}

.brand-mark::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  top: 7px;
  right: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.login-hero { margin: auto 0; padding: 56px 0 44px; }

.login-index {
  margin: 0 0 24px;
  color: #a3aa9f;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.login-brand h1 {
  margin: 0;
  max-width: 800px;
  color: #f5f7f1;
  font-size: clamp(44px, 4.6vw, 76px);
  line-height: 1.02;
  letter-spacing: -0.065em;
  font-weight: 780;
}

.login-brand h1 span { color: var(--accent); }

.login-brand .login-lede {
  margin: 24px 0 0;
  max-width: 540px;
  color: #aeb5a9;
  font-size: 15px;
  line-height: 1.8;
}

.login-proof {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 0 0 36px;
  border-top: 1px solid var(--nav-line);
}

.login-proof-item {
  padding: 18px 20px 0 0;
  border-right: 1px solid var(--nav-line);
}
.login-proof-item:not(:first-child) { padding-left: 20px; }
.login-proof-item:last-child { border-right: 0; }
.login-proof-item span {
  display: block;
  color: #80887d;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.login-proof-item strong {
  display: block;
  margin-top: 7px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.login-proof-item small { display: block; color: var(--accent); margin-top: 4px; font-size: 11px; }

.login-foot {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-top: 1px solid var(--nav-line);
  padding-top: 16px;
  color: #7f877c;
  font-size: 10px;
  letter-spacing: 0.04em;
}
/* ---------- App shell ---------- */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 15px 18px;
  display: flex;
  flex-direction: column;
  color: #c3cabf;
  background:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    var(--nav);
  background-size: 24px 24px;
  border-right: 1px solid rgba(18, 21, 19, 0.2);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 7px 18px;
  border-bottom: 1px solid var(--nav-line);
}

.sidebar-brand .brand-mark { width: 40px; height: 40px; border-radius: 11px; font-size: 14px; }
.sidebar-brand strong {
  display: block;
  color: #f4f6f0;
  font-size: 15px;
  letter-spacing: -0.025em;
}
.sidebar-brand small {
  display: block;
  color: #7f877c;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  display: grid;
  align-content: start;
  gap: 3px;
  overflow-y: auto;
  padding: 4px 0 10px;
  margin-top: 2px;
}

.nav-section {
  margin: 16px 9px 5px;
  color: #666e64;
  font-size: 9px;
  letter-spacing: 0.16em;
  font-weight: 750;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 37px;
  color: #aab2a6;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13px;
  line-height: 1.35;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.nav-item:hover {
  color: #f0f3ec;
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: #fff;
  background: var(--brand);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 3px 0 0 var(--accent), 0 7px 18px rgba(0, 0, 0, 0.16);
  font-weight: 720;
}

.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: 0.88; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 15px 9px 0;
  border-top: 1px solid var(--nav-line);
  color: #778075;
  font-size: 10px;
  line-height: 1.7;
}

.sidebar-footer strong { color: #c9d0c4; display: block; margin-bottom: 3px; font-size: 11px; }
.sidebar-status {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #96a48f;
  margin-bottom: 5px;
  font-size: 10px;
}
.sidebar-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 243, 106, 0.12);
}

.main { min-width: 0; padding: 22px 30px 48px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.topbar-left { display: flex; align-items: center; gap: 11px; min-width: 0; }
.topbar-context {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.03em;
}
.topbar-context::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
  flex: 0 0 6px;
}
.topbar-context strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-context .sep { color: var(--line-strong); }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar-date {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 0 4px;
  white-space: nowrap;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 6px 5px 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(20, 26, 20, 0.025);
}
.user-chip .small { line-height: 1.35; }
.user-chip .small strong { font-size: 12px; }
.user-chip .small .muted { font-size: 10px; }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 30px;
}

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

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 22px;
  margin: 2px 0 24px;
}

.page-head h1 {
  margin: 0 0 10px;
  font-size: clamp(34px, 4vw, 52px);
  line-height: 1.03;
  letter-spacing: -0.06em;
  font-weight: 780;
}
.page-head p {
  margin: 0;
  max-width: 820px;
  color: var(--muted);
  line-height: 1.72;
  font-size: 14px;
}

.eyebrow { display: none !important; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }

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

.btn {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink-soft);
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
  box-shadow: 0 1px 0 rgba(20, 26, 20, 0.03);
}

.btn:hover {
  border-color: #aeb6a9;
  background: #fbfcf8;
  box-shadow: 0 5px 14px rgba(20, 26, 20, 0.06);
}
.btn svg { width: 14px; height: 14px; flex: 0 0 14px; }
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 7px 18px rgba(47, 92, 255, 0.18);
}
.btn.primary:hover { background: #244bd8; border-color: #244bd8; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.dark:hover { background: #292f29; border-color: #292f29; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--panel); }
.btn.amber { background: var(--amber-soft); border-color: #efd58e; color: #7e5100; }
.btn.amber:hover { background: #ffefbd; }
.btn.danger { color: var(--red); border-color: #f1c6bf; background: #fff8f6; }
.btn.danger:hover { background: var(--red-soft); border-color: #e8aaa1; }
.btn.sm { min-height: 30px; padding: 5px 9px; font-size: 11px; border-radius: 8px; }
.btn[hidden] { display: none !important; }
.btn:disabled { opacity: 0.48; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.w-full { width: 100%; }

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--brand);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Metrics ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-grid:has(> .metric-card:nth-child(5)):not(:has(> .metric-card:nth-child(6))) { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.metric-card {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px 18px 16px;
  box-shadow: 0 1px 0 rgba(20, 26, 20, 0.022);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.metric-card::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  top: 16px;
  right: 17px;
  border-radius: 50%;
  background: var(--brand);
}

.metric-card.red::after { background: var(--red); }
.metric-card.amber::after { background: #d59a24; }
.metric-card.blue::after { background: var(--blue); }
.metric-card.purple::after { background: var(--purple); }
.metric-card.green::after { background: var(--green); }

.metric-card.clickable { cursor: pointer; }
.metric-card.clickable:hover {
  transform: translateY(-2px);
  border-color: #c7cec2;
  box-shadow: var(--shadow-soft);
}
.metric-card.clickable:focus-visible { outline: 3px solid rgba(47, 92, 255, 0.22); outline-offset: 2px; }

.metric-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.35;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 14px;
}
.metric-label::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand);
  flex: 0 0 5px;
}
.metric-card.red .metric-label::before { background: var(--red); }
.metric-card.amber .metric-label::before { background: #d59a24; }
.metric-card.blue .metric-label::before { background: var(--blue); }
.metric-card.purple .metric-label::before { background: var(--purple); }
.metric-card.green .metric-label::before { background: var(--green); }

.metric-link {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--brand);
  font-size: 10px;
  font-weight: 750;
}
.metric-link svg { width: 11px; height: 11px; }

.metric-value {
  font-size: clamp(27px, 2.55vw, 36px);
  font-weight: 780;
  letter-spacing: -0.055em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.metric-value small {
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
  letter-spacing: 0;
  margin-left: 2px;
}
.metric-sub {
  margin-top: 9px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.55;
}

.kpi-grid > .metric-card:first-child {
  background: var(--ink);
  border-color: var(--ink);
  color: #f4f6f0;
}
.kpi-grid > .metric-card:first-child::after { background: var(--accent); }
.kpi-grid > .metric-card:first-child .metric-label { color: #abb2a7; }
.kpi-grid > .metric-card:first-child .metric-label::before { background: var(--accent); }
.kpi-grid > .metric-card:first-child .metric-value { color: #fff; }
.kpi-grid > .metric-card:first-child .metric-value small,
.kpi-grid > .metric-card:first-child .metric-sub { color: #aeb5aa; }
.kpi-grid > .metric-card:first-child .metric-link { color: var(--accent); }

/* ---------- Layout & cards ---------- */

.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.side-main { grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.5fr); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(20, 26, 20, 0.022);
  overflow: hidden;
}

.card-head {
  padding: 16px 18px 13px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.card-head > svg { width: 20px; height: 20px; flex: 0 0 20px; color: var(--muted); }
.card-head h3 { margin: 0; font-size: 15px; letter-spacing: -0.03em; line-height: 1.35; }
.card-head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.card-body { padding: 17px 18px; }
.card-body.tight { padding: 0; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 12px;
}
.section-title h2 { margin: 0; font-size: 17px; letter-spacing: -0.035em; }
.section-title p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */

.input, .select, .textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  background: #fbfcf8;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--ink);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
  font-size: 13px;
}
.input:hover, .select:hover, .textarea:hover { border-color: #b9c0b3; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: var(--focus);
}
.input::placeholder, .textarea::placeholder { color: #9ba196; }
.textarea { min-height: 110px; resize: vertical; line-height: 1.65; }
.search-input { min-width: 230px; }

.field { display: grid; gap: 6px; margin-bottom: 13px; }
.field label { font-size: 11px; color: var(--ink-soft); font-weight: 700; line-height: 1.45; }
.field .hint { font-size: 10px; color: var(--muted); line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-soft); }
.check-line input { width: auto; }
/* ---------- Tables ---------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  scrollbar-gutter: stable;
}
.table-wrap > table { min-width: 780px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
th {
  text-align: left;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.045em;
  padding: 11px 14px;
  background: #f7f8f3;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid #eef0ea;
  vertical-align: middle;
  color: var(--ink-soft);
  line-height: 1.5;
}
tbody tr { transition: background 130ms ease; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbf7; }
tbody tr.clickable { cursor: pointer; }
td .sub {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
  margin-top: 3px;
}
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.strong { font-weight: 750; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.nowrap { white-space: nowrap; }
.wrap-cell { min-width: 220px; max-width: 380px; white-space: normal; line-height: 1.55; }

.report-unit-table-wrap { border: 1px solid #eef0ea; border-radius: 14px; }
.report-unit-table { min-width: 860px; }
.report-unit-table th { background: #f7f8f3; }
.report-unit-table .report-select-cell { width: 42px; text-align: center; padding-left: 10px; padding-right: 10px; }
.report-unit-check,
.report-row-check,
.report-select-cell input[type='checkbox'] { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.report-unit-name { display: flex; align-items: center; gap: 8px; min-width: 220px; }
.report-unit-name strong { font-size: 13px; }
.report-unit-toggle { flex: 0 0 auto; display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--muted); cursor: pointer; }
.report-unit-toggle svg { width: 14px; height: 14px; transition: transform 0.16s ease; }
.report-unit-toggle.is-open svg { transform: rotate(90deg); }
.report-unit-toggle:hover { border-color: var(--brand-2); color: var(--brand); background: var(--brand-soft); }
.report-unit-row { cursor: pointer; }
.report-unit-detail > td { padding: 0 14px 14px 54px; background: #fafbf7; }
.report-elevator-table-wrap { border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; background: #fff; }
.report-elevator-table { min-width: 940px; }
.report-elevator-table th { background: #f3f5ef; padding-top: 9px; padding-bottom: 9px; }
.report-elevator-table td { padding-top: 10px; padding-bottom: 10px; }

.customer-table th:last-child,
.customer-table td:last-child {
  white-space: nowrap;
}
.customer-table td:last-child { min-width: 196px; }
.customer-table td:last-child > .btn + .btn { margin-left: 6px; }

/* ---------- Status ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  line-height: 1.5;
  font-weight: 750;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 5px;
  opacity: 0.8;
}
.badge.green { background: var(--green-soft); color: #116442; }
.badge.red { background: var(--red-soft); color: #a62d23; }
.badge.amber { background: var(--amber-soft); color: #855500; }
.badge.blue { background: var(--blue-soft); color: #1d46b8; }
.badge.purple { background: var(--purple-soft); color: #5743a8; }
.badge.gray { background: #f0f2ec; color: #596056; }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  background: var(--brand);
  flex: 0 0 7px;
}
.dot.red { background: var(--red); }
.dot.amber { background: #d59a24; }
.dot.blue { background: var(--blue); }

/* ---------- Charts & data viz ---------- */

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: 220px;
  padding: 8px 2px 0;
}
.bar-group {
  flex: 1;
  min-width: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  height: 100%;
}
.bar-pair {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
}
.bar {
  width: 34%;
  max-width: 18px;
  border-radius: 5px 5px 2px 2px;
  min-height: 3px;
  transition: height 500ms ease;
}
.bar.revenue { background: var(--brand); }
.bar.cost { background: #d1a841; }
.bar-label { font-size: 9px; color: var(--muted); white-space: nowrap; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 10px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.hbar-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 68px;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 11px;
}
.hbar-track { height: 8px; background: #eef0e9; border-radius: 999px; overflow: hidden; }
.hbar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
  min-width: 2px;
}
.hbar-fill.amber { background: #d1a841; }
.hbar-fill.red { background: var(--red); }
.hbar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  white-space: nowrap;
}

.exception-list { display: grid; gap: 8px; }
.exception-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 12px;
}
.exception-item .dot { margin-top: 5px; }
.exception-item strong { display: block; font-size: 12px; margin-bottom: 3px; }
.exception-item span { color: var(--muted); font-size: 11px; line-height: 1.5; }
.exception-item.high { border-color: #f0c4be; background: #fff7f5; }

.priority-list { display: grid; gap: 9px; }
.priority-item {
  padding: 12px;
  border-radius: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}
.priority-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.priority-top strong { font-size: 12px; }
.priority-item p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }

.progress { height: 7px; background: #eef0e9; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.progress.amber > i { background: #d1a841; }
.progress.red > i { background: var(--red); }

.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.stat-chip {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
}
.stat-chip span { display: block; font-size: 10px; color: var(--muted); margin-bottom: 5px; line-height: 1.45; }
.stat-chip strong { font-size: 17px; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }

/* ---------- Empty / loading / toast ---------- */

.empty, .loading {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.loading::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #d8dcf8;
  border-top-color: var(--brand);
  animation: spin 800ms linear infinite;
  margin-right: 8px;
  vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast-root { position: fixed; right: 22px; bottom: 22px; z-index: 1000; display: grid; gap: 8px; }
.toast {
  background: var(--ink);
  color: #f4f6f0;
  padding: 11px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  box-shadow: var(--shadow);
  font-size: 12px;
  animation: toast-in 180ms ease;
  max-width: 360px;
}
.toast.error { background: #7f2019; }
.toast.warn { background: #6f4900; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 16, 14, 0.58);
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade-in 150ms ease;
}
.document-preview-backdrop { z-index: 950; background: rgba(13, 16, 14, 0.68); }
.modal {
  width: min(760px, 100%);
  max-height: min(88vh, 920px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  box-shadow: 0 28px 90px rgba(5, 8, 6, 0.32);
  animation: modal-in 180ms ease;
}
.modal.wide { width: min(980px, 100%); }
.modal-head {
  padding: 19px 22px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}
.modal-head h3 { margin: 0; font-size: 18px; letter-spacing: -0.04em; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.modal-close {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 9px;
  font-size: 18px;
  line-height: 1;
}
.modal-close:hover { background: var(--canvas-deep); color: var(--ink); }
.modal-body { padding: 20px 22px; }
.modal-foot {
  padding: 14px 22px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: var(--panel);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.992); } to { opacity: 1; transform: translateY(0) scale(1); } }
/* ---------- Upload & media ---------- */

.upload-zone {
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  padding: 19px;
  background: var(--panel-soft);
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.upload-zone.is-dragging { border-color: var(--brand); background: var(--brand-soft); }
.upload-zone input { display: none; }
.upload-zone label { cursor: pointer; color: var(--brand); font-weight: 750; }
.upload-selected-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.file-chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 7px 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-soft);
  font-size: 10px;
}
.file-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.file-chip button { border: 0; background: transparent; color: var(--soft); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 0 0 2px; }
.file-chip button:hover { color: var(--red); }
.upload-results { margin-top: 16px; display: grid; gap: 8px; }
.upload-result {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-soft);
}
.upload-result > div:first-child { min-width: 0; }
.upload-result > div:last-child { flex: 0 0 auto; }
.upload-result strong { display: block; font-size: 12px; }
.upload-result strong, .upload-result .sub { overflow-wrap: anywhere; }
.upload-result .sub { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; line-height: 1.55; }
.preview { width: 100%; max-height: 320px; object-fit: contain; border-radius: 12px; background: var(--panel-soft); margin-top: 12px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.photo-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.photo-card img { width: 100%; height: 160px; object-fit: cover; display: block; background: var(--panel-soft); }
.photo-meta { padding: 10px 12px; }
.photo-meta strong { display: block; font-size: 11px; }
.photo-meta span { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; line-height: 1.5; }

/* ---------- AI chat & import ---------- */

.chat-shell { display: grid; gap: 12px; }
.chat-log { display: grid; gap: 12px; max-height: 520px; overflow-y: auto; padding: 4px; }
.chat-message { max-width: 86%; padding: 12px 14px; border-radius: 14px; font-size: 12px; line-height: 1.75; white-space: pre-wrap; }
.chat-message.assistant { background: var(--panel-soft); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.chat-message.user { background: var(--ink); color: #fff; justify-self: end; border-bottom-right-radius: 5px; }
.chat-citations { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.chat-citations span { background: var(--brand-soft); color: var(--brand-deep); border-radius: 999px; padding: 3px 8px; font-size: 9px; }
.suggestions { display: flex; gap: 7px; flex-wrap: wrap; }
.suggestion { border: 1px solid #cfd7f3; background: #f7f8ff; color: var(--brand-deep); border-radius: 999px; padding: 6px 10px; font-size: 11px; }
.suggestion:hover { background: var(--brand-soft); }

.import-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.import-card { border: 1px solid var(--line); border-radius: 13px; padding: 15px; background: var(--panel-soft); }
.import-card h3 { margin: 0 0 5px; font-size: 13px; }
.import-card p { margin: 0 0 12px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.import-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.code-block {
  background: var(--ink);
  color: #dce2d7;
  border-radius: 12px;
  padding: 14px;
  font-size: 11px;
  line-height: 1.7;
  overflow: auto;
  font-family: var(--mono);
  white-space: pre-wrap;
}

/* ---------- Collection project cards ---------- */

.collection-node-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  margin-bottom: 10px;
}
.collection-node-row .field { margin-bottom: 0; }
.collection-node-remove { margin-bottom: 1px; }
.collection-node-list { display: grid; gap: 10px; }
.collection-node-card { border: 1px solid var(--line); border-radius: 13px; padding: 14px; background: var(--panel); }
.collection-node-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.collection-node-head strong { display: block; font-size: 13px; }
.collection-node-head .sub { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; }
.collection-node-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.collection-node-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.collection-node-metrics span { background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; color: var(--muted); font-size: 10px; }
.collection-node-metrics strong { display: block; color: var(--ink); font-size: 12px; margin-top: 3px; }
.collection-node-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 11px; border-top: 1px solid var(--line); }

/* ---------- Credentials / OCR / documents ---------- */

.credential-box { display: grid; gap: 9px; }
.credential-box > div, .credential-inline > div { background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.credential-box span, .credential-inline span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 3px; }
.credential-box strong, .credential-inline strong { font-size: 12px; word-break: break-all; }
.credential-password { color: var(--brand); letter-spacing: 0.06em; }
.credential-inline { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: 9px; align-items: center; }

.ocr-preview {
  max-height: 420px;
  overflow: auto;
  background: #fbfaf5;
  color: #262b25;
  border: 1px solid #deded2;
  border-radius: 12px;
  padding: 20px;
  font-size: 16px;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-all;
  box-shadow: inset 0 0 0 6px #f3f1e8;
}
.ocr-preview .ocr-key, .ocr-preview mark.ocr-key {
  color: #b42318;
  background: #ffebe6;
  font-weight: 850;
  padding: 1px 3px;
  border-radius: 3px;
  box-shadow: inset 0 -2px 0 #f2a396;
}
.ocr-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}
.ocr-actions .small { color: var(--muted); }
.invoice-list { display: flex; gap: 6px; flex-wrap: wrap; }
.invoice-list a { color: var(--brand-deep); background: var(--brand-soft); border-radius: 999px; padding: 3px 8px; font-size: 10px; }
.invoice-list a:hover { text-decoration: underline; }

.document-preview {
  height: min(70vh, 760px);
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
}
.document-preview iframe { width: 100%; height: 100%; border: 0; background: #fff; }

.permission-table-wrap { max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.permission-table-wrap > table { min-width: 620px; }
.permission-table th:first-child, .permission-table td:first-child { width: 42%; }
.permission-table .check-line { white-space: nowrap; }

/* ---------- Searchable select ---------- */

.searchable-select { position: relative; min-width: 0; }
.searchable-select-input { position: relative; }
.searchable-select-input .input { padding-right: 36px; }
.searchable-select-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--canvas-deep);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.searchable-select-clear:hover { background: var(--line); color: var(--ink); }
.searchable-select-clear[hidden], .searchable-select-menu[hidden] { display: none; }
.searchable-select-menu {
  margin-top: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}
.searchable-select-option {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.searchable-select-option:hover, .searchable-select-option.active { background: var(--brand-soft); color: var(--brand-deep); }
.searchable-select-count, .searchable-select-empty { padding: 7px 10px; color: var(--muted); font-size: 10px; line-height: 1.55; }

/* ---------- Utilities ---------- */

.divider { height: 1px; background: var(--line); margin: 18px 0; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.wrap { flex-wrap: wrap; }
.gap-6 { gap: 6px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-0 { margin-bottom: 0; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.hint { color: var(--muted); font-size: 11px; line-height: 1.6; }

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

@media (max-width: 1280px) {
  .main { padding: 20px 24px 40px; }
  .kpi-grid, .kpi-grid:has(> .metric-card:nth-child(5)):not(:has(> .metric-card:nth-child(6))) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .page-head h1 { font-size: clamp(34px, 4.2vw, 48px); }
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 226px minmax(0, 1fr); }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .kpi-grid, .kpi-grid:has(> .metric-card:nth-child(5)):not(:has(> .metric-card:nth-child(6))) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.side-main { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-date { display: none; }
}

@media (max-width: 900px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-panel { min-height: 100vh; padding: 36px 24px; border-right: 0; order: 1; flex-direction: column; align-items: center; justify-content: flex-start; }
  .login-brand { display: none; }
  .login-brand-mobile {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 34px;
  }
  .login-brand-mobile .brand-mark { width: 40px; height: 40px; border-radius: 11px; font-size: 14px; }
  .login-brand-mobile strong { display: block; font-size: 14px; }
  .login-brand-mobile span { display: block; color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; }

  .app-shell { display: block; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: auto;
    padding: 10px 12px 9px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .sidebar-brand { padding: 0 2px 9px; border-bottom: 0; }
  .sidebar-brand .brand-mark { width: 32px; height: 32px; border-radius: 9px; font-size: 12px; }
  .sidebar-brand strong { font-size: 13px; }
  .sidebar-brand small { display: none; }
  .sidebar-nav {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 0 2px;
    margin-top: 0;
  }
  .nav-section { display: none; }
  .nav-item {
    flex: 0 0 auto;
    justify-content: center;
    min-height: 34px;
    padding: 7px 10px;
    font-size: 11px;
    border-radius: 999px;
    white-space: nowrap;
  }
  .nav-item.active { box-shadow: none; }
  .nav-item svg { width: 14px; height: 14px; flex-basis: 14px; }
  .sidebar-footer { display: none; }

  .main { padding: 18px 16px 36px; }
  .topbar { margin-bottom: 18px; }
  .topbar-context::before { display: none; }
  .page-head { align-items: flex-start; flex-direction: column; gap: 14px; margin-bottom: 20px; }
  .head-actions { justify-content: flex-start; }
  .grid.two-col, .grid.three-col { grid-template-columns: 1fr; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .form-grid .span-2, .form-grid .span-3 { grid-column: auto; }
  .collection-node-row { grid-template-columns: 1fr; }
  .collection-node-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .collection-node-footer { align-items: flex-start; flex-direction: column; }
  .import-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .login-panel { padding: 28px 20px; align-items: center; justify-content: flex-start; }
  .login-card h2 { font-size: 34px; }
  .login-card .sub { margin-bottom: 24px; }
  .demo-grid { grid-template-columns: 1fr 1fr; }

  .main { padding: 15px 12px 34px; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 10px; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .user-chip { margin-left: auto; }
  .user-chip .small { display: none; }
  .page-head h1 { font-size: 32px; }
  .page-head p { font-size: 12px; }
  .kpi-grid, .kpi-grid.three, .kpi-grid:has(> .metric-card:nth-child(5)):not(:has(> .metric-card:nth-child(6))) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .metric-card { padding: 14px 14px 13px; }
  .metric-value { font-size: 26px; }
  .metric-sub { font-size: 10px; }
  .photo-grid { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .collection-node-head { flex-direction: column; }
  .collection-node-badges { justify-content: flex-start; }
  .credential-inline { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 10px; align-items: end; }
  .modal { max-height: 92vh; border-radius: 18px 18px 0 0; }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .toast-root { right: 12px; left: 12px; bottom: 12px; }
  .toast { max-width: none; }
  .document-preview { height: 62vh; min-height: 320px; }
  .chart-bars { gap: 7px; height: 190px; }
}

@media (max-width: 420px) {
  .kpi-grid, .kpi-grid.three, .kpi-grid:has(> .metric-card:nth-child(5)):not(:has(> .metric-card:nth-child(6))) { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: 1fr; }
  .login-card h2 { font-size: 31px; }
  .demo-grid { grid-template-columns: 1fr; }
  .nav-item span { max-width: 82px; overflow: hidden; text-overflow: ellipsis; }
}

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

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .head-actions, .toast-root { display: none !important; }
  .app-shell { display: block; }
  .main { padding: 0; }
  .card, .metric-card { break-inside: avoid; box-shadow: none; }
}

/* ---------- Payment queries ---------- */

.payment-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 9px;
  margin: 14px 0 10px;
}
.payment-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcf8;
}
.payment-stat span { color: var(--muted); font-size: 10px; font-weight: 700; }
.payment-stat strong { font-size: 20px; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.payment-stat.green strong { color: var(--green); }
.payment-stat.amber strong { color: #9a6200; }
.payment-stat.blue strong { color: var(--blue); }
.payment-stat.purple strong { color: var(--purple); }
.payment-folder { margin-bottom: 12px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.payment-folder code { color: var(--ink-soft); background: #f2f4ee; padding: 2px 6px; border-radius: 5px; }
.payment-table { width: 100%; min-width: 1020px; table-layout: fixed; }
.payment-table td { vertical-align: top; overflow-wrap: anywhere; }
.payment-col-unit { width: 20%; }
.payment-col-status { width: 18%; }
.payment-col-invoice { width: 11%; }
.payment-col-receipt { width: 12%; }
.payment-col-checked { width: 10%; }
.payment-col-actions { width: 29%; }
.payment-code {
  display: block;
  margin: 3px 0;
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
  word-break: break-all;
}
.payment-status-stack { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.payment-error {
  display: block;
  max-width: 100%;
  color: var(--red);
  font-size: 10px;
  line-height: 1.45;
  word-break: break-all;
}
.payment-file-link { display: inline-flex; align-items: center; gap: 4px; color: var(--brand); font-size: 11px; font-weight: 700; text-decoration: none; }
.payment-file-link svg { width: 13px; height: 13px; }
.payment-file-link:hover { text-decoration: underline; }
.payment-actions { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; max-width: none; margin-left: auto; }
.payment-query-text { min-height: 190px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; line-height: 1.65; }
.payment-preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 4px 0 8px; }
.payment-preview-head strong { font-size: 12px; }
.payment-preview .table-wrap { margin-top: 6px; }
.payment-preview-table { min-width: 720px; }
.payment-preview-table td { vertical-align: top; }
.payment-errors { display: grid; gap: 4px; margin-top: 8px; color: #9a6200; font-size: 10px; }
.payment-note { margin: 10px 0; padding: 9px 11px; border: 1px solid #efd58e; border-radius: 9px; background: #fff9e8; color: #7e5100; font-size: 10px; line-height: 1.6; }
.captcha-box { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.captcha-box .input { flex: 1 1 150px; }

/* ---------- Problem board ---------- */

.issue-metric-button {
  text-align: left;
  width: 100%;
  font: inherit;
  cursor: pointer;
}
.issue-metric-button.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(47, 92, 255, 0.16), var(--shadow-soft);
}

.issue-board-card .card-body { padding-top: 16px; }
.issue-toolbar { margin-bottom: 14px; }

.issue-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.issue-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 15px 16px 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.issue-card:hover {
  transform: translateY(-2px);
  border-color: #c7cec2;
  box-shadow: var(--shadow-soft);
}
.issue-state-open { border-left-color: var(--red); }
.issue-state-assigned { border-left-color: #d59a24; }
.issue-state-accepted { border-left-color: var(--blue); }
.issue-state-paused { border-left-color: var(--purple); }
.issue-state-resolved { border-left-color: #d59a24; }
.issue-state-closed { border-left-color: var(--green); opacity: 0.82; }

.issue-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.issue-card-title { min-width: 0; }
.issue-card-title strong {
  display: block;
  font-size: 15px;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.issue-card-title .sub { display: block; margin-top: 3px; }
.issue-card-desc {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.issue-owner-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-soft);
}
.issue-clocks,
.issue-detail-clocks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.issue-clock {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  background: #fafbf7;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 10px;
  line-height: 1.3;
  white-space: nowrap;
}
.issue-clock strong { color: var(--ink); font-size: 11px; }
.issue-clock.danger { background: var(--red-soft); border-color: #f1c6bf; color: #a62d23; }
.issue-clock.danger strong { color: #a62d23; }
.issue-clock.paused { background: var(--purple-soft); border-color: #d8d1f3; color: #5743a8; }
.issue-clock.paused strong { color: #5743a8; }

.issue-detail-clocks .issue-clock { font-size: 12px; padding: 7px 10px; }
.issue-detail-clocks .issue-clock strong { font-size: 15px; }

.issue-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  margin-top: auto;
}
.issue-card-foot .btn { flex: 0 0 auto; }

.issue-detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.issue-pause-note {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--purple-soft);
  color: #5743a8;
  font-size: 12px;
  line-height: 1.6;
}
.issue-detail-section { margin-top: 18px; }
.issue-detail-section h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.issue-detail-section p { margin: 0 0 8px; line-height: 1.75; font-size: 13px; white-space: pre-wrap; }

.issue-timeline { display: flex; flex-direction: column; gap: 0; margin-top: 8px; }
.issue-event {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 10px;
  position: relative;
  padding-bottom: 14px;
}
.issue-event::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 10px;
  bottom: -2px;
  width: 1px;
  background: var(--line);
}
.issue-event:last-child::before { display: none; }
.issue-event-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: 5px;
  position: relative;
  z-index: 1;
}
.issue-event-body { min-width: 0; }
.issue-event-body strong { display: block; font-size: 12px; }
.issue-event-body .sub { display: block; margin-top: 2px; }
.issue-event-body p { margin: 5px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.65; white-space: pre-wrap; }

.issue-comment-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.issue-comment-form .textarea { min-height: 66px; flex: 1; }
.issue-optional { margin-top: 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px; }
.issue-optional summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--muted); }
.issue-new-title { min-height: 96px; font-size: 14px; }

.danger-text { color: var(--red); font-weight: 700; }

.issue-cockpit-card { margin-bottom: 16px; }
.issue-cockpit-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.issue-cockpit-metric {
  border: 1px solid var(--line);
  background: #fafbf7;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.issue-cockpit-metric span { width: 100%; color: var(--muted); font-size: 10px; font-weight: 700; }
.issue-cockpit-metric strong { font-size: 24px; letter-spacing: -0.04em; }
.issue-cockpit-metric small { color: var(--muted); font-size: 10px; }
.issue-cockpit-metric.red strong { color: var(--red); }
.issue-cockpit-metric.amber strong { color: #855500; }
.issue-cockpit-metric.purple strong { color: #5743a8; }
.issue-cockpit-metric.green strong { color: var(--green); }
.issue-cockpit-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.issue-cockpit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
  background: var(--panel);
}
.issue-cockpit-item:hover { border-color: #c7cec2; background: #fbfcf8; }
.issue-cockpit-item div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.issue-cockpit-item strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.issue-cockpit-item span { color: var(--muted); font-size: 10px; }
.issue-cockpit-item em { flex: 0 0 auto; font-size: 11px; font-style: normal; color: var(--muted); font-weight: 700; }

@media (max-width: 980px) {
  .issue-grid { grid-template-columns: 1fr; }
  .issue-cockpit-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .issue-cockpit-metrics { grid-template-columns: 1fr; }
  .issue-clocks { gap: 4px; }
  .issue-clock { font-size: 9px; }
  .issue-comment-form { flex-direction: column; align-items: stretch; }
  .issue-comment-form .btn { width: 100%; }
  .issue-card-foot { align-items: flex-start; flex-direction: column; }
  .issue-card-foot .btn { width: 100%; }
}
.captcha-box img { width: 116px; height: 42px; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.payment-result-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-bottom: 12px; }
.payment-result-stats > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: #fbfcf8; }
.payment-result-stats span { color: var(--muted); font-size: 10px; font-weight: 700; }
.payment-result-stats strong { font-size: 19px; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .payment-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .payment-result-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .payment-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .payment-actions { justify-content: flex-start; max-width: none; margin-left: 0; }
}
