:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1f2a37;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --border: #e5e7eb;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --morning: #dbeafe;
  --evening: #fef3c7;
  --remote: #ede9fe;
  --mbt: #ffedd5;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 0.7rem 1.2rem; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.1rem; }
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.user-box { display: flex; align-items: center; gap: 0.8rem; }
.user-link { color: var(--muted); }

.container { max-width: 1200px; margin: 1.5rem auto; padding: 0 1.2rem; }
.footer { text-align: center; color: var(--muted); padding: 2rem 1rem; font-size: 0.85rem; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.2rem 1.4rem; margin-bottom: 1.2rem;
}
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.8rem; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.stat { text-align: center; }
.stat .num { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat .lbl { color: var(--muted); font-size: 0.9rem; }

.btn {
  display: inline-block; background: var(--primary); color: #fff; border: none;
  padding: 0.55rem 1rem; border-radius: 8px; cursor: pointer; font-size: 0.95rem;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: #e5e7eb; color: var(--ink); }
.btn.danger { background: var(--err); }
.btn.ok { background: var(--ok); }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font-size: 0.95rem; }
.inline { display: inline; }

table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid var(--border); padding: 0.45rem 0.6rem; text-align: left; font-size: 0.9rem; }
th { background: #f8fafc; }

.planning-table td { text-align: center; vertical-align: middle; }
.planning-table .empname { text-align: left; font-weight: 600; white-space: nowrap; }
.cell-morning { background: var(--morning); }
.cell-evening { background: var(--evening); }
.cell-remote { outline: 2px dashed #8b5cf6; outline-offset: -3px; }
.cell-mbt { outline: 2px dashed #ea580c; outline-offset: -3px; }
.cell-restconflict { outline: 3px solid #dc2626; outline-offset: -3px; }
.cell-pending { outline: 3px dashed #d97706; outline-offset: -3px; }
.cell-off { color: var(--muted); }
.cell-unavailable { background: #f3f4f6; color: var(--muted); font-style: italic; }
.cell-holiday { background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 6px, #e5e7eb 6px, #e5e7eb 12px); }
select.cell-select { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 0.2rem; font-size: 0.8rem; background: transparent; }

.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge.telework { background: var(--remote); color: #6d28d9; }
.badge.mbt { background: var(--mbt); color: #9a3412; }
.badge.oncall { background: #fee2e2; color: #b91c1c; }
.badge.published { background: #dcfce7; color: #166534; }
.badge.draft { background: #fef3c7; color: #92400e; }

.violations { list-style: none; padding: 0; margin: 0; }
.violations li { padding: 0.5rem 0.7rem; border-radius: 8px; margin-bottom: 0.4rem; font-size: 0.9rem; }
.v-error { background: #fef2f2; color: #991b1b; border-left: 4px solid var(--err); }
.v-warning { background: #fffbeb; color: #92400e; border-left: 4px solid var(--warn); }
.v-info { background: #eff6ff; color: #1e40af; border-left: 4px solid var(--primary); }
.v-ok { background: #f0fdf4; color: #166534; border-left: 4px solid var(--ok); padding: 0.6rem 0.8rem; border-radius: 8px; }

.alert { padding: 0.7rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert.error { background: #fef2f2; color: #991b1b; }
.alert.success { background: #f0fdf4; color: #166534; }

form.stack label { display: block; margin: 0.6rem 0 0.2rem; font-size: 0.9rem; color: var(--muted); }
form.stack input, form.stack select, form.stack textarea {
  width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 8px; font-size: 0.95rem;
}
.toolbar { display: flex; gap: 0.8rem; align-items: end; flex-wrap: wrap; margin-bottom: 1rem; }
.row-actions { display: flex; gap: 0.4rem; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); margin-top: 0.6rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }

.login-wrap { max-width: 380px; margin: 8vh auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

.month-grid { display: grid; grid-template-columns: repeat(7, minmax(110px, 1fr)); gap: 6px; }
.month-head { text-align: center; font-weight: 600; font-size: 0.8rem; color: var(--muted); padding-bottom: 0.2rem; }
.month-cell {
  display: block; border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem 0.5rem;
  min-height: 78px; background: var(--card); color: var(--ink); font-size: 0.8rem;
}
.month-cell:hover { border-color: var(--primary); text-decoration: none; }
.month-cell.out-of-month { opacity: 0.4; }
.month-cell.weekend { background: #f8fafc; }
.month-cell.today { border-color: var(--primary); border-width: 2px; }
.month-cell.holiday { background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 6px, #e5e7eb 6px, #e5e7eb 12px); }
.month-daynum { font-weight: 600; margin-bottom: 0.25rem; }
