/* ════════════════════════════════════════════════════════════════
   Digitalo Yield — Terminal Design System
   Ported from the claude.ai/design project "Python app redesign".
   Dark = :root default · Light = [data-theme="light"].
   This is the single design system for the portal. Link it on every
   page. Use the tokens / .t-* classes below instead of literal hex.
   ════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Color tokens ───────────────────────────────────────────── */
:root {
  --t-bg:          #11161e;
  --t-bg-deep:     #0c1118;   /* page void / app background */
  --t-surface:     #161d27;
  --t-surface-2:   #131a23;   /* table heads, footers, inset */
  --t-surface-3:   #1a212c;   /* controls, chips */

  --t-line:        #232c39;
  --t-line-strong: #2a3442;

  --t-text:        #eaf2f0;
  --t-text-2:      #cdd6db;
  --t-text-3:      #9fb0b8;   /* section labels */
  --t-muted:       #56657a;
  --t-muted-2:     #46556a;

  --t-accent:      #2fd6b8;
  --t-accent-ink:  #06231f;
  --t-accent-2:    #5a8a86;   /* dim accent text (deltas) */
  --t-accent-dim:  rgba(47,214,184,0.42);
  --t-accent-soft: rgba(47,214,184,0.14);

  --t-ok:          #2fd6b8;
  --t-ok-bg:       rgba(47,214,184,0.14);
  --t-warn:        #e0b341;
  --t-warn-bg:     rgba(224,179,65,0.16);
  --t-warn-line:   #3a2f12;
  --t-warn-fill:   #1a160a;
  --t-err:         #e06a5a;
  --t-err-bg:      rgba(224,106,90,0.16);
  --t-err-ink:     #1a0a07;

  --t-avatar-bg:   #1f3340;
  --t-avatar-ink:  #7da0a8;

  /* Heatmap intensity ramp (low → high) */
  --t-heat-0:      #1a2230;
  --t-heat-1:      #1f3340;
  --t-heat-2:      #21505a;
  --t-heat-3:      #1f8076;
  --t-heat-4:      #2fd6b8;

  --t-shadow-card: 0 14px 44px rgba(10,18,28,0.32);
  --t-shadow-modal:0 30px 80px rgba(0,0,0,0.5);

  /* Type families */
  --t-font-display: 'Space Grotesk', system-ui, sans-serif;
  --t-font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  /* Radii */
  --t-r-sm: 7px;
  --t-r-md: 9px;
  --t-r-lg: 10px;
  --t-r-xl: 12px;
  --t-r-2xl: 14px;
  --t-r-full: 999px;
}

[data-theme="light"] {
  --t-bg:          #ffffff;
  --t-bg-deep:     #eef1f4;
  --t-surface:     #ffffff;
  --t-surface-2:   #f4f7fa;
  --t-surface-3:   #f4f7fa;

  --t-line:        #e2e7ec;
  --t-line-strong: #d4dce2;

  --t-text:        #1a2230;
  --t-text-2:      #3d4a59;
  --t-text-3:      #4a5a68;
  --t-muted:       #8295a0;
  --t-muted-2:     #aab8c0;

  --t-accent:      #0d9488;
  --t-accent-ink:  #ffffff;
  --t-accent-2:    #3c8278;
  --t-accent-dim:  rgba(13,148,136,0.42);
  --t-accent-soft: rgba(13,148,136,0.12);

  --t-ok:          #0d9488;
  --t-ok-bg:       #e3f4ef;
  --t-warn:        #b8810a;
  --t-warn-bg:     #fbf0d8;
  --t-warn-line:   #ecdcae;
  --t-warn-fill:   #fbf5e6;
  --t-err:         #c0392b;
  --t-err-bg:      #fdeceb;
  --t-err-ink:     #ffffff;

  --t-avatar-bg:   #d8e6e9;
  --t-avatar-ink:  #3c6b73;

  --t-heat-0:      #e9eef1;
  --t-heat-1:      #cfeae4;
  --t-heat-2:      #a3dcd1;
  --t-heat-3:      #4fb3a6;
  --t-heat-4:      #0d9488;

  --t-shadow-card: 0 14px 44px rgba(20,35,50,0.16);
  --t-shadow-modal:0 30px 80px rgba(20,35,50,0.28);
}

