:root {
    --c-primary-50: #EFF6FF;
    --c-primary-100: #DBEAFE;
    --c-primary-200: #BFDBFE;
    --c-primary-300: #93C5FD;
    --c-primary-400: #60A5FA;
    --c-primary-500: #2563EB;
    --c-primary-600: #1D4ED8;
    --c-primary-700: #1E40AF;
    --c-primary-800: #1E3A8A;
    --c-primary-900: #172554;

    --c-gray-50: #F9FAFB;
    --c-gray-100: #F3F4F6;
    --c-gray-200: #E5E7EB;
    --c-gray-300: #D1D5DB;
    --c-gray-400: #9CA3AF;
    --c-gray-500: #6B7280;
    --c-gray-600: #4B5563;
    --c-gray-700: #374151;
    --c-gray-800: #1F2937;
    --c-gray-900: #111827;

    --c-teal-50: #F0FDFA;
    --c-teal-500: #14B8A6;
    --c-teal-700: #0F766E;

    --c-amber-50: #FFFBEB;
    --c-amber-500: #F59E0B;

    --c-violet-50: #F5F3FF;
    --c-violet-500: #8B5CF6;

    --c-success-bg: #ECFDF5;
    --c-success-text: #065F46;
    --c-success-border: #A7F3D0;

    --c-error-bg: #FEF2F2;
    --c-error-text: #991B1B;
    --c-error-border: #FECACA;

    --bg-body: var(--c-gray-50);
    --bg-card: #FFFFFF;
    --text-primary: var(--c-gray-900);
    --text-secondary: var(--c-gray-500);
    --text-muted: var(--c-gray-400);
    --border: var(--c-gray-200);
    --border-focus: var(--c-primary-300);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.03);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.04);

    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 18px;
    --r-2xl: 22px;
    --r-full: 9999px;

    --font: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --fast: 120ms;
    --base: 200ms;
    --slow: 300ms;

    --sidebar-w: 256px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg-body);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Icon === */

.icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    line-height: 1;
}

/* ============================================================
   SIDEBAR LAYOUT (index.php)
   ============================================================ */

body.app {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */

.sidebar {
    width: var(--sidebar-w);
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    background: var(--bg-card);
    border-inline-end: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--r-lg);
    background: linear-gradient(135deg, var(--c-primary-500), var(--c-primary-600));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.3;
}

.sidebar-brand small {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-secondary);
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--r-md);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: 0;
    background: transparent;
    width: 100%;
    text-align: start;
    transition: all var(--fast) var(--ease);
}

.nav-item:hover {
    background: var(--c-gray-100);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--c-primary-50);
    color: var(--c-primary-600);
}

.nav-item .icon {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    flex-shrink: 0;
}

/* --- Sidebar Overlay (mobile) --- */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.open {
    display: block;
}

/* --- Main Content Area --- */

.main {
    flex: 1;
    min-width: 0;
    margin-inline-start: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Header --- */

.header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-start {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
}

.menu-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--r-md);
    padding: 0;
    min-height: auto;
    align-items: center;
    justify-content: center;
    transition: background var(--fast) var(--ease);
}

.menu-toggle:hover {
    background: var(--c-gray-100);
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.header-meta {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.inline-form {
    display: contents;
}

.btn-sm {
    min-height: 36px;
    padding: 0 14px;
    font-size: 12px;
    gap: 6px;
}

.btn-sm:disabled,
button:disabled,
select:disabled {
    opacity: 0.58;
    cursor: not-allowed;
}

/* --- Content --- */

.content {
    flex: 1;
    padding: 24px;
}

/* --- Footer --- */

.footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-card);
}

/* --- Section Panels --- */

.section-panel {
    display: none;
}

.section-panel.active {
    display: block;
}

/* --- Devices --- */

.device-overview {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto;
    align-items: center;
    gap: 24px;
    padding: 18px 20px;
    margin-bottom: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-xs);
}

.device-overview-copy h2 {
    margin-bottom: 3px;
    font-size: 17px;
}

.device-overview-copy p {
    font-size: 12px;
}

.device-summary {
    display: flex;
    align-items: center;
    margin: 0;
}

.device-summary > div {
    min-width: 92px;
    padding: 1px 18px;
    border-inline-start: 1px solid var(--border);
}

