/* BayOps — back-of-house at Hodges Bay.
   Tokens: navy ink on cream field; gold is reserved for active states
   and the Day Board hairline. Serif appears only in greetings/titles. */
:root {
  --navy: #0a1628;
  --navy-2: #16263e;
  --navy-3: #24364f;
  --gold: #c9a96e;
  --gold-deep: #a8853f;
  --cream: #f8f6f3;
  --card: #ffffff;
  --line: #e5e0d7;
  --ink: #182234;
  --ink-2: #4c5568;
  --ink-3: #818999;
  --data: #2d63a8;      /* validated chart hue */
  --ok: #2e7d4f;
  --warn: #b07c1f;
  --danger: #b3452c;
  --danger-bg: #f9ece8;
  --radius: 10px;
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans); background: var(--cream); color: var(--ink);
  font-size: 15px; line-height: 1.45;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- boot ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; text-align: center; gap: 14px; }
.boot-logo { width: 190px; height: auto; margin: 0 auto; }
.boot p { color: var(--ink-3); letter-spacing: 3px; text-transform: uppercase; font-size: 11px; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 500px at 70% -10%, #1d3050 0%, var(--navy) 55%);
}
.login-card {
  width: 100%; max-width: 360px; background: var(--card); border-radius: 14px;
  padding: 36px 30px 30px; box-shadow: 0 24px 60px rgba(4, 10, 22, .45);
}
.login-logo { display: block; width: 230px; max-width: 80%; height: auto; margin: 4px auto 16px; }
.login-sub { text-align: center; color: var(--ink-3); font-size: 12.5px; letter-spacing: 2.5px; text-transform: uppercase; margin: 4px 0 24px; }
.login-sub::after { content: ""; display: block; width: 44px; height: 1px; background: var(--gold); margin: 14px auto 0; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; letter-spacing: .3px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fdfcfa; color: var(--ink); min-height: 42px;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold-deep); outline: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; min-height: 42px;
}
.btn-primary { background: var(--navy); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--navy-2); }
.btn-quiet { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-quiet:hover { border-color: var(--ink-3); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.form-error { background: var(--danger-bg); color: var(--danger); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }

/* ---------- app frame ---------- */
.frame { min-height: 100vh; padding-bottom: calc(72px + var(--sab)); }
.topbar {
  position: sticky; top: 0; z-index: 30; background: var(--navy); color: #fff;
  padding: calc(10px + var(--sat)) 16px 10px; display: flex; align-items: center; gap: 12px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 19px; letter-spacing: .5px; }
.topbar .brand img { height: 24px; width: auto; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12px; color: #b9c2d1; text-align: right; line-height: 1.3; }
.topbar .who span { display: block; color: #fff; font-weight: 600; font-size: 13px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--navy-3);
  color: var(--gold); display: grid; place-content: center; font-size: 13px; font-weight: 700;
  border: 1px solid rgba(201,169,110,.4); flex: none;
}

/* desktop sidebar */
.side { display: none; }
@media (min-width: 900px) {
  .frame { display: grid; grid-template-columns: 220px 1fr; padding-bottom: 0; }
  .topbar { grid-column: 1 / -1; }
  .side {
    display: flex; flex-direction: column; gap: 2px; padding: 18px 12px;
    background: #f1ede6; border-right: 1px solid var(--line); min-height: calc(100vh - 56px);
  }
  .side .nav-item {
    display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px;
    border: none; background: none; color: var(--ink-2); font-weight: 600; font-size: 14px; text-align: left;
  }
  .side .nav-item svg { width: 19px; height: 19px; flex: none; stroke: currentColor; }
  .side .nav-item.on { background: var(--navy); color: #fff; }
  .side .nav-item.on svg { stroke: var(--gold); }
  .side .nav-item:not(.on):hover { background: #e9e4da; }
  .tabbar { display: none !important; }
  .fab { display: none !important; }
  .side .side-new {
    margin: 14px 4px 4px; background: var(--gold); color: var(--navy); border-radius: 8px;
    font-weight: 700; padding: 11px;
  }
  .side .side-new:hover { background: #d6b982; }
}
main.view { padding: 18px 16px 40px; max-width: 1080px; width: 100%; margin: 0 auto; }
@media (min-width: 900px) { main.view { padding: 26px 32px 60px; } }

/* mobile tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(10, 22, 40, .97); backdrop-filter: blur(8px);
  padding: 6px 4px calc(6px + var(--sab));
}
.tabbar button {
  background: none; border: none; color: #7f8ba0; font-size: 10px; font-weight: 600;
  display: grid; justify-items: center; gap: 3px; padding: 6px 2px; letter-spacing: .3px;
}
.tabbar button svg { width: 21px; height: 21px; stroke: currentColor; }
.tabbar button.on { color: var(--gold); }
.fab {
  position: fixed; right: 16px; bottom: calc(78px + var(--sab)); z-index: 31;
  width: 54px; height: 54px; border-radius: 50%; border: none;
  background: var(--gold); color: var(--navy); font-size: 28px; line-height: 1;
  box-shadow: 0 8px 24px rgba(10, 22, 40, .35);
}

/* ---------- day board (signature) ---------- */
.dayboard { background: var(--navy); color: #fff; border-radius: 14px; padding: 22px 20px 18px; margin-bottom: 18px; }
.dayboard .db-date { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--gold); }
.dayboard h1 { font-family: var(--serif); font-size: 30px; font-weight: 600; margin: 6px 0 2px; }
.dayboard .db-sub { color: #aeb8c9; font-size: 13.5px; }
.dayboard .db-rule { height: 1px; background: linear-gradient(90deg, var(--gold), rgba(201,169,110,0)); margin: 16px 0 14px; }
.dayboard .db-nums { display: flex; gap: 26px; }
.dayboard .db-num b { display: block; font-family: var(--serif); font-size: 26px; font-weight: 600; line-height: 1.1; }
.dayboard .db-num span { font-size: 11px; color: #aeb8c9; letter-spacing: 1px; text-transform: uppercase; }
.dayboard .db-num.alert b { color: #e8a595; }

/* ---------- sections & cards ---------- */
.screen-title { font-family: var(--serif); font-size: 26px; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.screen-sub { color: var(--ink-3); font-size: 13.5px; margin-bottom: 18px; }
.section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  color: var(--ink-3); margin: 22px 0 10px; display: flex; align-items: center; gap: 10px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.cards { display: grid; gap: 10px; }
@media (min-width: 720px) { .cards.two { grid-template-columns: 1fr 1fr; } }

/* task rows */
.task-row {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  width: 100%; text-align: left;
}
.task-row { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.task-row:hover { border-color: #c9bfa9; box-shadow: 0 2px 10px rgba(10, 22, 40, .08); }
.task-row:active { box-shadow: none; background: #fdfbf8; }
.task-row .t-check {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%;
  border: 2px solid #c9c2b4; background: none; display: grid; place-content: center; color: transparent;
}
.task-row .t-check.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.task-row .t-main { flex: 1; min-width: 0; }
.task-row .t-title { font-weight: 600; font-size: 14.5px; }
.task-row.done .t-title { text-decoration: line-through; color: var(--ink-3); font-weight: 500; }
.task-row .t-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 4px; font-size: 12px; color: var(--ink-3); align-items: center; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-todo { background: #eef0f3; color: #55617a; }
.b-in_progress { background: #e7eef8; color: var(--data); }
.b-blocked { background: #f6e9e9; color: var(--danger); }
.b-done { background: #e9f2ec; color: var(--ok); }
.b-high { background: var(--danger); color: #fff; }
.b-medium { background: #eef0f3; color: #55617a; }
.b-low { background: #f2f2ef; color: #909a8d; }
.b-hold { background: #e9e5ee; color: #6d6284; }
.due { font-weight: 600; }
.due.overdue { color: var(--danger); }
.due.today { color: var(--gold-deep); }

/* project cards */
.proj-card { padding: 16px; display: block; width: 100%; text-align: left; }
.proj-card .p-name { font-weight: 700; font-size: 15.5px; color: var(--navy); }
.proj-card .p-desc { color: var(--ink-2); font-size: 13px; margin: 4px 0 10px; }
.proj-card .p-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-3); }
.progress { height: 5px; border-radius: 4px; background: #edeae3; overflow: hidden; margin-top: 12px; }
.progress i { display: block; height: 100%; background: var(--ok); border-radius: 4px; }

/* filters */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  border-radius: 20px; padding: 7px 14px; font-size: 13px; font-weight: 600;
}
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.filters select { border: 1px solid var(--line); border-radius: 20px; padding: 6px 10px; background: var(--card); color: var(--ink-2); font-size: 13px; }

/* ---------- sheet / modal ---------- */
.sheet-scrim { position: fixed; inset: 0; background: rgba(8, 14, 26, .5); z-index: 40; animation: fade .18s ease; }
.sheet {
  position: fixed; z-index: 41; background: var(--card); overflow-y: auto;
  inset: auto 0 0 0; max-height: 92vh; border-radius: 16px 16px 0 0;
  padding: 10px 18px calc(26px + var(--sab)); animation: rise .22s ease;
}
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 14px; }
@media (min-width: 720px) {
  .sheet { inset: 0; margin: auto; width: 560px; height: fit-content; max-height: 86vh; border-radius: 14px; padding: 24px 26px; }
  .sheet .grab { display: none; }
}
@keyframes rise { from { transform: translateY(30px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
.sheet h2 { font-family: var(--serif); font-size: 22px; color: var(--navy); margin-bottom: 14px; font-weight: 600; }
.sheet .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn-primary { flex: 1; width: auto; }

/* task detail — every field edits in place */
.sheet-close {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: #f1ede6; color: var(--ink-2); font-size: 14px; line-height: 1;
}
.sheet-close:hover { background: #e7e1d6; color: var(--ink); }
.d-title {
  width: 100%; font-family: inherit; font-size: 17px; font-weight: 700; color: var(--navy);
  background: #fdfcfa; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.d-title:focus { border-color: var(--gold-deep); outline: none; }
.sheet > .field:first-of-type { margin-right: 42px; }  /* clear the ✕ button */
.d-desc {
  display: block; width: 100%; min-height: 110px; resize: vertical; font-family: inherit;
  font-size: 14px; line-height: 1.55; color: var(--ink);
  background: #fdfcfa; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  white-space: pre-wrap;
}
.d-desc:focus { border-color: var(--gold-deep); outline: none; }
.d-meta { font-size: 12px; color: var(--ink-3); margin: 10px 0 6px; }
.seg-label {
  display: block; font-size: 12px; font-weight: 600; color: var(--ink-2);
  margin: 12px 0 5px; letter-spacing: .3px;
}
.sheet .field { margin-top: 10px; }

/* updates & history timeline */
.tl-update { padding: 10px 0 8px; border-top: 1px solid var(--line); font-size: 13.5px; }
.tl-update .c-head { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--ink-3); margin-bottom: 3px; }
.tl-update .c-head b { color: var(--ink); }
.tl-body { white-space: pre-wrap; color: var(--ink); }
.tl-comment .tl-body { color: var(--ink-2); }
.tl-event {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 7px 0; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-2);
}
.tl-event:first-child, .tl-update:first-child { border-top: none; }
.tl-event .tl-who { flex: none; color: var(--ink-3); font-size: 11.5px; }
.tl-empty { color: var(--ink-3); font-size: 13px; }

/* attachments */
.att-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
@media (min-width: 720px) { .att-grid { grid-template-columns: repeat(4, 1fr); } }
.att-thumb { position: relative; display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #f1ede6; }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-thumb.att-doc { aspect-ratio: 3 / 4; background: #fff; }
.att-thumb.att-doc img { object-fit: contain; object-position: top; }
.att-cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 7px;
  background: rgba(10, 22, 40, .74); color: #fff; font-size: 10.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.att-grid { align-items: start; }
.att-file {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-top: 6px;
  border: 1px solid var(--line); border-radius: 8px; text-decoration: none; font-size: 13px;
}
.att-file .att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.att-file .att-size { color: var(--ink-3); font-size: 12px; }
.att-hint { color: var(--ink-3); font-size: 12.5px; }
.detail-title { font-size: 18px; font-weight: 700; color: var(--navy); margin-bottom: 8px; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.detail-desc { color: var(--ink-2); font-size: 14px; white-space: pre-wrap; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13.5px; margin-bottom: 16px; }
.kv dt { color: var(--ink-3); }
.kv dd { font-weight: 600; }
.status-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 16px; }
.status-seg button { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 9px 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.status-seg button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.comment { padding: 10px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.comment .c-head { display: flex; gap: 8px; font-size: 12px; color: var(--ink-3); margin-bottom: 3px; }
.comment .c-head b { color: var(--ink); }
.comment-form { display: flex; gap: 8px; margin-top: 12px; }
.comment-form input { flex: 1; }
.comment-form .btn { min-width: 74px; }
.update-form { margin: 4px 0 12px; }
.update-form textarea {
  width: 100%; min-height: 88px; resize: vertical; font-family: inherit;
  font-size: 14px; line-height: 1.5; color: var(--ink);
  background: #fdfcfa; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.update-form textarea:focus { border-color: var(--gold-deep); outline: none; }
.uf-actions { display: flex; justify-content: flex-end; margin-top: 6px; }
.btn-sm { min-height: 32px; padding: 5px 16px; font-size: 13px; width: auto; }

/* ---------- reports ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { padding: 14px 16px; }
.kpi b { display: block; font-family: var(--serif); font-size: 30px; font-weight: 600; color: var(--navy); line-height: 1.1; }
.kpi span { font-size: 11.5px; color: var(--ink-3); letter-spacing: 1px; text-transform: uppercase; }
.kpi.k-danger b { color: var(--danger); }
.kpi.k-gold b { color: var(--gold-deep); }
.chart-card { padding: 16px; margin-bottom: 12px; }
.chart-card h3 { font-size: 14px; font-weight: 700; color: var(--navy); margin-bottom: 2px; }
.chart-card .c-sub { font-size: 12px; color: var(--ink-3); margin-bottom: 12px; }
.chart-card svg { display: block; width: 100%; height: auto; }
.chart-card details { margin-top: 10px; font-size: 13px; }
.chart-card summary { color: var(--ink-3); font-size: 12px; cursor: pointer; }
.chart-card table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.chart-card th, .chart-card td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.chart-card th { color: var(--ink-3); font-weight: 600; }
.chart-card td:last-child, .chart-card th:last-child { text-align: right; }
.hbar-label { font-size: 12px; fill: var(--ink-2); }
.hbar-val { font-size: 12px; font-weight: 600; fill: var(--ink); }
.axis-label { font-size: 10.5px; fill: var(--ink-3); }
.gridline { stroke: #edeae3; stroke-width: 1; }
.chart-tip {
  position: fixed; z-index: 60; background: var(--navy); color: #fff; font-size: 12px;
  padding: 6px 10px; border-radius: 6px; pointer-events: none; max-width: 240px;
  box-shadow: 0 6px 18px rgba(4,10,22,.3);
}
.chart-tip b { color: var(--gold); }
@media (min-width: 900px) { .report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } }

/* activity */
.act-row { display: flex; gap: 10px; padding: 10px 14px; font-size: 13px; border-top: 1px solid var(--line); }
.act-row:first-child { border-top: none; }
.act-row .a-time { flex: none; color: var(--ink-3); font-size: 12px; width: 74px; }

/* admin */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.admin-table th { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-3); }
.admin-table .muted { color: var(--ink-3); }
.table-scroll { overflow-x: auto; }

/* empty states */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty .e-mark { font-family: var(--serif); font-size: 30px; color: var(--gold); margin-bottom: 6px; }
.empty p { font-size: 14px; max-width: 340px; margin: 0 auto 14px; }
.empty .btn { width: auto; }

/* toast */
#toast-root { position: fixed; bottom: calc(84px + var(--sab)); left: 0; right: 0; z-index: 70; display: grid; place-items: center; gap: 8px; pointer-events: none; }
@media (min-width: 900px) { #toast-root { bottom: 30px; } }
.toast {
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 24px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 8px 24px rgba(4,10,22,.35);
  animation: rise .2s ease;
}
.toast.err { background: var(--danger); }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* mobile editing ergonomics: 16px inputs stop iOS focus-zoom; 44px touch targets */
@media (max-width: 719px) {
  .sheet input, .sheet select, .sheet textarea { font-size: 16px; }
  .sheet .field input, .sheet .field select { min-height: 44px; }
  .sheet .status-seg button { min-height: 42px; }
  .d-title { font-size: 17px; }
}
