:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1c2027;
  --text-muted: #6b7280;
  --border: #e3e5e9;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --weekend: #dc2626;
  --radius: 10px;

  --c-lic: #9ca3af;
  --c-cfi: #2563eb;
  --c-cfil: #0891b2;
  --c-serv: #7c3aed;
  --c-smont: #c2410c;
  --c-mix: #16a34a;
  --c-strd: #eab308;
  --c-rec: #db2777;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171c;
    --panel: #1e2128;
    --text: #e8eaee;
    --text-muted: #9aa1ab;
    --border: #30343c;
    --accent: #3b82f6;
    --accent-dark: #60a5fa;
    --weekend: #f87171;
  }
}
:root[data-theme="dark"] {
  --bg: #15171c;
  --panel: #1e2128;
  --text: #e8eaee;
  --text-muted: #9aa1ab;
  --border: #30343c;
  --accent: #3b82f6;
  --accent-dark: #60a5fa;
  --weekend: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 1180px; margin: 0 auto; padding: 16px; }

/* ---------- Login ---------- */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
}
#login-screen h1 { font-size: 22px; margin: 0; }
#login-screen p { color: var(--text-muted); margin: 0; }
.btn-google {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 20px; cursor: pointer;
  font-size: 15px; color: var(--text);
}
.btn-google:hover { border-color: var(--accent); }
#access-denied { color: var(--weekend); display: none; }

/* ---------- Top bar ---------- */
header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 2px 18px;
  flex-wrap: wrap; gap: 10px;
}
header.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }
header.topbar .user { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 13px; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 0; }

/* ---------- Year / month nav ---------- */
.nav-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.nav-row select {
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 14px;
}
.month-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-left: 6px; }
.month-tab {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text-muted); cursor: pointer; font-size: 13px;
}
.month-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px;
}
.panel h2 { font-size: 15px; margin: 0 0 12px; }

/* ---------- Calendar grid ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekday { text-align: center; font-size: 11px; color: var(--text-muted); padding-bottom: 4px; }
.cal-cell {
  border: 1px solid var(--border); border-radius: 8px; min-height: 76px;
  padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 4px;
  background: var(--bg);
}
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.empty { visibility: hidden; cursor: default; }
.cal-cell .daynum { font-size: 12px; font-weight: 600; }
.cal-cell.weekend .daynum { color: var(--weekend); }
.cal-cell .chips { display: flex; flex-wrap: wrap; gap: 3px; }
.chip {
  font-size: 10px; padding: 2px 6px; border-radius: 999px; color: #fff; font-weight: 600;
  white-space: nowrap;
}
.chip-loc { background: var(--text-muted); }
.chip-strd { background: var(--c-strd); color: #3a2c00; }
.chip.LIC { background: var(--c-lic); }
.chip.CFI { background: var(--c-cfi); }
.chip.CFIL { background: var(--c-cfil); }
.chip.SERV { background: var(--c-serv); }
.chip.SMONT { background: var(--c-smont); }
.chip.MIX { background: var(--c-mix); }
.chip-strd-neg { background: #dc2626; color: #fff; }
.chip.STRD { background: var(--c-strd); color: #3a2c00; }
.chip.REC-ORE { background: var(--c-rec); }

/* ---------- Riepilogo table ---------- */
.summary-wrap { overflow-x: auto; }
table.summary {
  width: 100%; min-width: 820px; border-collapse: collapse; table-layout: fixed;
  font-size: 13px; font-variant-numeric: tabular-nums;
}
table.summary th, table.summary td {
  padding: 7px 4px; text-align: center; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.summary th:first-child, table.summary td:first-child { text-align: left; width: 120px; padding-left: 8px; }
table.summary th:last-child, table.summary td:last-child { width: 70px; border-left: 1px solid var(--border); }
table.summary th { color: var(--text-muted); font-weight: 600; font-size: 12px; }
table.summary tr.total td { font-weight: 700; background: var(--bg); }
table.summary tr.group td { text-align: left; padding-top: 14px; color: var(--text-muted); font-size: 11px; border-bottom: none; }

.section-gap { margin-top: 18px; }

/* ---------- Locations manager ---------- */
.loc-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.loc-pill {
  display: flex; align-items: center; gap: 6px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 6px 4px 10px; font-size: 12px;
}
.loc-pill button { border: none; background: none; cursor: pointer; color: var(--text-muted); font-size: 13px; line-height: 1; }
.add-loc { display: flex; gap: 6px; }
.add-loc input { flex: 1; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }

/* ---------- Import ---------- */
.import-box { font-size: 12.5px; color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--weekend); }

/* ---------- Modal (day editor) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal {
  background: var(--panel); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 380px;
  border: 1px solid var(--border);
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; }
.field select, .field input {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 14px;
}
.hm-row { display: flex; gap: 8px; }
.hm-row .field { flex: 1; margin-bottom: 0; }
.modal-actions { display: flex; justify-content: space-between; margin-top: 18px; gap: 8px; }
.modal-actions .right { display: flex; gap: 8px; }

.hidden { display: none !important; }
.toast {
  position: fixed; bottom: 18px; right: 18px; background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 60;
}
