:root {
  --navy: #1f3a5f; --navy-dark: #162b47; --blue: #1d6fd1; --blue-dark: #1558a8; --sky: #e8f1fb;
  --bg: #f3f5f8; --card: #ffffff; --line: #e2e6ec; --text: #1c2430; --muted: #6b7684;
  --good: #16a34a; --warn: #d97706; --bad: #dc2626;
  --t-advance: #0ea5e9; --t-on_time: #16a34a; --t-delayed: #dc2626; --t-adhoc: #7c3aed;
  --st-upcoming: #94a3b8; --st-due_soon: #f59e0b; --st-partial: #3b82f6; --st-overdue: #dc2626; --st-completed: #22c55e; --st-cancelled: #cbd5e1;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.45; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 2px; font-weight: 700; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 700; }
h2.mt { margin-top: 18px; }
p { margin: 0 0 8px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.good { color: var(--good); font-weight: 600; } .warn { color: var(--warn); font-weight: 600; } .bad { color: var(--bad); font-weight: 600; }

/* ---------------------------------------------------------- top bar */
.topbar { background: var(--navy); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.18); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1440px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 18px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 38px; width: auto; border-radius: 5px; background: #fff; padding: 2px; }
.brand-name { font-size: 20px; letter-spacing: .2px; }
.brand-name strong { color: #8ec5ff; }
.brand-version { font-size: 11px; background: rgba(255,255,255,.14); padding: 2px 7px; border-radius: 999px; }
.nav { display: flex; align-items: center; gap: 2px; margin-left: 10px; flex-wrap: wrap; }
.nav a { color: #dbe6f3; padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; color: #fff; }
.nav a.on { background: #fff; color: var(--navy); }
.dropdown { position: relative; }
.dropdown-menu { display: none; position: absolute; top: 100%; left: 0; background: #fff; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); min-width: 190px; padding: 6px; z-index: 60; }
.dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu a { display: block; color: var(--text); padding: 8px 10px; }
.dropdown-menu a:hover { background: var(--sky); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip { color: #fff; font-weight: 600; }
.user-chip small { color: #b9cbe0; font-weight: 400; }

/* ---------------------------------------------------------- layout */
.page { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 22px 20px 40px; }
.page.wide { max-width: 1440px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: 12px; color: var(--muted); margin: 0; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card.nopad { padding: 0; overflow: auto; }
.card.narrow { max-width: 560px; margin: 40px auto; }
.card.note { background: #fffbeb; border: 1px solid #fde68a; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 14px; }
.empty { color: var(--muted); padding: 14px 4px; margin: 0; }
.link { font-size: 13px; }
.links { white-space: nowrap; font-size: 13px; }
.stack > * + * { margin-top: 10px; }
.plain, .plain-list { margin: 0; padding-left: 18px; }
.plain-list li { margin: 4px 0; }
.error-list { color: var(--bad); font-size: 13px; }

/* ---------------------------------------------------------- flash */
.flash-wrap { margin-bottom: 14px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-weight: 500; }
.flash-success { background: #e7f8ee; color: #166534; border: 1px solid #bbe7cc; }
.flash-error { background: #fdecec; color: #991b1b; border: 1px solid #f5c2c2; }
.flash-info { background: var(--sky); color: var(--navy); border: 1px solid #c7dbf3; }

/* ---------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--blue); background: #fff; color: var(--blue); font-weight: 600; font-size: 14px; cursor: pointer; line-height: 1.2; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--sky); text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-outline { border-color: #c9d3e0; color: var(--text); }
.btn-outline:hover { background: #f1f4f8; }
.btn-outline-light { border-color: rgba(255,255,255,.5); background: transparent; color: #fff; }
.btn-outline-light:hover { background: rgba(255,255,255,.12); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-danger[disabled] { opacity: .45; cursor: not-allowed; }
.btn-link { border-color: transparent; background: transparent; color: var(--blue); }
.btn-link:hover { background: transparent; text-decoration: underline; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-xs { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; }
.btn.danger { color: var(--bad); border-color: #f1b5b5; }
button.btn-link { border: 0; background: none; color: var(--blue); cursor: pointer; font: inherit; padding: 0; }
button.btn-link.danger { color: var(--bad); }
form.inline { display: inline; }
form.mini { display: inline-flex; gap: 6px; align-items: center; }
form.mini.check label { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; }
form.mini input[type=text], form.mini input[type=password] { padding: 4px 8px; font-size: 13px; width: 160px; }
form.mini select { padding: 4px 6px; font-size: 13px; }

/* ---------------------------------------------------------- forms */
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
label.check.tall { padding-top: 22px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #c9d3e0; border-radius: 8px; background: #fff; color: var(--text); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd6f5; border-color: var(--blue); }
textarea { resize: vertical; }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; min-height: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row label { min-width: 120px; }
.form-row label.grow { flex: 1; min-width: 180px; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: span 1; } }
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar input, .filter-bar select { padding: 6px 9px; font-size: 13px; }
.filter-bar input[type=search] { width: 170px; }
.seg { display: inline-flex; border: 1px solid #c9d3e0; border-radius: 8px; overflow: hidden; background: #fff; }
.seg label { flex-direction: row; padding: 6px 11px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); border-right: 1px solid #e3e8ef; }
.seg label:last-child { border-right: 0; }
.seg label.on { background: var(--navy); color: #fff; }
.seg input { display: none; }
.chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.chip { flex-direction: row; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; border: 1px solid #c9d3e0; font-size: 12px; font-weight: 600; cursor: pointer; background: #fff; color: var(--muted); }
.chip input { display: none; }
.chip.on { color: #fff; border-color: transparent; }
.chip.st-upcoming.on { background: var(--st-upcoming); } .chip.st-due_soon.on { background: var(--st-due_soon); }
.chip.st-partial.on { background: var(--st-partial); } .chip.st-overdue.on { background: var(--st-overdue); }
.chip.st-completed.on { background: var(--st-completed); } .chip.st-adhoc.on { background: var(--t-adhoc); }

/* ---------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table td.date { white-space: nowrap; }
.table th { background: #f6f8fb; font-weight: 700; font-size: 12.5px; color: #3b4654; white-space: nowrap; position: sticky; top: 0; }
.table.compact th, .table.compact td { padding: 6px 8px; font-size: 13px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table.hover tbody tr:hover { background: #f8fafc; }
.table tr.inactive td { color: var(--muted); }
.table tr.row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--st-overdue); }
.table tr.row-due_soon td:first-child { box-shadow: inset 3px 0 0 var(--st-due_soon); }
.table tfoot td { background: #f6f8fb; font-weight: 600; }
.users-table td { vertical-align: middle; }
.inline-edit summary { cursor: pointer; color: var(--blue); font-size: 12px; list-style: none; }
.inline-edit summary::-webkit-details-marker { display: none; }
.inline-edit.right { display: inline-block; margin-right: 6px; }
.inline-edit form { margin-top: 6px; }

/* ---------------------------------------------------------- badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; }
.badge.big { font-size: 14px; padding: 4px 12px; align-self: flex-start; }
.badge.ok { background: #e7f8ee; color: #166534; } .badge.off { background: #eef0f3; color: var(--muted); }
.badge.role { background: #eef2f7; color: var(--navy); }
.badge.t-advance { background: var(--t-advance); } .badge.t-on_time { background: var(--t-on_time); }
.badge.t-delayed { background: var(--t-delayed); } .badge.t-adhoc { background: var(--t-adhoc); }
.badge.st-upcoming { background: var(--st-upcoming); } .badge.st-due_soon { background: var(--st-due_soon); }
.badge.st-partial { background: var(--st-partial); } .badge.st-overdue { background: var(--st-overdue); }
.badge.st-completed { background: var(--st-completed); } .badge.st-cancelled { background: var(--st-cancelled); color: #475569; }
.t-advance-text { color: var(--t-advance); font-weight: 600; } .t-delayed-text { color: var(--t-delayed); font-weight: 600; }
.prio { font-size: 12px; font-weight: 600; } .prio-high { color: var(--warn); } .prio-urgent { color: var(--bad); } .prio-normal { color: var(--muted); }
.toggle { border: 1px solid #c9d3e0; background: #f1f4f8; color: var(--muted); border-radius: 999px; padding: 3px 12px; font-weight: 700; font-size: 12px; cursor: pointer; }
.toggle.on { background: #e7f8ee; color: #166534; border-color: #bbe7cc; }
.toggle.static { cursor: default; }
.pill-muted { background: #eef0f3; color: var(--muted); border-radius: 999px; padding: 3px 12px; font-size: 12px; font-weight: 600; }

/* ---------------------------------------------------------- dashboard */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 12px; }
@media (max-width: 1000px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; color: var(--text); border-top: 4px solid var(--navy); }
.kpi:hover { text-decoration: none; box-shadow: 0 4px 14px rgba(16,24,40,.12); transform: translateY(-1px); }
.kpi-danger { border-top-color: var(--bad); } .kpi-warn { border-top-color: var(--warn); } .kpi-good { border-top-color: var(--good); }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.kpi-value { font-size: 30px; font-weight: 800; line-height: 1.1; }
.kpi-value small { font-size: 16px; font-weight: 700; }
.kpi-hint { font-size: 12px; color: var(--muted); }
.type-strip { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.type-chip { display: inline-flex; gap: 8px; align-items: center; padding: 7px 14px; border-radius: 999px; color: #fff; font-weight: 600; }
.type-chip b { font-size: 16px; }
.type-chip:hover { text-decoration: none; filter: brightness(1.08); }
.type-chip.t-advance { background: var(--t-advance); } .type-chip.t-on_time { background: var(--t-on_time); }
.type-chip.t-delayed { background: var(--t-delayed); } .type-chip.t-adhoc { background: var(--t-adhoc); }
.chart { width: 100%; min-height: 240px; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend .sep { width: 1px; height: 14px; background: var(--line); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: #999; }
.sw.line { width: 16px; height: 3px; background: var(--navy); border-radius: 2px; }
.sw.t-advance { background: var(--t-advance); } .sw.t-on_time { background: var(--t-on_time); } .sw.t-delayed { background: var(--t-delayed); } .sw.t-adhoc { background: var(--t-adhoc); }
.sw.st-upcoming { background: var(--st-upcoming); } .sw.st-due_soon { background: var(--st-due_soon); } .sw.st-partial { background: var(--st-partial); }
.sw.st-overdue { background: var(--st-overdue); } .sw.st-completed { background: var(--st-completed); }
.sw.today-sw { background: transparent; border-left: 2px dashed var(--bad); width: 2px; border-radius: 0; }
.mk { display: inline-block; width: 10px; height: 10px; transform: rotate(45deg); border-radius: 2px; }
.mk.t-advance { background: var(--t-advance); } .mk.t-on_time { background: var(--t-on_time); } .mk.t-delayed { background: var(--t-delayed); } .mk.t-adhoc { background: var(--t-adhoc); }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-value { font-size: 20px; font-weight: 700; }
.progress { height: 8px; background: #e9edf3; border-radius: 999px; overflow: hidden; margin: 4px 0; }
.progress-bar { height: 100%; background: var(--good); border-radius: 999px; }

/* ---------------------------------------------------------- delivery type cards */
.type-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
@media (max-width: 760px) { .type-cards { grid-template-columns: repeat(2, 1fr); } }
.type-card { border: 2px solid #dfe5ec; border-radius: 10px; padding: 12px 14px; cursor: pointer; gap: 2px; font-weight: 500; background: #fff; }
.type-card input { display: none; }
.type-card b { font-size: 15px; }
.type-card span { font-size: 12px; color: var(--muted); }
.type-card.on { color: #fff; }
.type-card.on span { color: rgba(255,255,255,.85); }
.type-card.t-advance.on { background: var(--t-advance); border-color: var(--t-advance); }
.type-card.t-on_time.on { background: var(--t-on_time); border-color: var(--t-on_time); }
.type-card.t-delayed.on { background: var(--t-delayed); border-color: var(--t-delayed); }
.type-card.t-adhoc.on { background: var(--t-adhoc); border-color: var(--t-adhoc); }
.hint.warn { color: var(--warn); font-weight: 600; }
.hint.good { color: var(--good); font-weight: 600; }

/* ---------------------------------------------------------- login */
.login-body { background: linear-gradient(160deg, var(--navy) 0%, #2a5b96 100%); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); padding: 34px 36px; width: 100%; max-width: 400px; text-align: center; }
.login-logo { height: 72px; margin-bottom: 8px; }
.login-card h1 { font-size: 26px; margin-bottom: 2px; }
.login-card h1 strong { color: var(--blue); }
.login-card form { text-align: left; margin-top: 18px; }

/* ---------------------------------------------------------- gantt */
.gantt-wrap { overflow: hidden; }
.gantt { position: relative; display: flex; min-height: 240px; max-height: 72vh; overflow: auto; font-size: 12.5px; }
.gantt-loading { padding: 30px; color: var(--muted); }
.gantt-left { position: sticky; left: 0; z-index: 3; background: #fff; border-right: 2px solid var(--line); flex: 0 0 320px; width: 320px; }
.gantt-right { position: relative; flex: 0 0 auto; }
.gantt-head { position: sticky; top: 0; z-index: 2; background: #fff; border-bottom: 1px solid var(--line); height: 48px; }
.gantt-left .gantt-head { z-index: 4; display: flex; align-items: flex-end; padding: 6px 10px; font-weight: 700; color: #3b4654; gap: 8px; }
.gantt-head .months, .gantt-head .units { position: relative; height: 24px; }
.gantt-head .months div, .gantt-head .units div { position: absolute; top: 0; height: 24px; line-height: 24px; border-left: 1px solid var(--line); padding-left: 6px; white-space: nowrap; overflow: hidden; font-size: 11.5px; color: var(--muted); }
.gantt-head .months div { font-weight: 700; color: #3b4654; }
.gantt-head .units div.weekend { background: #f6f8fb; }
.gantt-head .units div.today-unit { color: var(--bad); font-weight: 700; }
.g-group { background: #eef2f7; border-bottom: 1px solid var(--line); font-weight: 700; padding: 0 10px; display: flex; align-items: center; gap: 8px; height: 32px; }
.g-group .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-group .name small { font-weight: 500; color: var(--muted); }
.g-group .cnt { font-weight: 500; color: var(--muted); font-size: 12px; white-space: nowrap; }
.g-group a { color: var(--navy); }
.g-row { border-bottom: 1px solid var(--line); padding: 4px 10px 4px 18px; display: flex; flex-direction: column; justify-content: center; }
.g-row .pn { font-weight: 700; }
.g-row .desc { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-row .sub { color: var(--muted); font-size: 11.5px; }
.gantt-body { position: relative; }
.g-grid-row { position: relative; border-bottom: 1px solid var(--line); }
.g-grid-row.group { background: #eef2f7; }
.g-col { position: absolute; top: 0; bottom: 0; border-left: 1px solid #eef1f5; }
.g-col.weekend { background: #f8fafc; }
.g-col.month { border-left-color: #cfd6e0; }
.g-today { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed var(--bad); z-index: 1; pointer-events: none; }
.g-bar { position: absolute; height: 22px; border-radius: 6px; color: #fff; font-size: 11.5px; font-weight: 600; display: flex; align-items: center; padding: 0 6px; overflow: hidden; white-space: nowrap; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.2); background: var(--st-upcoming); text-decoration: none; }
.g-bar:hover { filter: brightness(1.08); text-decoration: none; color: #fff; z-index: 2; }
.g-bar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,255,255,.35); }
.g-bar .lbl { position: relative; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.g-bar.st-upcoming { background: var(--st-upcoming); } .g-bar.st-due_soon { background: var(--st-due_soon); }
.g-bar.st-partial { background: var(--st-partial); } .g-bar.st-overdue { background: var(--st-overdue); }
.g-bar.st-completed { background: var(--st-completed); } .g-bar.st-cancelled { background: var(--st-cancelled); color: #475569; }
.g-bar.prio-urgent { outline: 2px solid #7f1d1d; outline-offset: -2px; }
.g-mark { position: absolute; width: 11px; height: 11px; transform: translate(-50%, 0) rotate(45deg); border-radius: 2px; border: 1.5px solid #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); cursor: pointer; z-index: 2; }
.g-mark.t-advance { background: var(--t-advance); } .g-mark.t-on_time { background: var(--t-on_time); }
.g-mark.t-delayed { background: var(--t-delayed); } .g-mark.t-adhoc { background: var(--t-adhoc); }
.g-empty { padding: 40px; color: var(--muted); text-align: center; width: 100%; }
.gantt-legend { margin: 8px 2px 0; }
.gantt-tip { position: fixed; z-index: 100; background: #0f172a; color: #fff; padding: 10px 12px; border-radius: 8px; font-size: 12px; max-width: 320px; box-shadow: 0 8px 24px rgba(0,0,0,.3); pointer-events: none; line-height: 1.4; }
.gantt-tip b { color: #8ec5ff; }
.gantt-tip .row { display: flex; justify-content: space-between; gap: 14px; }
.gantt-tip .t-advance { color: #7dd3fc; } .gantt-tip .t-on_time { color: #86efac; } .gantt-tip .t-delayed { color: #fca5a5; } .gantt-tip .t-adhoc { color: #c4b5fd; }
