:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border: #e2e8f0;
    --text: #172033;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --warning: #d97706;
    --success: #059669;
    --sidebar: #111827;
    --shadow: 0 14px 38px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 232px;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    color: #fff;
    background: radial-gradient(circle at top left, rgba(37, 99, 235, .25), transparent 38%), var(--sidebar);
    z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 25px; }
.brand-icon {
    width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    box-shadow: 0 10px 25px rgba(37, 99, 235, .35);
}
.brand strong, .brand span { display: block; }
.brand strong { font-size: 17px; }
.brand span { margin-top: 2px; color: #aeb9ca; font-size: 11px; }
.sidebar-nav { display: grid; gap: 7px; }
.nav-item {
    display: flex; align-items: center; gap: 11px; padding: 12px 13px; border-radius: 12px;
    color: #aeb9ca; transition: .18s ease;
}
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.09); }
.nav-item.active { box-shadow: inset 3px 0 0 #60a5fa; }
.nav-item i { width: 20px; }
.sidebar-note {
    margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 13px;
    border: 1px solid rgba(255,255,255,.08); border-radius: 14px; background: rgba(255,255,255,.04);
}
.sidebar-note i { color: #60a5fa; font-size: 19px; }
.sidebar-note span, .sidebar-note strong { display: block; }
.sidebar-note span { color: #8e9bad; font-size: 10px; text-transform: uppercase; }
.sidebar-note strong { margin-top: 2px; font-size: 12px; }

.main-content { grid-column: 2; min-width: 0; padding: 24px; }
.page-header {
    display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 19px;
}
.eyebrow { margin: 0 0 3px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.page-header h1 { margin: 0; font-size: clamp(25px, 3vw, 34px); font-weight: 850; letter-spacing: -.04em; }
.subtitle { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn { border-radius: 11px; font-weight: 700; }
.btn-icon { width: 40px; height: 40px; display: grid; place-items: center; padding: 0; }
.control-box {
    min-height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 11px;
    border: 1px solid var(--border); border-radius: 11px; background: var(--surface);
}
.control-box input, .control-box select { border: 0; outline: 0; background: transparent; min-width: 125px; color: var(--text); }

.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(145px, 1fr)); gap: 11px; margin-bottom: 14px; }
.summary-card {
    display: flex; align-items: center; gap: 10px; min-width: 0; padding: 13px;
    border: 1px solid var(--border); border-radius: 15px; background: var(--surface); box-shadow: 0 7px 20px rgba(15,23,42,.035);
}
.summary-icon { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border-radius: 11px; background: #eff6ff; color: var(--primary); }
.summary-card span, .summary-card strong { display: block; }
.summary-card span { color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-card strong { margin-top: 2px; font-size: 18px; letter-spacing: -.03em; }

.toolbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px;
}
.toolbar-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-control {
    min-height: 40px; display: flex; align-items: center; gap: 8px; min-width: 190px;
    padding: 0 11px; border: 1px solid var(--border); border-radius: 11px; background: #fff;
}
.search-control input { width: 100%; border: 0; outline: 0; }
.clipboard-indicator {
    display: none; align-items: center; gap: 7px; padding: 8px 10px; border-radius: 10px;
    background: #eff6ff; color: #1d4ed8; font-size: 11px; font-weight: 800;
}
.clipboard-indicator.visible { display: flex; }

.schedule-wrap {
    position: relative; border: 1px solid var(--border); border-radius: 18px; overflow: hidden;
    background: #fff; box-shadow: var(--shadow);
}
.schedule-scroll { max-height: calc(100vh - 292px); overflow: auto; }
.schedule-board { min-width: 1270px; }
.schedule-loading {
    position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; gap: 10px;
    background: rgba(255,255,255,.92);
}
.schedule-header, .employee-row {
    display: grid;
    grid-template-columns: 205px repeat(7, minmax(132px, 1fr)) 110px;
}
.schedule-header {
    position: sticky; top: 0; z-index: 9; border-bottom: 1px solid var(--border); background: #f8fafc;
}
.header-cell {
    min-height: 60px; display: flex; align-items: center; justify-content: center; padding: 8px;
    border-right: 1px solid var(--border); text-align: center;
}
.header-cell:first-child { position: sticky; left: 0; z-index: 11; justify-content: flex-start; background: #f8fafc; padding-left: 14px; }
.day-title span, .day-title strong { display: block; }
.day-title span { color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.day-title strong { margin-top: 2px; font-size: 13px; }
.day-title .holiday { max-width: 110px; margin-top: 2px; color: #c2410c; font-size: 8px; line-height: 1.1; }
.day-title.sunday strong { color: #b91c1c; }

.team-divider {
    position: sticky; left: 0; z-index: 7; display: flex; align-items: center; gap: 8px; min-height: 33px;
    padding: 6px 12px; border-bottom: 1px solid var(--border); background: #f1f5f9;
    font-size: 11px; font-weight: 850;
}
.team-dot { width: 8px; height: 8px; border-radius: 50%; }
.team-divider small { color: var(--muted); font-weight: 700; }

.employee-row { min-height: 102px; border-bottom: 1px solid var(--border); }
.employee-info {
    position: sticky; left: 0; z-index: 6; display: flex; gap: 9px; align-items: flex-start; padding: 11px;
    border-right: 1px solid var(--border); background: #fff;
}
.avatar { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 10px; color: #fff; font-size: 11px; font-weight: 850; }
.employee-info strong, .employee-info span, .employee-info small { display: block; }
.employee-info strong { max-width: 135px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.employee-info span { margin-top: 2px; color: var(--muted); font-size: 9px; }
.employee-info small { margin-top: 5px; color: var(--primary); font-size: 9px; font-weight: 800; }

.day-cell {
    position: relative; min-height: 102px; padding: 5px 5px 34px; border-right: 1px solid var(--border);
    background: #fff; transition: .16s ease;
}
.day-cell:hover { background: #f8fbff; }
.day-cell.sunday { background: #fffafa; }
.day-cell.holiday { background: #fff8ed; }
.day-cell.drag-over { background: #eff6ff; box-shadow: inset 0 0 0 2px #60a5fa; }
.cell-actions {
    position: absolute;
    right: 5px;
    bottom: 5px;
    top: auto;
    display: flex;
    gap: 3px;
    opacity: 0;
    pointer-events: none;
    transition: .15s;
    z-index: 1;
}
.day-cell:hover .cell-actions {
    opacity: 1;
    pointer-events: auto;
}
.cell-action {
    width: 22px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 7px;
    background: rgba(255,255,255,.92); color: #64748b; box-shadow: 0 3px 9px rgba(15,23,42,.12); font-size: 10px;
}
.turn-card {
    position: relative; z-index: 2; margin-bottom: 4px; padding: 6px 25px 6px 7px; min-height: 39px;
    border: 1px solid rgba(15,23,42,.08); border-left: 3px solid var(--card-color);
    border-radius: 9px; background: #fff; box-shadow: 0 4px 10px rgba(15,23,42,.08);
    cursor: grab; user-select: none; transition: .15s ease;
}
.turn-card:hover { transform: translateY(-1px); box-shadow: 0 7px 15px rgba(15,23,42,.13); }
.turn-card.dragging { opacity: .35; }
.turn-card.rest { background: #f8fafc; }
.turn-card.absence { background: #fff7ed; }
.turn-card.published::after {
    content: ""; position: absolute; right: 5px; bottom: 5px; width: 5px; height: 5px; border-radius: 50%; background: #10b981;
}
.turn-title { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; font-weight: 850; }
.turn-time { margin-top: 1px; font-size: 10px; font-weight: 800; }
.turn-badges { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 3px; }
.badge-mini { padding: 2px 4px; border-radius: 999px; background: #f1f5f9; color: #475569; font-size: 7px; font-weight: 850; }
.badge-mini.night { background: #f3e8ff; color: #6d28d9; }
.badge-mini.restday { background: #fee2e2; color: #b91c1c; }
.badge-mini.extra { background: #fef3c7; color: #92400e; }
.card-menu-button {
    position: absolute; z-index: 5; right: 3px; top: 3px; width: 20px; height: 20px; display: grid; place-items: center;
    border: 0; border-radius: 6px; background: transparent; color: #94a3b8; font-size: 11px;
}
.card-menu-button:hover { background: #f1f5f9; color: #334155; }

.employee-total {
    display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 7px;
    border-left: 1px solid var(--border); background: #fbfdff; text-align: center;
}
.employee-total strong { font-size: 16px; letter-spacing: -.03em; }
.employee-total span { color: var(--muted); font-size: 8px; }
.total-status { margin-top: 5px; padding: 3px 5px; border-radius: 999px; background: #dcfce7; color: #166534; font-size: 7px; font-weight: 850; }
.employee-total.warning .total-status { background: #fef3c7; color: #92400e; }
.employee-total.danger .total-status { background: #fee2e2; color: #b91c1c; }
.employee-total .progress { width: 70px; height: 4px; margin-top: 5px; }

.compact .employee-row { min-height: 76px; }
.compact .day-cell { min-height: 76px; padding: 4px 4px 32px; }
.compact .employee-info { padding: 8px; }
.compact .avatar { width: 29px; height: 29px; flex-basis: 29px; }
.compact .turn-card { min-height: 31px; padding-top: 4px; padding-bottom: 4px; margin-bottom: 3px; }
.compact .turn-badges { display: none; }
.compact .turn-title { font-size: 8px; }
.compact .turn-time { font-size: 9px; }

.context-menu {
    position: fixed; z-index: 1000; min-width: 205px; padding: 6px; display: none;
    border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: 0 20px 45px rgba(15,23,42,.18);
}
.context-menu.visible { display: block; }
.context-menu button {
    width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px 9px;
    border: 0; border-radius: 8px; background: transparent; color: #334155; text-align: left; font-size: 11px;
}
.context-menu button:hover { background: #f1f5f9; }
.context-menu button.danger { color: #b91c1c; }
.context-menu hr { margin: 5px 0; border-color: var(--border); }

.panel-card { border: 1px solid var(--border); border-radius: 17px; background: #fff; box-shadow: var(--shadow); overflow: hidden; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 15px 17px; border-bottom: 1px solid var(--border); }
.panel-header h2 { margin: 0; font-size: 16px; font-weight: 850; }
.panel-body { padding: 17px; }
.table { margin-bottom: 0; font-size: 12px; }
.table thead th { color: #64748b; font-size: 9px; text-transform: uppercase; letter-spacing: .04em; background: #f8fafc; }
.table td, .table th { vertical-align: middle; }
.table-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border-radius: 999px; background: #f1f5f9; font-size: 9px; font-weight: 800; }
.color-dot { width: 8px; height: 8px; border-radius: 50%; }
.actions-inline { display: flex; gap: 5px; justify-content: flex-end; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-full { grid-column: 1 / -1; }
.form-label { margin-bottom: 5px; color: #475569; font-size: 10px; font-weight: 800; }
.form-control, .form-select { min-height: 40px; border-color: var(--border); border-radius: 10px; font-size: 12px; }
.form-control:focus, .form-select:focus { border-color: #93c5fd; box-shadow: 0 0 0 4px rgba(37,99,235,.1); }
.modal-content { border: 0; border-radius: 18px; box-shadow: 0 28px 75px rgba(15,23,42,.25); }
.modal-header, .modal-footer { border-color: var(--border); }
.modal-title { font-size: 18px; font-weight: 850; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab-button { padding: 8px 11px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: #64748b; font-size: 11px; font-weight: 800; }
.tab-button.active { border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.report-table-wrap { overflow: auto; }
.report-table { min-width: 1280px; }
.alert-chip { display: inline-block; margin: 2px; padding: 3px 6px; border-radius: 999px; background: #fee2e2; color: #991b1b; font-size: 8px; font-weight: 800; }
.ok-chip { display: inline-block; padding: 3px 6px; border-radius: 999px; background: #dcfce7; color: #166534; font-size: 8px; font-weight: 800; }
.legal-note {
    margin-top: 14px; padding: 12px 14px; border: 1px solid #bfdbfe; border-radius: 12px;
    background: #eff6ff; color: #1e3a8a; font-size: 10px; line-height: 1.45;
}
.empty-state { padding: 55px 20px; text-align: center; color: var(--muted); }
.empty-state i { display: block; margin-bottom: 9px; font-size: 36px; }

@media (max-width: 1250px) {
    .summary-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
    .toolbar { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 900px) {
    .app-shell { display: block; }
    .sidebar { display: none; }
    .main-content { padding: 16px; }
    .page-header { align-items: flex-start; flex-direction: column; }
    .summary-grid { grid-template-columns: repeat(2, minmax(145px, 1fr)); }
    .form-grid, .form-grid.three { grid-template-columns: 1fr; }
    .form-full { grid-column: auto; }
}
@media (max-width: 560px) {
    .summary-grid { grid-template-columns: 1fr; }
    .toolbar-group, .control-box, .search-control { width: 100%; }
    .control-box select, .control-box input { width: 100%; }
}
