/* ==========================================================================
   TurniX Design System
   Tokens, layout primitives and reusable components for the SaaS UI.
   ========================================================================== */

/* 01. Global tokens */
:root {
    color-scheme: light;
    font-family: Inter, Segoe UI, Arial, sans-serif;

    --color-primary-50: #eff6ff;
    --color-primary-100: #dbeafe;
    --color-primary-500: #2563eb;
    --color-primary-600: #1d4ed8;
    --color-primary-700: #1e40af;
    --color-secondary-50: #ecfdf5;
    --color-secondary-500: #0f9f8c;
    --color-secondary-600: #0f766e;
    --color-success-50: #ecfdf5;
    --color-success-600: #16a34a;
    --color-warning-50: #fffbeb;
    --color-warning-600: #d97706;
    --color-danger-50: #fff1f2;
    --color-danger-600: #e11d48;
    --color-info-50: #eef2ff;
    --color-info-600: #4f46e5;

    --color-bg: #f4f7fb;
    --color-bg-strong: #eaf1f8;
    --color-surface: #ffffff;
    --color-surface-raised: rgba(255, 255, 255, 0.92);
    --color-surface-soft: #f8fafc;
    --color-border: #e2e8f0;
    --color-border-strong: #cbd5e1;
    --color-text: #121826;
    --color-text-soft: #334155;
    --color-text-muted: #64748b;
    --color-text-inverse: #ffffff;
    --color-sidebar: #101827;
    --color-sidebar-soft: #172033;

    --gradient-brand: linear-gradient(135deg, var(--color-primary-500), var(--color-secondary-500));
    --gradient-surface: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.92));
    --gradient-page: linear-gradient(135deg, rgba(37, 99, 235, 0.10), transparent 32%), linear-gradient(315deg, rgba(15, 159, 140, 0.10), transparent 30%);

    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 8px;
    --radius-pill: 999px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-sm: 0 8px 22px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 18px 42px rgba(15, 23, 42, 0.11);
    --shadow-lg: 0 28px 80px rgba(15, 23, 42, 0.16);
    --shadow-focus: 0 0 0 4px rgba(37, 99, 235, 0.14);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 28px;
    --space-8: 32px;
    --space-9: 36px;
    --space-10: 40px;

    --font-size-xs: 12px;
    --font-size-sm: 13px;
    --font-size-md: 15px;
    --font-size-lg: 17px;
    --font-size-xl: 24px;
    --font-size-2xl: 32px;

    --line-height-tight: 1.15;
    --line-height-normal: 1.5;

    --transition-fast: 140ms ease;
    --transition-base: 180ms ease;
    --transition-slow: 240ms ease;

    --z-sidebar: 30;
    --z-topbar: 20;
    --z-backdrop: 25;
    --z-modal: 60;
    --z-toast: 70;

    --content-max: 1180px;
    --sidebar-width: 272px;
    --sidebar-collapsed: 84px;
}

/* 02. Base reset and accessibility */
* {
    box-sizing: border-box;
}

html {
    background: var(--color-bg);
}

body {
    color: var(--color-text);
    font-size: var(--font-size-md);
    line-height: var(--line-height-normal);
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

a,
button,
input,
select,
textarea {
    transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast), transform var(--transition-fast);
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: var(--color-primary-600);
}

a:hover {
    color: var(--color-secondary-600);
}

:focus-visible {
    outline: 0;
    box-shadow: var(--shadow-focus);
}

.skip-link {
    background: var(--color-text);
    border-radius: var(--radius-md);
    color: var(--color-text-inverse);
    left: var(--space-4);
    padding: var(--space-3) var(--space-4);
    position: fixed;
    top: var(--space-4);
    transform: translateY(-140%);
    z-index: var(--z-toast);
}

.skip-link:focus {
    transform: translateY(0);
}

