:root {
    --bg: #0d1020;
    --panel: #171a2b;
    --panel-2: #202334;
    --line: rgba(255,255,255,0.08);
    --text: #f3f5fb;
    --muted: #9da6bf;
    --primary: #4f8cff;
    --success: #20d29b;
    --warning: #ffb84d;
    --danger: #ff5f6d;
    --radius: 18px;
    --shadow: 0 18px 50px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(79,140,255,0.20), transparent 30%),
        radial-gradient(circle at bottom right, rgba(32,210,155,0.10), transparent 25%),
        var(--bg);
    color: var(--text);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.auth-page, .agent-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-card, .agent-card, .card {
    background: rgba(23,26,43,0.92);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
}
.auth-card {
    width: min(460px, 100%);
    padding: 32px;
}
.desktop-login-card {
    width: min(520px, 100%);
    padding: 34px;
    background:
        linear-gradient(145deg, rgba(79,140,255,0.10), rgba(32,210,155,0.04)),
        rgba(23,26,43,0.94);
}
.agent-card {
    width: min(760px, 100%);
    padding: 28px;
}
.desktop-duty-card {
    width: min(980px, 100%);
    padding: 30px;
    background:
        radial-gradient(circle at top right, rgba(79,140,255,0.10), transparent 28%),
        linear-gradient(160deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01)),
        rgba(23,26,43,0.96);
}
.desktop-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
}
.desktop-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.desktop-login-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(79,140,255,0.16);
    border: 1px solid rgba(79,140,255,0.24);
    color: #bfd3ff;
    font-size: .85rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
}
.desktop-employee-display {
    padding: 22px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.02));
    border: 1px solid rgba(255,255,255,0.08);
}
.desktop-role-panel {
    margin-bottom: 18px;
    padding: 22px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.018));
    border: 1px solid rgba(255,255,255,0.08);
}
.desktop-role-buttons {
    justify-content: flex-start;
}
.desktop-hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 18px;
    margin-bottom: 18px;
}
.desktop-panel-label {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    color: #dbe4ff;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.desktop-time-panel {
    margin-bottom: 0;
    min-height: 100%;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 10px;
    background:
        radial-gradient(circle at top, rgba(79,140,255,0.14), transparent 40%),
        var(--panel-2);
    border: 1px solid rgba(255,255,255,0.08);
}
.desktop-time-line {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-top: 4px;
}
.current-meridian {
    color: #d8e3ff;
    font-weight: 800;
    letter-spacing: .08em;
    margin-top: 16px;
    font-size: 1rem;
}
.desktop-meta-strip {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 8px;
}
.desktop-meta-pill {
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    text-align: left;
}
.desktop-meta-pill span {
    display: block;
    color: var(--muted);
    font-size: .82rem;
    margin-bottom: 4px;
}
.desktop-meta-pill strong {
    color: #edf3ff;
    font-size: .98rem;
}
.desktop-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.desktop-mini-copy {
    color: var(--muted);
    font-size: .92rem;
}
.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}
.auth-logo svg {
    width: 54px;
    height: 54px;
    fill: var(--primary);
}
.auth-logo h1 { margin: 12px 0 8px; font-size: 2rem; }
.auth-logo p { margin: 0; color: var(--muted); }

.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-weight: 600;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
}
.form-textarea { min-height: 96px; resize: vertical; }

