:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2026;
  --text-muted: #6b7280;
  --accent: #2f6fed;
  --t1-bg: #fff3c4;
  --t1-text: #7a5b00;
  --t2-bg: #cfe3ff;
  --t2-text: #1a4a8a;
  --folga-bg: #e6e8eb;
  --folga-text: #5a6069;
  --ok: #2f9e52;
  --warn: #c2410c;
  --warn-bg: #fff4e5;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171b;
    --surface: #1d2025;
    --border: #2b2f36;
    --text: #e8eaed;
    --text-muted: #9aa1ab;
    --accent: #5b8def;
    --t1-bg: #4a3c0a;
    --t1-text: #ffdf7e;
    --t2-bg: #1d3a63;
    --t2-text: #bcdcff;
    --folga-bg: #2a2e35;
    --folga-text: #aab1bb;
    --ok: #4fbf74;
    --warn: #ff8a4c;
    --warn-bg: #3a2512;
  }
}

:root[data-theme="dark"] {
  --bg: #15171b;
  --surface: #1d2025;
  --border: #2b2f36;
  --text: #e8eaed;
  --text-muted: #9aa1ab;
  --accent: #5b8def;
  --t1-bg: #4a3c0a;
  --t1-text: #ffdf7e;
  --t2-bg: #1d3a63;
  --t2-text: #bcdcff;
  --folga-bg: #2a2e35;
  --folga-text: #aab1bb;
  --ok: #4fbf74;
  --warn: #ff8a4c;
  --warn-bg: #3a2512;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 14px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand-title { font-weight: 700; font-size: 17px; margin-right: 8px; }
.brand-sub { color: var(--text-muted); font-size: 13px; }

.tabs { display: flex; gap: 6px; }
.tab {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.alerts-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.alerts-icon { font-size: 15px; }
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  font-size: 13px;
  padding: 0;
}
.alerts-detail {
  padding: 10px 20px;
  background: var(--warn-bg);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  max-height: 180px;
  overflow-y: auto;
}
.alerts-detail div { padding: 2px 0; }

main { padding: 16px 20px 40px; max-width: 1200px; margin: 0 auto; }

.view { display: none; }
.view.active { display: block; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
}
.controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
}
select, input[type="text"], input[type="number"], input[type="time"] {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
}

.btn {
  padding: 8px 14px;
  border-radius: 7px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  cursor: pointer;
}
.btn-secondary { background: var(--text-muted); }
.btn:hover { opacity: 0.9; }

.legend { display: flex; gap: 10px; margin-bottom: 10px; }
.chip {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
}
.chip-t1 { background: var(--t1-bg); color: var(--t1-text); }
.chip-t2 { background: var(--t2-bg); color: var(--t2-text); }
.chip-folga { background: var(--folga-bg); color: var(--folga-text); }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.schedule-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 760px;
}
table.schedule-table th, table.schedule-table td {
  padding: 7px 9px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
  font-size: 12.5px;
}
table.schedule-table th {
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  position: sticky;
  top: 0;
}
table.schedule-table td:first-child, table.schedule-table th:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface);
  font-weight: 600;
}
table.schedule-table th:first-child { background: var(--bg); }

.cell-select {
  border: none;
  background: transparent;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
  width: 100%;
}
.cell-t1 { background: var(--t1-bg); color: var(--t1-text); }
.cell-t2 { background: var(--t2-bg); color: var(--t2-text); }
.cell-folga { background: var(--folga-bg); color: var(--folga-text); }
.cell-closed { background: var(--folga-bg); color: var(--text-muted); font-size: 11px; }

.row-summary td { font-weight: 600; }
.row-alert { color: var(--warn); }

.cov-ok { color: var(--ok); font-weight: 700; }
.cov-fail { color: var(--warn); font-weight: 700; }

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 14.5px; }
.card label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-muted);
}
.card label input, .card label select { flex: 0 0 140px; }
.hint { font-size: 12px; color: var(--warn); margin-top: 8px; min-height: 1em; }

.store-row, .employee-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.store-row input, .employee-row input { flex: 1; }
.icon-btn {
  border: none;
  background: var(--folga-bg);
  color: var(--text);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  cursor: pointer;
}
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row input { flex: 1; }

@media (max-width: 640px) {
  main { padding: 12px; }
  .topbar { padding: 12px; }
  table.schedule-table { min-width: 680px; }
}
