:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --line: #dde2ea;
  --text: #172033;
  --muted: #5f6b80;
  --primary: #2459d6;
  --primary-text: #ffffff;
  --danger: #c2333f;
  --today: #f5b83d;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1422;
    --surface: #161e31;
    --surface-2: #1d273d;
    --line: #2a3650;
    --text: #e8edf6;
    --muted: #97a3ba;
    --primary: #5b8cff;
    --primary-text: #0b1220;
    --danger: #ff6b76;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}

h1, h2 { margin: 0; }
h1 { font-size: 1.2rem; }
h2 { font-size: 1.05rem; }

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 600;
}

button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid currentColor;
}

button:disabled { opacity: 0.5; cursor: default; }

input, select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

input[type="color"] {
  width: 3rem;
  height: 2.3rem;
  padding: 0.15rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

label > input, label > select { color: var(--text); font-weight: 400; font-size: 0.95rem; }

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

.who { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; color: var(--muted); font-size: 0.9rem; }
.who a, button.link { color: var(--primary); }

button.link {
  background: none;
  padding: 0;
  font-weight: 400;
  text-decoration: underline;
}

.with-button { display: flex; gap: 0.4rem; }
.with-button input { flex: 1; font-family: ui-monospace, Consolas, monospace; }

label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
  font-weight: 400;
}

label.check input { width: auto; }
#view-users > .hint { margin: -0.4rem 0 1rem; }

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.tabs button {
  background: none;
  color: var(--muted);
  border-radius: 0;
  border-bottom: 3px solid transparent;
  padding: 0.7rem 0.8rem;
}

.tabs button[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--primary);
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

.fatal {
  padding: 1rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

/* ---- Schedule ---- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.week-nav { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.week-nav button { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.week-nav #prev-week, .week-nav #next-week { font-size: 1.2rem; line-height: 1; padding: 0.4rem 0.75rem; }
.week-nav h2 { margin-left: 0.5rem; }

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.6rem;
}

@media (max-width: 1000px) {
  .week-grid { grid-template-columns: 1fr; }
}

.wday {
  display: flex;
  flex-direction: column;
  min-height: 12rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.wday.today { border-color: var(--today); box-shadow: inset 0 3px 0 var(--today); }

.wday-head {
  display: flex;
  justify-content: space-between;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.wday-head span:last-child { color: var(--muted); font-weight: 400; }

.wshifts {
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.wshift {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.45rem;
  align-items: center;
  text-align: left;
  padding: 0.4rem 0.5rem;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 400;
}

.wshift:hover { outline: 2px solid var(--primary); }
.wshift-name { font-weight: 600; overflow-wrap: anywhere; }
.wshift-time { grid-column: 2; color: var(--muted); font-size: 0.85rem; }
.wshift.inactive .wshift-name { text-decoration: line-through; }

.dot {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  grid-row: span 2;
}

.add-shift {
  margin: 0 0.4rem 0.4rem;
  background: none;
  color: var(--primary);
  border: 1px dashed var(--line);
  font-weight: 600;
}

/* ---- Employees / Admins ---- */

.add-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.add-row label:first-child { flex: 1 1 14rem; }

.list { list-style: none; margin: 0; padding: 0; }

.list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
}

.list li:last-child { border-bottom: 0; }
.list li.inactive { opacity: 0.6; }
.list .grow { flex: 1 1 12rem; }
.list .grow input { max-width: 20rem; }
.list select { width: auto; }
.list .muted { color: var(--muted); font-size: 0.85rem; }
.list .empty { color: var(--muted); }

.badge {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}

/* ---- Dialog ---- */

dialog {
  width: min(26rem, calc(100vw - 2rem));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.2rem;
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog form { display: flex; flex-direction: column; gap: 0.8rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.hint { margin: 0; color: var(--muted); font-size: 0.8rem; }
.form-error { margin: 0; color: var(--danger); font-weight: 600; }
.dialog-actions { display: flex; gap: 0.5rem; }
.spacer { flex: 1; }

/* ---- Toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  max-width: calc(100vw - 2rem);
  padding: 0.65rem 1rem;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
}

.toast.error { background: var(--danger); color: #fff; }