.device-summary dt {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 1px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
}

.device-summary dd {
    margin: 0;
    color: var(--text-primary);
    font-size: 19px;
    font-weight: 800;
    line-height: 1.3;
}

.device-summary .is-connected dt,
.device-summary .is-connected dd {
    color: var(--c-success-text);
}

.device-summary .is-disconnected dt,
.device-summary .is-disconnected dd {
    color: var(--c-error-text);
}

.device-sync {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 6px;
}

.device-sync span {
    color: var(--text-secondary);
    font-size: 10px;
    white-space: nowrap;
}

.device-table {
    min-width: 980px;
}

.device-table th:first-child,
.device-table td:first-child {
    width: 110px;
}

.device-name {
    color: var(--text-primary);
    font-weight: 700;
}

.device-code {
    direction: ltr;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.device-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border: 1px solid transparent;
    border-radius: var(--r-full);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.4;
}

.device-status.connected {
    color: var(--c-success-text);
    background: var(--c-success-bg);
    border-color: var(--c-success-border);
}

.device-status.disconnected {
    color: var(--c-error-text);
    background: var(--c-error-bg);
    border-color: var(--c-error-border);
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

h1 {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.3;
}

h2 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
}

p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 13px;
}

/* ============================================================
   STATS CARDS
   ============================================================ */

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--base) var(--ease);
}