/* 03. Public layout */
.layout-public {
    background:
        radial-gradient(circle at 16% 18%, rgba(37, 99, 235, 0.22), transparent 30%),
        radial-gradient(circle at 86% 76%, rgba(15, 159, 140, 0.20), transparent 30%),
        linear-gradient(135deg, #f8fbff 0%, #edf4fb 46%, #f6fbf9 100%);
    overflow-x: hidden;
    position: relative;
}

.public-bg {
    background:
        linear-gradient(115deg, rgba(255, 255, 255, 0.22), transparent 42%),
        linear-gradient(90deg, rgba(37, 99, 235, 0.06), rgba(15, 159, 140, 0.05));
    inset: 0;
    pointer-events: none;
    position: fixed;
}

.public-shell {
    align-items: center;
    display: grid;
    min-height: 100vh;
    padding: var(--space-9) var(--space-4);
    position: relative;
}

/* 04. Authenticated app shell */
.layout-auth {
    background: var(--gradient-page), var(--color-bg);
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns var(--transition-base);
}

.sidebar-collapsed .app-shell {
    grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
}

.app-content {
    min-width: 0;
}

.app-main {
    display: grid;
    gap: var(--space-6);
    padding: var(--space-8);
}

/* 05. Sidebar and topbar */
.app-sidebar {
    background:
        linear-gradient(180deg, rgba(37, 99, 235, 0.24), transparent 36%),
        linear-gradient(0deg, rgba(15, 159, 140, 0.16), transparent 28%),
        var(--color-sidebar);
    border-right: 1px solid rgba(255, 255, 255, 0.10);
    color: var(--color-text-inverse);
    height: 100vh;
    overflow: hidden;
    padding: var(--space-6) 18px;
    position: sticky;
    top: 0;
    transition: transform var(--transition-base), padding var(--transition-base);
    z-index: var(--z-sidebar);
}

.brand {
    align-items: center;
    color: var(--color-text-inverse);
    display: flex;
    gap: var(--space-3);
    min-height: 44px;
    text-decoration: none;
}

.brand:hover {
    color: var(--color-text-inverse);
}

.brand-mark {
    align-items: center;
    background: var(--gradient-brand);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 35px rgba(37, 99, 235, 0.30);
    color: var(--color-text-inverse);
    display: inline-flex;
    flex: 0 0 44px;
    font-weight: 800;
    height: 44px;
    justify-content: center;
    width: 44px;
}

.brand-mark-image {
    background: transparent;
    overflow: hidden;
    padding: 0;
}

.brand-mark-image img {
    display: block;
    height: 100%;
    width: 100%;
}

.brand-copy,
.side-label {
    opacity: 1;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.brand strong {
    display: block;
    font-size: 18px;
    letter-spacing: 0;
}

.brand small {
    color: rgba(255, 255, 255, 0.66);
    display: block;
    font-size: var(--font-size-xs);
    margin-top: 2px;
}

.side-nav {
    display: grid;
    gap: var(--space-2);
    margin-top: var(--space-8);
}

.nav-item,
.side-nav a {
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: var(--radius-md);
    color: rgba(255, 255, 255, 0.86);
    display: flex;
    gap: 10px;
    min-height: 46px;
    padding: var(--space-3) 13px;
    position: relative;
    text-decoration: none;
}

.nav-item:hover,
.side-nav a:hover {
    background: rgba(255, 255, 255, 0.09);
    color: var(--color-text-inverse);
    transform: translateX(2px);
}

.side-icon {
    align-items: center;
    background: rgba(255, 255, 255, 0.10);
    border-radius: var(--radius-md);
    display: inline-flex;
    flex: 0 0 28px;
    font-size: var(--font-size-sm);
    font-weight: 800;
    height: 28px;
    justify-content: center;
    width: 28px;
}

.sidebar-collapsed .app-sidebar {
    padding-left: var(--space-5);
    padding-right: var(--space-5);
}

.sidebar-collapsed .brand-copy,
.sidebar-collapsed .side-label {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    transform: translateX(-6px);
}

.sidebar-collapsed .side-nav a {
    justify-content: center;
    padding: 10px 0;
}

.app-header {
    align-items: center;
    backdrop-filter: blur(18px);
    background: rgba(244, 247, 251, 0.84);
    border-bottom: 1px solid rgba(226, 232, 240, 0.88);
    display: flex;
    gap: var(--space-5);
    justify-content: space-between;
    padding: 20px var(--space-8);
    position: sticky;
    top: 0;
    z-index: var(--z-topbar);
}

.header-title {
    align-items: center;
    display: flex;
    gap: var(--space-4);
    min-width: 0;
}

.app-header h1 {
    font-size: 26px;
    letter-spacing: 0;
    line-height: var(--line-height-tight);
    margin: 0;
}

.app-nav,
.app-nav form {
    align-items: center;
    display: flex;
    gap: var(--space-2);
    margin: 0;
}

.app-nav {
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}

.user-summary {
    align-items: center;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(226, 232, 240, 0.92);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    display: inline-flex;
    gap: var(--space-3);
    max-width: 360px;
    min-height: 42px;
    min-width: 0;
    padding: 7px 11px;
}

.user-avatar {
    align-items: center;
    background: var(--gradient-brand);
    border-radius: var(--radius-md);
    color: var(--color-text-inverse);
    display: inline-flex;
    flex: 0 0 30px;
    font-size: var(--font-size-xs);
    font-weight: 800;
    height: 30px;
    justify-content: center;
    width: 30px;
}

.user-meta {
    display: grid;
    gap: 1px;
    min-width: 0;
}

.user-meta strong,
.user-meta small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-meta strong {
    color: var(--color-text);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-tight);
}

.user-meta small {
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
}

.identity-greeting {
    background:
        linear-gradient(135deg, rgba(37, 99, 235, 0.10), rgba(15, 159, 140, 0.08)),
        rgba(255, 255, 255, 0.76);
    border: 1px solid rgba(226, 232, 240, 0.92);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    padding: var(--space-5);
}

.identity-greeting h1 {
    margin-top: var(--space-1);
}

.sidebar-toggle {
    align-items: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 42px;
    flex-direction: column;
    gap: 4px;
    height: 42px;
    justify-content: center;
    padding: 0;
    width: 42px;
}

.sidebar-toggle span {
    background: var(--color-text-soft);
    border-radius: var(--radius-pill);
    display: block;
    height: 2px;
    width: 18px;
}

.sidebar-toggle:hover {
    border-color: rgba(37, 99, 235, 0.36);
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.14);
    transform: translateY(-1px);
}

