/* ─────────────────────────────────────────
   Modern Light Theme
───────────────────────────────────────── */
:root {
  --bg:      #f4f6fb;
  --s1:      #ffffff;
  --s2:      #f0f2f8;
  --s3:      #e8ebf4;
  --b:       rgba(0,0,0,.08);
  --bm:      rgba(0,0,0,.13);
  --acc:     #3b7ef8;
  --acc-bg:  rgba(59,126,248,.08);
  --acc-brd: rgba(59,126,248,.25);
  --text:    #111827;
  --t2:      #6b7280;
  --t3:      #c4c9d8;
  --green:   #16a34a;
  --amber:   #d97706;
  --red:     #dc2626;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

::-webkit-scrollbar              { width: 5px; height: 5px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: #d1d5e0; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover  { background: #adb5cc; }

body {
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

/* ── TOPBAR ────────────────────────────── */
.topbar {
  flex-shrink: 0;
  height: 54px;
  background: var(--s1);
  border-bottom: 1px solid var(--b);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.topbar h1 {
  font-size: 0.85em;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  min-width: 160px;
  letter-spacing: -0.01em;
}

/* ── HOURS COUNTERS ────────────────────── */
.hours-counter {
  height: 28px;
  padding: 0 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  font-size: 0.72em;
  font-weight: 600;
  color: #92400e;
  white-space: nowrap;
  letter-spacing: .01em;
  gap: 6px;
}
.hours-counter::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #f59e0b;
  flex-shrink: 0;
}

.hours-counter-dim {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}
.hours-counter-dim::before { background: var(--acc); }

/* ── BUTTON GROUP ──────────────────────── */
.btn-group { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }

.btn-sep {
  width: 1px;
  height: 20px;
  background: var(--b);
  flex-shrink: 0;
  margin: 0 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid #dde2ec;
  background: #fff;
  color: #374151;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.74em;
  font-weight: 500;
  white-space: nowrap;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  transition: background .12s, border-color .12s, box-shadow .12s, color .12s;
}

.btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.75;
  flex-shrink: 0;
  color: #6b7280;
  transition: color .12s;
}

.btn:hover {
  background: #f5f7ff;
  border-color: #b8c2d8;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  color: #111827;
}
.btn:hover svg { color: #374151; }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 2px rgba(0,0,0,.05); }

.file-input { display: none; }

/* Primary — filled blue */
.btn-primary {
  background: var(--acc);
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 1px 3px rgba(59,126,248,.35);
}
.btn-primary svg { color: rgba(255,255,255,.85); }
.btn-primary:hover {
  background: #2563eb;
  border-color: #1d4ed8;
  box-shadow: 0 3px 10px rgba(59,126,248,.35);
  color: #fff;
}
.btn-primary:hover svg { color: #fff; }

/* Danger — red text */
.btn-danger {
  color: var(--red);
}
.btn-danger svg { color: var(--red); }
.btn-danger:hover {
  background: #fff5f5;
  border-color: #fecaca;
  color: #b91c1c;
  box-shadow: 0 2px 6px rgba(220,38,38,.1);
}
.btn-danger:hover svg { color: #b91c1c; }

/* ── TAB BAR ───────────────────────────── */
.tab-bar {
  flex-shrink: 0;
  display: flex;
  gap: 0;
  padding: 0 18px;
  background: var(--s1);
  border-bottom: 1px solid var(--b);
}

.tab-btn {
  position: relative;
  height: 40px;
  padding: 0 16px;
  border: none;
  background: transparent;
  color: var(--t2);
  font-family: inherit;
  font-size: 0.78em;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: .01em;
  transition: color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--acc); font-weight: 600; }

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: 0; left: 16px; right: 16px;
  height: 2px;
  background: var(--acc);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.tab-btn.active::after { transform: scaleX(1); }

/* ── STATUS BAR ────────────────────────── */
.statusbar {
  flex-shrink: 0;
  height: 24px;
  padding: 0 20px;
  font-size: 0.69em;
  color: var(--t2);
  background: var(--s1);
  border-bottom: 1px solid var(--b);
  display: flex;
  align-items: center;
  letter-spacing: .01em;
  transition: color .25s;
}
.statusbar.ok  { color: var(--green); }
.statusbar.err { color: var(--red); }

/* ── TABLE WRAPPER ─────────────────────── */
.table-wrap { flex: 1; overflow: auto; }

/* ── TABLE ─────────────────────────────── */
table {
  border-collapse: collapse;
  min-width: 860px;
  width: 100%;
  font-size: 0.80em;
}

thead tr { position: sticky; top: 0; z-index: 20; }

th {
  background: var(--s1);
  color: var(--t2);
  padding: 9px 8px;
  border-bottom: 2px solid var(--bm);
  border-right: 1px solid var(--b);
  text-align: center;
  white-space: nowrap;
  user-select: none;
  font-size: 0.74em;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  box-shadow: 0 2px 4px rgba(0,0,0,.04);
}
th:last-child { border-right: none; }

td {
  border-bottom: 1px solid rgba(0,0,0,.05);
  border-right: 1px solid rgba(0,0,0,.04);
  padding: 0 2px;
  background: var(--s1);
}
td:last-child { border-right: none; }

tr.data-row:nth-child(even) td { background: #fafbfd; }

tr.data-row:hover td { background: #eef3ff !important; }
tr.data-row:hover td:first-child { box-shadow: inset 2px 0 0 var(--acc); }

/* ── ROW LABELS ────────────────────────── */
.td-num {
  text-align: center;
  color: var(--t3);
  font-size: 0.80em;
  min-width: 30px;
  user-select: none;
}

.td-date {
  text-align: center;
  color: var(--t2);
  font-weight: 600;
  font-size: 0.86em;
  min-width: 50px;
  padding: 2px 8px;
  user-select: none;
  white-space: nowrap;
}
.td-date.period { min-width: 110px; font-size: 0.80em; }

/* ── MONTH HEADER ──────────────────────── */
tr.month-hdr td {
  background: var(--bg) !important;
  box-shadow: none !important;
  color: var(--t2);
  font-size: 0.68em;
  font-weight: 700;
  padding: 6px 16px;
  border-top: 1px solid var(--bm);
  border-bottom: 1px solid var(--b);
  letter-spacing: .12em;
  text-transform: uppercase;
  user-select: none;
}

/* ── CELL INPUTS ───────────────────────── */
input.ci {
  width: 100%;
  min-width: 56px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  font-size: 0.96em;
  padding: 3px 4px;
  font-family: 'Consolas', 'SF Mono', monospace;
  text-align: center;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
input.ci:focus {
  outline: none;
  border-color: var(--acc);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(59,126,248,.12);
}
input.ci.invalid {
  border-color: var(--red) !important;
  color: var(--red);
  box-shadow: 0 0 0 3px rgba(220,38,38,.10);
}

/* ── DIM CELL ──────────────────────────── */
.dim-cell { display: flex; align-items: center; gap: 3px; padding: 1px 2px; }
.dim-cell input.ci { flex: 1; min-width: 48px; }

select.dim-select {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--t2);
  font-family: inherit;
  font-size: 0.74em;
  font-weight: 500;
  padding: 3px 5px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%236b7280'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 5px center;
  padding-right: 18px;
}
select.dim-select:focus {
  outline: none;
  border-color: var(--acc);
  background-color: #eff6ff;
}

/* ── HOURS COLUMN ──────────────────────── */
.td-hours {
  text-align: center;
  color: var(--amber);
  font-size: 0.80em;
  font-weight: 600;
  min-width: 46px;
  padding: 2px 6px;
  white-space: nowrap;
  user-select: none;
}
.td-hours.zero { color: var(--t3); }

/* ── DIM SELECT COLOR CODING ───────────── */
select.dim-select[data-val="00"] { color: var(--t3); }
select.dim-select[data-val="01"] { color: #dc2626; }
select.dim-select[data-val="04"] { color: #16a34a; }