.stat-card:hover {
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-info {
    min-width: 0;
}

.stat-info span {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 2px;
    letter-spacing: 0.02em;
}

.stat-info strong {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.3;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   NOTICES
   ============================================================ */

.notice {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: var(--r-md);
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 13px;
    transition: opacity var(--slow) var(--ease),
                transform var(--slow) var(--ease),
                margin var(--slow) var(--ease),
                padding var(--slow) var(--ease);
}

.notice .icon {
    flex-shrink: 0;
}

.notice.is-hiding {
    opacity: 0;
    transform: translateY(-6px);
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

.success {
    background: var(--c-success-bg);
    color: var(--c-success-text);
    border-color: var(--c-success-border);
}

.error {
    background: var(--c-error-bg);
    color: var(--c-error-text);
    border-color: var(--c-error-border);
}

/* ============================================================
   BUTTONS
   ============================================================ */

button,
.button-link,
.portal-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    border: 0;
    border-radius: var(--r-md);
    padding: 0 18px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--base) var(--ease),
                box-shadow var(--base) var(--ease),
                transform var(--base) var(--ease);
}

.primary,
.search button {
    background: var(--c-primary-500);
    color: white;
}

.primary:hover,
.search button:hover {
    background: var(--c-primary-600);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
    transform: translateY(-1px);
}

.secondary {
    background: var(--c-gray-700);
    color: white;
}

.secondary:hover {
    background: var(--c-gray-800);
    box-shadow: 0 4px 14px rgba(55, 65, 81, 0.25);
    transform: translateY(-1px);
}

.danger {
    background: #DC2626;
    color: white;
}

.danger:hover {
    background: #B91C1C;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25);
    transform: translateY(-1px);
}

.button-link {
    background: var(--c-gray-700);
    color: white;
}

.button-link:hover {
    background: var(--c-gray-800);
}

.portal-link {
    display: inline-flex;
    margin-top: 12px;
    min-height: 38px;
    background: var(--c-primary-50);
    color: var(--c-primary-700);
    border: 1px solid var(--c-primary-200);
}

.portal-link:hover {
    background: var(--c-primary-100);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* ============================================================
   ACTIONS
   ============================================================ */

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ============================================================
   SEARCH
   ============================================================ */

.search {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.search input {
    flex: 1;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 0 14px;
    font-family: var(--font);
    font-size: 13px;
    background: var(--bg-card);
    outline: none;
    transition: border-color var(--fast) var(--ease),
                box-shadow var(--fast) var(--ease);
}

.search input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border-radius: var(--r-md);
    padding: 0 14px;
    background: var(--c-gray-100);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    border: 1px solid var(--border);
    transition: background var(--fast) var(--ease);
}

.search a:hover {
    background: var(--c-gray-200);
}

/* ============================================================
   TABLES
   ============================================================ */

.table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    overflow: auto;
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

th,
td {
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-size: 13px;
}

th {
    background: var(--c-gray-50);
    color: var(--c-gray-700);
    font-weight: 700;
    font-size: 12px;
}

.sort-button {
    width: 100%;
    min-height: auto;
    padding: 0;
    background: transparent;
    color: inherit;
    justify-content: flex-start;
    box-shadow: none;
    transform: none;
    border-radius: 0;
    font-size: 12px;
}

.sort-button[data-table="employees"]::after {
    display: none;
}

.sidebar-header { gap: 8px; padding-inline: 14px; }
.sidebar-brand { flex: 1; min-width: 0; }
.sidebar-collapse {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 30px;
    width: 30px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: var(--c-gray-100);
    color: var(--text-secondary);
    cursor: pointer;
}
.sidebar-collapse:focus-visible { outline: 2px solid var(--c-primary-500); outline-offset: 2px; }
@media (min-width: 901px) {
    html.sidebar-collapsed { --sidebar-w: 76px; }
    .sidebar-collapsed .sidebar-brand,
    .sidebar-collapsed .sidebar-logo,
    .sidebar-collapsed .sidebar-nav .nav-item span,
    .sidebar-collapsed .sidebar-footer > span { display: none; }
    .sidebar-collapsed .sidebar-header { justify-content: center; min-height: 81px; box-sizing: border-box; }
    .sidebar-collapsed .sidebar-collapse svg { transform: rotate(180deg); }
    .sidebar-collapsed .sidebar-nav { padding-inline: 10px; }
    .sidebar-collapsed .nav-item { justify-content: center; padding-inline: 0; }
    .sidebar-collapsed .sidebar-footer { padding-inline: 8px; justify-content: center !important; }
}
@media (max-width: 900px) {
    .sidebar-collapse { display: none; }
}

.sort-button[data-table="employees"].column-filtered {
    color: var(--c-primary-600);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.employee-column-menu {
    position: fixed;
    inset: auto;
    margin: 0;
    width: 300px;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    box-sizing: border-box;
    overflow: auto;
    z-index: 2000;
    padding: 16px;
    border: 1px solid var(--border-color, #dce2eb);
    border-radius: 12px;
    background: var(--bg-card, #fff);
    color: var(--text-primary);
    box-shadow: 0 12px 36px #18223826;
    font: inherit;
}

.column-sort-actions, .column-filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.employee-column-menu button { padding: 7px 10px; font-size: 12px; }
.column-filter-body { margin-top: 12px; }
.column-filter-body label { display: flex; align-items: center; gap: 8px; padding: 7px 0; overflow-wrap: anywhere; }
.column-filter-body label[hidden] { display: none; }
.column-filter-body input[type="checkbox"] { width: 16px; height: 16px; flex: 0 0 16px; }
.column-filter-body input[type="search"], .column-filter-body input[type="date"] { width: 100%; min-width: 0; }
.column-filter-options { max-height: 220px; overflow-y: auto; }
.column-filter-error { color: #c53030; font-size: 12px; }

.sort-button:hover {
    background: transparent;
    box-shadow: none;
    transform: none;
    color: var(--c-primary-600);
}

.sort-button::after {
    content: "\2195";
    margin-inline-start: 6px;
    color: var(--text-muted);
    font-size: 11px;
}

.sort-button.active[data-direction="asc"]::after {
    content: "\2191";
    color: var(--c-primary-500);
}

.sort-button.active[data-direction="desc"]::after {
    content: "\2193";
    color: var(--c-primary-500);
}

tbody tr {
    transition: background var(--fast) var(--ease);
}

tbody tr:hover {
    background: var(--c-primary-50);
}

tr:last-child td {
    border-bottom: 0;
}

/* Inline filters */

.inline-filters th {
    background: var(--c-gray-100);
    padding: 10px;
}

.inline-filters input,
.inline-filters select,
.clear-filters {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0 10px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-card);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--fast) var(--ease),
                box-shadow var(--fast) var(--ease);
}

.inline-filters input:focus,
.inline-filters select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.clear-filters {
    background: var(--c-gray-100);
    color: var(--text-primary);
    border-color: var(--c-gray-200);
    cursor: pointer;
    transition: background var(--fast) var(--ease);
}

.clear-filters:hover {
    background: var(--c-gray-200);
}

/* Numeric columns */

td:nth-child(9),
td:nth-child(8),
td:nth-child(7),
td:nth-child(6) {
    font-variant-numeric: tabular-nums;
    direction: ltr;
    text-align: right;
}

/* Empty state */

.empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 28px;
    font-size: 13px;
}

/* ============================================================
   SETTINGS PANEL
   ============================================================ */

.settings-panel {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-xs);
}

.settings-copy h2 {
    margin: 0 0 6px;
    font-size: 18px;
}

.settings-copy p {
    font-size: 13px;
}

/* ============================================================
   FORMS
   ============================================================ */

.night-shift-form {
    display: flex;
    gap: 10px;
    min-width: min(480px, 100%);
}

.night-shift-form select,
.night-shift-form input[type="file"],
.account-form select,
.account-form input,
.employee-login-form input {
    flex: 1;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 0 12px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-card);
    outline: none;
    transition: border-color var(--fast) var(--ease),
                box-shadow var(--fast) var(--ease);
}

.night-shift-form select:focus,
.night-shift-form input[type="file"]:focus,
.account-form select:focus,
.account-form input:focus,
.employee-login-form input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.employee-create-panel {
    margin-bottom: 14px;
}

.employee-create-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.employee-create-error {
    font-size: 12px;
    font-weight: 700;
    color: var(--c-red-600);
}

.employee-create-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 16px;
    box-shadow: var(--shadow-xs);
}

