:root { color-scheme: light; }
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; background: #f7f8fb; color: #1a1a2e; font-size: 14px; }

/* Login screen */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, #4472C4 0%, #5a8dd6 100%); }
.login-card { background: white; border-radius: 10px; padding: 40px; max-width: 420px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.login-card h1 { margin: 0 0 8px; font-size: 22px; color: #1f3864; }
.login-card p { margin: 0 0 20px; color: #5a6378; font-size: 14px; }
.login-card input { width: 100%; padding: 12px; border: 1px solid #d0d4dc; border-radius: 6px; font-size: 15px; margin-bottom: 12px; }
.login-card input:focus { outline: none; border-color: #4472C4; box-shadow: 0 0 0 3px rgba(68,114,196,.15); }
.login-card button { width: 100%; padding: 12px; background: #4472C4; color: white; border: none; border-radius: 6px; font-size: 15px; font-weight: 600; cursor: pointer; }
.login-card button:hover { background: #355a9c; }
.login-card .msg { margin-top: 14px; padding: 10px; border-radius: 6px; font-size: 13px; }
.login-card .msg.error { background: #FFC7CE; color: #9C0006; }
.login-card .msg.success { background: #C6EFCE; color: #006100; }

header { background: linear-gradient(135deg, #4472C4 0%, #5a8dd6 100%); color: white; padding: 16px 28px; display: flex; justify-content: space-between; align-items: center; }
header .left h1 { margin: 0; font-size: 20px; font-weight: 600; }
header .left p { margin: 2px 0 0; opacity: 0.92; font-size: 12px; }
header .user-info { display: flex; align-items: center; gap: 10px; font-size: 13px; }
header .role-badge { background: rgba(255,255,255,0.25); padding: 3px 9px; border-radius: 11px; font-weight: 600; font-size: 11px; text-transform: uppercase; }
header button { background: rgba(255,255,255,0.2); color: white; border: 1px solid rgba(255,255,255,0.35); border-radius: 5px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
header button:hover { background: rgba(255,255,255,0.3); }

.tabs { display: flex; gap: 4px; background: white; padding: 0 20px; border-bottom: 1px solid #e4e7ec; position: sticky; top: 0; z-index: 10; overflow-x: auto; }
.tab { padding: 14px 18px; cursor: pointer; border: none; background: transparent; font-size: 14px; font-weight: 500; color: #5a6378; border-bottom: 3px solid transparent; white-space: nowrap; transition: all .15s; }
.tab:hover { color: #2c3e6a; background: #f7f8fb; }
.tab.active { color: #4472C4; border-bottom-color: #4472C4; }
.tab .badge { display: inline-block; background: #C00000; color: white; border-radius: 10px; padding: 1px 7px; font-size: 11px; margin-left: 6px; font-weight: 600; }

main { padding: 20px 28px 60px; }
.panel { display: none; }
.panel.active { display: block; }
h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; color: #1f3864; }
h3 { margin: 18px 0 10px; font-size: 15px; font-weight: 600; color: #2c3e6a; }
.hint { color: #5a6378; font-size: 13px; margin: 0 0 14px; }

table { border-collapse: collapse; background: white; border-radius: 6px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
th, td { padding: 8px 10px; border: 1px solid #e4e7ec; text-align: left; font-size: 13px; }
th { background: #4472C4; color: white; font-weight: 600; position: sticky; top: 49px; z-index: 5; }
tr:nth-child(even) td { background: #fafbfd; }

button { cursor: pointer; border: 1px solid #d0d4dc; background: white; border-radius: 5px; padding: 6px 12px; font-size: 13px; font-weight: 500; color: #2c3e6a; transition: all .15s; }
button:hover { background: #f0f4fa; border-color: #4472C4; }
button.primary { background: #4472C4; color: white; border-color: #4472C4; }
button.primary:hover { background: #355a9c; }
button.danger { color: #c00; }
button.danger:hover { background: #fff0f0; border-color: #c00; }
button.small { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input[type="text"], input[type="email"], input[type="date"], select, textarea {
  border: 1px solid #d0d4dc; border-radius: 4px; padding: 5px 8px; font-size: 13px; font-family: inherit; background: white;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #4472C4; box-shadow: 0 0 0 2px rgba(68,114,196,.15); }

.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }

.grid-wrap { overflow-x: auto; background: white; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.grid-wrap table { box-shadow: none; border-radius: 0; }
.week-num { font-weight: 600; text-align: center; width: 50px; }
.week-date { width: 92px; text-align: center; font-size: 12px; color: #5a6378; white-space: nowrap; }
.vac-cell { width: 60px; text-align: center; cursor: pointer; user-select: none; transition: background .1s; font-weight: 600; }
.vac-cell:hover { background: #f0f4fa !important; }
.vac-cell.vacation { background: #FFC7CE !important; color: #9C0006; }
.vac-cell.vacation::after { content: "V"; }
.vac-cell.locked { cursor: not-allowed; opacity: 0.6; }
.vac-cell.locked:hover { background: transparent !important; }
.vac-cell.locked.vacation:hover { background: #FFC7CE !important; }
.vac-cell.busy { opacity: 0.4; }

.month-q1 td.week-num, .month-q1 td.week-date { background: #EAF1FB !important; }
.month-q2 td.week-num, .month-q2 td.week-date { background: #E8F5E9 !important; }
.month-q3 td.week-num, .month-q3 td.week-date { background: #FFF8E1 !important; }
.month-q4 td.week-num, .month-q4 td.week-date { background: #FFE0B2 !important; }

.cov-ok  { background: #C6EFCE; color: #006100; text-align: center; font-weight: 600; }
.cov-bad { background: #FFC7CE; color: #9C0006; text-align: center; font-weight: 700; }
.cov-warn{ background: #FFEB9C; color: #9C5700; text-align: center; font-weight: 600; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 11px; font-size: 11px; font-weight: 600; background: #e8edf5; color: #2c3e6a; margin: 1px 2px 1px 0; }
.empty-state { padding: 36px 20px; text-align: center; color: #6a7488; background: white; border-radius: 6px; border: 1px dashed #d0d4dc; }

.alert { padding: 10px 14px; border-radius: 6px; background: #FFEB9C; color: #9C5700; margin-bottom: 14px; font-size: 13px; border-left: 4px solid #f0c040; }
.alert.danger  { background: #FFC7CE; color: #9C0006; border-left-color: #c00; }
.alert.success { background: #C6EFCE; color: #006100; border-left-color: #2a8e3a; }
.alert.info    { background: #E3F2FD; color: #0D47A1; border-left-color: #4472C4; }

.legend { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 14px; font-size: 12px; color: #5a6378; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 16px; height: 16px; border-radius: 3px; border: 1px solid rgba(0,0,0,.08); }

.checkboxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px 10px; margin-top: 4px; }
.checkboxes label { font-size: 13px; display: flex; gap: 6px; align-items: center; cursor: pointer; }

dialog { border: none; border-radius: 8px; padding: 0; box-shadow: 0 10px 40px rgba(0,0,0,.18); max-width: 500px; width: 92%; }
dialog::backdrop { background: rgba(0,0,0,.35); }
.dlg-inner { padding: 22px 24px; }
.dlg-inner h3 { margin-top: 0; }
.form-row { margin: 10px 0; }
.form-row label { display: block; font-size: 12px; font-weight: 600; color: #5a6378; margin-bottom: 4px; }
.form-row input, .form-row select, .form-row textarea { width: 100%; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.summary-row td { font-weight: 700; background: #f0f4fa !important; }

details { background: white; border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
details summary { cursor: pointer; font-weight: 600; color: #2c3e6a; }
details[open] summary { margin-bottom: 8px; }

.toast { position: fixed; bottom: 20px; right: 20px; background: #1f3864; color: white; padding: 12px 18px; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 100; }
.toast.show { opacity: 1; }
.toast.error { background: #9C0006; }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #cbd5e0; border-top-color: #4472C4; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(247, 248, 251, 0.85); display: flex; align-items: center; justify-content: center; z-index: 50; flex-direction: column; gap: 12px; color: #5a6378; }

.hidden { display: none !important; }
.admin-only { /* shown via JS */ }
