/* ==========================================================================
   King Fern Maintenance — stylesheet
   Chrome is deliberately desaturated: the four urgency colours are the only
   saturated things on screen, so severity reads at a glance from arm's length.
   ========================================================================== */

:root{
  --f-display:'Bricolage Grotesque','Archivo',system-ui,sans-serif;
  --f-body:'IBM Plex Sans',system-ui,-apple-system,'Segoe UI',sans-serif;
  --f-mono:'IBM Plex Mono',ui-monospace,'SFMono-Regular',monospace;

  /* light — cool neutrals biased toward the Atlantic teal accent */
  --ground:#e9eef0;
  --surface:#ffffff;
  --surface-2:#f3f7f8;
  --line:#d3dde0;
  --line-soft:#e6edee;
  --text:#0e1619;
  --muted:#5c7078;
  --accent:#0d5a60;
  --accent-soft:#d8ebec;
  --on-accent:#ffffff;

  --u-green:#2f8f5b;  --u-green-bg:#e4f3ea;
  --u-yellow:#b98400; --u-yellow-bg:#faefd5;
  --u-orange:#dd6510; --u-orange-bg:#fce8db;
  --u-red:#c22a2a;    --u-red-bg:#fae1e1;

  --shadow:0 1px 2px rgba(14,22,25,.05),0 10px 28px -16px rgba(14,22,25,.25);
  --r:10px;
  --rail:224px;
}

@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --ground:#0a1013;
    --surface:#121c20;
    --surface-2:#17242a;
    --line:#26383e;
    --line-soft:#1c2b30;
    --text:#e7eff0;
    --muted:#91a7ad;
    --accent:#4fb8bf;
    --accent-soft:#11343a;
    --on-accent:#04191c;

    --u-green:#5cc98d;  --u-green-bg:#102e22;
    --u-yellow:#e3b143; --u-yellow-bg:#332813;
    --u-orange:#f59450; --u-orange-bg:#3a2113;
    --u-red:#f2706f;    --u-red-bg:#3a1a1c;

    --shadow:0 1px 2px rgba(0,0,0,.4),0 10px 28px -16px rgba(0,0,0,.7);
  }
}
:root[data-theme="dark"]{
  --ground:#0a1013;
  --surface:#121c20;
  --surface-2:#17242a;
  --line:#26383e;
  --line-soft:#1c2b30;
  --text:#e7eff0;
  --muted:#91a7ad;
  --accent:#4fb8bf;
  --accent-soft:#11343a;
  --on-accent:#04191c;

  --u-green:#5cc98d;  --u-green-bg:#102e22;
  --u-yellow:#e3b143; --u-yellow-bg:#332813;
  --u-orange:#f59450; --u-orange-bg:#3a2113;
  --u-red:#f2706f;    --u-red-bg:#3a1a1c;

  --shadow:0 1px 2px rgba(0,0,0,.4),0 10px 28px -16px rgba(0,0,0,.7);
}

*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  margin:0;
  background:var(--ground);
  color:var(--text);
  font-family:var(--f-body);
  font-size:15px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4{font-family:var(--f-display);font-weight:600;margin:0;text-wrap:balance;letter-spacing:-.01em}
button,input,select,textarea{font:inherit;color:inherit}
a{color:var(--accent)}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:4px}
@media (prefers-reduced-motion:reduce){*{animation-duration:.01ms !important;transition-duration:.01ms !important}}

/* ---------- shell -------------------------------------------------- */
.shell{min-height:100vh;min-height:100dvh;display:flex;flex-direction:column}
.main{flex:1;padding:14px 14px 96px;max-width:980px;width:100%;margin:0 inline-auto}

.topbar{
  position:sticky;top:0;z-index:30;
  display:flex;align-items:center;gap:10px;
  padding:10px 14px;
  background:color-mix(in srgb,var(--surface) 88%,transparent);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);
}
.brand{display:flex;align-items:center;gap:9px;font-family:var(--f-display);font-weight:700;letter-spacing:-.02em;font-size:16px}
.fern{width:22px;height:22px;flex:none}
.brand small{
  display:block;font-family:var(--f-mono);font-size:9.5px;font-weight:500;
  letter-spacing:.14em;text-transform:uppercase;color:var(--muted);line-height:1
}
.topbar .spacer{flex:1}

