:root {
  --bg: #f4f6fb; --panel: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #0ea5e9; --brand-dark: #0284c7; --ok: #16a34a; --warn: #f59e0b; --bad: #ef4444;
  --side: #0f172a; --side-text: #cbd5e1; --radius: 12px; --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; }
a { color: var(--brand-dark); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 12px; font-weight: 650; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.ok { color: var(--ok); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.right { text-align: right; } .nowrap { white-space: nowrap; } .center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.hide-mobile { } .show-mobile { display: none; }

/* --- layout --- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); padding: 18px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; padding: 4px 8px 16px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--side-text); }
.nav a.active, .nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav .ico { width: 20px; text-align: center; font-size: 15px; }
.sidebar .spacer { flex: 1; }
.project-select { width: 100%; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); color: #fff; border-radius: 9px; padding: 8px; margin-bottom: 8px; }
.main { padding: 20px 24px 40px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }

/* --- controls --- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: #fff; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.input, select.input, textarea.input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; outline: none; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,165,233,.15); }
textarea.input { min-height: 70px; resize: vertical; }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 13px; }
.chip.active { background: var(--text); color: #fff; border-color: var(--text); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: none; padding: 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #e2e8f0; color: #334155; }
.badge.ok { background: #dcfce7; color: #166534; } .badge.bad { background: #fee2e2; color: #991b1b; } .badge.warn { background: #fef3c7; color: #92400e; } .badge.info { background: #e0f2fe; color: #075985; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

/* --- cards & tables --- */
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.kpi .label { color: var(--muted); font-size: 12px; } .kpi .value { font-size: 22px; font-weight: 700; margin: 4px 0 2px; } .kpi .delta { font-size: 12px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; position: sticky; top: 0; background: var(--panel); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; } tr.clickable:hover { background: #f8fafc; }
tr.total td { font-weight: 700; background: #f8fafc; }
.tree-toggle { display: inline-block; width: 18px; color: var(--muted); cursor: pointer; user-select: none; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
pre.code { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 9px; overflow-x: auto; font-size: 12px; white-space: pre-wrap; word-break: break-all; }

/* --- kanban --- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kcol { min-width: 260px; width: 260px; background: #eef2f7; border-radius: var(--radius); padding: 10px; flex-shrink: 0; }
.kcol h3 { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 8px; }
.kcard { background: #fff; border-radius: 10px; padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; border-left: 3px solid var(--line); }
.kcard .t { font-weight: 600; margin-bottom: 4px; } .kcard .s { font-size: 12px; color: var(--muted); }
.kcol.over { outline: 2px dashed var(--brand); }

/* --- modal / drawer --- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; display: flex; justify-content: flex-end; }
.modal { background: #fff; width: min(680px, 100%); height: 100%; overflow-y: auto; padding: 20px; box-shadow: -8px 0 30px rgba(0,0,0,.2); }
.modal.center-box { height: auto; max-height: 92vh; margin: auto; border-radius: var(--radius); width: min(560px, 94%); }
.modal-bg.centered { justify-content: center; align-items: center; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.history { border-left: 2px solid var(--line); padding-left: 12px; }
.history .h { margin-bottom: 10px; } .history .h .m { font-size: 12px; color: var(--muted); }

/* --- календарь мастера --- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-h { font-size: 11px; color: var(--muted); text-align: center; padding: 4px 0; }
.cal-d { min-height: 56px; border-radius: 8px; background: #f8fafc; padding: 4px 6px; cursor: pointer; border: 1px solid transparent; }
.cal-d.empty { background: transparent; cursor: default; }
.cal-d.today { border-color: var(--brand); }
.cal-d.sel { background: #e0f2fe; }
.cal-d.has .n { font-weight: 700; }
.cal-d .n { font-size: 13px; }
.marks { display: flex; gap: 3px; margin-top: 4px; flex-wrap: wrap; align-items: center; }
.mark { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.mark.planned { background: var(--warn); } .mark.done { background: var(--ok); } .mark.open { background: var(--brand); }

/* --- toast --- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow); max-width: 90vw; }
.toast.bad { background: var(--bad); }

/* --- auth --- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #0f172a, #1e3a8a 70%, #0ea5e9); }
.auth .card { width: min(420px, 100%); padding: 26px; }
.auth .logo { text-align: center; margin-bottom: 14px; } .auth .logo img { width: 56px; }

/* --- bottom nav (mobile) --- */
.bottom-nav { display: none; }
.sheet { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 60; display: flex; align-items: flex-end; }
.sheet .box { background: #fff; width: 100%; border-radius: 16px 16px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); }
.sheet .box a { display: flex; gap: 10px; align-items: center; padding: 12px 8px; border-bottom: 1px solid var(--line); color: var(--text); }
.chart-box { position: relative; height: 260px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 14px 12px calc(76px + env(safe-area-inset-bottom)); }
  .hide-mobile { display: none !important; } .show-mobile { display: initial; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi .value { font-size: 18px; }
  .modal { width: 100%; padding: 14px; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); z-index: 40; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; font-size: 11px; color: var(--muted); }
  .bottom-nav a.active { color: var(--brand-dark); }
  .bottom-nav .ico { font-size: 18px; }
  .kcol { min-width: 82vw; width: 82vw; }
  h1 { font-size: 19px; }
  .chart-box { height: 200px; }
}