.sidebar-backdrop {
    background: rgba(15, 23, 42, 0.42);
    inset: 0;
    opacity: 0;
    pointer-events: none;
    position: fixed;
    transition: opacity var(--transition-base);
    z-index: var(--z-backdrop);
}

/* 06. Page structure */
.page-header,
.page-head {
    align-items: center;
    display: flex;
    gap: var(--space-4);
    justify-content: space-between;
    max-width: var(--content-max);
}

.page-header h1,
.page-header h2,
.page-head h1,
.page-head h2 {
    font-size: var(--font-size-xl);
    letter-spacing: 0;
    line-height: 1.2;
    margin: 0;
}

.page-header p,
.page-head p,
.section-header p {
    color: var(--color-text-muted);
    margin: 6px 0 0;
}

.section-header {
    align-items: flex-start;
    display: flex;
    gap: var(--space-4);
    justify-content: space-between;
    margin-bottom: var(--space-5);
}

.section-header h2 {
    font-size: 20px;
    letter-spacing: 0;
    line-height: 1.2;
    margin: 0;
}

.eyebrow,
.panel-kicker {
    color: var(--color-secondary-600);
    display: inline-block;
    font-size: var(--font-size-xs);
    font-weight: 800;
    letter-spacing: 0;
    margin: 0 0 6px;
    text-transform: uppercase;
}

/* 07. Cards and surfaces */
.card,
.panel {
    animation: panel-in var(--transition-slow) both;
    background: var(--gradient-surface), var(--color-surface);
    border: 1px solid rgba(226, 232, 240, 0.94);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    max-width: var(--content-max);
    overflow: hidden;
    padding: var(--space-6);
    position: relative;
}

.card::before,
.panel::before {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.74), transparent);
    content: "";
    height: 1px;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
}

.form-card {
    max-width: 760px;
}

.hero-card,
.hero-panel {
    padding: var(--space-8);
}

.hero-card h2,
.hero-panel h2 {
    font-size: 34px;
    letter-spacing: 0;
    line-height: var(--line-height-tight);
    margin: 0;
    max-width: 760px;
}

.hero-card p,
.hero-panel p {
    color: var(--color-text-muted);
    font-size: var(--font-size-lg);
    max-width: 640px;
}

.layout-public .card,
.layout-public .panel {
    justify-self: center;
    width: min(100%, var(--content-max));
}

/* 08. Auth card */
.auth-card,
.login-card {
    background: rgba(255, 255, 255, 0.90);
    border: 1px solid rgba(255, 255, 255, 0.76);
    box-shadow: var(--shadow-lg);
    max-width: 460px;
    padding: var(--space-8);
    width: min(100%, 460px);
}

.auth-card::before,
.login-card::before {
    background: var(--gradient-brand);
    height: 4px;
}

.auth-brand,
.login-brand {
    align-items: center;
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-8);
}

.auth-brand strong,
.login-brand strong {
    display: block;
    font-size: 18px;
}

.auth-brand small,
.login-brand small,
.auth-heading p,
.login-heading p {
    color: var(--color-text-muted);
}

.auth-heading,
.login-heading {
    margin-bottom: var(--space-6);
}

.auth-heading h1,
.login-heading h1 {
    font-size: var(--font-size-2xl);
    letter-spacing: 0;
    line-height: var(--line-height-tight);
    margin: 0;
}

.auth-heading p,
.login-heading p {
    margin: 10px 0 0;
}

/* 09. Buttons and actions */
.button,
.app-nav a,
.app-nav button,
.auth-form button,
.form-grid button {
    align-items: center;
    border: 0;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 750;
    justify-content: center;
    line-height: 1;
    min-height: 44px;
    padding: 12px var(--space-4);
    text-decoration: none;
    white-space: nowrap;
}

.button-primary,
.app-nav a,
.app-nav button,
.auth-form button,
.form-grid button {
    background: var(--gradient-brand);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.20);
    color: var(--color-text-inverse);
}

.button-primary:hover,
.app-nav a:hover,
.app-nav button:hover,
.auth-form button:hover,
.form-grid button:hover {
    box-shadow: 0 18px 32px rgba(37, 99, 235, 0.26);
    color: var(--color-text-inverse);
    transform: translateY(-1px);
}

.button-secondary,
.button.secondary {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    color: var(--color-text-soft);
}

