/* ════════════════════════════════════════════════════════════════════════════
   HMPM Design System – style.css
   Conforms to docs/DESIGN_SPEC_SHEET.md v1.0
   ════════════════════════════════════════════════════════════════════════════ */

/* ── 1. Design Tokens ──────────────────────────────────────────────────────── */
:root {
    /* Semantic color tokens */
    --color-primary: #FFC000;
    --color-primary-hover: #E6AD00;
    --color-primary-active: #CC9900;
    --color-text-primary: #000000;
    --color-text-secondary: #6B6B6B;
    --color-text-muted: #A5A5A5;
    --color-surface-primary: #FFFFFF;
    --color-surface-secondary: #E7E6E6;
    --color-surface-tertiary: #F5F5F5;
    --color-border-default: #A5A5A5;
    --color-border-light: #E7E6E6;
    --color-error: #C41914;
    --color-success: #2E7D32;

    /* UI tokens (light theme) */
    --color-bg: #E7E6E6;
    --color-surface: #FFFFFF;
    --color-surface2: #F5F5F5;
    --color-stroke: #E7E6E6;
    --color-text: #000000;
    --color-muted: #6B6B6B;
    --color-accent: #FFC000;
    --color-focus: rgba(255, 192, 0, 0.4);

    /* Legacy aliases – kept for backward compat with admin.html inline styles */
    --hmpm-yellow: #FFC000;
    --hmpm-white: #1a1a1a;
    --hmpm-red: #C41914;
    --hmpm-gray-dark: #6B6B6B;
    --hmpm-gray-medium: #A5A5A5;
    --hmpm-gray-light: #E7E6E6;

    /* Typography */
    --font-primary: 'Outfit', Arial, Helvetica, sans-serif;
    --font-mono: Arial, monospace;
    --font-main: var(--font-primary);
    /* legacy alias */

    /* Type scale */
    --text-xs: 0.75rem;
    /* 12px */
    --text-sm: 0.875rem;
    /* 14px */
    --text-base: 0.9375rem;
    /* 15px */
    --text-lg: 1.125rem;
    /* 18px */
    --text-xl: 1.25rem;
    /* 20px */
    --text-2xl: 1.5rem;
    /* 24px */
    --text-3xl: 1.875rem;
    /* 30px */
    --text-4xl: 2.25rem;
    /* 36px */

    /* Spacing (8px grid) */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Border radius */
    --radius-sm: 0;
    --radius-md: 0;
    --radius-lg: 0;
    --radius-xl: 0;

    /* Border width */
    --border-width-default: 1px;
    --border-width-thick: 2px;

    /* Focus ring */
    --shadow-focus: 0 0 0 3px rgba(255, 192, 0, 0.4);
}