/* ── Global base (Terminal pages) ───────────────────────────── */
* { box-sizing: border-box; }
body.t-app {
  margin: 0;
  background: var(--t-bg-deep);
  color: var(--t-text);
  font-family: var(--t-font-display);
  -webkit-font-smoothing: antialiased;
}
body.t-app ::placeholder { color: var(--t-muted-2); }
body.t-app input, body.t-app textarea, body.t-app select { outline: none; }
body.t-app input:focus, body.t-app textarea:focus, body.t-app select:focus {
  border-color: var(--t-accent);
}
.t-mono { font-family: var(--t-font-mono); }
.t-display { font-family: var(--t-font-display); }

/* ── Desktop top nav (injected by Auth.renderNav) ───────────── */
.t-topnav {
  background: var(--t-bg);
  border-bottom: 1px solid var(--t-line);
  padding: 0 28px;
}
.t-topnav__inner {
  max-width: 1240px; margin: 0 auto;
  display: flex; align-items: center; gap: 24px; height: 62px;
}
.t-brand { display: flex; align-items: center; gap: 10px; }
.t-brand__mark {
  width: 26px; height: 26px; border-radius: var(--t-r-sm);
  background: var(--t-accent); color: var(--t-accent-ink);
  display: flex; align-items: center; justify-content: center;
  font: 700 14px var(--t-font-display);
}
.t-brand__name { font: 600 15px var(--t-font-display); color: var(--t-text); letter-spacing: .01em; }
.t-nav { display: flex; gap: 4px; margin-left: 8px; flex-wrap: wrap; }
.t-navlink {
  font: 500 12px var(--t-font-mono); color: var(--t-text-3);
  padding: 8px 13px; border-radius: var(--t-r-sm); text-decoration: none;
  border: 0; background: transparent; cursor: pointer; white-space: nowrap;
}
.t-navlink:hover { color: var(--t-text); background: var(--t-surface-3); }
.t-navlink--active { color: var(--t-accent); background: var(--t-accent-soft); }
.t-topnav__right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.t-status { display: flex; align-items: center; gap: 8px; font: 500 11px var(--t-font-mono); color: var(--t-text-3); }
.t-status__dot { width: 8px; height: 8px; border-radius: var(--t-r-full); background: var(--t-muted); }
.t-status__dot--online { background: var(--t-accent); }
.t-status__dot--offline { background: var(--t-err); }
.t-status__dot--loading { background: var(--t-warn); }
.t-user {
  display: flex; align-items: center; gap: 8px;
  padding-left: 14px; border-left: 1px solid var(--t-line);
  background: none; border-top: 0; border-right: 0; border-bottom: 0;
  cursor: pointer; font: 500 12px var(--t-font-mono); color: var(--t-text-2);
}
.t-avatar {
  width: 28px; height: 28px; border-radius: var(--t-r-full);
  background: var(--t-avatar-bg); color: var(--t-avatar-ink);
  display: flex; align-items: center; justify-content: center;
  font: 600 11px var(--t-font-mono);
}
.t-iconbtn {
  width: 32px; height: 32px; flex: none; border-radius: 8px;
  border: 1px solid var(--t-line-strong); background: var(--t-surface-3);
  color: var(--t-text-3); display: inline-flex; align-items: center;
  justify-content: center; cursor: pointer; padding: 0;
}
.t-iconbtn:hover { color: var(--t-accent); border-color: var(--t-accent); }

/* ── Account dropdown (top-nav avatar menu) ─────────────────── */
.t-account { position: relative; }
.t-user__caret { color: var(--t-muted); margin-left: 2px; }
.t-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 220px; z-index: 1100;
  background: var(--t-surface); border: 1px solid var(--t-line-strong);
  border-radius: var(--t-r-xl); box-shadow: var(--t-shadow-modal);
  padding: 6px; overflow: hidden;
}
.t-menu--open { display: block; }
.t-menu__head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 10px 12px; border-bottom: 1px solid var(--t-line); margin-bottom: 6px;
}
.t-menu__name { font: 600 12px var(--t-font-mono); color: var(--t-text); }
.t-menu__item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
  padding: 10px; border-radius: var(--t-r-sm); text-decoration: none;
  font: 500 12px var(--t-font-mono); color: var(--t-text-2);
}
.t-menu__item:hover { background: var(--t-surface-3); color: var(--t-text); }
.t-menu__item--danger { color: var(--t-err); }

/* ── Trailing action clusters (chips + buttons) ─────────────── */
.t-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ── Mobile bottom tab bar (injected by Auth.renderNav) ─────── */
.t-bottomnav { display: none; }

