:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1a1f2b;
  --muted: #5d6677;
  --line: #e3e6ec;
  --accent: #635bff;
  --accent-ink: #ffffff;
  --accent-soft: #eeedff;
  --ok: #1a7f4b;
  --ok-soft: #e6f4ec;
  --warn: #9a6200;
  --warn-soft: #fdf3e1;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 0.75rem; }
.boot { padding: 4rem; text-align: center; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #12162a; color: #c9cde0; padding: 1.25rem 0.75rem; display: flex; flex-direction: column; gap: 2px; }
.brand { color: #fff; font-weight: 700; padding: 0 0.6rem 1rem; font-size: 1.05rem; }
.side a { color: #c9cde0; text-decoration: none; padding: 0.55rem 0.7rem; border-radius: 8px; display: block; }
.side a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.side a.active { background: rgba(99, 91, 255, 0.25); color: #fff; }
.side .section { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: #7c82a0; padding: 1rem 0.7rem 0.3rem; }
.side .who { margin-top: auto; padding: 0.8rem 0.7rem 0; border-top: 1px solid rgba(255, 255, 255, 0.08); font-size: 0.85rem; }
.side .who button { margin-top: 0.5rem; }
main { padding: 1.75rem 2rem 4rem; max-width: 1200px; width: 100%; }
.topbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; position: fixed; inset: 0; z-index: 20; overflow: auto; }
  .side.open { display: flex; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: #12162a; color: #fff; padding: 0.7rem 1rem; }
  main { padding: 1.25rem 1rem 4rem; }
}

/* panels & grids */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1.1rem; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > .grow-2 { flex: 2 1 260px; }
.row > .shrink { flex: 0 0 auto; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.right { text-align: right; }
.stack > * + * { margin-top: 0.75rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 1.1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 1rem; }
.stat .v { font-size: 1.4rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 0.8rem; color: var(--muted); }

/* forms */
label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.25rem; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit; padding: 0.5rem 0.6rem; border: 1px solid #cfd4dd; border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type="checkbox"] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
.check { display: flex; align-items: center; gap: 0.45rem; color: var(--ink); font-size: 0.92rem; margin: 0; }
button, .btn {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 0.5rem 0.9rem; border: 1px solid #cfd4dd; background: #fff; color: var(--ink);
  text-decoration: none; display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap;
}
button:hover, .btn:hover { background: #f2f3f6; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(0.95); }
button.danger { color: var(--bad); border-color: #f1c0bb; }
button.link { border: none; background: none; color: var(--accent); padding: 0.2rem 0.3rem; }
button.ghost { background: transparent; border-color: rgba(255, 255, 255, 0.2); color: inherit; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.btns { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.5rem 0.55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.sub td { background: #fafbfc; }
tfoot td { font-weight: 650; border-bottom: none; }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); }

/* badges */
.badge { display: inline-block; font-size: 0.75rem; padding: 0.12rem 0.5rem; border-radius: 999px; background: #eef0f4; color: var(--muted); font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* timer */
.timer { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.clock { font-size: 2rem; font-weight: 650; font-variant-numeric: tabular-nums; min-width: 8ch; }
.timer.running .clock { color: var(--accent); }

.notice { border-radius: 8px; padding: 0.7rem 0.9rem; margin-bottom: 1rem; font-size: 0.92rem; }
.notice.warn { background: var(--warn-soft); color: #6b4500; }
.notice.info { background: var(--accent-soft); color: #3a33a8; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }

/* auth */
.auth { max-width: 400px; margin: 8vh auto; }
.auth .panel { padding: 1.6rem; }
.auth h1 { text-align: center; }

/* dialog */
dialog { border: none; border-radius: 12px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); }
dialog::backdrop { background: rgba(18, 22, 42, 0.45); }
#modal-form { padding: 1.3rem 1.4rem; }
#modal-form .actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.2rem; }

#toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: #12162a; color: #fff; padding: 0.65rem 1rem; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity 0.2s; max-width: 90vw; z-index: 50; }
#toast.show { opacity: 1; }
#toast.err { background: var(--bad); }

.client-block { border-top: 1px solid var(--line); padding: 0.9rem 0; }
.client-block:first-child { border-top: none; padding-top: 0; }
.proj { margin: 0.5rem 0 0 1rem; padding-left: 0.9rem; border-left: 2px solid var(--line); }
.task { margin-left: 1rem; font-size: 0.9rem; }
.archived { opacity: 0.55; }
code { background: #f0f1f4; padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.88em; }
