:root {
  --bg: #f4f6f9; --panel: #fff; --text: #1b2330; --muted: #677284; --line: #e1e5eb;
  --accent: #1e4fa3; --accent-soft: #e9f0fb; --danger: #c0262d; --danger-soft: #fdecec;
  --warn: #b45309; --warn-soft: #fff4e0; --ok: #15803d; --ok-soft: #e7f6ec;
  --radius: 10px; font-size: 15px;
}
html { color-scheme: light; }
* { box-sizing: border-box; }
body { margin: 0; font-family: "IBM Plex Sans Condensed", "Arial Narrow", system-ui, sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.center { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 400px; }
.card h1 { margin: 0 0 4px; font-size: 22px; }
.card p { margin: 0 0 16px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid #d3d8e0; border-radius: 8px; background: #fff; }
input[type=checkbox] { width: auto; min-height: 0; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c4cbd6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.icon { padding: 4px 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 10px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Каркас */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #15233d; color: #dbe3f0; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 18px; padding: 4px 10px 16px; color: #fff; }
.brand span { color: #7fb0ff; }
.side a { color: inherit; text-decoration: none; padding: 9px 10px; border-radius: 8px; display: block; }
.side a:hover { background: rgba(255,255,255,.07); }
.side a.on { background: rgba(127,176,255,.18); color: #fff; }
.side .grow { flex: 1; }
.side .who { font-size: 13px; padding: 8px 10px; color: #9fb0c8; }
.side .who b { color: #fff; display: block; font-weight: 600; }
.side button.link { background: none; border: 0; color: #9fb0c8; padding: 6px 10px; text-align: left; cursor: pointer; }
.side button.link:hover { color: #fff; }
.layout > div { min-width: 0; }
.main { padding: 22px 24px; min-width: 0; }
.head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.head h2 { margin: 0; font-size: 22px; flex: 1; min-width: 200px; }
.head select, .head input { width: auto; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { text-decoration: none; }

.timerbar { background: var(--ok-soft); border: 1px solid #bfe3cb; border-radius: var(--radius); padding: 10px 14px; display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.timerbar .t { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ok); }
.timerbar .grow { flex: 1; min-width: 160px; }

/* Таблиці */
.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f8f9fb; }
td.wrap { white-space: normal; min-width: 200px; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--accent-soft); }
tr.total td { font-weight: 600; background: #f8f9fb; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* Плитки і прогрес */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 20px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.bad .v { color: var(--danger); }
.prog { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.prog .bar { flex: 1; height: 8px; background: #e6eaf0; border-radius: 4px; overflow: hidden; }
.prog .bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.prog.done .bar i { background: var(--ok); }
.prog span { font-size: 12px; color: var(--muted); width: 34px; text-align: right; }
.over { color: var(--danger); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #eef1f5; color: var(--muted); }
.pill.active, .pill.in_progress { background: var(--accent-soft); color: var(--accent); }
.pill.done { background: var(--ok-soft); color: var(--ok); }
.pill.paused, .pill.waiting { background: var(--warn-soft); color: var(--warn); }
.pill.cancelled { background: var(--danger-soft); color: var(--danger); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* Канбан */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select { width: auto; min-width: 160px; }
.board { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #e9edf3; border-radius: var(--radius); padding: 8px; min-height: 200px; display: flex; flex-direction: column; gap: 8px; }
.col.drop { outline: 2px dashed var(--accent); }
.col h4 { margin: 2px 4px 4px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.col h4 .n { color: var(--muted); font-weight: 500; }
.tcard { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; cursor: pointer; font-size: 14px; }
.tcard:hover { border-color: #b9c3d2; }
.tcard.dragging { opacity: .4; }
.tcard .ti { font-weight: 600; margin-bottom: 5px; line-height: 1.3; }
.tcard .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 12px; color: var(--muted); }
.tcard .stage { font-size: 11px; color: var(--accent); margin-bottom: 3px; }
.tcard.p4 { border-left: 3px solid var(--danger); }
.tcard.p3 { border-left: 3px solid var(--warn); }
.tcard.overdue { background: var(--danger-soft); }
.addcard { background: none; border: 1px dashed #b9c3d2; border-radius: 8px; padding: 6px; color: var(--muted); cursor: pointer; }

/* Вікно */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto; z-index: 20; }
.modal.hidden { display: none; }
.dlg { background: var(--panel); border-radius: 12px; width: 100%; max-width: 640px; padding: 20px 22px; }
.dlg.wide { max-width: 860px; }
.dlg h3 { margin: 0 0 6px; font-size: 19px; }
.dlg .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.dlg .actions .left { margin-right: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.sec { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.sec h4 { margin: 0 0 8px; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.sec h4 .grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { min-width: 0; }
.list { display: flex; flex-direction: column; gap: 4px; }
.li { display: flex; gap: 8px; align-items: center; padding: 5px 0; font-size: 14px; }
.li .grow { flex: 1; min-width: 0; }
.li.done .grow { text-decoration: line-through; color: var(--muted); }
.comment { background: #f6f8fb; border-radius: 8px; padding: 8px 10px; font-size: 14px; white-space: pre-wrap; }
.comment .by { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; margin-top: 8px; }
.kv div:nth-child(odd) { color: var(--muted); }
.desc { white-space: pre-wrap; font-size: 14px; margin-top: 10px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label { display: flex; gap: 6px; align-items: center; color: var(--text); font-size: 14px; margin: 4px 0; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1b2330; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 30; font-size: 14px; max-width: 90vw; }
.toast.hidden { display: none; }

.mobnav { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: none; }
  .mobnav { display: flex; gap: 2px; background: #15233d; padding: 6px; position: sticky; top: 0; z-index: 10; overflow-x: auto; }
  .mobnav a { color: #dbe3f0; text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: 14px; white-space: nowrap; }
  .mobnav a.on { background: rgba(127,176,255,.18); color: #fff; }
  .main { padding: 14px 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(6, 78vw); }
  .kv { grid-template-columns: 110px 1fr; }
}
.grouph { margin: 18px 0 8px; font-size: 15px; }
tr.subrow td { background: #fbfcfe; }
tr.subrow td:nth-child(2) { padding-left: 28px; }
.pbtns { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
/* Технічний стиль: моноширинний шрифт для заголовків, цифр і кодів */
h1, h2, h3, h4, .brand, .tile .v, .num, .tile .k, th, .pill, .crumbs, .timerbar .t, .tabs button { font-family: "IBM Plex Mono", ui-monospace, monospace; }
h2, h3, .brand { letter-spacing: -0.01em; }
th, .tile .k { text-transform: uppercase; letter-spacing: .04em; font-size: 11px; }

/* ===== Технічний стиль елементів (як на кресленні) ===== */
:root { --radius: 3px; --line: #cfd6e0; --ink: #1b2330; }
body { background: var(--bg) linear-gradient(transparent 23px, rgba(30,79,163,.045) 24px), var(--bg); background-size: 100% 24px; }
.card, .tablewrap, .tile, .dlg, .col, .tcard, .timerbar { border-radius: var(--radius); }
.dlg { border: 1px solid var(--ink); box-shadow: 6px 6px 0 rgba(27,35,48,.18); }
.tile { border-color: var(--line); border-left: 3px solid var(--accent); }
.tile.bad { border-left-color: var(--danger); }

input, select, textarea {
  border-radius: 2px; border: 1px solid #aeb8c6; background: #fff; min-height: 38px;
  font-family: "IBM Plex Sans Condensed", sans-serif; font-size: 15px;
  transition: border-color .12s, box-shadow .12s;
}
input:hover, select:hover, textarea:hover { border-color: #7d8aa0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(30,79,163,.18); }
input[type=date], input[inputmode=decimal], input[inputmode=numeric] { font-family: "IBM Plex Mono", monospace; font-size: 14px; }
input::placeholder, textarea::placeholder { color: #9aa5b5; }
select {
  -webkit-appearance: none; appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%231b2330' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
select:disabled, input:disabled { background-color: #f1f3f6; color: var(--muted); cursor: default; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
input[type=file] { padding: 5px; font-size: 13px; }
input[type=file]::file-selector-button {
  font-family: "IBM Plex Mono", monospace; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  border: 1px solid var(--ink); background: #fff; padding: 5px 10px; margin-right: 10px; border-radius: 2px; cursor: pointer;
}
label { font-family: "IBM Plex Mono", monospace; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #5b6678; }
.checks label, label[style*="display:flex"] { font-family: "IBM Plex Sans Condensed", sans-serif; text-transform: none; letter-spacing: 0; font-size: 14px; }

.btn, .addcard, .tabs button, .side button.link {
  font-family: "IBM Plex Mono", monospace; font-size: 12.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em;
}
.btn { border-radius: 2px; border: 1px solid var(--ink); background: #fff; color: var(--ink); padding: 8px 14px; min-height: 36px;
  transition: background .12s, color .12s, transform .05s; }
.btn:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #163c7d; border-color: #163c7d; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { background: #0f6430; border-color: #0f6430; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.small { font-size: 11px; padding: 4px 9px; min-height: 28px; }
.btn.icon { padding: 3px 8px; }
.btn:disabled:hover { background: #fff; color: var(--ink); }
.addcard { border-radius: 2px; border: 1px dashed #8b97aa; font-size: 11px; }
.addcard:hover { border-style: solid; color: var(--accent); border-color: var(--accent); background: #fff; }

.pill { border-radius: 2px; border: 1px solid currentColor; background: transparent !important; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; }
.prog .bar { height: 6px; border-radius: 0; background: #e1e6ee; border: 1px solid #c7cfdb; }
.prog .bar i { border-radius: 0; }
.prog span { font-family: "IBM Plex Mono", monospace; }
.col { background: #e6ebf2; border: 1px solid #d3dae5; }
.col h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid #c7cfdb; padding-bottom: 6px; }
.tcard { border-color: #c7cfdb; }
.tcard:hover { border-color: var(--ink); }
.tcard .stage { font-family: "IBM Plex Mono", monospace; text-transform: uppercase; letter-spacing: .03em; font-size: 10px; }
.tabs { border-bottom: 1px solid var(--ink); }
.tabs button { font-size: 12px; border-bottom-width: 3px; }
.tabs button.on { color: var(--accent); }
.side { background: #111c31; }
.side a { border-radius: 2px; font-family: "IBM Plex Mono", monospace; font-size: 13px; }
.side a.on { box-shadow: inset 3px 0 0 #7fb0ff; }
.comment { border-radius: 2px; border-left: 3px solid #c7cfdb; }
.toast { border-radius: 2px; font-family: "IBM Plex Mono", monospace; font-size: 13px; }
table th { border-bottom: 1px solid #aeb8c6; }

/* Власні випадні списки */
.dd { position: relative; display: inline-block; width: 100%; min-width: 0; vertical-align: middle; }
.head .dd, .filters .dd, .row .dd { width: auto; min-width: 170px; }
.dd-native { position: absolute !important; opacity: 0; pointer-events: none; width: 1px !important; height: 1px; min-height: 0 !important; padding: 0 !important; border: 0 !important; left: 0; bottom: 0; }
.dd-btn {
  width: 100%; min-height: 38px; padding: 8px 34px 8px 11px; text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: "IBM Plex Sans Condensed", sans-serif; font-size: 15px; color: var(--ink);
  border: 1px solid #aeb8c6; border-radius: 2px; background: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%231b2330' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; transition: border-color .12s, box-shadow .12s;
}
.dd-btn:hover { border-color: #7d8aa0; }
.dd-btn:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(30,79,163,.18); }
.dd.open .dd-btn { border-color: var(--ink); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 6.5l5-5 5 5' fill='none' stroke='%231b2330' stroke-width='1.5'/%3E%3C/svg%3E"); }
.dd.disabled .dd-btn { background-color: #f1f3f6; color: var(--muted); cursor: default; }
.dd-menu {
  position: fixed; z-index: 50; max-height: 320px; overflow-y: auto; background: #fff;
  border: 1px solid var(--ink); border-radius: 2px; box-shadow: 4px 4px 0 rgba(27,35,48,.16); padding: 3px 0; max-width: 92vw;
}
.dd-item { padding: 7px 12px; cursor: pointer; font-size: 14.5px; white-space: nowrap; border-left: 3px solid transparent; }
.dd-item:hover, .dd-item.hi { background: var(--accent-soft); }
.dd-item.on { border-left-color: var(--accent); font-weight: 600; color: var(--accent); }
.dd-item.sub { color: #3d4757; }
.dd-item.off { color: #a3acba; cursor: default; }
