/* ============================================================
   RegenRoots · design system
   ============================================================ */

:root {
  --font-display: 'Sora', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --bg: #f1f4ee;
  --surface: #ffffff;
  --surface-2: #f7f9f5;
  --line: #e3e8dd;
  --line-2: #d2dac9;

  --ink: #1a241c;
  --ink-2: #4e5e53;
  --ink-3: #7e8d81;

  --pine-deep: #0d1911;
  --pine: #122319;
  --pine-2: #1a3122;
  --pine-3: #23452f;
  --pine-line: rgba(255,255,255,.07);
  --pine-text: #aabfae;

  --green: #2f7d46;
  --green-d: #266239;
  --green-soft: #e4f1e7;
  --green-ring: rgba(47,125,70,.22);
  --lime: #8fd9a0;

  --gold: #a87f15;
  --gold-soft: #f6efd8;
  --red: #c2452f;
  --red-soft: #faeae6;
  --info: #2b6e86;
  --info-soft: #e4f0f4;

  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 9px;

  --shadow-s: 0 1px 2px rgba(20, 31, 23, .05);
  --shadow-m: 0 1px 2px rgba(20,31,23,.04), 0 8px 24px -12px rgba(20,31,23,.18);
  --shadow-l: 0 12px 28px -8px rgba(13,25,17,.22), 0 48px 80px -32px rgba(13,25,17,.3);

  --ease: cubic-bezier(.22,.8,.32,1);
  --ease-pop: cubic-bezier(.3,1.4,.46,1);
  --sidebar-w: 262px;
}

/* ---------- reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(143,217,160,.10), transparent 60%),
    radial-gradient(900px 420px at -10% 110%, rgba(176,148,33,.06), transparent 55%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { margin: 0; font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--green); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { display: block; flex-shrink: 0; }
::selection { background: rgba(47,125,70,.18); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--ink-3); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 4px; }

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.muted { color: var(--ink-3); }

/* ---------- keyframes ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes slide-r { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes slide-l { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes pulse-dot { 0%,100% { box-shadow: 0 0 0 0 rgba(143,217,160,.5);} 60% { box-shadow: 0 0 0 5px rgba(143,217,160,0);} }
@keyframes shake { 10%,90% { transform: translateX(-1px);} 20%,80% { transform: translateX(2px);} 30%,50%,70% { transform: translateX(-3px);} 40%,60% { transform: translateX(3px);} }
@keyframes drift { from { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-14px) rotate(4deg); } to { transform: translateY(0) rotate(0deg); } }

.anim-rise { animation: rise .45s var(--ease) both; }
.anim-pop { animation: pop .3s var(--ease) both; }
.shake { animation: shake .5s linear; }

.stagger > * { opacity: 0; animation: rise .5s var(--ease) forwards; }
.stagger > *:nth-child(1) { animation-delay: .02s; } .stagger > *:nth-child(2) { animation-delay: .07s; }
.stagger > *:nth-child(3) { animation-delay: .12s; } .stagger > *:nth-child(4) { animation-delay: .17s; }
.stagger > *:nth-child(5) { animation-delay: .22s; } .stagger > *:nth-child(6) { animation-delay: .27s; }
.stagger > *:nth-child(7) { animation-delay: .32s; } .stagger > *:nth-child(8) { animation-delay: .37s; }
.stagger > *:nth-child(n+9) { animation-delay: .42s; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--r-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; line-height: 1.2; white-space: nowrap;
  transition: background .18s, border-color .18s, color .18s, transform .12s, box-shadow .18s;
  user-select: none; position: relative;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 1px 2px rgba(20,31,23,.2), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover { background: var(--green-d); }
.btn-dark { background: var(--pine-2); color: #e9f2ea; }
.btn-dark:hover { background: var(--pine-3); }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--ink-3); color: var(--ink); }
.btn-soft { background: var(--green-soft); color: var(--green-d); }
.btn-soft:hover { background: #d4e9da; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #a83a27; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn-ghost.is-loading::after, .btn-soft.is-loading::after { border-color: rgba(47,125,70,.25); border-top-color: var(--green); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--r-sm); border: none; background: transparent;
  color: var(--ink-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- forms ---------- */
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fld > label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.fld-in { position: relative; display: flex; align-items: center; }
.fld-in > svg { position: absolute; left: 11px; color: var(--ink-3); pointer-events: none; }
.fld-in > svg + input { padding-left: 36px; }
input.in, select.in, textarea.in {
  width: 100%; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 9px 12px; font-size: 14px; background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s; outline: none; appearance: none;
}
textarea.in { resize: vertical; min-height: 74px; }
input.in:hover, select.in:hover, textarea.in:hover { border-color: var(--ink-3); }
input.in:focus, select.in:focus, textarea.in:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-ring); }
input.in::placeholder, textarea.in::placeholder { color: #a6b2a8; }
select.in {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237e8d81' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px;
}
.fld.has-error input.in, .fld.has-error select.in, .fld.has-error textarea.in { border-color: var(--red); box-shadow: 0 0 0 3px rgba(194,69,47,.14); }
.fld-err { font-size: 12px; color: var(--red); font-weight: 500; display: flex; gap: 5px; align-items: center; }
.fld-hint { font-size: 12px; color: var(--ink-3); }
.frm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.frm-grid .span2 { grid-column: span 2; }
@media (max-width: 640px) { .frm-grid { grid-template-columns: 1fr; } .frm-grid .span2 { grid-column: span 1; } }

.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; color: var(--ink-2); user-select: none; }
.check input { position: absolute; opacity: 0; width: 0; }
.check .box {
  width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-2); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; transition: all .15s var(--ease-pop); color: #fff;
}
.check .box svg { opacity: 0; transform: scale(.4); transition: all .18s var(--ease-pop); }
.check input:checked + .box { background: var(--green); border-color: var(--green); }
.check input:checked + .box svg { opacity: 1; transform: none; }
.check input:focus-visible + .box { box-shadow: 0 0 0 3px var(--green-ring); }

