/* ============================================================
   Soft SaaS design system, shared with Between
   Light neutral ground · white rounded cards · pastel gradients
   ============================================================ */

:root {
  --ground: #f2f1ef;       /* page background */
  --surface: #ffffff;      /* cards */
  --surface-2: #f4f4f5;    /* wells, tracks */
  --line: #ececee;         /* hairlines */
  --ink: #17171c;          /* primary text */
  --ink-2: #4b4b53;        /* secondary text */
  --ink-3: #9a9aa2;        /* tertiary text */
  --peach: #ffe9db;
  --peach-strong: #dd7a3c;
  --green: #3e9b4f;
  --green-soft: #e7f4e9;
  --blue: #3f7fe8;
  --blue-soft: #e7effc;
  --purple: #8a6ff0;
  --purple-soft: #efeafc;
  --pink-soft: #fce9f1;
  --danger: #d64a35;
  --danger-soft: #fdece8;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(23,23,28,0.04), 0 8px 24px rgba(23,23,28,0.05);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--ground);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- App shell: left sidebar ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 242px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
}

.sidebar-brand { display: block; text-decoration: none; padding: 2px 10px 24px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark { width: 34px; height: 34px; flex-shrink: 0; }
.logo-word { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }

.side-nav { display: flex; flex-direction: column; }
.side-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 12px 10px;
}
.side-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 3px;
  transition: background 0.12s ease, color 0.12s ease;
}
.side-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.side-item:hover { background: var(--surface-2); color: var(--ink); }
.side-item.active { background: var(--peach); color: var(--peach-strong); font-weight: 600; }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 10px 2px;
  border-top: 1px solid var(--line);
}
.side-user strong { display: block; font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.side-user span { font-size: 12px; color: var(--ink-3); }

.avatar {
  width: 36px; height: 36px; border-radius: 999px;
  background: var(--ink); color: #ffffff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}

.content { flex: 1; min-width: 0; }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 12px 16px; }
  .sidebar-brand { padding: 0 14px 0 0; }
  .side-nav { flex-direction: row; align-items: center; }
  .side-label, .sidebar-foot { display: none; }
  .side-item { margin-bottom: 0; }
}

/* ---------- Main ---------- */
.main { max-width: 1180px; margin: 0 auto; padding: 34px 36px 80px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 28px; }
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; color: var(--ink); margin: 0; }
.page-sub { color: var(--ink-3); margin: 6px 0 0; font-size: 14px; }