/* ── 2. Reset ───────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── 3. Base ────────────────────────────────────────────────────────────────── */
body {
    font-family: var(--font-primary);
    font-size: var(--text-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    color-scheme: light dark;
}

/* ── 4. Navigation ──────────────────────────────────────────────────────────── */
.navbar {
    background-color: black;
    height: 56px;
    padding: 0 var(--space-4);
    color: white;
    display: flex;
    align-items: center;
    /* No decorative shadow per spec */
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-content {
    width: 100%;
    max-width: 100%;
    margin: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-link {
    color: rgba(255, 255, 255, 0.85);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s;
}

.nav-link:hover {
    color: var(--color-primary);
}

.nav-link:focus {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-md);
}

.nav-link-active {
    background-color: var(--color-primary);
    color: var(--color-text-primary);
    font-weight: 600;
}

.lang-select {
    background: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    padding: 4px 8px;
    font-family: var(--font-primary);
    font-size: var(--text-xs);
    font-weight: 700;
    cursor: pointer;
}

.lang-select:hover,
.lang-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

.lang-select option {
    background: var(--color-text-primary);
    color: white;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-name {
    font-weight: 600;
    font-size: var(--text-sm);
}

.user-role {
    font-size: var(--text-xs);
    opacity: 0.8;
}

.user-role.has-tooltip {
    cursor: help;
    position: relative;
}

.user-role.has-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: rgba(10, 10, 10, 0.97);
    color: #fff;
    font-size: 11px;
    line-height: 1.6;
    white-space: pre;
    padding: 6px 10px;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.user-role.has-tooltip:hover::after {
    opacity: 1;
    transform: translateY(0);
}

/* ── 5. Layout ──────────────────────────────────────────────────────────────── */
.main-content {
    max-width: 100%;
    margin: 0;
    padding: var(--space-3) var(--space-4);
    height: calc(100vh - 56px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: var(--space-3);
}

.header-controls {
    display: flex;
    gap: var(--space-5);
    align-items: flex-end;
}

.session-selector,
.period-selector {
    display: flex;
    align-items: flex-end;
    gap: var(--space-2);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: var(--space-4);
    align-items: stretch;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

@media (max-width: 1280px) {
    .dashboard-grid {
        grid-template-columns: 260px minmax(0, 1fr);
    }
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .main-content {
        height: auto;
        overflow: visible;
    }
    .dashboard-grid {
        align-items: start;
        overflow: visible;
        flex: none;
    }
    .preview-card {
        overflow: visible;
        min-height: auto;
    }
    .table-container {
        overflow-x: auto;
        overflow-y: visible;
        flex: none;
    }
}

/* ── 6. Typography ──────────────────────────────────────────────────────────── */
.page-title {
    font-size: clamp(var(--text-lg), 2.5vw, var(--text-2xl));
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-text);
}

/* ── 7. Card ────────────────────────────────────────────────────────────────── */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: var(--border-width-default) solid var(--color-border-light);
    border-top: var(--border-width-thick) solid var(--color-primary);
    padding: var(--space-5);
    /* No decorative shadow per spec */
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-text);
}

.preview-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    padding-bottom: 0;
}

/* ── 8. Forms ───────────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: var(--space-3);
}

.label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-2);
    text-transform: uppercase;
}

.input {
    font-family: var(--font-primary);
    font-size: var(--text-base);
    color: var(--color-text);
    background-color: var(--color-surface);
    border: var(--border-width-default) solid var(--color-border-default);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    width: 100%;
    box-sizing: border-box;
    height: 38px;
}

input[type="date"] {
    font-family: var(--font-primary);
    font-size: var(--text-base);
    color: var(--color-text);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border-default);
    border-radius: 0;
    padding: 8px 12px;
    width: 100%;
    box-sizing: border-box;
    height: 38px;
    cursor: pointer;
}

input[type="date"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: brightness(0);
}

select.input {
    appearance: auto;
    height: 38px;
}

.input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

.input.input-error {
    border-color: var(--color-error);
}

.help-text {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    margin-top: var(--space-1);
    display: block;
}

/* ── 9. Buttons ─────────────────────────────────────────────────────────────── */
.button {
    font-family: var(--font-primary);
    font-weight: 600;
    text-transform: uppercase;
    padding: 9px var(--space-5);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-base);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.button:focus {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* Primary: yellow bg + dark blue text – spec §6.1 */
.button-primary {
    background-color: var(--color-primary);
    color: var(--color-text-primary);
    justify-content: center;
}

/* Entry form card – compact spacing so layout fits at 100% zoom */
.entry-form-card {
    padding: var(--space-4);
    overflow-y: auto;
}

.entry-form .form-group {
    margin-bottom: var(--space-2);
}

.entry-form .label {
    margin-bottom: var(--space-1);
}

/* Button row in entry form */
.form-btn-row {
    display: flex;
    gap: 8px;
    width: 100%;
}
.form-btn-row .button {
    flex: 1;
    padding: 10px 12px;
    font-size: var(--text-sm);
    justify-content: center;
}

.button-primary:hover {
    background-color: var(--color-primary-hover);
}

.button-primary:active {
    background-color: var(--color-primary-active);
}

/* Secondary: transparent + dark blue border – spec §6.2 */
.button-secondary {
    background: transparent;
    color: var(--color-text-primary);
    border: var(--border-width-default) solid var(--color-text-primary);
}

.button-secondary:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Accent: yellow (same visual as primary, no full-width) */
.button-accent {
    background-color: var(--color-primary);
    color: var(--color-text-primary);
}

.button-accent:hover {
    background-color: var(--color-primary-hover);
}

.button-accent:active {
    background-color: var(--color-primary-active);
}

/* Small variant */
.button-sm {
    padding: 6px 12px;
    font-size: var(--text-xs);
}

/* ── 10. Table ──────────────────────────────────────────────────────────────── */
.table-container {
    overflow: auto;
    border: var(--border-width-default) solid var(--color-border-light);
    border-radius: var(--radius-md);
    flex: 1;
    min-height: 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    table-layout: fixed;
}

.table th {
    background-color: var(--color-surface-secondary);
    color: var(--color-text);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.04em;
    padding: 8px 6px;
    text-align: left;
    border-bottom: var(--border-width-thick) solid var(--color-border-default);
    overflow: hidden;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table td {
    padding: 7px 6px;
    border-bottom: var(--border-width-default) solid var(--color-border-light);
    overflow: hidden;
}

.table tr:hover td {
    background-color: var(--color-surface2);
}

.table tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background-color: var(--color-surface-secondary);
    font-weight: 700;
    border-top: var(--border-width-thick) solid var(--color-border-default);
}

/* Tooltip for truncated cells — rendered via JS (#cell-tooltip) */
#cell-tooltip {
    position: fixed;
    z-index: 9999;
    background: rgba(10, 10, 10, 0.88);
    color: #fff;
    font-family: var(--font-primary);
    font-size: 11px;
    font-weight: 400;
    line-height: 1.6;
    white-space: nowrap;
    padding: 6px 10px;
    border-radius: 6px;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: none;
}

/* Fixed information columns */
.table th.col-project,
.table td:nth-child(1) {
    width: 88px;
    white-space: normal;
    word-break: break-word;
}

.table th.col-service,
.table td:nth-child(2) {
    width: 96px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.table th.col-booking,
.table td:nth-child(3) {
    width: 56px;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 10px;
}

/* Summe (last column) */
.table th:last-child,
.table td:last-child {
    width: 52px;
    text-align: right;
    padding-right: 14px;
}

.text-right {
    text-align: right;
}

/* Editable cells */
.editable-cell {
    cursor: pointer;
}
.editable-cell:hover {
    background-color: rgba(0, 0, 0, 0.08) !important;
}
.editable-cell.editing {
    background-color: rgba(255, 192, 0, 0.18) !important;
    border-left: 2px solid var(--color-accent) !important;
    border-right: 1px solid rgba(255, 192, 0, 0.4) !important;
}
.cell-edit-input {
    width: 28px;
    padding: 1px 2px;
    font-size: 10px;
    font-family: var(--font-primary);
    font-variant-numeric: tabular-nums;
    text-align: center;
    border: 1px solid var(--color-accent);
    border-radius: 3px;
    background: var(--color-surface);
    color: var(--color-text-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 192, 0, 0.25);
    -moz-appearance: textfield;
    appearance: textfield;
}
.cell-edit-input::-webkit-inner-spin-button,
.cell-edit-input::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; }

/* Day columns */
.day-col {
    width: 30px;
    text-align: center !important;
    padding-left: 2px !important;
    padding-right: 2px !important;
    font-size: 10px;
    letter-spacing: 0;
}

.numeric-cell {
    text-align: center;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-size: 11px;
    padding-left: 2px !important;
    padding-right: 2px !important;
}

.empty-cell {
    color: var(--color-text-muted);
    opacity: 0.4;
}

/* ── Day column coloring ─────────────────────────────────────────────────── */
.day-even th, th.day-even,
.day-even td, td.day-even {
    background-color: rgba(0, 0, 0, 0.05);
}

.day-odd th, th.day-odd,
.day-odd td, td.day-odd {
    background-color: rgba(255, 255, 255, 0);
}

.day-weekend th, th.day-weekend,
.day-weekend td, td.day-weekend {
    background-color: rgba(200, 50, 30, 0.07);
    color: rgba(180, 50, 30, 0.7);
}

th.day-weekend {
    font-weight: 600;
}

.day-today th, th.day-today,
.day-today td, td.day-today {
    background-color: rgba(255, 192, 0, 0.15) !important;
    border-left: 2px solid var(--color-accent) !important;
    border-right: 1px solid rgba(255, 192, 0, 0.3) !important;
}

th.day-today {
    color: var(--color-accent);
    font-weight: 700;
}

.day-out {
    opacity: 0.2;
}

[data-theme="dark"] .day-even th, [data-theme="dark"] th.day-even,
[data-theme="dark"] .day-even td, [data-theme="dark"] td.day-even {
    background-color: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .day-weekend th, [data-theme="dark"] th.day-weekend,
[data-theme="dark"] .day-weekend td, [data-theme="dark"] td.day-weekend {
    background-color: rgba(220, 80, 50, 0.12);
    color: rgba(255, 130, 110, 0.8);
}

/* ── Table Legend ─────────────────────────────────────────────────────────── */
.table-legend {
    display: flex;
    gap: var(--space-4);
    align-items: center;
    padding: var(--space-2) var(--space-2) var(--space-3);
    font-size: 11px;
    color: var(--color-text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.legend-today   { background: rgba(255, 192, 0, 0.3); border-color: var(--color-accent); }
.legend-weekend { background: rgba(200, 50, 30, 0.12); border-color: rgba(200, 50, 30, 0.25); }
.legend-even    { background: rgba(0, 0, 0, 0.06); border-color: rgba(0, 0, 0, 0.1); }
.legend-odd     { background: transparent; border-color: rgba(0,0,0,0.12); }

[data-theme="dark"] .legend-today   { background: rgba(255, 192, 0, 0.25); }
[data-theme="dark"] .legend-weekend { background: rgba(220, 80, 50, 0.2); border-color: rgba(220, 80, 50, 0.35); }
[data-theme="dark"] .legend-even    { background: rgba(255, 255, 255, 0.05); border-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .legend-odd     { background: transparent; border-color: rgba(255,255,255,0.15); }

/* ── 11. Modal ──────────────────────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
    background-color: var(--color-surface);
    margin: 10% auto;
    padding: var(--space-8);
    border-radius: var(--radius-lg);
    border: var(--border-width-default) solid var(--color-border-light);
    border-top: var(--border-width-thick) solid var(--color-primary);
    width: min(400px, calc(100% - 2 * var(--space-6)));
    /* No decorative shadow per spec */
}

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

/* ── 12. Alerts ─────────────────────────────────────────────────────────────── */
.alert-error {
    border: var(--border-width-thick) solid var(--color-error);
    padding: 16px;
    color: var(--color-error);
    font-weight: 600;
    border-radius: var(--radius-md);
}

.alert-info {
    border: var(--border-width-thick) solid var(--color-text-primary);
    padding: 16px;
    color: var(--color-text-primary);
    border-radius: var(--radius-md);
}

.ics-title-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.confidence-high { color: var(--color-success, #22a05a); font-weight: 600; }
.confidence-mid  { color: var(--color-warning, #d97706); font-weight: 600; }
.confidence-low  { color: var(--color-error); font-weight: 600; }

.ics-preview-hint {
    margin-top: var(--space-3);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    line-height: 1.5;
}

.ics-modal-help-box {
    background: var(--color-surface2);
    border-left: 3px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-4) var(--space-2);
    margin-top: var(--space-4);
}

.ics-modal-help-box .help-purpose {
    font-size: var(--text-sm);
    color: var(--color-muted);
    margin-bottom: var(--space-3);
}

.ics-modal-help-box .help-tips {
    flex-direction: column;
    gap: var(--space-2);
}

.ics-modal-help-box .help-tip {
    font-size: var(--text-sm);
}

.ics-spinner {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: var(--space-2);
}
.ics-spinner span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--color-primary);
    animation: ics-bounce 1.2s ease-in-out infinite;
}
.ics-spinner span:nth-child(2) { animation-delay: 0.2s; }
.ics-spinner span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ics-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%            { transform: scale(1.0); opacity: 1;   }
}

.ics-sel {
    height: 26px;
    padding: 2px 4px;
    font-size: var(--text-xs);
    min-width: 90px;
}

.ics-please-wait {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-top: var(--space-1);
}

/* ── 13. Dark Theme ─────────────────────────────────────────────────────────── */
[data-theme="dark"] {
    /* Spec §2.5 tokens */
    --color-bg: #0a0a0a;
    --color-surface: rgba(255, 255, 255, 0.06);
    --color-surface2: rgba(255, 255, 255, 0.08);
    --color-stroke: rgba(255, 255, 255, 0.12);
    --color-text: rgba(255, 255, 255, 0.92);
    --color-muted: rgba(255, 255, 255, 0.62);
    --color-success: #2EEC96;
    --color-danger: #FF5D5D;
    --color-warning: #FFCC66;
    --color-error: #FF5D5D;

    /* Surface / border adaptations */
    --color-surface-primary: rgba(255, 255, 255, 0.06);
    --color-surface-secondary: rgba(255, 255, 255, 0.08);
    --color-surface-tertiary: rgba(255, 255, 255, 0.04);
    --color-border-default: rgba(255, 255, 255, 0.2);
    --color-border-light: rgba(255, 255, 255, 0.12);
    --color-text-secondary: rgba(255, 255, 255, 0.62);
    --color-text-muted: rgba(255, 255, 255, 0.38);

    /* Legacy aliases used in admin.html */
    --hmpm-gray-light: rgba(255, 255, 255, 0.12);
    --hmpm-gray-medium: rgba(255, 255, 255, 0.2);
    --hmpm-gray-dark: rgba(255, 255, 255, 0.62);
    --hmpm-red: #FF5D5D;
    --hmpm-white: #ffffff;
}

/* Secondary button adapts in dark mode */
[data-theme="dark"] .button-secondary {
    color: rgba(255, 255, 255, 0.85);
    border-color: rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .button-secondary:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Modal overlay darkens further */
[data-theme="dark"] .modal {
    background-color: rgba(0, 0, 0, 0.75);
}

[data-theme="dark"] .modal-content {
    background-color: #1a1a1a;
}

/* Theme toggle button (in navbar) */
.theme-toggle-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-md);
    padding: 4px 9px;
    font-family: var(--font-primary);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.theme-toggle-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.theme-toggle-btn:focus {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.theme-toggle-btn::before {
    content: '☾';
}

[data-theme="dark"] .theme-toggle-btn::before {
    content: '☀';
}

/* ── 13.1 Darkmode Select / Dropdown Fix ─────────────────────────────────── */
[data-theme="dark"] select.input,
[data-theme="dark"] .filter-btn,
[data-theme="dark"] .lang-select,
[data-theme="dark"] .input {
    background-color: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] select.input:focus,
[data-theme="dark"] .filter-btn:focus {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

[data-theme="dark"] select.input option {
    background-color: #1a1a1a;
    color: #ffffff;
}

[data-theme="dark"] .filter-panel {
    background-color: #1a1a1a;
    color: #ffffff;
}

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
    filter: brightness(0) invert(1);
}

/* ── 14. Responsive ─────────────────────────────────────────────────────────── */

/* Tablet (≤768px) ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .navbar {
        height: 48px;
        padding: 0 var(--space-4);
    }

    /* Hide user role subtitle to save space */
    .user-role { display: none; }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
    }

    .header-controls {
        width: 100%;
    }

    .period-selector {
        align-items: center;
    }

    .card {
        padding: var(--space-4);
    }

    .card-header {
        margin-bottom: var(--space-3);
    }

    .form-group {
        margin-bottom: var(--space-2);
    }

    .table th {
        padding: 8px 10px;
    }

    .table td {
        padding: 8px 10px;
    }
}

/* Mobile (≤480px) ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .navbar { overflow: hidden; }

    .nav-actions {
        gap: var(--space-3) !important;
    }

    /* Hide admin link in main navbar — accessible via direct URL on mobile */
    .nav-actions a[href="/admin.html"] { display: none; }

    /* Collapse lang selector */
    .lang-select {
        font-size: 10px;
        padding: 3px 5px;
    }

    .user-name { font-size: var(--text-xs); }


    .card {
        padding: var(--space-3);
    }

    .card-title {
        font-size: var(--text-base);
    }

    .table th {
        padding: 6px 8px;
        font-size: 10px;
    }

    .table td {
        padding: 6px 8px;
        font-size: var(--text-xs);
    }

    .day-col {
        width: 26px;
    }

    .button {
        font-size: var(--text-sm);
        padding: 8px var(--space-4);
    }

    .modal-content {
        margin: 5% auto;
        padding: var(--space-5);
    }
}

/* ── 15. Login Page ─────────────────────────────────────────────────────────── */
.login-wrap {
    width: 100%;
    max-width: 400px;
    padding: 24px;
}

.brand {
    text-align: center;
    margin-bottom: 32px;
}

.brand-name {
    display: block;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
}

.brand-title {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin-top: 4px;
}

.login-wrap .card {
    background: var(--login-card-bg, #fff);
    border-radius: 0;
    border: 1px solid var(--login-card-border, rgba(255, 255, 255, 0.15));
    padding: 32px;
}

.login-wrap .card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--hmpm-white);
    margin-bottom: 24px;
}

[data-theme="dark"] .login-wrap .card-title {
    color: rgba(255, 255, 255, 0.92);
}

.login-wrap select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--hmpm-gray-medium);
    border-radius: 4px;
    font-family: var(--font-primary);
    font-size: 15px;
    color: var(--hmpm-white);
    background: var(--login-input-bg, #fff);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2344546A' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

.login-wrap select:focus {
    outline: none;
    border-color: var(--hmpm-yellow);
    box-shadow: 0 0 0 3px rgba(255, 192, 0, 0.4);
}

[data-theme="dark"] .login-wrap select {
    color: rgba(255, 255, 255, 0.92);
}

.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-family: var(--font-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.login-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 192, 0, 0.4);
}