.employee-create-form[hidden] {
    display: none;
}

.employee-create-form label {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.employee-create-form label span {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-secondary);
}

.employee-create-form label small {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    min-height: 16px;
}

.employee-create-form label small.is-error {
    color: var(--c-red-600);
}

.employee-create-form input,
.employee-create-form select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 0 12px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-card);
    outline: none;
    transition: border-color var(--fast) var(--ease),
                box-shadow var(--fast) var(--ease);
}

.employee-create-form input[type="file"] {
    padding: 8px 12px;
}

.employee-create-form input:focus,
.employee-create-form select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.employee-create-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    grid-column: span 2;
}

.employee-photo-action {
    direction: ltr;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    min-width: 92px;
}

.employee-photo-trigger {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: var(--r-md);
    padding: 0;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.employee-photo-trigger:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.18);
    outline-offset: 2px;
}

.employee-photo-thumb,
.employee-photo-placeholder {
    width: 42px;
    height: 42px;
    border-radius: var(--r-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.employee-photo-thumb {
    object-fit: cover;
    border: 1px solid var(--border);
    background: var(--c-gray-100);
}

.employee-photo-placeholder {
    color: oklch(55% 0.15 145);
    background: var(--c-gray-100);
    border: 1px dashed var(--c-gray-300);
}

.employee-photo-trigger:hover .employee-photo-thumb,
.employee-photo-trigger:hover .employee-photo-placeholder {
    border-color: var(--border-focus);
}

.employee-photo-modal-card {
    width: var(--employee-photo-modal-width, fit-content);
    max-width: calc(100vw - 28px);
    max-height: 92dvh;
    border-radius: var(--r-lg);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    display: grid;
    grid-template-rows: minmax(240px, 1fr) auto;
}

.employee-photo-close {
    position: absolute;
    inset-block-start: 12px;
    inset-inline-start: 12px;
    z-index: 2;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: var(--r-md);
    background: oklch(98% 0.006 255 / 0.92);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.employee-photo-stage {
    min-height: 280px;
    background: oklch(96% 0.006 255);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    overflow: hidden;
}

.employee-photo-stage img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.employee-photo-empty {
    width: min(46vw, 220px);
    aspect-ratio: 1;
    border-radius: var(--r-lg);
    border: 1px dashed var(--c-gray-300);
    color: oklch(55% 0.15 145);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
}

.employee-photo-empty[hidden],
.photo-tool-button[hidden],
#employee-photo-large[hidden] {
    display: none !important;
}

.employee-photo-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 18px;
    border-top: 1px solid var(--border);
}

.employee-photo-details {
    min-width: min(440px, calc(100vw - 28px));
}

.employee-photo-footer h3 {
    margin: 0 0 4px;
    font-size: 16px;
}

.employee-photo-footer p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
}