.button-secondary:hover,
.button.secondary:hover {
    border-color: rgba(37, 99, 235, 0.36);
    color: var(--color-primary-600);
    transform: translateY(-1px);
}

.button-danger {
    background: linear-gradient(135deg, var(--color-danger-600), #be123c);
    box-shadow: 0 12px 24px rgba(225, 29, 72, 0.20);
    color: var(--color-text-inverse);
}

.button-danger:hover {
    box-shadow: 0 18px 32px rgba(225, 29, 72, 0.26);
    color: var(--color-text-inverse);
    transform: translateY(-1px);
}

.button-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--color-primary-600);
}

.button-small {
    font-size: var(--font-size-sm);
    min-height: 40px;
    padding: 10px 14px;
}

.button-block {
    width: 100%;
}

.notification-button {
    gap: var(--space-2);
    position: relative;
}

.notification-badge {
    align-items: center;
    background: var(--color-danger-600);
    border-radius: var(--radius-pill);
    color: var(--color-text-inverse);
    display: inline-flex;
    font-size: 11px;
    font-weight: 800;
    height: 20px;
    justify-content: center;
    min-width: 20px;
    padding: 0 6px;
}

.notification-badge[hidden] {
    display: none;
}

.toolbar,
.actions,
td.actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar form,
.actions form,
td.actions form {
    margin: 0;
}

.toolbar-compact {
    gap: var(--space-3);
}

td a,
.link-button {
    background: none;
    border: 0;
    color: var(--color-primary-600);
    cursor: pointer;
    font: inherit;
    font-weight: 750;
    padding: 0;
    text-decoration: none;
}

td a:hover,
.link-button:hover {
    color: var(--color-secondary-600);
}

.link-danger {
    color: var(--color-danger-600);
}

/* 10. Forms */
.auth-form,
.form-grid {
    display: grid;
    gap: var(--space-3);
    max-width: 620px;
}

.auth-card .auth-form,
.login-card .auth-form {
    max-width: none;
}

.password-field {
    position: relative;
    width: 100%;
}

.password-field input {
    padding-right: 92px;
    width: 100%;
}

.password-field .password-toggle {
    align-items: center;
    background: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: none;
    color: var(--color-primary-600);
    cursor: pointer;
    display: inline-flex;
    font-size: var(--font-size-sm);
    font-weight: 800;
    height: 32px;
    justify-content: center;
    line-height: 1;
    min-height: 32px;
    padding: 0 9px;
    position: absolute;
    right: var(--space-2);
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    width: auto;
}

.password-field .password-toggle:hover {
    border-color: rgba(37, 99, 235, 0.36);
    box-shadow: none;
    color: var(--color-secondary-600);
    transform: translateY(-50%);
}

label {
    color: var(--color-text-soft);
    font-size: var(--font-size-sm);
    font-weight: 750;
}

.required-marker {
    color: var(--color-danger-600);
}

.form-help {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin: 0;
}

.auth-form input,
.form-grid input,
.form-grid select,
.form-grid textarea {
    background: var(--color-surface);
    border: 1px solid #d7deea;
    border-radius: var(--radius-md);
    color: var(--color-text);
    min-height: 46px;
    outline: none;
    padding: 11px 12px;
    width: 100%;
}

.auth-form input:hover,
.form-grid input:hover,
.form-grid select:hover,
.form-grid textarea:hover {
    border-color: var(--color-border-strong);
}

.auth-form input:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
    border-color: var(--color-primary-500);
    box-shadow: var(--shadow-focus);
}

.form-grid textarea {
    min-height: 108px;
    resize: vertical;
}

.form-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-2);
}

.check-line {
    align-items: center;
    display: flex;
    gap: 9px;
}

.check-line input {
    min-height: auto;
    width: auto;
}

.readonly-value {
    background: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    margin: 0;
    padding: var(--space-3);
}

.color-palette {
    display: grid;
    gap: var(--space-2);
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.color-option {
    align-items: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    gap: var(--space-2);
    min-height: 44px;
    padding: 10px 12px;
    position: relative;
}

.color-option:hover,
.color-option:focus-within,
.color-option:has(input:checked),
.color-option.is-selected {
    border-color: var(--swatch-color, var(--color-primary-500));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--swatch-color, var(--color-primary-500)) 18%, transparent);
}

.color-option input {
    height: 1px;
    opacity: 0;
    position: absolute;
    width: 1px;
}

.color-swatch {
    background: var(--swatch-color, var(--color-primary-500));
    border-radius: var(--radius-pill);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
    flex: 0 0 18px;
    height: 18px;
    width: 18px;
}

.schedule-form {
    max-width: none;
}

.schedule-section {
    display: grid;
    gap: var(--space-3);
    margin-top: var(--space-5);
}

.schedule-table input,
.schedule-table select {
    min-width: 130px;
}

.calendar-filter {
    align-items: end;
    background: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
    padding: var(--space-4);
}

