:root {
  --navy: #1f3864; --navy-2: #2a4a80; --accent: #2e75b6; --accent-soft: #e8f1fb;
  --bg: #f4f6fa; --card: #ffffff; --text: #1d2433; --muted: #667085; --line: #e4e8ef;
  --red: #c0392b; --red-soft: #fdecea; --amber: #b7791f; --amber-soft: #fff6e0;
  --green: #2f855a; --green-soft: #e6f6ec; --blue-soft: #eaf2fd;
  --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, Arial, sans-serif;
  font-size: 14px; color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 60px; text-align: center; color: var(--muted); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #dbe6f7; padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand small { display: block; font-weight: 400; color: #9fb6da; font-size: 11px; }
.logo { width: 32px; height: 32px; border-radius: 8px; background: #66c2ff22; display: grid; place-items: center; font-size: 18px; }
.nav-group { margin: 14px 8px 4px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #8ea6cc; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 7px; color: #dbe6f7; }
.nav a:hover { background: var(--navy-2); text-decoration: none; }
.nav a.active { background: #ffffff1f; color: #fff; font-weight: 600; }
.nav .ico { width: 20px; text-align: center; }
.main { min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 18px; margin: 0; }
.top-right { display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; }
.page { padding: 20px 24px 60px; max-width: 1500px; }
.page-desc { color: var(--muted); margin: -4px 0 16px; }
.who { text-align: right; line-height: 1.2; }
.who small { color: var(--muted); display: block; }

/* ---------- Common ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h2 { font-size: 15px; margin: 0 0 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.tile .lbl { color: var(--muted); font-size: 12px; }
.tile .val { font-size: 22px; font-weight: 700; margin-top: 4px; }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.ok > i { background: var(--green); } .bar.over > i { background: var(--red); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c7cfdb; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #28679f; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { position: relative; background: none; border: 0; font-size: 18px; cursor: pointer; padding: 6px; }
.badge-dot { position: absolute; top: 0; right: 0; background: var(--red); color: #fff; border-radius: 10px; font-size: 10px; padding: 1px 5px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.toolbar input[type=search], .toolbar select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); max-width: 220px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: var(--accent-soft); color: var(--navy); white-space: nowrap; }
.chip.red { background: var(--red-soft); color: var(--red); } .chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.green { background: var(--green-soft); color: var(--green); } .chip.grey { background: #eef0f4; color: var(--muted); }
.muted { color: var(--muted); }
.right { text-align: right; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); max-height: calc(100vh - 230px); }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.data th { position: sticky; top: 0; background: #f7f9fc; text-align: left; font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; z-index: 1; }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; max-width: 340px; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: #f8fbff; }
table.data tfoot td { position: sticky; bottom: 0; background: #f7f9fc; font-weight: 700; border-top: 1px solid var(--line); }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
table.plain { width: 100%; border-collapse: collapse; font-size: 13px; }
table.plain th, table.plain td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.plain th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.plain td.num, table.plain th.num { text-align: right; }

/* ---------- Insights ---------- */
.insight { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.insight:last-child { border-bottom: 0; }
.insight .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; }
.lvl-critical .dot { background: var(--red-soft); color: var(--red); } .lvl-warning .dot { background: var(--amber-soft); color: var(--amber); }
.lvl-info .dot { background: var(--blue-soft); color: var(--accent); } .lvl-good .dot { background: var(--green-soft); color: var(--green); }
.insight b { display: block; }
.insight .area { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Board ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #eef1f6; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.col h3 { font-size: 13px; margin: 0 0 8px; display: flex; justify-content: space-between; }
.tcard { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow); }
.tcard:hover { border-color: var(--accent); }
.tcard .t { font-weight: 600; margin-bottom: 6px; }
.tcard .meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); align-items: center; }
.tcard.overdue { border-left: 3px solid var(--red); }

/* ---------- Modal & forms ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--card); border-radius: 12px; width: 100%; max-width: 820px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; font-size: 16px; }
.modal .body { padding: 16px 18px; }
.modal footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal footer .left { margin-right: auto; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form .full { grid-column: 1 / -1; }
.form label { display: block; font-size: 12px; font-weight: 600; color: #475467; margin-bottom: 4px; }
.form label .req { color: var(--red); }
.form input, .form select, .form textarea { width: 100%; padding: 8px 10px; border: 1px solid #d0d7e2; border-radius: 8px; background: #fff; }
.form textarea { min-height: 80px; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid #2e75b633; border-color: var(--accent); }
.form [disabled] { background: #f4f6fa; color: #475467; }
.computed-box { background: #f7f9fc; border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; }
.err { color: var(--red); margin-top: 8px; }
.comments { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.comment { padding: 8px 10px; background: #f7f9fc; border-radius: 8px; margin-bottom: 6px; }
.comment small { color: var(--muted); }
.comment-form { display: flex; gap: 8px; margin-top: 8px; }
.comment-form textarea { flex: 1; min-height: 38px; padding: 8px; border: 1px solid #d0d7e2; border-radius: 8px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #1f3864, #2e75b6); padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login .form { grid-template-columns: 1fr; margin-top: 18px; }

/* ---------- Notifications ---------- */
.dropdown { position: absolute; right: 16px; top: 54px; width: 360px; max-height: 420px; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(0, 0, 0, .15); z-index: 30; }
.dropdown .n { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.dropdown .n.unread { background: #f3f8ff; }
.dropdown .n small { color: var(--muted); display: block; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 99; }
#toast div { background: #1d2433; color: #fff; padding: 10px 16px; border-radius: 8px; margin-top: 6px; box-shadow: var(--shadow); }
#toast div.error { background: var(--red); }
.temp-pw { font-family: monospace; font-size: 18px; background: #f7f9fc; padding: 10px; border-radius: 8px; border: 1px dashed var(--accent); user-select: all; }
.chart-box { position: relative; height: 260px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: -260px; width: 240px; z-index: 40; transition: left .2s; }
  .side.open { left: 0; }
  .menu-btn { display: inline-block; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  .page { padding: 16px; }
  .top { padding: 10px 16px; }
  .who { display: none; }
  .dropdown { width: calc(100vw - 32px); }
}
.tinput { width: 100%; max-width: 110px; padding: 6px 8px; border: 1px solid #d0d7e2; border-radius: 8px; }