.pwd-meter { display: flex; gap: 4px; margin-top: 2px; }
.pwd-meter span { height: 4px; flex: 1; border-radius: 2px; background: var(--line); transition: background .25s; }
.pwd-meter.s1 span:nth-child(1) { background: var(--red); }
.pwd-meter.s2 span:nth-child(-n+2) { background: var(--gold); }
.pwd-meter.s3 span:nth-child(-n+3) { background: #6aa84f; }
.pwd-meter.s4 span { background: var(--green); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-s); }
.card-pad { padding: 20px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.card-h2 { display:flex; flex-direction: column; gap: 1px; }
.card-title { font-size: 14.5px; font-weight: 700; font-family: var(--font-display); letter-spacing: -.005em; }
.card-sub { font-size: 12px; color: var(--ink-3); }
.card-body { padding: 16px 20px 20px; }
.card-h + .card-bd:not(.card-body) { margin-top: 14px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1180px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .kpi-grid { grid-template-columns: 1fr; } }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px 18px; box-shadow: var(--shadow-s); position: relative; overflow: hidden;
  transition: box-shadow .25s, transform .25s, border-color .25s;
}
.kpi:hover { box-shadow: var(--shadow-m); transform: translateY(-2px); border-color: var(--line-2); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.kpi-ic {
  width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.kpi-ic.tone-green { background: var(--green-soft); color: var(--green-d); }
.kpi-ic.tone-gold { background: var(--gold-soft); color: var(--gold); }
.kpi-ic.tone-red { background: var(--red-soft); color: var(--red); }
.kpi-ic.tone-slate { background: #edf0ea; color: var(--ink-2); }
.kpi-ic.tone-info { background: var(--info-soft); color: var(--info); }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--ink-3); letter-spacing: .015em; }
.kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 99px; }
.delta.up { background: var(--green-soft); color: var(--green-d); }
.delta.down { background: var(--red-soft); color: var(--red); }
.delta.flat { background: #eef0ec; color: var(--ink-3); }

/* ---------- pills / badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill-green { background: var(--green-soft); color: var(--green-d); }
.pill-gold { background: var(--gold-soft); color: var(--gold); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-slate { background: #edf0ea; color: var(--ink-2); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-dark { background: var(--pine-2); color: #cfe6d4; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; border-radius: 0 0 var(--r-lg) var(--r-lg); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl thead th {
  text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); position: sticky; top: 0; white-space: nowrap;
}
.tbl thead th:first-child { padding-left: 20px; } .tbl thead th:last-child { padding-right: 20px; }
.tbl tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody td:first-child { padding-left: 20px; } .tbl tbody td:last-child { padding-right: 20px; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th.num { text-align: right; }
.tbl .cell-main { font-weight: 600; }
.tbl .cell-sub { font-size: 11.5px; color: var(--ink-3); font-weight: 400; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable .sort-ic { display: inline-block; margin-left: 4px; opacity: .55; vertical-align: -2px; }

/* ---------- progress bars ---------- */
.bar { height: 8px; background: #e9ede5; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--green); transform-origin: left; transition: width .9s var(--ease); }
.bar > i.low { background: var(--red); }
.bar > i.mid { background: var(--gold); }

/* ---------- empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 44px 24px; gap: 6px; }
.empty .empty-ic {
  width: 52px; height: 52px; border-radius: 16px; background: var(--surface-2); border: 1px dashed var(--line-2);
  display: flex; align-items: center; justify-content: center; color: var(--ink-3); margin-bottom: 8px;
}
.empty h4 { font-size: 14.5px; }
.empty p { font-size: 12.5px; color: var(--ink-3); max-width: 320px; }
.empty .btn { margin-top: 12px; }

/* ---------- toasts ---------- */
.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 36px)); }
.toast {
  display: flex; gap: 11px; align-items: flex-start; background: var(--pine-deep); color: #eef5ee;
  border: 1px solid rgba(255,255,255,.08); padding: 13px 14px; border-radius: 13px; box-shadow: var(--shadow-l);
  animation: slide-r .35s var(--ease-pop); transition: opacity .3s, transform .3s;
}
.toast.bye { opacity: 0; transform: translateX(20px); }
.toast .t-ic { margin-top: 1px; }
.toast .t-ic.ok { color: var(--lime); } .toast .t-ic.err { color: #f1a08e; } .toast .t-ic.info { color: #9ccfe0; }
.toast b { display: block; font-size: 13.5px; font-weight: 600; }
.toast span { font-size: 12.5px; color: #b9c8bc; }
.toast .t-x { margin-left: auto; color: #8fa394; background: none; border: none; padding: 2px; border-radius: 6px; }
.toast .t-x:hover { color: #fff; background: rgba(255,255,255,.08); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; background: rgba(13,25,17,.45);
  backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 18px 18px; overflow-y: auto; animation: fadein .2s ease;
}
.modal-backdrop.closing { opacity: 0; transition: opacity .18s; }
.modal {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-l); width: 100%; max-width: 520px;
  animation: pop .28s var(--ease-pop); border: 1px solid var(--line);
}
.modal.closing { opacity: 0; transform: scale(.97); transition: all .18s; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 0; }
.modal-h h3 { font-size: 16.5px; }
.modal-b { padding: 16px 22px 22px; }
.modal-f { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 20px; }

/* ---------- dropdown ---------- */
.dd { position: relative; }
.dd-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 218px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow-m); padding: 6px; z-index: 120;
  animation: pop .18s var(--ease-pop); transform-origin: top right;
}
.dd-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 11px;
  border-radius: 8px; border: none; background: none; font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  transition: background .12s, color .12s;
}
.dd-item:hover { background: var(--surface-2); color: var(--ink); }
.dd-item.danger { color: var(--red); }
.dd-item.danger:hover { background: var(--red-soft); }
.dd-sep { height: 1px; background: var(--line); margin: 6px 8px; }
.dd-head { padding: 10px 11px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); position: relative; }
.tab {
  padding: 10px 16px 12px; border: none; background: none; font-size: 13.5px; font-weight: 600; color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 8px; position: relative; transition: color .15s;
}
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--green-d); }
.tab-ink { position: absolute; bottom: -1px; height: 2.5px; background: var(--green); border-radius: 3px 3px 0 0; transition: left .3s var(--ease), width .3s var(--ease); }