/* ── Page shell ─────────────────────────────────────────────── */
.t-page { max-width: 1240px; margin: 0 auto; padding: 28px; }
.t-page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.t-kicker {
  font: 500 11px var(--t-font-mono); letter-spacing: .14em;
  text-transform: uppercase; color: var(--t-muted);
}
.t-title { font: 700 24px var(--t-font-display); color: var(--t-text); margin-top: 8px; }

/* ── Card ───────────────────────────────────────────────────── */
.t-card {
  background: var(--t-surface); border: 1px solid var(--t-line);
  border-radius: var(--t-r-lg); padding: 22px;
}
.t-card--flush { padding: 0; overflow: hidden; }
.t-card__head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; background: var(--t-surface-2);
  border-bottom: 1px solid var(--t-line);
}
.t-card-title {
  font: 600 13px var(--t-font-mono); color: var(--t-text-3); letter-spacing: .04em;
}
.t-card-sub { font: 400 11px var(--t-font-mono); color: var(--t-muted); margin-top: 4px; line-height: 1.6; }

/* ── Stat tiles ─────────────────────────────────────────────── */
.t-stats { display: grid; gap: 12px; }
.t-stat {
  background: var(--t-surface); border: 1px solid var(--t-line);
  border-radius: var(--t-r-md); padding: 14px 15px;
}
.t-stat__label {
  font: 500 10px var(--t-font-mono); letter-spacing: .08em;
  text-transform: uppercase; color: var(--t-muted);
}
.t-stat__value { font: 600 20px var(--t-font-mono); color: var(--t-text); margin-top: 7px; }
.t-stat__value--accent { color: var(--t-accent); }
.t-stat__value--warn { color: var(--t-warn); }
.t-stat__value--err { color: var(--t-err); }
.t-stat__value--lg { font-size: 26px; }
.t-stat__delta { font: 400 11px var(--t-font-mono); color: var(--t-accent-2); margin-top: 5px; }
.t-stat__delta--muted { color: var(--t-muted); }

/* ── Mono data table ────────────────────────────────────────── */
.t-table { width: 100%; border-collapse: collapse; }
.t-table th {
  text-align: left; font: 500 9px var(--t-font-mono); color: var(--t-muted);
  letter-spacing: .06em; text-transform: uppercase;
  padding: 11px 14px; background: var(--t-surface-2);
  border-bottom: 1px solid var(--t-line); white-space: nowrap;
}
.t-table td {
  font: 400 11px var(--t-font-mono); color: var(--t-text-2);
  padding: 9px 14px; border-top: 1px solid var(--t-line);
}
.t-table tbody tr:hover td { background: var(--t-surface-3); }
.t-table .t-td--ref { color: var(--t-accent); font-weight: 500; }
.t-table .t-td--strong { color: var(--t-text); font-weight: 500; }
.t-table .t-td--num { text-align: right; }
.t-th--num { text-align: right; }

/* ── Buttons ────────────────────────────────────────────────── */
.t-btn {
  border: none; border-radius: var(--t-r-sm); padding: 9px 16px; cursor: pointer;
  font: 600 12px var(--t-font-mono); display: inline-flex; align-items: center;
  justify-content: center; gap: 7px; text-decoration: none;
}
.t-btn--lg { padding: 13px; border-radius: var(--t-r-xl); font-size: 14px; }
.t-btn--block { width: 100%; }
.t-btn--accent { background: var(--t-accent); color: var(--t-accent-ink); }
.t-btn--err    { background: var(--t-err);    color: var(--t-err-ink); }
.t-btn--ghost  { background: var(--t-surface-3); color: var(--t-text-3); border: 1px solid var(--t-line-strong); }
.t-btn:disabled { opacity: 0.55; cursor: default; }

/* ── Form fields ────────────────────────────────────────────── */
.t-field { display: flex; flex-direction: column; }
.t-field__label {
  font: 500 10px var(--t-font-mono); letter-spacing: .1em;
  text-transform: uppercase; color: var(--t-muted); margin-bottom: 6px;
}
.t-field__label--edit { color: var(--t-accent); }
.t-input, .t-textarea, .t-select {
  width: 100%; background: var(--t-bg); border: 1px solid var(--t-line-strong);
  border-radius: var(--t-r-sm); padding: 9px 11px; color: var(--t-text);
  font: 500 12px var(--t-font-mono);
}
.t-input--lg { padding: 14px; border-radius: var(--t-r-lg); font-size: 15px; }
.t-input--edit { border-color: var(--t-accent); }
.t-input--locked { background: var(--t-bg-deep); color: var(--t-muted); }
.t-textarea { resize: vertical; }
.t-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.t-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
/* let grid children shrink so inner overflow:auto scrollers (wide tables)
   contain themselves instead of stretching the card past its edges */