.login-btn-primary {
    background: var(--hmpm-yellow);
    color: var(--hmpm-white);
}

.login-btn-primary:hover { background: #E6AD00; }
.login-btn-primary:active { background: #CC9900; }
.login-btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--hmpm-gray-medium);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--hmpm-gray-light);
}

.btn-microsoft {
    background: #f3f3f3;
    color: #555;
    border: 1.5px solid #ddd;
    position: relative;
}

[data-theme="dark"] .btn-microsoft {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-microsoft:disabled { opacity: 0.55; cursor: not-allowed; }

.badge-soon {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    background: var(--hmpm-gray-light);
    color: var(--hmpm-gray-dark);
    padding: 2px 7px;
    border-radius: 20px;
    text-transform: uppercase;
    margin-left: auto;
}

.ms-logo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    width: 16px;
    height: 16px;
}

.ms-logo span { display: block; width: 7px; height: 7px; }
.ms-logo span:nth-child(1) { background: #F25022; }
.ms-logo span:nth-child(2) { background: #7FBA00; }
.ms-logo span:nth-child(3) { background: #00A4EF; }
.ms-logo span:nth-child(4) { background: #FFB900; }

.login-error {
    background: #fff0f0;
    border: 1.5px solid var(--hmpm-red);
    color: var(--hmpm-red);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.04em;
}

/* Login page body needs full-height centered layout */
body.login-page {
    background: var(--login-bg, var(--hmpm-white));
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] body.login-page {
    background: #0a0a0a;
}

/* Login-specific CSS custom properties */
:root {
    --login-bg: var(--hmpm-white);
    --login-card-bg: #fff;
    --login-card-border: rgba(255, 255, 255, 0.15);
    --login-input-bg: #fff;
}

[data-theme="dark"] {
    --login-bg: #0a0a0a;
    --login-card-bg: rgba(255, 255, 255, 0.06);
    --login-card-border: rgba(255, 255, 255, 0.12);
    --login-input-bg: rgba(255, 255, 255, 0.08);
}

/* ── 16. Navbar Links ────────────────────────────────────────────────────────── */
.nav-link {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: color 0.15s;
}

.nav-link:hover {
    color: var(--color-accent);
}

.nav-link-muted {
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: color 0.15s;
}

.nav-link-muted:hover {
    color: var(--color-accent);
}

/* ── 17. Help Sidebar ────────────────────────────────────────────────────────── */
.help-toggle-btn {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: var(--color-text-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 91;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-toggle-btn:hover {
    background: var(--color-primary);
    color: var(--color-text-primary);
}

.help-sidebar {
    position: fixed;
    top: 56px;
    right: 0;
    width: 320px;
    bottom: 0;
    background: var(--color-surface);
    border-left: 4px solid var(--color-text-primary);
    border-top: 3px solid var(--color-primary);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.12);
    z-index: 92;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
}

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

.help-sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.help-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
}

.help-sidebar-title {
    font-weight: 600;
    color: var(--color-text-primary);
    font-size: 0.95rem;
}

.help-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-primary);
    font-size: 1.25rem;
    line-height: 1;
    padding: 2px 6px;
    border-radius: var(--radius-md);
    transition: background 0.15s;
}

.help-close-btn:hover {
    background: var(--color-surface-secondary);
}

.help-sidebar-body {
    padding: var(--space-4);
    overflow-y: auto;
    flex: 1;
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    transition: opacity 0.15s;
}

.help-purpose {
    margin-bottom: var(--space-4);
    color: var(--color-muted);
}

.help-section-label {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-primary);
    margin-bottom: var(--space-2);
}

.help-tips {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.help-tip {
    padding: var(--space-2) var(--space-3);
    border-left: 2px solid var(--color-primary);
    background: rgba(255, 192, 0, 0.08);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

[data-theme="dark"] .help-sidebar {
    background: #1a1a1a;
}

[data-theme="dark"] .help-sidebar-title,
[data-theme="dark"] .help-close-btn,
[data-theme="dark"] .help-section-label {
    color: rgba(255, 255, 255, 0.92);
}

[data-theme="dark"] .help-tip {
    background: rgba(255, 192, 0, 0.18);
}

@media (max-width: 768px) {
    .help-sidebar {
        width: 100%;
        top: auto;
        height: 50vh;
        border-left: none;
        transform: translateY(100%);
    }

    .help-sidebar.open {
        transform: translateY(0);
    }

    .help-toggle-btn {
        top: auto;
        bottom: var(--space-8);
        transform: none;
    }
}

/* ── 18. Accessibility: prefers-reduced-motion ──────────────────────────────── */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}