:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1d2430;
  --ink-2: #5a6474;
  --ink-3: #8a93a2;
  --line: #e1e4ea;
  --brand: #1f3a5f;
  --brand-2: #2c5282;
  --accent: #e07a1f;
  --ok: #2f855a;
  --warn: #b7791f;
  --bad: #c53030;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
small, .muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }

/* ---------- layout ---------- */
.topbar { background: var(--brand); color: #fff; display: flex; align-items: center; gap: 1rem; padding: .55rem 1.25rem; position: sticky; top: 0; z-index: 20; }
.topbar .logo { font-weight: 700; color: #fff; white-space: nowrap; display: flex; align-items: center; gap: .5rem; }
.topbar .logo span { color: var(--accent); }
.topbar nav { display: flex; gap: .15rem; flex-wrap: wrap; }
.topbar nav a { color: #cdd6e3; padding: .35rem .6rem; border-radius: 6px; font-size: .92rem; }
.topbar nav a:hover, .topbar nav a.on { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.topbar form.search { margin-left: auto; }
.topbar input[type=search] { border: 0; border-radius: 6px; padding: .4rem .65rem; width: 220px; background: rgba(255,255,255,.15); color: #fff; }
.topbar input[type=search]::placeholder { color: #aebbd0; }
.topbar .me { color: #cdd6e3; font-size: .9rem; white-space: nowrap; }
main { max-width: 1280px; margin: 0 auto; padding: 1.25rem; }
main.wide { max-width: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 1rem; align-items: start; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
@media (max-width: 900px) { .grid.side { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 1rem; }
.panel.flush { padding: 0; overflow: hidden; }
.panel .panel-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.panel .panel-head h2 { margin: 0; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--shadow); }
.stat .label { font-size: .8rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.45rem; font-weight: 700; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .82rem; color: var(--ink-2); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
.table-wrap { overflow-x: auto; }
tbody tr:hover { background: #fafbfd; }

/* ---------- forms ---------- */
label { display: block; font-size: .83rem; color: var(--ink-2); margin-bottom: .2rem; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid #cbd1da; border-radius: 7px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cb8dc; border-color: var(--brand-2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .35rem; }
.inline { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline > * { flex: 1 1 140px; }
.inline > .shrink { flex: 0 0 auto; }
.check { display: flex; align-items: center; gap: .4rem; font-weight: 400; color: var(--ink); }
details.quick { margin-top: .4rem; }
details.quick summary { cursor: pointer; font-size: .83rem; color: var(--brand-2); }
details.quick .form-grid { margin-top: .5rem; padding: .6rem; background: #f8f9fb; border-radius: 8px; }

.btn { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid #cbd1da; background: #fff; color: var(--ink); padding: .45rem .85rem; border-radius: 7px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f5f8; text-decoration: none; }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.primary:hover { background: var(--brand); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); border-color: #f1c0c0; }
.btn.small { padding: .2rem .55rem; font-size: .82rem; }
.btn.link { border: 0; background: none; color: var(--brand-2); padding: 0; font-weight: 500; }
form.inline-form { display: inline; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .76rem; font-weight: 600; background: #edf0f4; color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: #e3f4ea; color: var(--ok); }
.badge.warn { background: #fdf1dc; color: var(--warn); }
.badge.bad { background: #fde5e5; color: var(--bad); }
.badge.blue { background: #e3ecf8; color: var(--brand-2); }
.badge.orange { background: #fdebd9; color: #b35c0e; }

/* ---------- flash ---------- */
.flash { padding: .6rem .9rem; border-radius: 8px; margin-bottom: .8rem; background: #e3f4ea; color: #22543d; border: 1px solid #c6e6d3; }
.flash.error { background: #fde5e5; color: #822727; border-color: #f5c2c2; }

/* ---------- pipeline board ---------- */
.board { display: flex; gap: .8rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; min-height: 70vh; }
.col { flex: 1 0 215px; max-width: 320px; background: #e9ecf1; border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 170px); }
.col-head { padding: .6rem .75rem .4rem; border-bottom: 1px solid #d8dde5; }
.col-head .title { font-weight: 700; font-size: .9rem; }
.col-head .meta { font-size: .78rem; color: var(--ink-2); }
.cards { padding: .5rem; overflow-y: auto; flex: 1; min-height: 60px; }
.cards.drop { background: #dbe6f5; border-radius: 0 0 var(--radius) var(--radius); }
.card { position: relative; -webkit-touch-callout: none; -webkit-user-drag: none; user-select: none; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .55rem .65rem; margin-bottom: .5rem; box-shadow: var(--shadow); cursor: grab; display: block; color: var(--ink); }
.card:hover { text-decoration: none; border-color: #b8c4d6; }
.card.dragging { opacity: .45; }
.card .grip { position: absolute; top: .25rem; right: .3rem; padding: .25rem .4rem; font-size: 1.05rem; line-height: 1; color: var(--ink-3); touch-action: none; cursor: grab; border-radius: 6px; }
.card .grip:hover { background: #eef1f5; color: var(--ink-2); }
.grip-demo { font-weight: 700; }
@media (max-width: 760px) { .card .grip { padding: .45rem .6rem; font-size: 1.25rem; background: #f1f3f6; } }
.card .num { font-size: .74rem; color: var(--ink-3); font-weight: 600; }
.card .nm { font-weight: 650; font-size: .92rem; margin: .05rem 0 .15rem; }
.card .co { font-size: .82rem; color: var(--ink-2); }
.card .foot { display: flex; justify-content: space-between; gap: .4rem; margin-top: .35rem; font-size: .78rem; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid #cbd1da; border-radius: 8px; overflow: hidden; }
.seg a { padding: .35rem .8rem; color: var(--ink-2); font-weight: 600; font-size: .88rem; }
.seg a.on { background: var(--brand-2); color: #fff; }
.seg a:hover { text-decoration: none; }

/* ---------- stage bar on project ---------- */
.stagebar { display: flex; gap: 2px; margin: .6rem 0 1rem; overflow-x: auto; }
.stagebar form { flex: 1 0 auto; }
.stagebar button { width: 100%; border: 0; padding: .45rem .55rem; font: inherit; font-size: .75rem; font-weight: 600; background: #e5e9ef; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.stagebar form:first-child button { border-radius: 7px 0 0 7px; }
.stagebar form:last-child button { border-radius: 0 7px 7px 0; }
.stagebar button.done { background: #c9d8ec; color: var(--brand); }
.stagebar button.cur { background: var(--brand-2); color: #fff; }
.stagebar button:hover { filter: brightness(.96); }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .9rem; color: var(--ink-2); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--brand); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.facts dt { color: var(--ink-2); font-size: .85rem; }
dl.facts dd { margin: 0; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .55rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .6rem; }
.timeline li:last-child { border-bottom: 0; }
.timeline .k { flex: 0 0 74px; }
.timeline .b { flex: 1; min-width: 0; }
.timeline .txt { white-space: pre-wrap; }
.timeline .when { font-size: .78rem; color: var(--ink-3); }
.timeline li.task.done .b { text-decoration: line-through; color: var(--ink-3); }

/* ---------- files ---------- */
.dropzone { border: 2px dashed #b8c4d6; border-radius: var(--radius); padding: 1rem; text-align: center; background: #f8fafc; }
.dropzone.over { background: #e3ecf8; border-color: var(--brand-2); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.gallery figure { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.gallery img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: #eef1f5; }
.gallery figcaption { padding: .3rem .45rem; font-size: .76rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist td { font-size: .9rem; }

.empty { text-align: center; color: var(--ink-3); padding: 1.2rem; }
.progress { height: 8px; background: #e5e9ef; border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand-2); }
.progress > span.over { background: var(--bad); }

/* ---------- funnel ---------- */
.funnel-row { display: grid; grid-template-columns: 170px 1fr 90px; gap: .6rem; align-items: center; padding: .25rem 0; font-size: .88rem; }
.funnel-row .bar { height: 18px; background: #c9d8ec; border-radius: 4px; min-width: 2px; }

/* ---------- mobile ---------- */
.bottomnav { display: none; }
@media (max-width: 760px) {
  :root { font-size: 15.5px; }
  .topbar { padding: .5rem .8rem; }
  .topbar nav, .topbar .me { display: none; }
  .topbar form.search { flex: 1; }
  .topbar input[type=search] { width: 100%; }
  main { padding: .8rem .7rem 5.5rem; }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a { flex: 1; text-align: center; padding: .5rem 0 .45rem; font-size: .72rem; color: var(--ink-2); font-weight: 600; }
  .bottomnav a .i { display: block; font-size: 1.2rem; line-height: 1.2; }
  .bottomnav a.on { color: var(--brand-2); }
  .bottomnav a.plus .i { color: var(--accent); }
  .col { flex: 0 0 82vw; max-width: none; }
  .hide-sm { display: none; }
  .funnel-row { grid-template-columns: 120px 1fr 70px; }
}