.seg { display: inline-flex; flex-wrap: wrap; background: #e9ede4; padding: 4px; border-radius: 12px; gap: 2px; }
.seg button {
  border: none; background: none; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--ink-2);
  border-radius: 9px; transition: all .18s var(--ease); display: inline-flex; gap: 7px; align-items: center;
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--surface); color: var(--green-d); box-shadow: 0 1px 3px rgba(20,31,23,.12); }

/* ---------- skeleton ---------- */
.skel { border-radius: 8px; background: linear-gradient(90deg, #e8ece4 25%, #f3f6f0 50%, #e8ece4 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }

/* ---------- alerts list ---------- */
.alert-row { display: flex; gap: 11px; padding: 11px 12px; border-radius: 11px; align-items: flex-start; }
.alert-row.red { background: var(--red-soft); } .alert-row.gold { background: var(--gold-soft); } .alert-row.info { background: var(--info-soft); }
.alert-row .a-ic { margin-top: 1px; }
.alert-row.red .a-ic { color: var(--red); } .alert-row.gold .a-ic { color: var(--gold); } .alert-row.info .a-ic { color: var(--info); }
.alert-row b { font-size: 13px; display: block; }
.alert-row span { font-size: 12px; color: var(--ink-2); }

/* ---------- timeline ---------- */
.tline { position: relative; padding-left: 22px; display: flex; flex-direction: column; gap: 16px; }
.tline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); border-radius: 2px; }
.tline-item { position: relative; }
.tline-item::before {
  content: ''; position: absolute; left: -21px; top: 4px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--green); box-shadow: 0 0 0 3px var(--surface);
}
.tline-item .tl-date { font-size: 11.5px; color: var(--ink-3); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.tline-item .tl-main { font-size: 13.5px; margin-top: 1px; }
.tline-item .tl-main b { font-weight: 600; }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
@media (max-width: 980px) { .kanban { grid-template-columns: 1fr; } }
.kb-col { background: #ecefe8; border-radius: var(--r-lg); padding: 12px; }
.kb-col-h { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-weight: 700; font-size: 13px; font-family: var(--font-display); }
.kb-count { margin-left: auto; background: var(--surface); color: var(--ink-3); font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 99px; }
.kb-cards { display: flex; flex-direction: column; gap: 9px; min-height: 40px; }
.kb-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px;
  box-shadow: var(--shadow-s); transition: box-shadow .2s, transform .2s; animation: pop .25s var(--ease);
}
.kb-card:hover { box-shadow: var(--shadow-m); transform: translateY(-1px); }
.kb-title { font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.kb-meta { display: flex; align-items: center; gap: 7px; margin-top: 9px; font-size: 11.5px; color: var(--ink-3); flex-wrap: wrap; }
.kb-actions { display: flex; gap: 6px; margin-top: 10px; }
.kb-card.done { opacity: .62; }
.kb-card.done .kb-title { text-decoration: line-through; text-decoration-color: var(--ink-3); }

/* ---------- code viewer ---------- */
.code-view {
  background: var(--pine-deep); color: #cfe0d2; border-radius: 13px; overflow: hidden;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.65; border: 1px solid var(--pine-2);
}
.code-view .cv-head { display: flex; align-items: center; gap: 9px; padding: 10px 14px; background: var(--pine); border-bottom: 1px solid var(--pine-2); color: #9db4a2; font-size: 12px; }
.code-view pre { margin: 0; padding: 14px 0; overflow: auto; max-height: 440px; }
.code-view .ln { display: flex; padding: 0 14px; white-space: pre; }
.code-view .ln:hover { background: rgba(255,255,255,.04); }
.code-view .ln i { width: 40px; flex-shrink: 0; color: #51695a; font-style: normal; user-select: none; text-align: right; padding-right: 14px; }
.code-view .ln.c { color: #7d967f; }
.code-view .ln .kw { color: #8fd9a0; }

/* ============================================================
   AUTH (setup wizard + login)
   ============================================================ */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 44%) 1fr; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-brand { display: none; } }
.auth-brand {
  position: relative; overflow: hidden; color: #eaf4ec; display: flex; flex-direction: column; justify-content: space-between;
  padding: 44px 48px; background:
    radial-gradient(800px 480px at 110% -20%, rgba(143,217,160,.16), transparent 55%),
    radial-gradient(700px 500px at -30% 115%, rgba(176,148,33,.14), transparent 50%),
    linear-gradient(160deg, #10231725 ,transparent),
    var(--pine-deep);
}
.auth-brand::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(255,255,255,.045) 1px, transparent 1px); background-size: 22px 22px;
}
.auth-logo { display: flex; align-items: center; gap: 13px; z-index: 1; }
.auth-tagline { z-index: 1; max-width: 400px; }
.auth-tagline h2 { font-size: clamp(26px, 3vw, 34px); line-height: 1.18; letter-spacing: -.02em; color: #f4faf4; }
.auth-tagline p { margin-top: 14px; color: #a9bfae; font-size: 14.5px; line-height: 1.65; }
.auth-points { z-index: 1; display: flex; flex-direction: column; gap: 13px; }
.auth-point { display: flex; gap: 12px; align-items: center; color: #b9ccbd; font-size: 13.5px; }
.auth-point .pt-ic { width: 34px; height: 34px; border-radius: 10px; background: rgba(143,217,160,.1); border: 1px solid rgba(143,217,160,.18); display: flex; align-items: center; justify-content: center; color: var(--lime); }
.auth-orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; animation: drift 9s ease-in-out infinite; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 460px; }
.auth-card.wide { max-width: 560px; }
.auth-head { margin-bottom: 26px; }
.auth-head h1 { font-size: 24px; letter-spacing: -.02em; }
.auth-head p { color: var(--ink-3); margin-top: 6px; font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-foot { margin-top: 26px; text-align: center; font-size: 12.5px; color: var(--ink-3); }

.logo-mark { width: 42px; height: 42px; border-radius: 13px; background: linear-gradient(145deg, #3c9457, #256238); display: flex; align-items: center; justify-content: center; color: #ecfcef; box-shadow: 0 6px 16px -6px rgba(47,125,70,.55), inset 0 1px 0 rgba(255,255,255,.25); }
.logo-type { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -.01em; line-height: 1.1; }
.logo-type small { display: block; font-family: var(--font-body); font-weight: 500; font-size: 11px; color: var(--ink-3); letter-spacing: .04em; }
.auth-brand .logo-type { color: #f1f8f1; } .auth-brand .logo-type small { color: #93a899; }

/* stepper */
.stepper { display: flex; align-items: center; gap: 0; margin-bottom: 30px; }
.step { display: flex; align-items: center; gap: 9px; }
.step-dot {
  width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--line-2); background: var(--surface);
  display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; color: var(--ink-3);
  transition: all .3s var(--ease); flex-shrink: 0;
}
.step.active .step-dot { border-color: var(--green); background: var(--green); color: #fff; box-shadow: 0 0 0 4px var(--green-ring); }
.step.done .step-dot { border-color: var(--green); background: var(--green-soft); color: var(--green-d); }
.step-label { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.step.active .step-label { color: var(--ink); }
.step-line { flex: 1; height: 1.5px; background: var(--line-2); margin: 0 12px; min-width: 24px; position: relative; overflow: hidden; }
.step-line::after { content: ''; position: absolute; inset: 0; background: var(--green); transform: scaleX(0); transform-origin: left; transition: transform .45s var(--ease); }
.step-line.done::after { transform: scaleX(1); }

.conn-status { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; padding: 11px 13px; border-radius: 10px; animation: pop .25s var(--ease); }
.conn-status.ok { background: var(--green-soft); color: var(--green-d); }
.conn-status.err { background: var(--red-soft); color: var(--red); }
.conn-status.busy { background: var(--surface-2); color: var(--ink-2); }

.run-log { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.run-row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; padding: 5px 7px; border-radius: 7px; animation: slide-l .25s var(--ease) both; }
.run-row .mono { color: var(--ink-2); }
.run-row .r-ok { color: var(--green); } .run-row .r-skip { color: var(--ink-3); } .run-row .r-err { color: var(--red); }
.run-row small { margin-left: auto; color: var(--ink-3); flex-shrink: 0; }

.big-check { width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 50%; background: var(--green-soft); display: flex; align-items: center; justify-content: center; color: var(--green); animation: pop .5s var(--ease-pop); }
.big-check svg path { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw-check .55s .25s var(--ease) forwards; }
@keyframes draw-check { to { stroke-dashoffset: 0; } }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--green); animation: spin .7s linear infinite; }

/* ============================================================
   APP SHELL
   ============================================================ */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: fixed; top: 0; bottom: 0; left: 0; z-index: 90;
  background: linear-gradient(180deg, var(--pine) 0%, var(--pine-deep) 100%);
  color: var(--pine-text); display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.05);
  transition: transform .32s var(--ease);
}
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; border-bottom: 1px solid var(--pine-line); }
.sb-brand .logo-type { color: #f1f8f1; font-size: 16px; } .sb-brand .logo-type small { color: #8aa190; }
.sb-nav { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.sb-nav::-webkit-scrollbar { width: 6px; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--pine-3); }
.nav-label { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #5d7263; padding: 14px 10px 6px; }
.navlink {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px; border: none; background: none;
  color: #b4c6b8; font-size: 13.5px; font-weight: 500; width: 100%; text-align: left; position: relative;
  transition: background .15s, color .15s;
}
.navlink svg { color: #7e947f; transition: color .15s; }
.navlink:hover { background: rgba(255,255,255,.05); color: #e9f2ea; }
.navlink:hover svg { color: var(--lime); }
.navlink.active { background: linear-gradient(90deg, rgba(143,217,160,.14), rgba(143,217,160,.05)); color: #f1faf2; font-weight: 600; }
.navlink.active svg { color: var(--lime); }
.navlink.active::before {
  content: ''; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--lime); animation: pop .3s var(--ease);
}
.sb-foot { padding: 14px 16px; border-top: 1px solid var(--pine-line); display: flex; flex-direction: column; gap: 12px; }
.sb-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #8fa896; }
.sb-status .dot { background: var(--lime); animation: pulse-dot 2.4s infinite; }
.sb-user { display: flex; align-items: center; gap: 10px; }
.sb-user .avatar { flex-shrink: 0; }
.sb-user-name { font-size: 13px; font-weight: 600; color: #e9f2ea; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user-role { font-size: 11px; color: #87a08d; }
.sb-user .icon-btn { margin-left: auto; color: #87a08d; }
.sb-user .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(145deg, #3c9457, #256238);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700;
  letter-spacing: .02em; box-shadow: inset 0 1px 0 rgba(255,255,255,.22);
}

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 80; display: flex; align-items: center; gap: 14px;
  padding: 14px 28px; background: rgba(241,244,238,.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; letter-spacing: -.015em; }
.topbar .tb-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.tb-date { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); padding: 7px 13px; border-radius: 99px; box-shadow: var(--shadow-s); }
.tb-bell { position: relative; }
.tb-bell .bell-badge {
  position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}
.menu-btn { display: none; }

.content { padding: 26px 28px 60px; max-width: 1480px; width: 100%; }
.view-grid { display: flex; flex-direction: column; gap: 16px; }
.cols { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-31 { grid-template-columns: 2fr 1fr; }
.cols-13 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1080px) { .cols-2, .cols-31, .cols-13 { grid-template-columns: 1fr; } }

/* page header inside content */
.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* charts */
.chart-box { width: 100%; position: relative; }
.chart-box svg { width: 100%; height: auto; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; padding-top: 10px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); font-weight: 500; }
.chart-tip {
  position: fixed; z-index: 400; pointer-events: none; background: var(--pine-deep); color: #edf5ee;
  border-radius: 10px; padding: 9px 12px; font-size: 12px; box-shadow: var(--shadow-l); border: 1px solid rgba(255,255,255,.09);
  opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s; max-width: 260px;
}
.chart-tip.show { opacity: 1; transform: none; }
.chart-tip .tip-t { font-weight: 700; margin-bottom: 4px; color: #fff; font-size: 12px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 7px; padding: 1.5px 0; }
.chart-tip .tip-row b { margin-left: auto; padding-left: 14px; font-variant-numeric: tabular-nums; }

/* callout */
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 13px; border: 1px solid; align-items: flex-start; font-size: 13px; }
.callout.gold { background: var(--gold-soft); border-color: #ecd9a4; color: #6e5510; }
.callout.gold svg { color: var(--gold); }
.callout b { font-weight: 700; }

/* settings layout */
.set-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.set-row { display: grid; grid-template-columns: 230px 1fr; gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: none; }
.set-row h4 { font-size: 13.5px; } .set-row .set-desc { font-size: 12px; color: var(--ink-3); margin-top: 4px; line-height: 1.5; }
@media (max-width: 860px) { .set-row { grid-template-columns: 1fr; gap: 10px; } }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--line); padding: 6px 8px 6px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.chip button { border: none; background: none; color: var(--ink-3); display: flex; padding: 2px; border-radius: 50%; }
.chip button:hover { color: var(--red); background: var(--red-soft); }

.kv { display: flex; flex-direction: column; gap: 2px; }
.kv b { font-size: 13px; } .kv span { font-size: 11.5px; color: var(--ink-3); }

/* recent entries list (forms) */
.recent-list { display: flex; flex-direction: column; gap: 9px; max-height: 560px; overflow-y: auto; padding-right: 2px; }
.recent-item { border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; transition: border-color .15s, box-shadow .15s; animation: rise .3s var(--ease); }
.recent-item:hover { border-color: var(--line-2); box-shadow: var(--shadow-s); }
.recent-item .ri-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.recent-item .ri-top b { font-size: 13px; }
.recent-item .ri-top time { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.recent-item .ri-sub { font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.recent-item .ri-note { font-size: 11.5px; color: var(--ink-3); font-style: italic; margin-top: 3px; }

/* splash */
.splash { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.splash .logo-mark { width: 56px; height: 56px; border-radius: 17px; animation: pop .5s var(--ease-pop); }
.splash p { color: var(--ink-3); font-size: 13px; animation: fadein .6s .2s both; }

/* error screen */
.fatal { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.fatal .card { max-width: 460px; padding: 34px; text-align: center; }
.fatal .empty-ic { margin: 0 auto 14px; width: 56px; height: 56px; color: var(--red); background: var(--red-soft); border: none; border-radius: 17px; display:flex; align-items:center; justify-content:center; }
.fatal h2 { font-size: 19px; margin-bottom: 8px; }
.fatal p { color: var(--ink-2); font-size: 13.5px; line-height: 1.6; }

/* ---------- responsive shell ---------- */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-l); }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .content { padding: 20px 16px 48px; }
  .topbar { padding: 12px 16px; }
  .sb-overlay { position: fixed; inset: 0; background: rgba(13,25,17,.45); z-index: 85; animation: fadein .25s; }
}
@media (max-width: 640px) { .tb-date { display: none; } }

/* ---------- print (weekly report) ---------- */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .toast-stack { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  .stagger > * { opacity: 1; animation: none; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