.t-grid-2 > *, .t-grid-3 > * { min-width: 0; }

/* ── Dropzone ───────────────────────────────────────────────── */
.t-dropzone {
  border: 2px dashed var(--t-line-strong); border-radius: var(--t-r-lg);
  padding: 30px 20px; text-align: center; cursor: pointer;
}
.t-dropzone__title { font: 600 12px var(--t-font-mono); color: var(--t-text-2); }
.t-dropzone__hint { font: 400 11px var(--t-font-mono); color: var(--t-muted); margin-top: 6px; }

/* ── Badges / chips ─────────────────────────────────────────── */
.t-chip {
  border-radius: 6px; padding: 3px 10px;
  font: 600 10px var(--t-font-mono); letter-spacing: .04em;
  display: inline-block; white-space: nowrap;
}
.t-chip--warn { background: var(--t-warn-bg); color: var(--t-warn); }
.t-chip--ok   { background: var(--t-ok-bg);   color: var(--t-ok); }
.t-chip--err  { background: var(--t-err-bg);  color: var(--t-err); }
.t-chip--neutral { background: var(--t-avatar-bg); color: var(--t-avatar-ink); }
.t-chip--muted { background: var(--t-surface-3); color: var(--t-muted); }

/* ── Filter pills ───────────────────────────────────────────── */
.t-filter {
  flex: none; background: var(--t-surface-3); color: var(--t-text-3);
  border: 1px solid var(--t-line-strong); border-radius: var(--t-r-full);
  padding: 6px 14px; font: 500 11px var(--t-font-mono); cursor: pointer;
}
.t-filter--active { background: var(--t-accent); color: var(--t-accent-ink); border-color: transparent; }

/* ── Tabs ───────────────────────────────────────────────────── */
.t-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--t-line); flex-wrap: wrap; }
.t-tab {
  font: 500 11px var(--t-font-mono); color: var(--t-muted);
  padding: 9px 13px; cursor: pointer; border: 0; background: transparent;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.t-tab--active { color: var(--t-text); border-bottom-color: var(--t-accent); }

/* ── Calendar / heatmap (Puls) ──────────────────────────────── */
.t-cal { display: flex; flex-direction: column; gap: 4px; }
.t-cal__dow { display: grid; grid-template-columns: 24px repeat(7,1fr); gap: 4px; margin-bottom: 5px; }
.t-cal__dow span { font: 500 9px var(--t-font-mono); color: var(--t-muted); text-align: center; }
.t-cal__week { display: grid; grid-template-columns: 24px repeat(7,1fr); gap: 4px; align-items: center; }
.t-cal__iso { font: 500 9px var(--t-font-mono); color: var(--t-muted-2); text-align: right; padding-right: 2px; }
.t-cal__cell {
  aspect-ratio: 1; border-radius: 3px; display: flex; align-items: center;
  justify-content: center; font: 500 10px var(--t-font-mono); cursor: pointer;
  color: var(--t-text-2);
}
.t-heat-0 { background: var(--t-heat-0); }
.t-heat-1 { background: var(--t-heat-1); }
.t-heat-2 { background: var(--t-heat-2); color: var(--t-text); }
.t-heat-3 { background: var(--t-heat-3); color: var(--t-bg-deep); }
.t-heat-4 { background: var(--t-heat-4); color: var(--t-accent-ink); }
.t-cal__cell--sel { outline: 2px solid var(--t-accent); outline-offset: 1px; }

/* ── Alerts ─────────────────────────────────────────────────── */
.t-alert {
  border-radius: var(--t-r-lg); padding: 12px 14px;
  font: 400 11px var(--t-font-mono); line-height: 1.6;
}
.t-alert--ok { background: var(--t-ok-bg); color: var(--t-ok); border: 1px solid var(--t-warn-line); }
.t-alert--ok { background: var(--t-accent-soft); color: var(--t-accent); border: 1px solid var(--t-accent-dim); }
.t-alert--err { background: var(--t-err-bg); color: var(--t-err); border: 1px solid var(--t-err); }
.t-alert--warn {
  background: var(--t-warn-fill); color: var(--t-warn);
  border: 1px solid var(--t-warn-line);
  display: flex; align-items: center; gap: 8px;
}

/* ── Reusable "better on desktop" notice (HANDOFF §4) ────────── */
.ds-desktop-notice {
  background: var(--t-surface); border: 1px solid var(--t-line-strong);
  border-radius: var(--t-r-2xl); padding: 18px;
}
.ds-desktop-notice__row { display: flex; align-items: flex-start; gap: 12px; }
.ds-desktop-notice__icon {
  flex: none; width: 38px; height: 38px; border-radius: var(--t-r-lg);
  background: var(--t-warn-fill); border: 1px solid var(--t-warn-line);
  display: flex; align-items: center; justify-content: center;
}
.ds-desktop-notice__title { font: 600 13px var(--t-font-display); color: var(--t-text); }
.ds-desktop-notice__body { font: 400 11px var(--t-font-mono); color: var(--t-text-2); margin-top: 4px; line-height: 1.55; }
.ds-desktop-link {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--t-accent); color: var(--t-accent-ink);
  border: none; border-radius: 11px; padding: 13px; margin-top: 14px;
  font: 600 13px var(--t-font-mono); text-decoration: none; cursor: pointer; width: 100%;
}
.ds-desktop-link:active { filter: brightness(0.95); }
.ds-desktop-notice__hint { text-align: center; font: 400 10px var(--t-font-mono); color: var(--t-muted); margin-top: 9px; }