.calendar-filter label {
    color: var(--color-text-soft);
    font-size: var(--font-size-sm);
    font-weight: 800;
}

.calendar-filter input,
.calendar-filter select {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    min-height: 42px;
    padding: 10px 12px;
}

.calendar-legend {
    align-items: center;
    color: var(--color-text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.calendar-department-legend {
    align-items: center;
    background: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    padding: var(--space-3);
}

.calendar-legend-title {
    color: var(--color-text-soft);
    font-size: var(--font-size-xs);
    font-weight: 850;
    text-transform: uppercase;
}

.calendar-legend span {
    align-items: center;
    display: inline-flex;
    gap: var(--space-2);
}

.calendar-dot {
    border-radius: var(--radius-pill);
    display: inline-block;
    height: 10px;
    width: 10px;
}

.calendar-dot-absence {
    background: var(--color-primary-500);
}

.calendar-dot-on-call {
    background: var(--color-secondary-500);
}

.calendar-dot-holiday {
    background: var(--color-warning-600);
}

.calendar-dot-non-working {
    background: var(--color-text-muted);
}

.calendar-grid {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    display: grid;
    grid-template-columns: repeat(7, minmax(130px, 1fr));
    overflow-x: auto;
}

.calendar-weekday {
    background: var(--color-surface-soft);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: 800;
    padding: var(--space-3);
    text-transform: uppercase;
}

.calendar-day {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    min-height: 150px;
    padding: var(--space-3);
}

.calendar-day:nth-child(7n) {
    border-right: 0;
}

.calendar-day header {
    color: var(--color-text-soft);
    font-size: var(--font-size-xs);
    font-weight: 800;
    margin-bottom: var(--space-2);
}

.calendar-day header small {
    color: var(--color-warning-600);
    display: block;
    font-weight: 800;
    margin-top: 2px;
}

.calendar-day-muted {
    background: #f8fafc;
    opacity: 0.62;
}

.calendar-day-holiday {
    background: linear-gradient(180deg, var(--color-warning-50), var(--color-surface));
}

.calendar-day-sunday,
.calendar-day-non-working {
    box-shadow: inset 0 0 0 1px rgba(100, 116, 139, 0.14);
}

.calendar-day-sunday:not(.calendar-day-holiday),
.calendar-day-non-working:not(.calendar-day-holiday) {
    background: #f8fafc;
}

.calendar-events {
    display: grid;
    gap: var(--space-2);
}

.calendar-event {
    border-left: 3px solid var(--department-color, var(--color-primary-500));
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
    display: grid;
    gap: 2px;
    padding: 8px 10px;
}

.calendar-event-absence {
    background: linear-gradient(90deg, color-mix(in srgb, var(--department-color, var(--color-primary-500)) 13%, white), var(--color-primary-50));
    border-left-color: var(--department-color, var(--color-primary-500));
}

.calendar-event-on-call {
    background: linear-gradient(90deg, color-mix(in srgb, var(--department-color, var(--color-secondary-500)) 13%, white), var(--color-secondary-50));
    border-left-color: var(--department-color, var(--color-secondary-500));
}

.calendar-event-line {
    align-items: center;
    display: flex;
    gap: 6px;
    min-width: 0;
}

.calendar-event-separator {
    color: var(--color-text-muted);
    flex: 0 0 auto;
}

.calendar-event strong,
.calendar-event span,
.calendar-event small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-event strong {
    color: var(--color-text);
    flex: 0 1 auto;
    font-size: var(--font-size-sm);
}

.calendar-event-employee {
    color: var(--color-text-soft);
    flex: 0 1 auto;
    font-weight: 760;
}

.calendar-event-department {
    align-items: center;
    display: inline-flex;
    flex: 0 1 auto;
    gap: var(--space-2);
}

.calendar-event-department::before {
    background: var(--department-color, var(--color-border-strong));
    border-radius: var(--radius-pill);
    content: "";
    display: inline-block;
    height: 7px;
    width: 7px;
}

.calendar-event span,
.calendar-event small,
.calendar-empty {
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
}

.calendar-event .calendar-event-employee {
    color: var(--color-text-soft);
    font-weight: 760;
}

.calendar-event-department-desktop,
.calendar-event-time {
    display: inline-flex;
}

.calendar-event-department-mobile {
    display: none;
}

.calendar-summary {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: var(--space-5);
}

.department-chip {
    align-items: center;
    color: var(--color-text);
    display: inline-flex;
    font-size: var(--font-size-xs);
    font-weight: 800;
    gap: var(--space-2);
    line-height: 1.2;
    white-space: normal;
}

.department-chip small {
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: 700;
}

.department-chip::before {
    background: var(--department-color, var(--color-border-strong));
    border-radius: var(--radius-pill);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--department-color, var(--color-border-strong)) 18%, transparent);
    content: "";
    flex: 0 0 auto;
    height: 10px;
    width: 10px;
}

.summary-box {
    background: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
}

