:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1a2230;
  --muted: #6b7688;
  --line: #e5e9f0;
  --blue: #2450d8;
  --blue-dark: #1c3fac;
  --green: #16855a;
  --green-bg: #e6f5ee;
  --amber: #9a6a12;
  --amber-bg: #fdf2dd;
  --red: #c23b3b;
  --shadow: 0 1px 3px rgba(20,30,60,.08), 0 6px 20px rgba(20,30,60,.05);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
a { color: var(--blue); }

/* header */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar .brand { font-weight: 700; font-size: 17px; letter-spacing: -.2px; }
.topbar .brand span { color: var(--blue); }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 14px; }

.wrap { max-width: 860px; margin: 0 auto; padding: 22px 18px 60px; }
.auth-wrap { max-width: 400px; margin: 8vh auto; padding: 0 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card .sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

h1.page { font-size: 22px; margin: 0 0 4px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
textarea { resize: vertical; min-height: 42px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--blue); color: #fff; border: none; border-radius: 8px;
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--blue-dark); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--blue); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f0f3fb; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.danger { background: transparent; color: var(--red); border: 1px solid #f0d4d4; }
.btn.danger:hover { background: #fbeeee; }
.btn:disabled { opacity: .5; cursor: default; }

.grid { display: grid; gap: 12px; }
.grid.form-row { grid-template-columns: 130px 90px 1fr; align-items: end; }
.grid.form-row .full { grid-column: 1 / -1; }
@media (max-width: 620px) { .grid.form-row { grid-template-columns: 1fr 1fr; } .grid.form-row .full { grid-column: 1 / -1; } }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions button { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 13px; padding: 2px 6px; }
.row-actions button:hover { color: var(--blue); }
.row-actions button.del:hover { color: var(--red); }

.weektabs { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.weektabs .label { font-weight: 600; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.pill.ok { background: var(--green-bg); color: var(--green); }
.pill.pending { background: var(--amber-bg); color: var(--amber); }

.totals { display: flex; gap: 26px; flex-wrap: wrap; align-items: baseline; margin-top: 10px; }
.totals .big { font-size: 26px; font-weight: 700; }
.totals .lbl { color: var(--muted); font-size: 13px; }

.msg { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin: 10px 0; display: none; }
.msg.err { background: #fbeaea; color: var(--red); display: block; }
.msg.ok { background: var(--green-bg); color: var(--green); display: block; }

.empty { color: var(--muted); font-size: 14px; padding: 18px 4px; text-align: center; }

/* modal (custom confirm, no native popups) */
.overlay { position: fixed; inset: 0; background: rgba(20,28,48,.4); display: none; align-items: center; justify-content: center; z-index: 50; }
.overlay.show { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 22px; max-width: 360px; width: calc(100% - 40px); box-shadow: var(--shadow); }
.modal p { margin: 0 0 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1a2230; color: #fff; padding: 11px 18px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s; z-index: 60; }
.toast.show { opacity: 1; }

.icon { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

/* sticky header + live clock */
.topbar { position: sticky; top: 0; z-index: 20; }
.clock { font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; background: #eef2fb; border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; white-space: nowrap; }
@media (max-width: 560px) { .clock { font-size: 11px; padding: 4px 7px; } .topbar .brand { font-size: 15px; } }

/* two-column dashboard layout */
.layout { display: flex; gap: 18px; align-items: flex-start; }
.layout .main { flex: 1; min-width: 0; }
.layout .aside { width: 250px; flex-shrink: 0; position: sticky; top: 74px; }
@media (max-width: 780px) {
  .layout { flex-direction: column; }
  .layout .aside { width: 100%; position: static; order: -1; }
}

/* mini calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 600; font-size: 14px; }
.cal-head button { background: none; border: 1px solid var(--line); border-radius: 6px; width: 28px; height: 28px; cursor: pointer; color: var(--ink); font-size: 16px; line-height: 1; }
.cal-head button:hover { background: #f0f3fb; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow span { text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; padding: 2px 0; }
.cal-day { aspect-ratio: 1; border: none; background: none; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.cal-day:hover { background: #eef2fb; }
.cal-day.empty { visibility: hidden; cursor: default; }
.cal-day.inweek { background: #e7edfc; }
.cal-day.today { background: var(--blue); color: #fff; font-weight: 700; }
.cal-hint { color: var(--muted); font-size: 12px; margin: 12px 0 0; }

/* time-range picker */
.timerow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timerow input[type=time] { width: auto; flex: 1; min-width: 110px; }
.timerow select { width: auto; }
.timerow .to { color: var(--muted); font-size: 13px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.presets button { background: #eef2fb; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--blue); font-weight: 600; }
.presets button:hover { background: #dfe7fa; }
.calc-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* account modal radios */
.radio { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 8px 0; cursor: pointer; }
.radio input { width: auto; margin: 0; }
.modal.wide { max-width: 440px; text-align: left; }