.btn, .action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 18px;
    border: 0;
    border-radius: 14px;
    cursor: pointer;
    transition: .2s ease;
}
.btn:hover, .action-btn:hover { transform: translateY(-1px); }
.btn-primary, .action-btn { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: rgba(255,255,255,0.06); color: white; border: 1px solid var(--line); }
.btn-lg { padding: 14px 22px; }
.btn-sm { padding: 9px 14px; border-radius: 12px; }
.btn-clock { min-width: 220px; min-height: 56px; font-size: 1.05rem; font-weight: 700; }

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 18px;
}
.alert-success { background: rgba(32,210,155,0.12); border: 1px solid rgba(32,210,155,0.24); color: #91f0cd; }
.alert-danger { background: rgba(255,95,109,0.12); border: 1px solid rgba(255,95,109,0.24); color: #ff9aa4; }

.main-wrapper {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px;
    background: rgba(10,12,22,0.92);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.sidebar-brand {
    display: block;
    padding: 16px 18px;
    border-radius: 20px;
    background:
        linear-gradient(135deg, rgba(79,140,255,0.18), rgba(32,210,155,0.08)),
        rgba(255,255,255,0.03);
    border: 1px solid rgba(124, 163, 255, 0.22);
    box-shadow: 0 0 24px rgba(79,140,255,0.14), inset 0 0 0 1px rgba(255,255,255,0.03);
}
.brand-mark {
    width: 48px; height: 48px; border-radius: 16px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary), #76a8ff);
    color: white; font-weight: 800;
}
.sidebar-brand h1 { margin: 0; font-size: 1.1rem; }
.sidebar-brand p { margin: 6px 0 0; color: var(--muted); font-size: .9rem; }
.sidebar-nav { display: grid; gap: 8px; }
.sidebar-nav a, .logout-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    color: var(--muted);
}
.sidebar-nav a.active, .sidebar-nav a:hover, .logout-link:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text);
}
.logout-link { margin-top: auto; display: block; }
.sidebar-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: currentColor;
    opacity: 0.95;
    flex: 0 0 20px;
}
.sidebar-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.main-content { padding: 28px; }
.page-header { margin-bottom: 20px; }
.page-title { margin: 0 0 6px; font-size: 2rem; }
.page-subtitle { margin: 0; color: var(--muted); }
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 14px; left: 14px;
    z-index: 20;
    width: 48px; height: 48px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(23,26,43,0.95);
    color: white;
}
.mobile-menu-btn svg { width: 24px; height: 24px; fill: currentColor; }

.card { padding: 22px; }
.card-header, .topbar, .filter-bar, .quick-actions, .clock-buttons {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
.card-title { margin: 0; font-size: 1.15rem; }
.stats-grid, .grid-2 {
    display: grid;
    gap: 18px;
}
.stats-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.stat-card {
    background: rgba(23,26,43,0.92);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    gap: 14px;
    align-items: center;
}
.stat-icon {
    width: 52px; height: 52px; border-radius: 16px;
    display: grid; place-items: center;
    background: rgba(79,140,255,0.15); color: var(--primary);
}
.stat-icon.success { background: rgba(32,210,155,0.12); color: var(--success); }
.stat-icon.warning { background: rgba(255,184,77,0.14); color: var(--warning); }
.stat-icon.danger { background: rgba(255,95,109,0.14); color: var(--danger); }
.stat-icon svg { width: 26px; height: 26px; fill: currentColor; }
.stat-info h3 { margin: 0; font-size: 1.7rem; }
.stat-info p { margin: 5px 0 0; color: var(--muted); }

.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
th { color: var(--muted); font-size: .88rem; }

.badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.06);
    color: white;
    font-size: .82rem;
}
.badge-success { background: rgba(32,210,155,0.15); color: #89efca; }
.badge-warning { background: rgba(255,184,77,0.15); color: #ffd289; }
.badge-danger { background: rgba(255,95,109,0.15); color: #ffadb5; }
.badge-info { background: rgba(79,140,255,0.15); color: #a8c5ff; }
.badge-glow {
    background: rgba(32,210,155,0.24);
    color: #d8ffef;
    border: 1px solid rgba(124, 255, 212, 0.55);
    box-shadow: 0 0 12px rgba(32,210,155,0.38), 0 0 24px rgba(32,210,155,0.18);
    font-weight: 700;
}
.matrix-table th,
.matrix-table td {
    text-align: center;
}
.matrix-table td:first-child,
.matrix-table th:first-child {
    text-align: left;
}
.matrix-table {
    border-collapse: separate;
    border-spacing: 0;
}
.matrix-cell {
    min-width: 56px;
    height: 56px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(157, 166, 191, 0.18);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}
.matrix-table tbody tr:hover .matrix-cell {
    background: rgba(79,140,255,0.05);
    border-color: rgba(79,140,255,0.24);
}

.time-display {
    text-align: center;
    padding: 26px;
    border-radius: 20px;
    background: var(--panel-2);
    margin-bottom: 22px;
}
.current-time {
    font-size: clamp(2.5rem, 8vw, 4rem);
    color: var(--primary);
    font-weight: 800;
    line-height: 1;
    letter-spacing: .02em;
}
.current-date { color: var(--muted); margin-top: 8px; }
.employee-list {
    max-height: 390px;
    overflow: auto;
    display: grid;
    gap: 10px;
    margin-top: 14px;
    padding-right: 6px;
}
.employee-list::-webkit-scrollbar {
    width: 10px;
}
.employee-list::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.04);
    border-radius: 999px;
}
.employee-list::-webkit-scrollbar-thumb {
    background: rgba(79,140,255,0.45);
    border-radius: 999px;
}
.employee-list::-webkit-scrollbar-thumb:hover {
    background: rgba(79,140,255,0.7);
}
.employee-option {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    cursor: pointer;
}
.employee-option.selected { outline: 2px solid rgba(79,140,255,0.65); }
.employee-option-avatar, .employee-avatar {
    width: 46px; height: 46px; border-radius: 14px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary), #7aaeff);
    color: white; font-weight: 800;
}
.employee-display {
    display: grid;
    justify-items: center;
    gap: 8px;
    margin-bottom: 20px;
}
.employee-name { font-size: 1.35rem; font-weight: 700; }
.employee-id { color: var(--muted); }

.hidden { display: none !important; }
.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 36px 16px;
}
.pagination {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    flex-wrap: wrap;
}
.pagination a {
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.05);
}
.pagination a.active { background: var(--primary); color: white; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 16, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 30;
}
.modal-overlay.active { display: flex; }
.modal {
    width: min(560px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 24px;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
.modal-close {
    width: 42px; height: 42px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,0.05);
    color: white;
}

.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    margin-bottom: 14px;
}
.toggle-label span { display: block; color: var(--muted); margin-top: 4px; font-size: .92rem; }
.toggle {
    position: relative;
    width: 52px;
    height: 30px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: rgba(255,255,255,0.12);
    border-radius: 999px;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    width: 22px; height: 22px;
    left: 4px; top: 4px;
    background: white; border-radius: 50%;
    transition: .2s ease;
}
.toggle input:checked + .toggle-slider { background: rgba(32,210,155,0.6); }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }

.settings-layout {
    display: grid;
    gap: 20px;
}
.settings-card {
    padding: 24px;
}
.settings-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}
.settings-copy {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: .95rem;
}
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 18px;
}
.settings-sound-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}
.sound-card .settings-grid {
    align-items: end;
}
.settings-inline-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    margin-bottom: 0;
}
.settings-note {
    margin-top: 10px;
    color: var(--muted);
    font-size: .92rem;
}
.sound-upload-block {
    margin-top: 6px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.settings-file-note {
    color: var(--muted);
    font-size: .92rem;
    margin-top: -4px;
}
.settings-rule-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.settings-rule-card {
    margin-bottom: 0;
    min-height: 108px;
}
.settings-savebar {
    position: sticky;
    bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-top: 22px;
    padding: 16px 18px;
    border-radius: 22px;
    background:
        linear-gradient(135deg, rgba(79,140,255,0.16), rgba(32,210,155,0.08)),
        rgba(17, 21, 36, 0.92);
    border: 1px solid rgba(124, 163, 255, 0.18);
    box-shadow: 0 18px 38px rgba(0,0,0,0.28);
    backdrop-filter: blur(10px);
}
.settings-savebar-copy {
    display: grid;
    gap: 4px;
}
.settings-savebar-copy strong {
    font-size: 1rem;
    color: #f4f7ff;
}
.settings-savebar-copy span {
    color: var(--muted);
    font-size: .92rem;
}

@media (max-width: 980px) {
    .main-wrapper { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: -290px;
        z-index: 15;
        transition: left .2s ease;
    }
    .sidebar.open { left: 0; }
    .mobile-menu-btn { display: grid; place-items: center; }
    .main-content { padding-top: 74px; }
    .stats-grid, .grid-2 { grid-template-columns: 1fr; }
    .settings-grid, .settings-sound-grid, .settings-rule-grid { grid-template-columns: 1fr; }
    .settings-head { flex-direction: column; align-items: stretch; }
    .settings-savebar { flex-direction: column; align-items: stretch; }
    .agent-card { padding: 22px; }
    .btn-clock { width: 100%; }
    .clock-buttons { display: grid; grid-template-columns: 1fr; }
    .desktop-hero-grid { grid-template-columns: 1fr; }
    .desktop-panel-head { display: block; }
    .desktop-topbar { display: block; }
    .desktop-topbar-actions { margin-top: 14px; justify-content: flex-start; }
    .desktop-time-line { justify-content: center; }
}
