:root {
  --bg: #f4f6fa; --panel: #fff; --text: #1d2433; --muted: #637087; --border: #e3e8ef; --brand: #0f6cbd; --brand-2: #115ea3;
  --ok: #107c10; --warn: #c27c00; --bad: #c50f1f; --info: #0f6cbd; --side: #111a2e; --side-text: #c8d1e3; --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 600; } h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; } h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* Layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; }
.brand-logo { width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(135deg, #3aa0ff, #0f6cbd); display: grid; place-items: center; font-size: 14px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 8px 12px; border-radius: 7px; margin: 2px 0; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(58,160,255,.18); color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.nav-sep { border-top: 1px solid rgba(255,255,255,.08); margin: 10px 6px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar .search { flex: 1; max-width: 480px; }
.topbar .search input { width: 100%; }
.topbar .who { margin-left: auto; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.content { padding: 20px 24px 60px; max-width: 1500px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Grid & cards */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g-auto { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1100px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .layout { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.click { cursor: pointer; } .card.click:hover { border-color: #b8c7dc; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-head h2, .card-head h3 { margin: 0; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 24px; font-weight: 600; margin-top: 4px; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.bad .value { color: var(--bad); } .kpi.warn .value { color: var(--warn); } .kpi.ok .value { color: var(--ok); }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.empty { color: var(--muted); padding: 10px 0; font-style: italic; }
.pre { white-space: pre-wrap; word-break: break-word; }
.section { margin-top: 20px; }
.split { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.stack > * + * { margin-top: 8px; }

/* Controls */
.btn { border: 1px solid var(--border); background: #fff; padding: 7px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f6fb; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); } .btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); border-color: #f1c4c8; } .btn.danger:hover { background: #fdf1f2; }
.btn.sm { padding: 4px 9px; font-size: 12px; } .btn.ghost { border-color: transparent; background: transparent; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; } .seg button.on { background: var(--brand); color: #fff; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px; background: #fff; width: 100%; }
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid #9cc8f5; outline-offset: 0; border-color: var(--brand); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 140px; }
label.chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; } .tabs a:hover { text-decoration: none; color: var(--text); }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 8px; border-bottom: 1px solid #eef1f5; vertical-align: top; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #f7f9fc; }
.tbl tr.sub td:first-child { padding-left: 28px; }
.tbl-wrap { overflow-x: auto; }

/* Badges & progress */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #eef2f7; color: #3b4659; white-space: nowrap; }
.b-critical, .b-bad { background: #fde7e9; color: var(--bad); } .b-high, .b-warn { background: #fff4ce; color: #8a5a00; }
.b-medium, .b-info { background: #e5f1fb; color: var(--brand-2); } .b-low { background: #eef2f7; color: #4a5568; }
.b-ok { background: #dff6dd; color: var(--ok); } .b-est { background: #f3e8ff; color: #6b21a8; }
.progress { height: 8px; background: #edf1f6; border-radius: 99px; overflow: hidden; position: relative; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.progress.ok > span { background: var(--ok); } .progress.warn > span { background: var(--warn); } .progress.bad > span { background: var(--bad); }
.progress .marker { position: absolute; top: -3px; width: 2px; height: 14px; background: #6b21a8; }
.pbar { display: grid; grid-template-columns: 1fr 44px; gap: 8px; align-items: center; } .pbar .pct { font-size: 12px; color: var(--muted); text-align: right; }
.stacked { display: flex; height: 22px; border-radius: 6px; overflow: hidden; background: #edf1f6; }
.stacked > span { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid #eef1f5; display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.list li:last-child { border-bottom: 0; }
.list .main-col { min-width: 0; flex: 1; }
.list .t { font-weight: 500; }
.insight { display: flex; gap: 10px; padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; align-items: flex-start; }
.insight.critical { background: #fdf1f2; } .insight.warning { background: #fffaeb; } .insight.info { background: #f1f7fd; }
.insight .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.insight.critical .dot { background: var(--bad); } .insight.warning .dot { background: var(--warn); } .insight.info .dot { background: var(--info); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.col { background: #eef2f7; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.col.drop { outline: 2px dashed var(--brand); }
.col-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 8px; color: #3b4659; }
.kcard { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); }
.kcard .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.kcard.overdue { border-left: 3px solid var(--bad); }

/* Timeline */
.timeline { position: relative; overflow-x: auto; }
.tl-row { display: grid; grid-template-columns: 220px 1fr; align-items: center; border-bottom: 1px solid #eef1f5; min-height: 36px; }
.tl-name { padding: 6px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-track { position: relative; height: 36px; }
.tl-bar { position: absolute; top: 9px; height: 18px; border-radius: 5px; background: #9cc8f5; overflow: hidden; cursor: pointer; }
.tl-bar > span { display: block; height: 100%; background: var(--brand); }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); opacity: .6; }
.tl-month { position: absolute; top: 0; font-size: 11px; color: var(--muted); border-left: 1px solid var(--border); padding-left: 4px; height: 100%; }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal .dow { padding: 6px; font-weight: 600; color: var(--muted); font-size: 12px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #fafbfd; }
.cal .day { min-height: 104px; padding: 4px 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #fff; }
.cal .day.out { background: #fafbfd; color: #aab3c2; } .cal .day.today { background: #f1f7fd; }
.cal .num { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.ev { display: block; font-size: 11px; padding: 2px 5px; border-radius: 4px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #e5f1fb; color: var(--brand-2); }
.ev.Commitment { background: #fff4ce; color: #8a5a00; } .ev.Milestone { background: #dff6dd; color: var(--ok); } .ev.Exam, .ev.Renewal { background: #f3e8ff; color: #6b21a8; }
.ev.Meeting { background: #e8eaf6; color: #303f9f; } .ev.Project { background: #fde7e9; color: var(--bad); } .ev.Reminder { background: #eef2f7; color: #4a5568; }

/* Modal */
.modal-back { 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: #fff; border-radius: 12px; width: 100%; max-width: 760px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 1000px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px 18px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-foot { display: flex; justify-content: space-between; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form .full { grid-column: 1 / -1; }
.form label.f { display: block; font-size: 12px; font-weight: 600; color: #3b4659; margin-bottom: 4px; }
.form .req::after { content: " *"; color: var(--bad); }
.err { background: #fdf1f2; color: var(--bad); padding: 8px 10px; border-radius: 7px; margin-bottom: 10px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #1d2433; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 60; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0b1830, #12305c); }
.login .card { width: 360px; padding: 28px; }
.login h1 { margin-bottom: 4px; }

/* Markdown preview */
.md h1 { font-size: 20px; margin: 0 0 8px; } .md h2 { font-size: 16px; margin: 18px 0 8px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.md h3 { font-size: 14px; margin: 12px 0 6px; } .md table { border-collapse: collapse; width: 100%; margin: 6px 0; }
.md td, .md th { border: 1px solid var(--border); padding: 4px 8px; text-align: left; } .md ul { margin: 4px 0; padding-left: 20px; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .editor textarea { min-height: 520px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.donut-wrap { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: center; }
.donut-wrap > div { flex: 1; min-width: 210px; }
.donut-wrap .split { padding: 3px 0; }
@media print { .sidebar, .topbar, .actions, .btn { display: none !important; } .layout { display: block; } .card { box-shadow: none; break-inside: avoid; } }
