/* ===================================================================
   Aura Energy CRM - design tokens
   Light is the base; dark values are redeclared under both the OS media
   query and the data-theme scope so a toggle wins in either direction.
   =================================================================== */
:root {
  color-scheme: light;

  --plane:        #f9f9f7;
  --surface:      #fcfcfb;
  --surface-2:    #f3f3f0;
  --ink:          #0b0b0b;
  --ink-2:        #52514e;
  --ink-muted:    #898781;
  --hairline:     #e1e0d9;
  --axis:         #c3c2b7;
  --ring:         rgba(11,11,11,0.10);

  --accent:       #2a78d6;
  --accent-soft:  #eaf2fd;

  /* reserved status roles - never reused as series colors */
  --good:         #0ca30c;
  --warning:      #fab219;
  --serious:      #ec835a;
  --critical:     #d03b3b;
  --good-text:    #006300;

  /* ordinal blue ramp for the pipeline funnel: lightest step still
     clears 2:1 on the light surface (step 250) */
  --ord-1: #86b6ef; --ord-2: #6da7ec; --ord-3: #5598e7; --ord-4: #3987e5;
  --ord-5: #2a78d6; --ord-6: #256abf; --ord-7: #1c5cab; --ord-8: #184f95;

  --r: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
    --ink: #ffffff; --ink-2: #c3c2b7; --ink-muted: #898781;
    --hairline: #2c2c2a; --axis: #383835; --ring: rgba(255,255,255,0.10);
    --accent: #3987e5; --accent-soft: #15243a;
    --good-text: #0ca30c;
    --ord-1: #cde2fb; --ord-2: #b7d3f6; --ord-3: #9ec5f4; --ord-4: #86b6ef;
    --ord-5: #6da7ec; --ord-6: #3987e5; --ord-7: #256abf; --ord-8: #184f95;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
  --ink: #ffffff; --ink-2: #c3c2b7; --ink-muted: #898781;
  --hairline: #2c2c2a; --axis: #383835; --ring: rgba(255,255,255,0.10);
  --accent: #3987e5; --accent-soft: #15243a;
  --good-text: #0ca30c;
  --ord-1: #cde2fb; --ord-2: #b7d3f6; --ord-3: #9ec5f4; --ord-4: #86b6ef;
  --ord-5: #6da7ec; --ord-6: #3987e5; --ord-7: #256abf; --ord-8: #184f95;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 var(--font);
  background: var(--plane);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; color: var(--ink-2); font-weight: 600;
     text-transform: uppercase; letter-spacing: 0.04em; }

