:root {
  --bg: #f4f5f7; --card: #fff; --border: #dfe1e6; --text: #172b4d; --muted: #6b778c;
  --primary: #0c66e4; --primary-d: #0055cc; --danger: #c9372c; --ok: #1f845a; --warn: #b65c02;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 8px; } h3 { font-size: 14px; margin: 12px 0 6px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { margin-left: auto; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* header */
header.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #0b2a5b; color: #fff; padding: 0 16px; min-height: 52px; position: sticky; top: 0; z-index: 10; }
header.top .btn, header.top .brand { white-space: nowrap; }
header.top .brand { font-weight: 700; font-size: 16px; }
header.top nav { display: flex; gap: 2px; }
header.top nav a { color: #cfe0ff; padding: 16px 12px; border-bottom: 3px solid transparent; }
header.top nav a.active, header.top nav a:hover { color: #fff; text-decoration: none; border-color: #4c9aff; }
header.top select { background: #163a75; color: #fff; border: 1px solid #2c5aa5; }
header.top .btn.ghost { color: #fff; border-color: #2c5aa5; background: transparent; }
main { padding: 16px; max-width: 1500px; margin: 0 auto; }

/* controls */
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #85b8ff; border-color: var(--primary); }
textarea { width: 100%; min-height: 90px; resize: vertical; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.field { margin-bottom: 10px; } .field input, .field select { width: 100%; }
.btn { border: 1px solid var(--border); background: #fff; border-radius: 4px; padding: 6px 12px; cursor: pointer; font: inherit; }
.btn:hover { background: #f1f2f4; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); } .btn.primary:hover { background: var(--primary-d); }
.btn.danger { color: var(--danger); } .btn.sm { padding: 2px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login-box { background: var(--card); padding: 28px; width: 360px; border-radius: 8px; box-shadow: 0 4px 20px rgba(9,30,66,.15); }
.login-box h1 { margin-bottom: 16px; }
.error { color: var(--danger); margin: 8px 0; }

/* cards / tables */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; margin-bottom: 14px; }
table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; background: #fafbfc; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f7f8f9; }

/* badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; background: #dfe1e6; }
.badge.todo { background: #dfe1e6; } .badge.in_progress { background: #cce0ff; color: #0055cc; }
.badge.in_review { background: #f5e6ff; color: #6e5dc6; } .badge.done { background: #dcfff1; color: var(--ok); }
.badge.planned { background: #dfe1e6; } .badge.active { background: #cce0ff; color: #0055cc; } .badge.completed { background: #dcfff1; color: var(--ok); }
.badge.admin { background: #ffd5d2; color: var(--danger); } .badge.leader { background: #fce8c8; color: var(--warn); } .badge.user { background: #dfe1e6; }
.badge.sent { background: #dcfff1; color: var(--ok); } .badge.failed { background: #ffd5d2; color: var(--danger); } .badge.logged { background: #fff3c4; } .badge.pending { background: #cce0ff; }
.prio { font-size: 11px; font-weight: 700; } .prio.highest, .prio.high { color: var(--danger); } .prio.medium { color: var(--warn); } .prio.low, .prio.lowest { color: var(--primary); }
.avatar { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #6554c0; color: #fff; font-size: 10px; font-weight: 700; }
.key { color: var(--muted); font-weight: 600; white-space: nowrap; }
.overdue { color: var(--danger); font-weight: 600; }

/* progress */
.progress { background: #dfe1e6; border-radius: 4px; height: 8px; overflow: hidden; min-width: 80px; }
.progress > div { background: var(--ok); height: 100%; }

/* board */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; align-items: start; }
.col { background: #ebecf0; border-radius: 6px; padding: 8px; min-height: 300px; }
.col.over { outline: 2px dashed var(--primary); }
.col h3 { margin: 2px 4px 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; }
.card { background: #fff; border-radius: 4px; padding: 8px 10px; margin-bottom: 8px; box-shadow: 0 1px 1px rgba(9,30,66,.25); cursor: grab; }
.card:hover { background: #f7f8f9; } .card.dragging { opacity: .4; }
.card .title { margin-bottom: 6px; } .card .meta { display: flex; gap: 8px; align-items: center; font-size: 12px; }

/* backlog */
.section { background: #ebecf0; border-radius: 6px; padding: 10px; margin-bottom: 14px; }
.section.over { outline: 2px dashed var(--primary); }
.section .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.trow { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--border); padding: 6px 10px; margin-bottom: 2px; cursor: grab; }
.trow:hover { background: #f7f8f9; } .trow .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.empty { color: var(--muted); padding: 14px; text-align: center; border: 1px dashed var(--border); border-radius: 4px; background: #fff; }

/* modal */
#modal-root .backdrop { position: fixed; inset: 0; background: rgba(9,30,66,.55); display: flex; justify-content: center; align-items: flex-start; overflow: auto; padding: 40px 12px; z-index: 50; }
.modal { background: #fff; border-radius: 8px; width: 100%; max-width: 520px; padding: 20px; box-shadow: 0 8px 30px rgba(9,30,66,.4); }
.modal.wide { max-width: 980px; }
.modal .mhead { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal .x { margin-left: auto; border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); }
.tgrid { display: grid; grid-template-columns: 1fr 280px; gap: 0 20px; }
.tcol { display: contents; }
.tmain { grid-column: 1; grid-row: 1; min-width: 0; }
.side { grid-column: 2; grid-row: 1; }
.tbottom { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
@media (max-width: 800px) { .tgrid { grid-template-columns: 1fr; } .tmain, .side, .tbottom { grid-column: 1; } .side { grid-row: 2; } .tbottom { grid-row: 3; } .board { grid-template-columns: 1fr 1fr; } }
.side .field { margin-bottom: 8px; }
.title-input { width: 100%; font-size: 18px; font-weight: 600; border-color: transparent; }
.title-input:hover { border-color: var(--border); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 14px 0 10px; }
.tabs button { border: 0; background: none; padding: 6px 12px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--primary); border-color: var(--primary); font-weight: 600; }
.entry { padding: 8px 0; border-bottom: 1px solid var(--border); } .entry .who { font-weight: 600; } .entry p { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; }
.pw { font: 16px Consolas, monospace; background: #f1f2f4; padding: 8px 12px; border-radius: 4px; user-select: all; display: inline-block; margin: 6px 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 10px 0; }
.stat { background: #f4f5f7; border-radius: 6px; padding: 10px; } .stat b { font-size: 20px; display: block; }
.desc { white-space: pre-wrap; word-break: break-word; padding: 8px; border: 1px solid transparent; border-radius: 4px; min-height: 40px; cursor: text; }
.desc:hover { border-color: var(--border); }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; }
#toast div { background: #172b4d; color: #fff; padding: 10px 16px; border-radius: 4px; margin-top: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
#toast div.err { background: var(--danger); }