.summary-box span {
    color: var(--color-text-muted);
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 750;
}

.summary-box strong {
    display: block;
    font-size: 30px;
    line-height: 1;
    margin-top: var(--space-2);
}

.decision-form {
    align-items: center;
    display: inline-flex;
    gap: var(--space-2);
}

.decision-form input {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    min-height: 34px;
    padding: 7px 9px;
    width: 150px;
}

.notification-list {
    display: grid;
    gap: var(--space-3);
}

.notification-item {
    align-items: flex-start;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    display: flex;
    gap: var(--space-4);
    justify-content: space-between;
    padding: var(--space-4);
}

.notification-clickable {
    cursor: pointer;
}

.notification-clickable:hover {
    border-color: rgba(37, 99, 235, 0.36);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.notification-unread {
    background: var(--color-primary-50);
    border-color: #bfdbfe;
}

.notification-item h2 {
    font-size: var(--font-size-lg);
    line-height: 1.2;
    margin: 0;
}

.notification-item p {
    color: var(--color-text-soft);
    margin: var(--space-2) 0;
}

/* 11. Tables */
.table-wrap {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow-x: auto;
}

table,
.data-table {
    background: var(--color-surface);
    border-collapse: collapse;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--color-border);
    padding: 14px var(--space-4);
    text-align: left;
    vertical-align: middle;
}

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

tbody tr:hover {
    background: #f8fbff;
}

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

th {
    background: var(--color-surface-soft);
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.table-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}

/* 12. Feedback, badges and empty states */
.alert,
.form-error {
    align-items: flex-start;
    border-radius: var(--radius-md);
    display: flex;
    gap: var(--space-2);
    line-height: 1.45;
    padding: var(--space-3) 14px;
}

.alert::before,
.form-error::before {
    border-radius: var(--radius-pill);
    content: "";
    flex: 0 0 auto;
    height: 10px;
    margin-top: 6px;
    width: 10px;
}

.alert-error,
.form-error {
    background: var(--color-danger-50);
    border: 1px solid #fecdd3;
    color: #9f1239;
}

.alert-error::before,
.form-error::before {
    background: var(--color-danger-600);
}

.alert-info {
    background: var(--color-primary-50);
    border: 1px solid #bfdbfe;
    color: var(--color-primary-600);
}

.alert-info::before {
    background: var(--color-primary-500);
}

.alert-warning {
    background: var(--color-warning-50);
    border: 1px solid #fde68a;
    color: #92400e;
}

.alert-warning::before {
    background: var(--color-warning-600);
}

.alert-success {
    background: var(--color-success-50);
    border: 1px solid #bbf7d0;
    color: #166534;
}

.alert-success::before {
    background: var(--color-success-600);
}

.toast-region {
    display: grid;
    gap: var(--space-3);
    max-width: min(420px, calc(100vw - 32px));
    position: fixed;
    right: var(--space-5);
    top: var(--space-5);
    width: 420px;
    z-index: var(--z-toast);
}

.toast {
    align-items: flex-start;
    animation: toast-in var(--transition-slow) both;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary-500);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    gap: var(--space-3);
    justify-content: space-between;
    padding: var(--space-4);
}

.toast strong,
.toast p {
    margin: 0;
}

.toast strong {
    display: block;
    font-size: var(--font-size-sm);
    line-height: 1.25;
}

.toast p {
    color: var(--color-text-soft);
    font-size: var(--font-size-sm);
    margin-top: var(--space-1);
}

.toast-success {
    border-left-color: var(--color-success-600);
}

.toast-error {
    border-left-color: var(--color-danger-600);
}

.toast-info {
    border-left-color: var(--color-info-600);
}

.toast-warning {
    border-left-color: var(--color-warning-600);
}

.toast-close {
    align-items: center;
    background: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    color: var(--color-text-muted);
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 28px;
    font-size: 18px;
    height: 28px;
    justify-content: center;
    line-height: 1;
    padding: 0;
    width: 28px;
}

.toast-close:hover {
    border-color: var(--color-border-strong);
    color: var(--color-text);
}

.toast-hiding {
    animation: toast-out var(--transition-fast) both;
}

.badge {
    align-items: center;
    background: var(--color-info-50);
    border: 1px solid #c7d2fe;
    border-radius: var(--radius-pill);
    color: #3730a3;
    display: inline-flex;
    font-size: var(--font-size-xs);
    font-weight: 800;
    line-height: 1;
    padding: 7px 10px;
    white-space: nowrap;
}

.badge-success {
    background: var(--color-success-50);
    border-color: #bbf7d0;
    color: #166534;
}

.badge-warning {
    background: var(--color-warning-50);
    border-color: #fde68a;
    color: #92400e;
}

.badge-danger {
    background: var(--color-danger-50);
    border-color: #fecdd3;
    color: #9f1239;
}

.badge-info {
    background: var(--color-info-50);
    border-color: #c7d2fe;
    color: var(--color-info-600);
}