.employee-photo-tools,
.employee-photo-modal-upload {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.photo-tool-button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.photo-tool-button:hover {
    border-color: var(--border-focus);
    color: var(--text-primary);
}

.photo-tool-add {
    color: oklch(55% 0.15 145);
}

.photo-tool-delete {
    color: var(--c-error-text);
    border-color: var(--c-error-border);
    background: var(--c-error-bg);
}

.employee-photo-data-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 18px 18px;
}

.employee-photo-data-form label {
    display: grid;
    gap: 6px;
    text-align: right;
}

.employee-photo-data-form label:first-of-type {
    grid-column: 1 / -1;
}

.employee-photo-data-form label span {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.employee-photo-data-form input,
.employee-photo-data-form select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 0 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    outline: none;
}

.employee-photo-data-form input:focus,
.employee-photo-data-form select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.employee-photo-data-form input:disabled,
.employee-photo-data-form select:disabled {
    cursor: wait;
    opacity: 0.65;
}

.employee-photo-form-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.employee-photo-form-status {
    min-height: 20px;
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

.employee-photo-form-status.is-error {
    color: var(--c-error-text);
}

.employee-photo-form-status.is-success {
    color: oklch(45% 0.14 145);
}

@media (max-width: 640px) {
    .employee-photo-modal-card {
        max-width: calc(100vw - 12px);
        max-height: calc(100dvh - 12px);
        border-radius: var(--r-lg);
        grid-template-rows: 1fr auto;
    }

    .employee-photo-stage {
        min-height: 0;
        padding: 14px;
    }

    .employee-photo-stage img {
        max-height: 34dvh;
    }

    .employee-photo-footer {
        padding: 14px;
    }

    .employee-photo-details {
        min-width: 0;
    }

    .employee-photo-data-form {
        grid-template-columns: 1fr;
        padding: 0 14px 14px;
    }

    .employee-photo-data-form label,
    .employee-photo-data-form label:first-of-type,
    .employee-photo-form-actions {
        grid-column: 1;
    }
}

.employee-enroll-button {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: var(--r-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: oklch(98% 0.006 145);
    background: oklch(58% 0.17 145);
    box-shadow: 0 6px 14px rgba(22, 163, 74, 0.2);
    cursor: pointer;
    transition: background-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.employee-enroll-button:hover {
    background: oklch(52% 0.17 145);
    box-shadow: 0 8px 18px rgba(22, 163, 74, 0.26);
}

.employee-enroll-button:focus-visible {
    outline: 3px solid rgba(34, 197, 94, 0.25);
    outline-offset: 2px;
}

.employee-enroll-button:active {
    transform: translateY(1px);
    box-shadow: 0 4px 10px rgba(22, 163, 74, 0.2);
}

.account-form {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr auto;
    gap: 10px;
    min-width: min(780px, 100%);
}

/* Inline action (delete) */

.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.inline-action {
    margin: 0;
}

.inline-action button {
    min-height: 32px;
    background: var(--c-error-bg);
    color: var(--c-error-text);
    border: 1px solid var(--c-error-border);
    font-size: 12px;
    padding: 0 12px;
    gap: 6px;
}

.inline-action button:hover {
    background: #FEE2E2;
    box-shadow: none;
    transform: none;
}

.edit-admin-user {
    min-height: 32px;
    background: var(--c-primary-50);
    color: var(--c-primary-700);
    border: 1px solid var(--c-primary-200);
    font-size: 12px;
    padding: 0 10px;
}

.edit-admin-user:hover {
    background: var(--c-primary-100);
    box-shadow: none;
    transform: none;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

body.login-body {
    display: block;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #EBF4FF 0%, var(--c-gray-100) 50%, #F0FDFA 100%);
    position: relative;
}

.login-page::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 20%, rgba(37, 99, 235, 0.06) 0%, transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(20, 184, 166, 0.06) 0%, transparent 50%);
    pointer-events: none;
}

.login-card {
    width: min(420px, 100%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-xl);
    padding: 40px 32px;
    text-align: center;
    position: relative;
}

.login-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: var(--r-lg);
    background: linear-gradient(135deg, var(--c-primary-50), var(--c-primary-100));
    color: var(--c-primary-500);
    margin-bottom: 20px;
}

.login-card h1 {
    font-size: 22px;
    margin-bottom: 8px;
}

.login-card > p {
    margin-bottom: 0;
    font-size: 13px;
}

.login-card .notice {
    text-align: right;
    justify-content: flex-start;
}

.employee-login-form {
    display: grid;
    gap: 14px;
    margin-top: 24px;
}

.employee-login-form label {
    display: grid;
    gap: 6px;
    text-align: right;
}

.employee-login-form label span {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
}

.employee-login-form .primary {
    margin-top: 4px;
    min-height: 44px;
    font-size: 14px;
    font-weight: 800;
}

/* ============================================================
   PORTAL PAGE (standalone, no sidebar)
   ============================================================ */

body.portal-body {
    display: block;
}

.page {
    width: min(1400px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.portal-header {
    display: flex;
    align-items: center;
    gap: 14px;
}

.portal-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--r-full);
    background: var(--c-primary-50);
    color: var(--c-primary-500);
    flex-shrink: 0;
}

/* ============================================================
   CONFIRMATION MODAL
   ============================================================ */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    place-items: center;
}