.whoami{
  display:flex;align-items:center;gap:8px;border:1px solid var(--line);
  background:var(--surface);border-radius:999px;padding:3px 10px 3px 3px;cursor:pointer
}
.avatar{
  width:26px;height:26px;border-radius:50%;flex:none;display:grid;place-items:center;
  color:#fff;font-size:11px;font-weight:600;font-family:var(--f-mono)
}
.whoami span{font-size:12.5px;font-weight:500}
.whoami em{font-style:normal;color:var(--muted);font-size:11px}

.iconbtn{
  width:34px;height:34px;display:grid;place-items:center;border-radius:8px;
  border:1px solid var(--line);background:var(--surface);cursor:pointer
}
.iconbtn:hover{background:var(--surface-2)}

/* ---------- navigation --------------------------------------------- */
.nav{
  position:fixed;bottom:0;left:0;right:0;z-index:40;
  display:grid;grid-template-columns:repeat(5,1fr);
  background:color-mix(in srgb,var(--surface) 94%,transparent);
  backdrop-filter:blur(12px);
  border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom);
}
.nav a{
  display:flex;flex-direction:column;align-items:center;gap:3px;
  padding:9px 2px 8px;text-decoration:none;color:var(--muted);
  font-size:10.5px;font-weight:500;letter-spacing:.01em
}
.nav a svg{width:20px;height:20px}
.nav a.on{color:var(--accent)}
.nav a.on svg{stroke-width:2.2}

/* ---------- generic bits -------------------------------------------- */
.eyebrow{
  font-family:var(--f-mono);font-size:10.5px;font-weight:500;letter-spacing:.16em;
  text-transform:uppercase;color:var(--muted)
}
.page-head{display:flex;align-items:flex-end;gap:12px;margin:6px 0 14px}
.page-head h1{font-size:24px;line-height:1.15}
.page-head .sub{color:var(--muted);font-size:13px}
.stack{display:flex;flex-direction:column;gap:10px}
.row{display:flex;align-items:center;gap:8px}
.wrap{flex-wrap:wrap}
.muted{color:var(--muted)}
.mono{font-family:var(--f-mono)}
.tnum{font-variant-numeric:tabular-nums}
.hidden{display:none !important}
.section{margin-top:22px}
.section > h2{font-size:15px;margin-bottom:9px;display:flex;align-items:center;gap:8px}
.section > h2 .count{font-family:var(--f-mono);font-size:12px;color:var(--muted);font-weight:500}

.btn{
  border:1px solid var(--line);background:var(--surface);border-radius:8px;
  padding:8px 13px;font-size:13.5px;font-weight:500;cursor:pointer;
  display:inline-flex;align-items:center;gap:7px;text-decoration:none;color:var(--text)
}
.btn:hover{background:var(--surface-2)}
.btn.primary{background:var(--accent);border-color:var(--accent);color:var(--on-accent);font-weight:600}
.btn.primary:hover{filter:brightness(1.08)}
.btn.ghost{border-color:transparent;background:transparent}
.btn.sm{padding:5px 10px;font-size:12.5px}
.btn:disabled{opacity:.45;cursor:not-allowed}

.field{display:flex;flex-direction:column;gap:5px;margin-bottom:12px}
.field > label{font-size:12px;font-weight:600;color:var(--muted)}
.field input,.field select,.field textarea{
  border:1px solid var(--line);background:var(--surface);border-radius:8px;
  padding:9px 11px;font-size:14.5px;width:100%
}
.field textarea{min-height:82px;resize:vertical;font-family:inherit}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}

/* ---------- urgency ------------------------------------------------- */
.dot{width:9px;height:9px;border-radius:50%;flex:none;display:inline-block}
.u-green .dot,.sw-green{background:var(--u-green)}
.u-yellow .dot,.sw-yellow{background:var(--u-yellow)}
.u-orange .dot,.sw-orange{background:var(--u-orange)}
.u-red .dot,.sw-red{background:var(--u-red)}