.badge-muted {
    background: var(--color-surface-soft);
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

.empty-state {
    align-items: center;
    background: var(--color-surface-soft);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    display: grid;
    justify-items: center;
    padding: var(--space-8);
    text-align: center;
}

.empty-state::before {
    background: var(--gradient-brand);
    border-radius: var(--radius-pill);
    content: "";
    display: block;
    height: 4px;
    margin-bottom: var(--space-3);
    width: 44px;
}

.empty-state h3 {
    color: var(--color-text);
    font-size: 18px;
    margin: 0 0 var(--space-2);
}

.empty-state p {
    margin: 0;
}

.empty-state-compact {
    padding: var(--space-5);
}

.muted {
    color: var(--color-text-muted);
}

/* 13. Modal-ready primitives */
.modal-open {
    overflow: hidden;
}

.modal-backdrop {
    align-items: center;
    background: rgba(15, 23, 42, 0.46);
    display: grid;
    inset: 0;
    justify-items: center;
    padding: var(--space-4);
    position: fixed;
    z-index: var(--z-modal);
}

.modal-panel {
    animation: modal-in var(--transition-slow) both;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 560px;
    padding: var(--space-6);
    width: min(100%, 560px);
}

.confirm-modal {
    backdrop-filter: blur(4px);
}

.confirm-modal-panel {
    display: grid;
    gap: var(--space-4);
}

.confirm-modal-panel h2,
.confirm-modal-panel p {
    margin: 0;
}

.confirm-modal-panel h2 {
    font-size: 22px;
    line-height: 1.2;
}

.confirm-modal-panel p {
    color: var(--color-text-soft);
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: flex-end;
    margin-top: var(--space-2);
}

.error-card {
    display: grid;
    gap: var(--space-4);
    margin: min(8vh, var(--space-10)) auto;
    max-width: 720px;
}

.error-card h1,
.error-card p {
    margin: 0;
}

.error-card p {
    color: var(--color-text-muted);
    font-size: var(--font-size-lg);
}

.session-timeout-modal .modal-panel {
    display: grid;
    gap: var(--space-4);
    text-align: center;
}

.session-timeout-modal h2,
.session-timeout-modal p {
    margin: 0;
}

.session-timeout-modal p {
    color: var(--color-text-muted);
}

/* 14. Motion */
.ui-ready .card,
.ui-ready .panel,
.ui-ready .auth-card,
.ui-ready .login-card {
    will-change: transform, opacity;
}

@keyframes panel-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(18px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(18px);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }
}