.modal-overlay.open {
    display: grid;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-xl);
    padding: 28px;
    width: min(400px, calc(100% - 32px));
    text-align: center;
    animation: modalIn 0.2s var(--ease);
}

.salary-modal-card {
    width: min(720px, calc(100% - 32px));
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 24px;
}

.attendance-modal-card {
    width: min(420px, calc(100% - 32px));
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.attendance-history-modal-card {
    width: min(720px, calc(100% - 32px));
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.attendance-time-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: var(--r-full);
    background: var(--c-error-bg);
    color: var(--c-error-text);
    margin-bottom: 16px;
}

.modal-card h3 {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 800;
    color: var(--text-primary);
}

.modal-card p {
    font-size: 13px;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-actions .btn-cancel {
    flex: 1;
    background: var(--c-gray-100);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.modal-actions .btn-cancel:hover {
    background: var(--c-gray-200);
}

.modal-actions .btn-danger {
    flex: 1;
    background: #DC2626;
    color: white;
}

.modal-actions .btn-danger:hover {
    background: #B91C1C;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.3);
    transform: translateY(-1px);
}

.modal-actions .btn-primary {
    flex: 1;
    background: var(--c-primary-500);
    color: white;
}

.modal-actions .btn-primary:hover {
    background: var(--c-primary-600);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
    transform: translateY(-1px);
}

/* ============================================================
   PAGINATION
   ============================================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}

.pagination-buttons {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.btn-page {
    min-height: 34px;
    min-width: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--fast) var(--ease);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-page:hover {
    background: var(--c-gray-100);
    border-color: var(--c-gray-300);
}

.btn-page.active {
    background: var(--c-primary-500);
    color: white;
    border-color: var(--c-primary-500);
}

.btn-page.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================================
   SETTINGS SECTION (admin password)
   ============================================================ */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 20px;
    box-shadow: var(--shadow-xs);
}

.settings-card h3 {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 700;
}

.settings-card p {
    margin-bottom: 16px;
}

.danger-zone {
    border-color: #FECACA;
    background: #FEF2F2;
}

.danger-zone h3 {
    color: #991B1B;
}

.danger-zone p {
    color: #7F1D1D;
}

.settings-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.settings-form label {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}

.settings-form label span {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.settings-form input,
.settings-form select {
    flex: 1;
    min-width: 140px;
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 0 12px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-card);
    outline: none;
    transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.settings-form select {
    cursor: pointer;
}

.settings-form input:focus,
.settings-form select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.settings-form .primary {
    align-self: flex-end;
    min-height: 40px;
}

.settings-form .settings-cancel {
    align-self: flex-end;
    min-height: 40px;
}

/* Sticky table header */

.table-wrap-sticky {
    max-height: 70vh;
}

.table-wrap-sticky thead th {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: var(--shadow-xl);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main {
        margin-inline-start: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .employee-create-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .header {
        padding: 12px 16px;
        flex-wrap: wrap;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .header-meta {
        display: none;
    }

    .content {
        padding: 16px;
    }

    .device-overview {
        grid-template-columns: 1fr auto;
    }

    .device-sync {
        grid-column: 1 / -1;
        align-items: center;
        flex-direction: row;
        justify-content: space-between;
        padding-top: 12px;
        border-top: 1px solid var(--border);
    }
}

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

    .settings-panel,
    .night-shift-form,
    .account-form {
        flex-direction: column;
        align-items: stretch;
    }

    .account-form {
        display: flex;
    }

    .search {
        flex-direction: column;
    }

    .employee-create-form {
        grid-template-columns: 1fr;
    }

    .employee-create-actions {
        grid-column: auto;
        flex-direction: column;
        align-items: stretch;
    }

    .header-title {
        font-size: 15px;
    }

    .btn-sm {
        font-size: 11px;
        padding: 0 10px;
        min-height: 34px;
    }

    .content {
        padding: 12px;
    }

    .device-overview {
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 16px;
    }

    .device-summary {
        justify-content: space-between;
    }

    .device-summary > div {
        min-width: 0;
        flex: 1;
        padding-inline: 10px;
    }

    .device-summary > div:first-child {
        padding-inline-start: 0;
        border-inline-start: 0;
    }

    .device-sync {
        grid-column: auto;
        align-items: stretch;
        flex-direction: column;
    }

    .device-sync .btn-sm {
        width: 100%;
    }

    .salary-modal-card {
        width: min(460px, calc(100% - 20px));
        padding: 18px;
    }

    #salary-form,
    .late-rule-editor {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 901px) and (max-width: 1200px) {
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   Payroll Styles
   ============================================================ */

#payroll-table .net-salary {
    font-weight: 800;
    color: var(--c-primary-500, #2563EB);
    background: var(--c-primary-50, #eff6ff);
    white-space: nowrap;
}

.employee-picker {
    width: min(460px, calc(100vw - 32px));
    max-height: 85vh;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
}
.employee-picker::backdrop { background: rgba(15, 23, 42, .45); }
.employee-picker input[type="search"] { width: 100%; padding: 10px; font: inherit; margin-bottom: 12px; }
.employee-picker-list { max-height: 45vh; overflow-y: auto; margin-block: 12px; }
.employee-picker-option { display: flex; align-items: center; gap: 10px; padding: 10px 4px; cursor: pointer; }
.employee-picker-option[hidden] { display: none; }
.employee-picker-option input[type="checkbox"] { width: 18px; height: 18px; flex-shrink: 0; accent-color: #2563eb; }

#payroll-table {
    --payroll-cell-font-size: 11.5px;
    --payroll-head-font-size: 11px;
    min-width: 1124px;
    table-layout: fixed;
}

#payroll-table th,
#payroll-table td {
    padding: 8px 7px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.35;
    font-size: var(--payroll-cell-font-size);
}

#payroll-table th {
    font-size: var(--payroll-head-font-size);
}

#payroll-table .sort-button {
    align-items: flex-start;
    white-space: normal;
    line-height: 1.35;
    font-size: var(--payroll-head-font-size);
}

#payroll-table th:nth-child(1),
#payroll-table td:nth-child(1),
#payroll-table th:nth-child(7),
#payroll-table td:nth-child(7),
#payroll-table th:nth-child(8),
#payroll-table td:nth-child(8),
#payroll-table th:nth-child(14),
#payroll-table td:nth-child(14) {
    width: 62px;
}

#payroll-table th:nth-child(2),
#payroll-table td:nth-child(2),
#payroll-table th:nth-child(3),
#payroll-table td:nth-child(3),
#payroll-table th:nth-child(4),
#payroll-table td:nth-child(4) {
    width: 112px;
}

#payroll-table th:nth-child(5),
#payroll-table td:nth-child(5),
#payroll-table th:nth-child(6),
#payroll-table td:nth-child(6) {
    width: 90px;
}

#payroll-table th:nth-child(n+9):nth-child(-n+13),
#payroll-table td:nth-child(n+9):nth-child(-n+13) {
    width: 72px;
}