.chip{
  display:inline-flex;align-items:center;gap:6px;border-radius:999px;
  padding:3px 9px;font-size:11.5px;font-weight:600;white-space:nowrap;
  border:1px solid transparent
}
.chip.u-green{background:var(--u-green-bg);color:var(--u-green);border-color:color-mix(in srgb,var(--u-green) 30%,transparent)}
.chip.u-yellow{background:var(--u-yellow-bg);color:var(--u-yellow);border-color:color-mix(in srgb,var(--u-yellow) 30%,transparent)}
.chip.u-orange{background:var(--u-orange-bg);color:var(--u-orange);border-color:color-mix(in srgb,var(--u-orange) 30%,transparent)}
.chip.u-red{background:var(--u-red-bg);color:var(--u-red);border-color:color-mix(in srgb,var(--u-red) 32%,transparent)}
.chip .dot{width:7px;height:7px}
.chip.plain{background:var(--surface-2);color:var(--muted);border-color:var(--line)}

/* ---------- job rows ------------------------------------------------ */
.joblist{display:flex;flex-direction:column;gap:7px}
.job{
  position:relative;display:block;text-decoration:none;color:inherit;
  background:var(--surface);border:1px solid var(--line-soft);
  border-radius:var(--r);padding:11px 12px 11px 16px;overflow:hidden;cursor:pointer;
  text-align:left;width:100%;font:inherit
}
.job:hover{border-color:var(--line);background:var(--surface-2)}
.job::before{content:"";position:absolute;left:0;top:0;bottom:0;width:4px}
.job.u-green::before{background:var(--u-green)}
.job.u-yellow::before{background:var(--u-yellow)}
.job.u-orange::before{background:var(--u-orange)}
.job.u-red::before{background:var(--u-red)}
.job.is-done{opacity:.55}
.job.is-done .job-title{text-decoration:line-through}