/* ---------- Hero (dashboard greeting) ---------- */
.hero {
  border-radius: 22px;
  padding: 44px 44px 40px;
  margin-bottom: 26px;
  background:
    radial-gradient(90% 160% at 88% 0%, rgba(196,168,245,0.35) 0%, rgba(196,168,245,0) 55%),
    radial-gradient(70% 140% at 65% 10%, rgba(255,170,120,0.38) 0%, rgba(255,170,120,0) 60%),
    linear-gradient(115deg, #fff2e8 0%, #ffe7d6 34%, #fdeaf0 68%, #f2ecfd 100%);
}
.hero-title { font-size: 34px; font-weight: 700; letter-spacing: -0.025em; margin: 0 0 6px; }
.hero-sub { font-size: 15px; color: var(--ink-2); margin: 0 0 24px; }

/* ---------- Cards & stats ---------- */
.card {
  background: var(--surface);
  border: 1px solid rgba(23,23,28,0.04);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; margin-bottom: 30px; }

.stat-grid .card {
  border: none;
  box-shadow: none;
  min-height: 116px;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
}
.stat-grid .card:nth-child(4n+1) { background: linear-gradient(135deg, #eaf2fd 0%, #dce9fb 100%); }
.stat-grid .card:nth-child(4n+2) { background: linear-gradient(135deg, #f0ebfd 0%, #e5dcfa 100%); }
.stat-grid .card:nth-child(4n+3) { background: linear-gradient(135deg, #fdecf4 0%, #fadbe9 100%); }
.stat-grid .card:nth-child(4n+4) { background: linear-gradient(135deg, #e9f7ec 0%, #daf0df 100%); }

.stat-label { font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: auto; }
.stat-value { font-size: 27px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); line-height: 1.1; margin-top: 14px; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 12px; color: var(--ink-2); opacity: 0.75; margin-top: 4px; }

.section { margin-bottom: 34px; }
.section-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); margin: 0 0 14px; }

/* ---------- Table ---------- */
.table-wrap { border-radius: var(--radius); overflow-x: auto; background: var(--surface); box-shadow: var(--shadow); border: 1px solid rgba(23,23,28,0.04); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 14px 20px; color: var(--ink-3); font-weight: 500; font-size: 13px; border-bottom: 1px solid var(--line); }
td { padding: 16px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.row-link:hover { background: #fafafa; }
td a.file-link, a.file-link { font-weight: 600; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; text-decoration-color: var(--ink-3); }
td a.file-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Status badges (soft pills) ---------- */
.badge { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.badge-processed { background: var(--green-soft); color: var(--green); }
.badge-processing, .badge-pending { background: var(--blue-soft); color: var(--blue); }
.badge-failed { background: var(--danger-soft); color: var(--danger); }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #ffffff;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: #303038; border-color: #303038; }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(23,23,28,0.04); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 7px 14px; font-size: 12.5px; }
@media (pointer: coarse) { .btn, .btn-sm { min-height: 44px; } }  /* finger-sized on phones */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field label .muted { color: var(--ink-3); font-weight: 400; }
/* Required fields: a red * after the label, found automatically from the input's `required`. */
.field:has(:required) > label::after { content: " *"; color: var(--danger); font-weight: 700; }
.required-mark { color: var(--danger); font-weight: 700; }
/* A required dropdown still on its "Choose ..." prompt shows the prompt in red; the choices stay normal. */
select:required:invalid { color: var(--danger); }
select:required option { color: var(--ink); }
.field input[type="text"], .field input[type="number"] {
  padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font);
  font-size: 14px; background: var(--surface); color: var(--ink);
}
.field input:focus { outline: 2px solid rgba(63,127,232,0.35); outline-offset: 0; border-color: #b9cff5; }

.flash { padding: 13px 18px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 14px; font-weight: 500; }
.flash-notice { background: var(--green-soft); color: var(--green); }
.flash-alert { background: var(--danger-soft); color: var(--danger); }

.empty-panel { text-align: center; padding: 56px 20px; }
.empty-panel p { color: var(--ink-3); margin: 0 0 18px; }
.empty { text-align: center; color: var(--ink-3); padding: 50px 20px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--ink-3); }
.kv .v { font-weight: 600; color: var(--ink); text-align: right; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 14px; }
.section-head .section-title { margin: 0; flex: 1; }

/* ============================================================
   App components (built on the tokens above)
   ============================================================ */
:root {
  --warn: #b7791f; --warn-soft: #fdf3dc;
  --c-civil: #2a78d6; --c-plumb: #eb6834; --c-elec: #1baf7a; --c-int: #eda100; --c-ext: #e87ba4; --c-cont: #9a9aa2;
}
.main { max-width: 1320px; padding: 28px 32px 80px; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 18px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* Links open something to read: always underlined, so they are recognisable on phones (no hover).
   Actions that do something use .btn instead. A link opening a new tab (PDF, proof) gets an arrow. */
.link { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; font-weight: 600; font-size: 13px; }
.link:hover { text-decoration-thickness: 2px; }
a.link[target="_blank"]::after, a.file-link[target="_blank"]::after { content: " \2197"; text-decoration: none; display: inline-block; margin-left: 2px; }
button.link { background: none; border: none; cursor: pointer; font-family: var(--font); padding: 0; }
form.inline { display: inline; }

.side-label-gap { margin-top: 18px; }
.side-item .soon { margin-left: auto; font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); background: var(--surface-2); padding: 2px 7px; border-radius: 999px; }
.side-count { margin-left: auto; font-size: 11.5px; font-weight: 600; background: var(--danger-soft); color: var(--danger); padding: 1px 8px; border-radius: 999px; }
.sidebar-foot form { margin-left: auto; }
.sidebar-foot button { background: none; border: none; color: var(--ink-3); cursor: pointer; padding: 6px; border-radius: 8px; display: flex; }
.sidebar-foot button:hover { background: var(--surface-2); color: var(--ink); }
.side-nav { overflow-y: auto; }

/* badges */
.badge-ok { background: var(--green-soft); color: var(--green); }
.badge-info { background: var(--blue-soft); color: var(--blue); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-muted { background: var(--surface-2); color: var(--ink-2); }
.badge-sm { padding: 3px 9px; font-size: 11.5px; }

/* buttons */
.btn-blue { background: var(--blue); border-color: var(--blue); }
.btn-blue:hover { background: #2f6bd0; border-color: #2f6bd0; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* forms */
.field input[type="text"], .field input[type="number"], .field input[type="email"], .field input[type="password"], .field input[type="date"], .field input[type="tel"], .field select, .field textarea {
  padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font);
  font-size: 14px; background: var(--surface); color: var(--ink); width: 100%;
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field select:focus, .field textarea:focus { outline: 2px solid rgba(63,127,232,0.35); border-color: #b9cff5; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-actions { display: flex; gap: 10px; margin-top: 22px; align-items: center; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.errors { background: var(--danger-soft); color: var(--danger); padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 18px; }
.inline-form { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.inline-form .field { min-width: 120px; flex: 1; }
details.adder { margin-top: 14px; }
details.adder > summary { cursor: pointer; list-style: none; font-size: 13px; font-weight: 600; color: var(--blue); }
details.adder > summary::-webkit-details-marker { display: none; }
details.adder[open] > summary { margin-bottom: 14px; }

/* progress bars */
.bar { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; min-width: 60px; flex: 1; }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-blue { background: var(--blue); } .bar-ok { background: var(--green); } .bar-warn { background: #e0a23a; } .bar-danger { background: var(--danger); }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-row .pct { font-size: 12.5px; font-weight: 600; color: var(--ink-2); width: 38px; text-align: right; font-variant-numeric: tabular-nums; }

/* thumbnails */
.thumb { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; flex-shrink: 0; display: block; }
.thumb-lg { width: 84px; height: 84px; border-radius: 16px; object-fit: cover; flex-shrink: 0; display: block; }
.thumb-blank { background: linear-gradient(135deg, #ffe7d6, #f2ecfd); color: var(--peach-strong); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; }
.thumb-lg.thumb-blank { font-size: 30px; }

/* hero */
.hero { padding: 30px 34px 28px; margin-bottom: 20px; display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; }
.hero-title { font-size: 30px; }
.hero-sub { margin: 0; }
.hero-meta { text-align: right; font-size: 13px; color: var(--ink-2); font-weight: 500; white-space: nowrap; }

/* attention cards */
.alert-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 20px; }
.alert-card { border-radius: var(--radius); padding: 16px 18px 0; text-decoration: none; display: flex; flex-direction: column; overflow: hidden; border: 1px solid transparent; transition: transform 0.12s ease, box-shadow 0.12s ease; min-height: 250px; }
.alert-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.alert-card.danger { background: linear-gradient(160deg, #fdece8, #fbdcd5); }
.alert-card.warn { background: linear-gradient(160deg, #fff6e2, #fdebc6); }
.alert-card.info { background: linear-gradient(160deg, #eaf2fd, #dce9fb); }
.alert-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.alert-card.danger .alert-head { color: var(--danger); } .alert-card.warn .alert-head { color: var(--warn); } .alert-card.info .alert-head { color: var(--blue); }
.alert-head .go { margin-left: auto; opacity: 0.7; display: flex; }
.alert-name { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
.alert-place { font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; }
.alert-text { font-size: 13px; color: var(--ink); line-height: 1.45; margin-bottom: 14px; }
.alert-img { margin: auto -18px 0; height: 96px; object-fit: cover; width: calc(100% + 36px); display: block; }

/* count tiles */
.count-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.count { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); border: 1px solid rgba(23,23,28,0.04); }
.count-ico { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.count-ico.blue { background: var(--blue-soft); color: var(--blue); } .count-ico.green { background: var(--green-soft); color: var(--green); }
.count-ico.warn { background: var(--warn-soft); color: var(--warn); } .count-ico.danger { background: var(--danger-soft); color: var(--danger); }
.count-ico.purple { background: var(--purple-soft); color: var(--purple); } .count-ico.peach { background: var(--peach); color: var(--peach-strong); }
.count-num { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.count-label { font-size: 12.5px; color: var(--ink-2); }

/* layout: main + rail */
.with-rail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.rail { display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 1180px) { .with-rail { grid-template-columns: 1fr; } }
.card-title { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-head { padding: 20px 24px 0; }
.card-flush table th:first-child, .card-flush table td:first-child { padding-left: 24px; }
.card-flush .table-scroll { overflow-x: auto; }
td, th { white-space: nowrap; }
td.wrap { white-space: normal; min-width: 200px; }
td .sub { font-size: 12.5px; color: var(--ink-3); }

/* pill filter tabs (links) */
.tabs { flex-wrap: wrap; }
a.tab { text-decoration: none; display: inline-block; }
.tabs-flat { background: none; box-shadow: none; border: none; padding: 0; margin-bottom: 14px; border-radius: 0; }
.tabs-flat .tab { padding: 7px 14px; font-size: 13px; }
.subtabs { display: flex; gap: 2px; border-top: 1px solid var(--line); margin: 18px -24px -22px; padding: 0 16px; overflow-x: auto; }
.subtab { padding: 13px 12px 12px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.subtab:hover { color: var(--ink); }
.subtab.active { color: var(--peach-strong); border-bottom-color: var(--peach-strong); font-weight: 600; }

/* project header */
.proj-head { margin-bottom: 20px; }
.proj-top { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.proj-name { font-size: 23px; font-weight: 700; letter-spacing: -0.02em; margin: 0; line-height: 1.2; }
.proj-place { color: var(--ink-2); font-size: 13.5px; display: flex; align-items: center; gap: 5px; margin-top: 3px; }
.proj-facts { margin-left: auto; display: flex; gap: 26px; align-items: center; flex-wrap: wrap; }
.fact-k { font-size: 12px; color: var(--ink-3); }
.fact-v { font-size: 14px; font-weight: 600; }

/* timeline lists */
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda li { display: grid; grid-template-columns: 56px 14px 1fr; gap: 8px; padding-bottom: 16px; position: relative; font-size: 13px; }
.agenda li:last-child { padding-bottom: 0; }
.agenda .when { color: var(--ink-3); font-size: 12px; padding-top: 1px; font-weight: 500; }
.agenda .dot { width: 10px; height: 10px; border-radius: 999px; margin-top: 4px; position: relative; z-index: 1; }
.agenda li:not(:last-child)::after { content: ""; position: absolute; left: 68px; top: 14px; bottom: 0; width: 2px; background: var(--line); }
.dot.blue { background: var(--blue); } .dot.green { background: var(--green); } .dot.peach { background: var(--peach-strong); } .dot.purple { background: var(--purple); } .dot.pink { background: #e87ba4; }
.agenda a { text-decoration: none; }
.agenda .t { font-weight: 600; color: var(--ink); line-height: 1.35; }
.agenda .s { color: var(--ink-3); font-size: 12.5px; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.feed li:last-child { border-bottom: none; padding-bottom: 0; } .feed li:first-child { padding-top: 0; }
.feed .t { font-weight: 600; } .feed .s { color: var(--ink-2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } .feed .w { color: var(--ink-3); font-size: 12px; }
.feed a { text-decoration: none; display: flex; gap: 12px; flex: 1; min-width: 0; }

/* gantt */
.gantt { overflow-x: auto; }
.gantt-inner { min-width: 900px; }
.g-row { display: grid; grid-template-columns: 250px 120px 1fr; align-items: center; border-bottom: 1px solid var(--line); min-height: 40px; font-size: 13px; }
.g-row:last-child { border-bottom: none; }
.g-head { color: var(--ink-3); font-size: 12px; font-weight: 500; min-height: 34px; }
.g-phase { background: #faf9f7; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2); min-height: 32px; }
.g-name { padding: 6px 12px 6px 24px; white-space: normal; line-height: 1.3; display: flex; gap: 7px; align-items: center; }
.g-dates { color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.g-track { position: relative; height: 40px; }
.g-months { position: relative; height: 34px; }
.g-month { position: absolute; top: 9px; font-size: 12px; font-weight: 600; color: var(--ink-2); padding-left: 6px; border-left: 1px solid var(--line); height: 1000px; pointer-events: none; }
.g-bar { position: absolute; top: 13px; height: 14px; border-radius: 4px; min-width: 4px; }
.g-bar.done { background: var(--green); } .g-bar.run { background: var(--blue); } .g-bar.todo { background: #b9cff5; }
.g-bar.late { background: var(--danger); } .g-bar.ghost { background: repeating-linear-gradient(135deg, #f5c6bd 0 5px, #fbe3de 5px 10px); }
.g-bar.crit { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--peach-strong); }
.g-bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--blue); border-radius: 4px; }
.g-late .g-name, .g-late .g-dates { color: var(--danger); font-weight: 600; }
.g-row.g-late { background: #fef6f4; }
.g-note { position: absolute; top: 11px; font-size: 12px; font-weight: 600; color: var(--danger); white-space: nowrap; padding-left: 8px; }
.g-today { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed var(--ink); opacity: 0.55; z-index: 2; pointer-events: none; }
.g-today-tag { position: absolute; top: 4px; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; z-index: 3; white-space: nowrap; }
.g-body { position: relative; }
.g-deps { font-size: 12px; color: var(--ink-3); padding: 0 12px; white-space: normal; line-height: 1.35; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.g-edit summary { cursor: pointer; list-style: none; color: var(--ink-3); display: flex; }
.g-edit summary::-webkit-details-marker { display: none; }
.g-edit[open] { grid-column: 1 / -1; }
.edit-row { grid-column: 1 / -1; padding: 14px 24px 18px; background: #fbfbfa; border-bottom: 1px solid var(--line); }

/* warning panel */
.warn-panel { background: linear-gradient(160deg, #fdece8, #fbdcd5); border-radius: var(--radius); padding: 20px 22px; }
.warn-panel h3 { margin: 0 0 10px; font-size: 12.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--danger); display: flex; gap: 8px; align-items: center; }
.warn-big { font-size: 22px; font-weight: 700; color: var(--danger); letter-spacing: -0.02em; margin: 8px 0; }
.ok-panel { background: linear-gradient(160deg, #e9f7ec, #daf0df); border-radius: var(--radius); padding: 20px 22px; }
.tone-list { list-style: none; padding: 0; margin: 0; font-size: 13.5px; }
.tone-list li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(23,23,28,0.07); align-items: flex-start; }
.tone-list li:last-child { border-bottom: none; }
.tone-list .grow { flex: 1; min-width: 0; }
.tone-list .tag { font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.tone-danger { color: var(--danger); } .tone-ok { color: var(--green); } .tone-blue { color: var(--blue); } .tone-warn { color: var(--warn); }
.steps-list { list-style: none; counter-reset: s; padding: 0; margin: 0 0 16px; font-size: 13.5px; }
.steps-list li { counter-increment: s; display: flex; gap: 10px; padding: 7px 0; line-height: 1.45; }
.steps-list li::before { content: counter(s); flex-shrink: 0; width: 22px; height: 22px; border-radius: 999px; background: var(--blue); color: #fff; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 1100px) { .three-col { grid-template-columns: 1fr; } }

/* money tiles */
.money-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.money { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); border: 1px solid rgba(23,23,28,0.04); }
.money-k { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 500; }
.money-v { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.money-h { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }

/* charts */
.donut-wrap { display: flex; gap: 26px; align-items: center; flex-wrap: wrap; }
.donut { position: relative; width: 178px; height: 178px; flex-shrink: 0; }
.donut svg { transform: rotate(-90deg); display: block; }
.donut path, .donut circle.seg { cursor: default; transition: opacity 0.12s ease; }
.donut:hover .seg { opacity: 0.45; } .donut .seg:hover { opacity: 1; }
.donut-mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-mid b { font-size: 19px; letter-spacing: -0.02em; } .donut-mid span { font-size: 12px; color: var(--ink-3); }
.chart-table { flex: 1; min-width: 250px; font-size: 13.5px; }
.chart-table td, .chart-table th { padding: 8px 6px; border-bottom: 1px solid var(--line); }
.chart-table tr:last-child td { border-bottom: none; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 9px; }
.chart svg text { font-family: var(--font); }
.chart { position: relative; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; padding: 8px 11px; border-radius: 10px; line-height: 1.5; white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity 0.1s ease; z-index: 5; }
.chart-tip.on { opacity: 1; }
.chart-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 99px; margin-right: 6px; }

/* phase stepper */
.phase-steps { display: flex; overflow-x: auto; padding: 6px 2px 4px; gap: 0; }
.pstep { flex: 1; min-width: 104px; text-align: center; position: relative; text-decoration: none; padding: 0 4px 8px; border-radius: 12px; }
.pstep::before { content: ""; position: absolute; top: 15px; left: -50%; right: 50%; height: 3px; background: #e6e5e1; z-index: 0; }
.pstep:first-child::before { display: none; }
.pstep.done::before, .pstep.current::before { background: var(--green); }
.pnode { width: 32px; height: 32px; border-radius: 999px; margin: 0 auto 8px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; position: relative; z-index: 1; background: var(--surface-2); color: var(--ink-3); border: 2px solid #e0dfdb; }
.pstep.done .pnode { background: var(--green); border-color: var(--green); color: #fff; }
.pstep.current .pnode { background: var(--blue); border-color: var(--blue); color: #fff; }
.pstep.selected .pnode { box-shadow: 0 0 0 4px var(--peach); }
.pname { font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.pmeta { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.pstep.done .pmeta { color: var(--green); } .pstep.current .pmeta { color: var(--blue); font-weight: 600; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.photo { border-radius: 14px; overflow: hidden; background: var(--surface-2); position: relative; aspect-ratio: 4 / 3; display: block; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-more { position: absolute; inset: 0; background: rgba(23,23,28,0.6); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; }
.photo-cap { font-size: 12px; color: var(--ink-2); margin-top: 6px; }

.signoffs { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.signoff { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; }
.signoff .ico { color: var(--ink-3); display: flex; margin-top: 1px; }
.signoff.done .ico { color: var(--green); }
.signoff.done { background: #f7fcf8; border-color: #d7eddb; }
.signoff b { font-size: 13.5px; display: block; } .signoff span { font-size: 12.5px; color: var(--ink-2); }

.letter { background: var(--blue-soft); border-radius: 14px; padding: 16px 18px; font-size: 13px; line-height: 1.55; white-space: pre-line; color: var(--ink); max-height: 260px; overflow-y: auto; }
.doc-link { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; margin: 8px 6px 0 0; }
.doc-link:hover { background: var(--surface-2); }
.pay-box { background: var(--surface-2); border-radius: 14px; padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; margin-bottom: 14px; }
.bank-box { background: var(--surface-2); border-radius: 14px; padding: 12px 16px; font-size: 12.5px; color: var(--ink-2); display: flex; gap: 12px; align-items: center; margin-top: 12px; line-height: 1.5; }
.quote { font-size: 14px; line-height: 1.55; border-left: 3px solid var(--peach-strong); padding: 4px 0 4px 14px; margin: 0; }
.stars { color: #e0a23a; letter-spacing: 2px; }

/* site updates */
.update { display: grid; gap: 14px; }
.update-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.update-body { background: var(--green-soft); border-radius: 14px; padding: 14px 16px; font-size: 14px; line-height: 1.55; }
.update-issue { background: var(--danger-soft); border-radius: 14px; padding: 12px 16px; font-size: 13.5px; }
.update-plan { background: var(--blue-soft); border-radius: 14px; padding: 12px 16px; font-size: 13.5px; }
.update-issue b, .update-plan b { display: flex; gap: 7px; align-items: center; font-size: 12.5px; margin-bottom: 4px; }
.update-issue b { color: var(--danger); } .update-plan b { color: var(--blue); }
.avatar-sm { width: 30px; height: 30px; font-size: 11.5px; }

/* mobile update form */
.narrow { max-width: 560px; margin: 0 auto; }
.step-card { background: var(--surface); border-radius: var(--radius); padding: 18px 18px 20px; box-shadow: var(--shadow); margin-bottom: 14px; }
.step-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; margin-bottom: 14px; }
.step-num { width: 26px; height: 26px; border-radius: 999px; background: var(--peach); color: var(--peach-strong); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.work-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.work-item:last-child { border-bottom: none; padding-bottom: 0; }
.work-item:first-child { padding-top: 0; }
.work-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.work-top output { color: var(--blue); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--blue); height: 28px; }
.mic-row { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.mic-btn { width: 58px; height: 58px; border-radius: 999px; border: none; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; box-shadow: 0 6px 18px rgba(63,127,232,0.35); }
.mic-btn.live { background: var(--danger); box-shadow: 0 0 0 0 rgba(214,74,53,0.5); animation: mic 1.4s ease-out infinite; }
@keyframes mic { 0% { box-shadow: 0 0 0 0 rgba(214,74,53,0.5); } 100% { box-shadow: 0 0 0 18px rgba(214,74,53,0); } }
.mic-state { font-size: 13px; color: var(--ink-2); flex: 1; min-width: 150px; }
.lang-pick { display: flex; gap: 6px; }
.lang-pick label { font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; background: var(--surface); }
.lang-pick input { position: absolute; opacity: 0; pointer-events: none; }
.lang-pick input:checked + span { color: var(--peach-strong); }
.lang-pick label:has(input:checked) { background: var(--peach); border-color: transparent; }
.preview-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.preview-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; display: block; }
.site-pick { display: flex; gap: 14px; align-items: center; text-decoration: none; padding: 14px; }
.site-pick + .site-pick { margin-top: 12px; }

/* plan preview on create */
.plan-preview .kv { font-size: 13.5px; padding: 9px 0; }
.estimate-big { font-size: 30px; font-weight: 700; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.sticky { position: sticky; top: 20px; }
.tpl-pick { display: grid; gap: 10px; }
.tpl { display: flex; gap: 12px; align-items: center; border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 14px; cursor: pointer; }
.tpl:has(input:checked) { border-color: var(--peach-strong); background: #fffaf6; }
.tpl input { accent-color: var(--peach-strong); }

/* kanban-ish stage strip */
.stage-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
@media (max-width: 1000px) { .stage-strip { grid-template-columns: repeat(2, 1fr); } }
.stage { border-radius: var(--radius); padding: 14px 16px; min-height: 84px; }
.stage:nth-child(5n+1) { background: linear-gradient(135deg, #eaf2fd, #dce9fb); } .stage:nth-child(5n+2) { background: linear-gradient(135deg, #f0ebfd, #e5dcfa); }
.stage:nth-child(5n+3) { background: linear-gradient(135deg, #fdecf4, #fadbe9); } .stage:nth-child(5n+4) { background: linear-gradient(135deg, #fff2e8, #ffe3d0); }
.stage:nth-child(5n+5) { background: linear-gradient(135deg, #e9f7ec, #daf0df); }
.stage-k { font-size: 12px; font-weight: 600; color: var(--ink-2); } .stage-v { font-size: 22px; font-weight: 700; margin-top: 6px; } .stage-h { font-size: 12px; color: var(--ink-2); }

/* login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(60% 80% at 85% 0%, rgba(196,168,245,0.35), rgba(196,168,245,0) 60%), radial-gradient(60% 80% at 20% 100%, rgba(255,170,120,0.35), rgba(255,170,120,0) 60%), var(--ground); }
.login-card { width: 100%; max-width: 400px; padding: 34px 32px; }
.login-card h1 { font-size: 22px; letter-spacing: -0.02em; margin: 22px 0 4px; }
.login-card p { color: var(--ink-3); margin: 0 0 22px; font-size: 14px; }
.login-card .field + .field { margin-top: 14px; }

.soon-page { text-align: center; padding: 80px 20px; }
.soon-page h1 { font-size: 24px; letter-spacing: -0.02em; margin: 18px 0 6px; }

@media (max-width: 900px) {
  .main { padding: 18px 16px 70px; }
  .sidebar { overflow-x: auto; gap: 4px; position: sticky; top: 0; z-index: 20; height: auto; }
  .side-nav { overflow: visible; }
  .side-item { white-space: nowrap; padding: 8px 10px; }
  .side-item .soon, .side-count, .logo-word { display: none; }
  .hero { flex-direction: column; align-items: flex-start; padding: 24px 22px; }
  .hero-meta { text-align: left; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: auto; }
  .proj-facts { margin-left: 0; gap: 18px; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
/* ---------- Insight tabs ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 24px; background: var(--surface); border-radius: 999px; padding: 5px; width: fit-content; box-shadow: var(--shadow); border: 1px solid rgba(23,23,28,0.04); }
.tab {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  background: none;
  border: none;
  padding: 9px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab.active { background: var(--peach); color: var(--peach-strong); font-weight: 600; }

.tab-panel { margin-bottom: 40px; }
.tabs { flex-wrap: wrap; }
.tabs-flat { background: none; box-shadow: none; border: none; padding: 0; margin-bottom: 14px; border-radius: 0; }
.tabs-flat .tab { padding: 7px 14px; font-size: 13px; }
.two-col > *, .with-rail > *, .three-col > * { min-width: 0; }
.chart-table td, .chart-table th { white-space: normal; }
.chart-table td.num, .chart-table th.right { white-space: nowrap; }
.count-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.count { padding: 14px 14px; gap: 10px; }
@media (max-width: 1000px) { .count-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card-flush td, .card-flush th { padding-left: 14px; padding-right: 14px; }
.pstep { min-width: 78px; }
.pname { font-size: 12px; }
.g-note.left { padding: 0 8px 0 0; }
.kv .v.num { white-space: nowrap; }
.kv .v { min-width: 0; overflow-wrap: anywhere; }
.money-grid { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }

.rail-300 { grid-template-columns: minmax(0, 1fr) 300px; }
.rail-360 { grid-template-columns: minmax(0, 1fr) 360px; }
.rail-400 { grid-template-columns: minmax(0, 1fr) 400px; }
@media (max-width: 1180px) { .with-rail, .rail-300, .rail-360, .rail-400 { grid-template-columns: minmax(0, 1fr); } .sticky { position: static; } }
.pstep { min-width: 70px; padding: 0 2px 8px; }
.pname { font-size: 11.5px; }
.pmeta { font-size: 11px; }
@media (max-width: 900px) { .alert-card { min-height: 0; padding-bottom: 0; } .alert-grid { grid-template-columns: 1fr; } }

/* Hidden visually, still read by screen readers (labels for compact filter fields) */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.inline-form input[type="search"], .inline-form select { font: inherit; font-size: 14px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); }

/* New project: show only the chosen customer option (D-056) */
.customer-choice .existing-customer { display: none; }
.customer-choice:has(#customer_choice_existing:checked) .existing-customer { display: block; }
.customer-choice:has(#customer_choice_existing:checked) .new-customer { display: none; }
.person-row { align-items: end; padding: 10px 0; border-top: 1px solid var(--line); }
.person-row .check { grid-column: 1 / -1; }
.inline-input { font: inherit; min-height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink-2); }

/* A summary that opens a small form (e.g. Reverse) looks like a button, without the browser's triangle. */
summary.btn { list-style: none; display: inline-flex; }
summary.btn::-webkit-details-marker { display: none; }

/* Bank loan details appear only once "Customer has a bank loan" is ticked. */
form:has(#project_bank_loan:not(:checked)) .bank-field { display: none; }

/* A field that failed: red border and label. ".field-error" comes from the server (field_errors.rb);
   ":user-invalid" is the browser's own check (e.g. an email without @) after the person has tried. */
.field .field-error:not(label), .field :user-invalid { border-color: var(--danger) !important; background: var(--danger-soft); }
.field label.field-error, .field:has(:user-invalid) > label { color: var(--danger); }