@media (max-width: 900px) {
    #payroll-table {
        --payroll-cell-font-size: 10.5px;
        --payroll-head-font-size: 10px;
    }
}

#payroll-table .row-absent td {
    color: var(--text-muted, #94a3b8);
    background: rgba(148, 163, 184, 0.06);
}

#payroll-table .row-absent .net-salary {
    color: var(--c-danger-500, #ef4444);
    background: rgba(239, 68, 68, 0.08);
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
}

.badge-success {
    background: var(--c-teal-50, #f0fdfa);
    color: var(--c-teal-500, #14b8a6);
}

.badge-info {
    background: var(--c-primary-50, #eff6ff);
    color: var(--c-primary-500, #2563EB);
    margin-inline-start: 6px;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--c-danger-500, #ef4444);
}

.row-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--r-md, 8px);
    background: var(--bg-card, #fff);
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-icon:hover {
    border-color: var(--c-primary-500, #2563EB);
    color: var(--c-primary-500, #2563EB);
    background: var(--c-primary-50, #eff6ff);
}

.attendance-time-cell .btn-edit-attendance-time,
.attendance-time-cell .attendance-override-badge {
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 0;
    padding: 1px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--c-teal-500, #14B8A6);
    box-shadow: none;
    opacity: 0.9;
}

.attendance-time-cell .btn-edit-attendance-time svg,
.attendance-time-cell .attendance-override-badge svg {
    width: 13px;
    height: 13px;
}

.attendance-time-cell .btn-edit-attendance-time:hover,
.attendance-time-cell .attendance-override-badge:hover {
    border: 0;
    background: transparent;
    color: var(--c-teal-700, #0F766E);
    opacity: 1;
    transform: none;
}

.sort-button.primary-sort {
    background: var(--c-primary-50, #eff6ff);
    color: var(--c-primary-500, #2563EB);
}

/* Form rows inside modals */
.form-row {
    display: flex;
    gap: 12px;
}

.form-row label {
    flex: 1;
}

#salary-form label,
#attendance-form label,
#deduction-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: right;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 13px;
}

#salary-form input,
#attendance-form input,
#deduction-form input {
    min-height: 42px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--r-md, 8px);
    padding: 0 12px;
    font: inherit;
    background: var(--bg-card, #fff);
}

.attendance-history {
    border-top: 1px solid var(--border);
    margin-top: 14px;
    padding-top: 12px;
}

.attendance-history h4 {
    margin: 0 0 8px;
    font-size: 14px;
}

.attendance-history table {
    min-width: auto;
    margin: 0 0 14px;
}

.attendance-history th,
.attendance-history td {
    padding: 9px 10px;
    font-size: 12px;
}

#salary-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 14px;
    text-align: right;
}

#salary-form > input[type="hidden"] {
    display: none;
}

#salary-form > .form-row {
    display: contents;
}

#salary-form label {
    margin-bottom: 0;
}

#salary-form .salary-check,
#salary-form .salary-late-rules,
#salary-form .modal-actions {
    grid-column: 1 / -1;
}

#salary-form .salary-check {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 2px 0;
}

#salary-form .salary-check input {
    min-height: auto;
}

.salary-late-rules {
    border-top: 1px solid var(--border);
    margin-top: 2px;
    padding-top: 12px;
}

.salary-late-rules h4 {
    margin: 0 0 8px;
    font-size: 14px;
    text-align: center;
}

.salary-late-rules table {
    min-width: auto;
    margin: 0 0 10px;
}

.salary-late-rules th,
.salary-late-rules td {
    padding: 9px 10px;
}

.late-rule-editor {
    display: grid;
    grid-template-columns: 110px 120px minmax(180px, 1fr) auto;
    gap: 8px;
    align-items: end;
}

.late-rule-editor label {
    margin-bottom: 0;
    font-size: 12px;
}

.late-rule-editor button {
    min-height: 38px;
}

.btn-primary {
    background: var(--c-primary-500, #2563EB);
    color: #fff;
    border: none;
    border-radius: var(--r-md, 8px);
    padding: 0 18px;
    min-height: 40px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary:hover {
    background: var(--c-primary-600, #1d4ed8);
}

/* Late penalty / repeat penalty highlight */
#payroll-table .penalty-cell {
    font-weight: 700;
    color: var(--c-danger-500, #ef4444);
    background: rgba(239, 68, 68, 0.08);
    white-space: nowrap;
}