.job-top{display:flex;align-items:baseline;gap:8px}
.job-title{font-weight:600;font-size:14.5px;line-height:1.3;flex:1;min-width:0}
.job-ref{font-family:var(--f-mono);font-size:10.5px;color:var(--muted);flex:none}
.job-meta{display:flex;align-items:center;gap:7px;flex-wrap:wrap;margin-top:6px;font-size:12px;color:var(--muted)}
.job-meta .sep{opacity:.4}
.job-prop{font-weight:600;color:var(--text)}
.job-prop .code{font-family:var(--f-mono);font-size:10.5px;color:var(--muted);font-weight:500;margin-left:4px}
.pill-due{font-family:var(--f-mono);font-size:11px;font-variant-numeric:tabular-nums}
.pill-due.late{color:var(--u-red);font-weight:600}
.mini-av{width:19px;height:19px;border-radius:50%;display:grid;place-items:center;color:#fff;font-size:9px;font-weight:700;font-family:var(--f-mono)}

.empty{
  border:1px dashed var(--line);border-radius:var(--r);padding:26px 18px;
  text-align:center;color:var(--muted);font-size:13.5px;background:var(--surface-2)
}

/* ---------- filter bar ---------------------------------------------- */
.filters{
  display:flex;gap:6px;overflow-x:auto;padding:2px 0 8px;
  scrollbar-width:none;-ms-overflow-style:none
}
.filters::-webkit-scrollbar{display:none}
.filters button{
  border:1px solid var(--line);background:var(--surface);border-radius:999px;
  padding:5px 11px;font-size:12.5px;white-space:nowrap;cursor:pointer;
  display:inline-flex;align-items:center;gap:6px
}
.filters button.on{background:var(--accent);border-color:var(--accent);color:var(--on-accent);font-weight:600}
.filters button.on .dot{box-shadow:0 0 0 2px color-mix(in srgb,var(--on-accent) 55%,transparent)}

/* ---------- cards / tiles ------------------------------------------- */
.tiles{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
.tile{
  background:var(--surface);border:1px solid var(--line-soft);border-radius:var(--r);
  padding:11px 12px;display:flex;flex-direction:column;gap:3px
}
.tile .n{font-family:var(--f-mono);font-size:24px;font-weight:600;line-height:1;font-variant-numeric:tabular-nums}
.tile .l{font-size:11px;color:var(--muted);font-weight:500}
.tile.u-green .n{color:var(--u-green)}
.tile.u-yellow .n{color:var(--u-yellow)}
.tile.u-orange .n{color:var(--u-orange)}
.tile.u-red .n{color:var(--u-red)}

.card{background:var(--surface);border:1px solid var(--line-soft);border-radius:var(--r);padding:14px}
.card + .card{margin-top:10px}
.card h3{font-size:14px;margin-bottom:8px}

.kv{display:grid;grid-template-columns:auto 1fr;gap:6px 14px;font-size:13px}
.kv dt{color:var(--muted)}
.kv dd{margin:0;text-align:right;font-variant-numeric:tabular-nums}

/* property rows */
.prop{
  display:flex;align-items:center;gap:11px;background:var(--surface);
  border:1px solid var(--line-soft);border-radius:var(--r);padding:11px 12px;
  cursor:pointer;width:100%;text-align:left;font:inherit;color:inherit
}
.prop:hover{background:var(--surface-2)}
.prop .pname{flex:1;min-width:0}
.prop .pname b{display:block;font-size:14px;font-weight:600}
.prop .pname span{font-size:11.5px;color:var(--muted)}
.prop .badges{display:flex;gap:4px;align-items:center;flex:none}
.badge{
  font-family:var(--f-mono);font-size:11px;font-weight:600;min-width:22px;height:22px;
  border-radius:6px;display:grid;place-items:center;padding:0 5px
}
.badge.u-green{background:var(--u-green-bg);color:var(--u-green)}
.badge.u-yellow{background:var(--u-yellow-bg);color:var(--u-yellow)}
.badge.u-orange{background:var(--u-orange-bg);color:var(--u-orange)}
.badge.u-red{background:var(--u-red-bg);color:var(--u-red)}
.badge.zero{background:var(--surface-2);color:var(--muted);opacity:.55}

/* bar rows for cost / workload */
.bars{display:flex;flex-direction:column;gap:9px}
.bar-row{display:grid;grid-template-columns:96px 1fr auto;align-items:center;gap:10px;font-size:12.5px}
.bar-track{display:block;height:9px;border-radius:5px;background:var(--surface-2);overflow:hidden;border:1px solid var(--line-soft)}
.bar-fill{display:block;height:100%;min-width:3px;background:var(--accent);border-radius:5px}
.bar-row .val{font-family:var(--f-mono);font-size:12px;font-variant-numeric:tabular-nums;color:var(--muted)}

/* ---------- job detail ---------------------------------------------- */
.detail-head{
  background:var(--surface);border:1px solid var(--line-soft);border-radius:var(--r);
  padding:14px;position:relative;overflow:hidden
}
.detail-head::before{content:"";position:absolute;left:0;top:0;bottom:0;width:5px}
.detail-head.u-green::before{background:var(--u-green)}
.detail-head.u-yellow::before{background:var(--u-yellow)}
.detail-head.u-orange::before{background:var(--u-orange)}
.detail-head.u-red::before{background:var(--u-red)}
.detail-head h1{font-size:19px;line-height:1.25;margin:6px 0 8px}

.urgency-picker{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}
.urgency-picker button{
  border:1px solid var(--line);background:var(--surface);border-radius:8px;
  padding:8px 4px;cursor:pointer;display:flex;flex-direction:column;align-items:center;gap:5px;
  font-size:10.5px;font-weight:600;color:var(--muted);line-height:1.15;text-align:center
}
.urgency-picker button .dot{width:12px;height:12px}
.urgency-picker button.on.u-green{background:var(--u-green-bg);border-color:var(--u-green);color:var(--u-green)}
.urgency-picker button.on.u-yellow{background:var(--u-yellow-bg);border-color:var(--u-yellow);color:var(--u-yellow)}
.urgency-picker button.on.u-orange{background:var(--u-orange-bg);border-color:var(--u-orange);color:var(--u-orange)}
.urgency-picker button.on.u-red{background:var(--u-red-bg);border-color:var(--u-red);color:var(--u-red)}

.steps{display:flex;gap:0;border:1px solid var(--line);border-radius:8px;overflow:hidden}
.steps button{
  flex:1;border:0;border-right:1px solid var(--line);background:var(--surface);
  padding:9px 4px;font-size:12px;font-weight:600;cursor:pointer;color:var(--muted)
}
.steps button:last-child{border-right:0}
.steps button.on{background:var(--accent);color:var(--on-accent)}
.steps button:disabled{opacity:.4;cursor:not-allowed}

.photos{display:grid;grid-template-columns:repeat(auto-fill,minmax(88px,1fr));gap:7px}
.photos figure{margin:0;position:relative;aspect-ratio:1;border-radius:8px;overflow:hidden;border:1px solid var(--line)}
.photos img{width:100%;height:100%;object-fit:cover;display:block}
.photos figcaption{
  position:absolute;left:0;right:0;bottom:0;font-size:9.5px;font-family:var(--f-mono);
  letter-spacing:.08em;text-transform:uppercase;background:rgba(0,0,0,.62);color:#fff;
  padding:3px 5px;text-align:center
}
.photo-add{display:flex;gap:6px;flex-wrap:wrap;margin-top:10px}
.photo-add label{cursor:pointer}
.photo-x{
  position:absolute;top:4px;right:4px;width:21px;height:21px;border-radius:50%;
  border:0;background:rgba(0,0,0,.6);color:#fff;font-size:15px;line-height:1;
  cursor:pointer;display:grid;place-items:center;padding:0
}
.photo-x:hover{background:rgba(0,0,0,.85)}
.addphoto{
  aspect-ratio:1;border:1px dashed var(--line);border-radius:8px;background:var(--surface-2);
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;
  cursor:pointer;color:var(--muted);font-size:10.5px;font-weight:600
}

.timeline{display:flex;flex-direction:column;gap:0;font-size:12.5px}
.timeline li{display:flex;gap:9px;padding:6px 0;list-style:none;border-bottom:1px solid var(--line-soft)}
.timeline li:last-child{border-bottom:0}
.timeline time{font-family:var(--f-mono);font-size:11px;color:var(--muted);flex:none;width:78px;font-variant-numeric:tabular-nums}

.costlist{display:flex;flex-direction:column;gap:0}
.costlist li{display:flex;gap:8px;align-items:baseline;padding:7px 0;border-bottom:1px solid var(--line-soft);list-style:none;font-size:13px}
.costlist li:last-child{border-bottom:0}
.costlist .amt{margin-left:auto;font-family:var(--f-mono);font-variant-numeric:tabular-nums;font-weight:600}
.total-row{display:flex;align-items:baseline;gap:8px;margin-top:9px;padding-top:9px;border-top:1px solid var(--line);font-weight:700}
.total-row .amt{margin-left:auto;font-family:var(--f-mono);font-variant-numeric:tabular-nums}

/* ---------- check-in banner ----------------------------------------- */
.checkin-note{
  display:flex;align-items:center;gap:9px;border-radius:8px;padding:9px 11px;font-size:12.5px;
  background:var(--accent-soft);color:var(--text);border:1px solid color-mix(in srgb,var(--accent) 26%,transparent)
}
.checkin-note b{font-family:var(--f-mono);font-variant-numeric:tabular-nums}
.checkin-note.warn{background:var(--u-orange-bg);border-color:color-mix(in srgb,var(--u-orange) 32%,transparent);color:var(--u-orange)}

/* ---------- sheet / modal ------------------------------------------- */
.sheet-bg{position:fixed;inset:0;background:rgba(6,14,17,.5);z-index:60;display:flex;align-items:flex-end;justify-content:center}
.sheet{
  background:var(--surface);border-radius:16px 16px 0 0;width:100%;max-width:520px;
  max-height:86vh;overflow-y:auto;padding:16px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow:var(--shadow);animation:rise .18s ease-out
}
@keyframes rise{from{transform:translateY(14px);opacity:.6}to{transform:none;opacity:1}}
.sheet h2{font-size:17px;margin-bottom:12px}
.sheet-actions{display:flex;gap:8px;margin-top:6px}
.sheet-actions .btn{flex:1;justify-content:center}
.picklist{display:flex;flex-direction:column;gap:5px}
.picklist button{
  display:flex;align-items:center;gap:10px;border:1px solid var(--line);background:var(--surface);
  border-radius:8px;padding:9px 11px;cursor:pointer;text-align:left;width:100%;font:inherit
}
.picklist button:hover{background:var(--surface-2)}
.picklist button.on{border-color:var(--accent);background:var(--accent-soft)}
.picklist small{color:var(--muted);font-size:11.5px}

.toast{
  position:fixed;left:50%;transform:translateX(-50%);bottom:84px;z-index:80;
  background:var(--text);color:var(--ground);padding:9px 15px;border-radius:999px;
  font-size:13px;font-weight:500;box-shadow:var(--shadow);animation:rise .18s ease-out
}

/* permissions matrix */
table.perms{border-collapse:collapse;width:100%;font-size:13px;min-width:340px}
table.perms th,table.perms td{padding:7px 8px;text-align:left;border-bottom:1px solid var(--line-soft)}
table.perms thead th{
  font-family:var(--f-mono);font-size:10.5px;letter-spacing:.1em;text-transform:uppercase;
  color:var(--muted);font-weight:500;border-bottom:1px solid var(--line)
}
table.perms th:not(:first-child),table.perms td:not(:first-child){text-align:center;width:64px}
table.perms tbody tr:last-child td{border-bottom:0}
table.perms td.yes{color:var(--u-green);font-size:15px;line-height:1}
table.perms td.no{color:var(--line);font-size:15px;line-height:1}

.swatches{display:flex;gap:7px;flex-wrap:wrap}
.swatches button{
  width:28px;height:28px;border-radius:50%;border:2px solid transparent;
  cursor:pointer;padding:0;outline-offset:2px
}
.swatches button.on{border-color:var(--text);box-shadow:0 0 0 2px var(--surface) inset}

.legend{display:flex;flex-direction:column;gap:7px}
.legend li{display:flex;gap:9px;align-items:flex-start;list-style:none;font-size:12.5px;line-height:1.4}
.legend .dot{margin-top:5px}
.legend b{display:block;font-size:13px}

.banner{
  background:var(--surface-2);border:1px solid var(--line);border-radius:var(--r);
  padding:10px 12px;font-size:12.5px;color:var(--muted);display:flex;gap:9px;align-items:flex-start
}
.banner b{color:var(--text)}

/* ---------- desktop -------------------------------------------------- */
@media (min-width:900px){
  .shell{flex-direction:row}
  .nav{
    position:sticky;top:0;left:auto;right:auto;bottom:auto;height:100vh;height:100dvh;
    width:var(--rail);flex:none;grid-template-columns:1fr;grid-auto-rows:max-content;
    border-top:0;border-right:1px solid var(--line);align-content:start;gap:2px;padding:14px 10px
  }
  .nav .rail-brand{display:flex;align-items:center;gap:9px;padding:4px 8px 16px;font-family:var(--f-display);font-weight:700;font-size:16px;letter-spacing:-.02em;white-space:nowrap}
  .nav a{flex-direction:row;justify-content:flex-start;gap:11px;padding:9px 10px;border-radius:8px;font-size:13.5px}
  .nav a.on{background:var(--accent-soft)}
  .colwrap{flex:1;display:flex;flex-direction:column;min-width:0}
  .main{padding:18px 26px 40px;max-width:none}
  .main-inner{max-width:920px;margin:0 auto}
  .tiles{grid-template-columns:repeat(4,1fr)}
  .two-col{display:grid;grid-template-columns:1.35fr 1fr;gap:16px;align-items:start}
  .sheet-bg{align-items:center}
  .sheet{border-radius:14px;max-width:480px}
  .toast{bottom:26px}
}
@media (max-width:899px){
  .nav .rail-brand{display:none}
  .colwrap{display:contents}
}
@media (max-width:420px){
  .tiles{grid-template-columns:repeat(2,1fr)}
  .grid2{grid-template-columns:1fr}
}
