:root {
  --bg: #f4f5f2; --panel: #ffffff; --ink: #1b2422; --muted: #6b7672; --line: #e2e5df;
  --accent: #1f6f5c; --accent-ink: #ffffff; --accent-soft: #e4f1ec;
  --warn: #b4541a; --warn-soft: #fbeadd; --danger: #a8322d; --side: #18211f; --side-ink: #cfd8d4;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 30, 28, .06), 0 4px 16px rgba(20, 30, 28, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 22px; } h3 { font-size: 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; }
a { color: var(--accent); cursor: pointer; text-decoration: none; }

.logo-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--accent);
  box-shadow: inset 0 0 0 6px rgba(255,255,255,.18), inset 0 0 0 12px var(--accent), inset 0 0 0 14px rgba(255,255,255,.5); }
.logo-mark.small { width: 28px; height: 28px; border-radius: 8px; flex: none; }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px;
  padding: 9px 14px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c9cfc8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, .link:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
.link { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; opacity: .75; text-align: left; }
.link:hover { opacity: 1; text-decoration: underline; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 8px; }
textarea { min-height: 76px; resize: vertical; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 10px; }

.login { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 22px; margin-top: 16px; }
.login-card p { margin: 4px 0 20px; }
.login-card .btn { width: 100%; padding: 11px; }

#app { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.side { background: var(--side); color: var(--side-ink); padding: 20px 14px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; padding: 0 8px 18px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { color: var(--side-ink); padding: 9px 12px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
#nav a:hover { background: rgba(255,255,255,.06); }
#nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.badge { background: var(--warn); color: #fff; border-radius: 999px; font-size: 12px; padding: 1px 7px; }
.side-user { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.1); display: grid; gap: 4px; font-size: 14px; }
.side-user .muted { color: #8d9a95; }

main { padding: 24px 28px 48px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.panel h3 { margin-bottom: 12px; }
.grid { display: grid; gap: 12px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat b { display: block; font-size: 26px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat.warn b { color: var(--warn); }
.two { grid-template-columns: 1.2fr 1fr; align-items: start; }

.bar-row { display: grid; grid-template-columns: 130px 1fr 36px; gap: 10px; align-items: center; margin: 7px 0; font-size: 14px; }
.bar { height: 10px; border-radius: 6px; background: var(--accent-soft); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.bar-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.row { cursor: pointer; } tr.row:hover td { background: #fafbf9; }
.table-wrap { overflow-x: auto; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; white-space: nowrap; }
.chip.lost { background: #eeeeea; color: var(--muted); }
.chip.late { background: var(--warn-soft); color: var(--warn); }
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input, .filters select { margin: 0; width: auto; flex: 1 1 180px; }

.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: #eceee9; border-radius: var(--radius); padding: 10px; min-height: 140px; }
.col.over { outline: 2px dashed var(--accent); }
.col-head { display: flex; justify-content: space-between; font-weight: 600; font-size: 14px; padding: 2px 4px 10px; }
.card { background: var(--panel); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(20,30,28,.08); cursor: grab; }
.card:active { cursor: grabbing; }
.card b { display: block; font-weight: 600; font-size: 14px; }
.card .meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.card select { margin-top: 8px; padding: 5px 8px; font-size: 13px; display: none; }

.task { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: start; padding: 11px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task input[type=checkbox] { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 14px; font: inherit; cursor: pointer; }
.tabs button.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { padding-left: 20px; border-left: 1px solid var(--line); margin-left: 8px; }
.dep { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; font-weight: 600; }
.dep .link { font-weight: 400; }
.person { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0 6px 14px; font-size: 14px; }
.person.off { opacity: .5; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: 12.5px; }

.road { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.road .panel { margin: 0; }
.road ul { margin: 8px 0 0; padding-left: 18px; } .road li { margin: 4px 0; }
.tag { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.tag.next { color: var(--warn); } .tag.later { color: var(--muted); }

.modal { position: fixed; inset: 0; background: rgba(20, 28, 26, .5); display: grid; place-items: start center; padding: 5vh 14px; overflow-y: auto; z-index: 20; }
.modal-box { background: var(--panel); border-radius: 14px; width: 100%; max-width: 620px; padding: 24px; position: relative; }
.modal-close { position: absolute; right: 12px; top: 8px; border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: 90vw; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

@media (max-width: 860px) {
  #app { display: block; }
  .side { position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
  .side-brand, .side-user { display: none; }
  #nav { flex-direction: row; width: 100%; justify-content: space-between; }
  #nav a { flex: 1; justify-content: center; padding: 9px 2px; font-size: 12px; text-align: center; gap: 3px; }
  #nav a[data-view=roadmap] { display: none; }
  main { padding: 16px 14px 96px; }
  .two { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .card select { display: block; }
  .kanban { grid-auto-columns: 78vw; }
  .bar-row { grid-template-columns: 104px 1fr 30px; }
  .hide-mobile { display: none; }
  .mobile-only-links { display: flex !important; }
}
.mobile-only-links { display: none; gap: 16px; margin-top: 18px; font-size: 14px; }
@media (prefers-reduced-motion: no-preference) { .card, .btn, #nav a { transition: background .15s, border-color .15s, filter .15s; } }