/* ------------------------------------------------------------ layout */
.app { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }
.side {
  background: var(--surface); border-right: 1px solid var(--hairline);
  padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 0 8px 14px;
         font-weight: 700; letter-spacing: -0.02em; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 9px; border-radius: 8px; color: var(--ink-2);
  font-weight: 500; text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .count { font-size: 11px; font-variant-numeric: tabular-nums;
              background: var(--surface-2); color: var(--ink-2);
              padding: 1px 6px; border-radius: 99px; }
.nav a.on .count { background: var(--surface); }
.nav .count.alert { background: var(--critical); color: #fff; }
.side .sep { height: 1px; background: var(--hairline); margin: 12px 4px; }

.main { padding: 20px 24px 64px; max-width: 1180px; }
.head { display: flex; align-items: baseline; justify-content: space-between;
        gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.sub { color: var(--ink-muted); font-size: 13px; margin-top: 3px; }

/* ------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r); padding: 14px 16px;
}
.card + .card { margin-top: 12px; }
.card .card-h { display: flex; align-items: center; justify-content: space-between;
                gap: 12px; margin-bottom: 12px; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }

/* --------------------------------------------------------- stat tiles */
.tile { background: var(--surface); border: 1px solid var(--hairline);
        border-radius: var(--r); padding: 13px 14px; }
.tile .k { font-size: 11px; font-weight: 600; color: var(--ink-muted);
           text-transform: uppercase; letter-spacing: 0.05em; }
.tile .v { font-size: 27px; font-weight: 640; letter-spacing: -0.025em;
           margin-top: 5px; line-height: 1.1; }
.tile .n { font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.tile .v.crit { color: var(--critical); }
.tile .v.ok { color: var(--good-text); }

/* ---------------------------------------------- pipeline funnel chart */
.funnel { display: flex; flex-direction: column; gap: 2px; }
.funnel .row { display: grid; grid-template-columns: 150px 1fr auto;
               align-items: center; gap: 10px; }
.funnel .lbl { font-size: 12px; color: var(--ink-2); text-align: right;
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funnel .track { background: var(--surface-2); border-radius: 4px; height: 22px;
                 position: relative; overflow: hidden; }
.funnel .fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 3px;
                transition: width .25s ease; }
.funnel .num { font-size: 12px; font-variant-numeric: tabular-nums;
               color: var(--ink); font-weight: 600; min-width: 92px; }
.funnel .num small { color: var(--ink-muted); font-weight: 400; }
.funnel .row:hover .track { outline: 2px solid var(--ring); outline-offset: 1px; }

/* ------------------------------------------------------------ tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; font-weight: 600; color: var(--ink-muted);
     text-transform: uppercase; letter-spacing: 0.04em;
     padding: 0 10px 7px; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.t-wrap { overflow-x: auto; }

/* -------------------------------------------------------- pills/chips */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px;
        font-weight: 600; padding: 2px 8px; border-radius: 99px;
        background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.crit { background: color-mix(in srgb, var(--critical) 14%, transparent);
             color: var(--critical); }
.pill.warn { background: color-mix(in srgb, var(--warning) 20%, transparent);
             color: #7a5300; }
.pill.good { background: color-mix(in srgb, var(--good) 14%, transparent);
             color: var(--good-text); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
:root[data-theme="dark"] .pill.warn,
:root:not([data-theme="light"]) .pill.warn { color: var(--warning); }

/* ----------------------------------------------------------- controls */
button, .btn {
  font: inherit; font-weight: 550; cursor: pointer;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 8px; padding: 7px 13px;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary, button.primary {
  background: var(--accent); border-color: transparent; color: #fff;
}
.btn-primary:hover, button.primary:hover { filter: brightness(1.06); background: var(--accent); }
button.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
button.ghost:hover { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn-wa { background: #25d366; border-color: transparent; color: #04310f; }

input, select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2);
        margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.req::after { content: " *"; color: var(--critical); }
.hint { font-size: 11px; color: var(--ink-muted); margin-top: 4px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
           margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; min-width: 140px; }

/* ------------------------------------------------------------ misc */
.empty { text-align: center; padding: 36px 16px; color: var(--ink-muted); }
.empty .big { font-size: 15px; color: var(--ink-2); font-weight: 550; margin-bottom: 4px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 18px 1fr; gap: 10px;
               padding: 9px 0; border-bottom: 1px solid var(--hairline); }
.timeline li:last-child { border-bottom: 0; }
.timeline .ic { width: 18px; height: 18px; border-radius: 50%;
                background: var(--surface-2); display: grid; place-items: center;
                font-size: 10px; margin-top: 1px; }
.timeline .when { font-size: 11px; color: var(--ink-muted); }
.ck { display: flex; align-items: flex-start; gap: 10px; padding: 9px 2px;
      border-bottom: 1px solid var(--hairline); }
.ck:last-child { border-bottom: 0; }
.ck input[type=checkbox] { width: 17px; height: 17px; margin: 1px 0 0; flex: 0 0 auto;
                           accent-color: var(--accent); cursor: pointer; }
.ck .t { font-weight: 550; }
.ck.done .t { color: var(--ink-muted); text-decoration: line-through; }
.ck .m { font-size: 11px; color: var(--ink-muted); }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 2px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--ink-muted); }
.small { font-size: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
         background: var(--ink); color: var(--plane); padding: 10px 18px;
         border-radius: 99px; font-weight: 550; z-index: 99;
         box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.toast.err { background: var(--critical); color: #fff; }

/* ------------------------------------------------------------ login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 360px; }

/* ------------------------------------------------- mobile quick-add */
.qa { max-width: 520px; margin: 0 auto; }
.mobile-bar { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; display: none; }
  .side.open { display: block; height: auto; }
  .main { padding: 14px 14px 80px; }
  .g4, .g3, .g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .funnel .row { grid-template-columns: 104px 1fr auto; }
  .funnel .num { min-width: 60px; }
  .mobile-bar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: var(--surface); border-top: 1px solid var(--hairline);
    padding: 6px 4px 8px; justify-content: space-around;
  }
  .mobile-bar a { display: flex; flex-direction: column; align-items: center;
                  gap: 2px; font-size: 10px; color: var(--ink-muted);
                  padding: 4px 10px; border-radius: 8px; font-weight: 600; }
  .mobile-bar a.on { color: var(--accent); background: var(--accent-soft); }
  .mobile-bar .i { font-size: 17px; }
  .row2 { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .g4, .g3, .g2 { grid-template-columns: 1fr 1fr; }
  .tile .v { font-size: 22px; }
}

/* --------------------------------- installation & commissioning dates
   The two dates clients phone about. They sit inside a project row, so
   they need to read at a glance without competing with the headline. */
.dates { display: flex; gap: 18px; margin-top: 8px; padding-top: 8px;
         border-top: 1px solid var(--hairline); flex-wrap: wrap; }
.dates .d { min-width: 118px; }
.dates .k { font-size: 10px; font-weight: 600; color: var(--ink-muted);
            text-transform: uppercase; letter-spacing: 0.05em; }
.dates .val { font-size: 15px; font-weight: 600; margin-top: 2px;
              letter-spacing: -0.01em; }
.dates .val.pending { color: var(--ink-muted); font-weight: 500; }