/* ── Modal primitives (recon detail modal) ──────────────────── */
.t-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(6,10,16,0.66);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
[data-theme="light"] .t-modal-overlay { background: rgba(20,35,50,0.45); }
.t-modal {
  width: 760px; max-width: 100%; max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--t-bg); border: 1px solid var(--t-line-strong);
  border-radius: var(--t-r-2xl); box-shadow: var(--t-shadow-modal); overflow: hidden;
}
.t-modal__head, .t-modal__foot { flex: none; display: flex; align-items: center; padding: 18px 22px; }
.t-modal__head { justify-content: space-between; border-bottom: 1px solid var(--t-line); }
.t-modal__foot { gap: 10px; justify-content: flex-end; border-top: 1px solid var(--t-line); background: var(--t-surface-2); }
.t-modal__body { flex: 1; overflow: auto; padding: 22px; }
.t-modal__close {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--t-line-strong); background: var(--t-surface-3);
  color: var(--t-text-2); display: flex; align-items: center; justify-content: center;
  font-size: 17px; cursor: pointer;
}

/* hide scrollbars on horizontal scroll panes that match the design */
.t-scroll::-webkit-scrollbar { display: none; }
.t-scroll { scrollbar-width: none; max-width: 100%; }
.t-hscroll { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; }

/* ── Spinner ────────────────────────────────────────────────── */
.t-spinner {
  display: inline-block; width: 13px; height: 13px; margin-right: 7px;
  border: 2px solid var(--t-accent-dim); border-top-color: var(--t-accent);
  border-radius: 50%; animation: t-spin .7s linear infinite; vertical-align: -2px;
}
@keyframes t-spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════════
   Responsive — phone: hide top nav, show bottom tab bar.
   The page header switches to the mobile "brand row + big title".
   ════════════════════════════════════════════════════════════ */
@media (max-width: 760px) {
  .t-topnav { display: none; }
  .t-page { padding: 16px 16px 80px; }
  .t-title { font-size: 27px; }

  .t-bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    background: var(--t-bg); border-top: 1px solid var(--t-line);
    padding: 10px 6px max(10px, env(safe-area-inset-bottom));
  }
  .t-bottomnav__item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
    text-decoration: none; border: 0; background: none; cursor: pointer;
  }
  .t-bottomnav__item span { font: 500 9px var(--t-font-mono); color: var(--t-muted); }
  .t-bottomnav__item svg { stroke: var(--t-muted); }
  .t-bottomnav__item--active span { color: var(--t-accent); }
  .t-bottomnav__item--active svg { stroke: var(--t-accent); }

  /* dense desktop grids collapse to single column on phones */
  .t-grid-2, .t-grid-3 { grid-template-columns: 1fr; }
}

/* "Mer" sheet for overflow nav items on mobile */
.t-sheet {
  display: none; position: fixed; inset: 0; z-index: 950;
  background: rgba(6,10,16,0.6); align-items: flex-end;
}
.t-sheet--open { display: flex; }
.t-sheet__panel {
  width: 100%; background: var(--t-bg); border-top: 1px solid var(--t-line);
  border-radius: var(--t-r-2xl) var(--t-r-2xl) 0 0; padding: 10px 14px 28px;
}
.t-sheet__item {
  display: block; padding: 15px 8px; border-top: 1px solid var(--t-line);
  font: 500 14px var(--t-font-mono); color: var(--t-text); text-decoration: none;
}