/* 15. Responsive behavior */
@media (max-width: 920px) {
    .app-shell,
    .sidebar-collapsed .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        height: 100vh;
        left: 0;
        max-width: 84vw;
        padding: var(--space-6) 18px;
        position: fixed;
        top: 0;
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

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

    .sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-collapsed .brand-copy,
    .sidebar-collapsed .side-label {
        opacity: 1;
        pointer-events: auto;
        position: static;
        transform: none;
    }

    .sidebar-collapsed .side-nav a {
        justify-content: flex-start;
        padding: var(--space-3) 13px;
    }

    .app-header {
        align-items: center;
        display: grid;
        gap: var(--space-3);
        grid-template-columns: minmax(0, 1fr) auto;
        padding: 12px var(--space-4);
    }

    .app-nav {
        grid-column: 1 / -1;
        justify-content: space-between;
        width: 100%;
    }

    .user-summary {
        max-width: 100%;
    }

    .app-main {
        padding: var(--space-5) var(--space-4);
    }

    .page-header,
    .page-head,
    .section-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 760px) {
    .public-shell {
        align-items: stretch;
        padding: var(--space-5) var(--space-4);
    }

    .app-main {
        gap: var(--space-5);
    }

    .header-title {
        gap: var(--space-3);
    }

    .header-title .eyebrow {
        display: none;
    }

    .app-header h1 {
        font-size: 20px;
        max-width: 58vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sidebar-toggle {
        flex-basis: 38px;
        height: 38px;
        width: 38px;
    }

    .app-nav {
        align-items: center;
        display: grid;
        gap: var(--space-2);
        grid-template-columns: minmax(0, 1fr) auto auto;
    }

    .app-nav form,
    .app-nav .button {
        width: auto;
    }

    .user-summary {
        gap: var(--space-2);
        min-height: 38px;
        padding: 5px 8px;
        width: auto;
    }

    .user-avatar {
        flex-basis: 26px;
        height: 26px;
        width: 26px;
    }

    .user-meta strong {
        font-size: 12px;
    }

    .user-meta small {
        font-size: 11px;
    }

    .notification-button {
        font-size: var(--font-size-sm);
        gap: var(--space-2);
        min-height: 38px;
        padding: 0 12px;
        position: relative;
    }

    .notification-badge {
        position: absolute;
        right: -5px;
        top: -5px;
    }

    .app-nav button.button-small {
        height: 38px;
        min-height: 38px;
        min-width: 50px;
        padding-inline: 12px;
    }

    .app-nav a.button-small {
        height: 38px;
        min-height: 38px;
    }

    .page-header,
    .page-head {
        gap: var(--space-4);
    }

    .card,
    .panel {
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        padding: var(--space-5);
        width: 100%;
    }

    .hero-card,
    .hero-panel,
    .identity-greeting {
        padding: var(--space-5);
    }

    .form-grid,
    .auth-form,
    .calendar-filter {
        max-width: none;
        width: 100%;
    }

    .form-grid input,
    .form-grid select,
    .form-grid textarea,
    .auth-form input,
    .auth-form select,
    .auth-form textarea,
    .calendar-filter input,
    .calendar-filter select {
        min-height: 46px;
        width: 100%;
    }

    .calendar-filter {
        align-items: stretch;
        display: grid;
        gap: var(--space-3);
    }

    .table-wrap {
        border: 0;
        overflow: visible;
    }

    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table tr,
    .data-table th,
    .data-table td {
        display: block;
    }

    .data-table thead {
        height: 1px;
        margin: -1px;
        overflow: hidden;
        position: absolute;
        white-space: nowrap;
        width: 1px;
    }

    .data-table tbody {
        display: grid;
        gap: var(--space-3);
    }

    .data-table tr {
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-xs);
        overflow: hidden;
    }

    .data-table tr:hover {
        background: var(--color-surface);
    }

    .data-table td {
        align-items: start;
        border-bottom: 1px solid var(--color-border);
        display: grid;
        gap: var(--space-3);
        grid-template-columns: minmax(112px, 38%) minmax(0, 1fr);
        min-height: 44px;
        overflow-wrap: anywhere;
    }

    .data-table td::before {
        color: var(--color-text-muted);
        content: attr(data-label);
        font-size: var(--font-size-xs);
        font-weight: 850;
        text-transform: uppercase;
    }

    .data-table td[colspan] {
        display: block;
    }

    .data-table td[colspan]::before {
        display: none;
    }

    .data-table td:last-child {
        border-bottom: 0;
    }

    td a,
    .link-button {
        align-items: center;
        display: inline-flex;
        min-height: 44px;
    }

    .decision-form {
        align-items: stretch;
        display: grid;
        width: 100%;
    }

    .decision-form input {
        width: 100%;
    }

    .calendar-grid {
        border: 0;
        display: grid;
        gap: var(--space-3);
        grid-template-columns: 1fr;
        overflow: visible;
    }

    .calendar-weekday {
        display: none;
    }

    .calendar-day {
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-xs);
        min-height: auto;
        padding: var(--space-2);
    }

    .calendar-day:nth-child(7n) {
        border-right: 1px solid var(--color-border);
    }

    .calendar-day header {
        margin-bottom: var(--space-1);
    }

    .calendar-day header span {
        font-size: var(--font-size-sm);
    }

    .calendar-empty {
        display: none;
    }

    .calendar-events {
        gap: 6px;
    }

    .calendar-event {
        border-left-width: 4px;
        gap: 0;
        min-height: 36px;
        padding: 7px 9px;
    }

    .calendar-event-line {
        gap: 5px;
        width: 100%;
    }

    .calendar-event strong,
    .calendar-event-employee,
    .calendar-event-department {
        font-size: var(--font-size-xs);
    }

    .calendar-event-department-desktop,
    .calendar-event-time {
        display: none;
    }

    .calendar-event-department-mobile {
        display: inline-flex;
    }

    .calendar-legend,
    .calendar-department-legend {
        align-items: flex-start;
        flex-direction: column;
    }

    .notification-item {
        align-items: stretch;
        display: grid;
        grid-template-columns: 1fr;
    }

    .notification-item .toolbar {
        justify-content: flex-start;
    }
}

@media (max-width: 560px) {
    .toast-region {
        left: var(--space-4);
        right: var(--space-4);
        top: var(--space-4);
        width: auto;
    }

    .modal-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .public-shell {
        padding: var(--space-6) 14px;
    }

    .card,
    .panel,
    .auth-card,
    .login-card {
        padding: var(--space-5);
    }

    .auth-heading h1,
    .login-heading h1 {
        font-size: 28px;
    }

    .hero-card h2,
    .hero-panel h2 {
        font-size: 26px;
    }

    .user-department {
        display: none;
    }

    .password-field input {
        padding-right: 76px;
    }

    .password-field .password-toggle {
        height: 30px;
        font-size: var(--font-size-xs);
        min-height: 30px;
        padding: 0 7px;
        right: 6px;
    }

    .toolbar,
    .toolbar .button,
    .form-actions,
    .form-actions .button {
        width: 100%;
    }

    .toolbar,
    .form-actions {
        align-items: stretch;
    }

    .toolbar-compact,
    .toolbar-compact .button {
        width: auto;
    }

    th,
    td {
        padding: var(--space-3);
    }
}
