/* ============================================================
   Mainsail – Theme Styles
   ============================================================ */

/* ---- Theme Palettes ---- */
[data-theme="dark"] {
    --color-canvas: #0d1117;
    --color-surface: #161b22;
    --color-surface-raised: #1c2128;
    --color-surface-hover: #21262d;
    --color-border: #30363d;
    --color-border-hover: #484f58;
    --color-gantt-bg: #0d1117;
    --color-gantt-row-border: #21262d;
    --color-gantt-row-hover: #21262d;
    --color-labels-bg: #0d1117;
    --color-input-bg: #0d1117;
    --color-nav-bg: #161b22;
    --color-controls-bg: #161b22;
    --color-header-bg: #161b22;
    --color-text: #e0e0e0;
    --color-text-secondary: #c9d1d9;
    --color-text-muted: #8b949e;
    --color-text-dimmed: #6e7681;
    --color-accent: #58a6ff;
    --color-accent-emphasis: #1f6feb;
    --color-accent-hover: #388bfd;
    --color-accent-subtle: rgba(31, 111, 235, 0.2);
    --color-danger: #f85149;
    --color-danger-subtle: rgba(248, 81, 73, 0.2);
    --color-warning: #f59e0b;
    --color-warning-text: #fbbf24;
    --color-warning-subtle: rgba(245, 158, 11, 0.15);
    --color-success: #3fb950;
    --color-success-emphasis: #238636;
    --color-success-subtle: rgba(35, 134, 54, 0.2);
    --btn-primary-bg: linear-gradient(180deg, #2a7fff 0%, #1a6ad9 100%);
    --btn-primary-hover-bg: linear-gradient(180deg, #388bfd 0%, #1f6feb 100%);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-inset: inset 0 1px 3px rgba(0,0,0,0.25);
    --shadow-nav: 0 0 7px rgba(0,0,0,1);
    --shadow-label-row: inset 0px -30px 5px -30px rgb(0 0 0);
    --shadow-row-depth: inset 0 -1px 3px -2px rgba(0,0,0,0.2);
    --shadow-section-bottom: inset 0 -3px 6px -4px rgba(0,0,0,0.25);
    --shadow-section-top: inset 0 2px 4px -2px rgba(0,0,0,0.25);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.3), 0 0 1px rgba(0,0,0,0.4);
    --shadow-gantt-edge: rgba(0,0,0,0.3);
    --zebra-stripe: rgba(255,255,255,0.02);
    --overlay-bg: rgba(0,0,0,0.6);
    --overlay-loading: rgba(13,17,23,0.7);
    --surface-glass: rgba(22, 27, 34, 0.92);
    --highlight-top: rgba(255,255,255,0.03);
    --highlight-bar: rgba(255,255,255,0.08);
    --highlight-border-top: rgba(255,255,255,0.06);
    --highlight-modal-inset: rgba(255,255,255,0.04);
    --logo-invert: 1;
    --toast-error-bg: #2d1215;
    --toast-error-text: #f7b4b0;
}

[data-theme="light"] {
    --color-canvas: #F2F4FB;
    --color-surface: #ffffff;
    --color-surface-raised: #F8F9FF;
    --color-surface-hover: #E0E4F0;
    --color-border: #C5CBE0;
    --color-border-hover: #A8B0CC;
    --color-gantt-bg: #ffffff;
    --color-gantt-row-border: #D8DCE8;
    --color-gantt-row-hover: #EDF0FA;
    --color-labels-bg: #E5EAFA;
    --color-input-bg: #f4f6ff;
    --color-nav-bg: #E5EAFA;
    --color-controls-bg: #E5EAFA;
    --color-header-bg: #E5EAFA;
    --color-text: #1f2328;
    --color-text-secondary: #424a53;
    --color-text-muted: #586069;
    --color-text-dimmed: #7d8590;
    --color-accent: #0969da;
    --color-accent-emphasis: #0969da;
    --color-accent-hover: #0550ae;
    --color-accent-subtle: rgba(9, 105, 218, 0.12);
    --color-danger: #cf222e;
    --color-danger-subtle: rgba(207, 34, 46, 0.1);
    --color-warning: #9a6700;
    --color-warning-text: #7c5300;
    --color-warning-subtle: rgba(154, 103, 0, 0.12);
    --color-success: #1a7f37;
    --color-success-emphasis: #1a7f37;
    --color-success-subtle: rgba(26, 127, 55, 0.1);
    --btn-primary-bg: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
    --btn-primary-hover-bg: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.07);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --shadow-inset: inset 0 1px 2px rgba(0,0,0,0.08);
    --shadow-nav: 0px 0px 5px rgba(0,0,0,0.36);
    --shadow-label-row: inset 0px -30px 5px -31px #62646b;
    --shadow-row-depth: inset 0 -1px 3px -2px rgba(0,0,0,0.08);
    --shadow-section-bottom: inset 0 -3px 6px -4px rgba(0,0,0,0.1);
    --shadow-section-top: inset 0 2px 4px -2px rgba(0,0,0,0.06);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.08), 0 0 1px rgba(0,0,0,0.12);
    --shadow-gantt-edge: rgba(0,0,0,0.15);
    --zebra-stripe: rgba(0,0,0,0.015);
    --overlay-bg: rgba(0,0,0,0.3);
    --overlay-loading: rgba(242, 244, 251, 0.7);
    --surface-glass: rgba(242, 244, 251, 0.94);
    --highlight-top: rgba(255,255,255,0.6);
    --highlight-bar: rgba(255,255,255,0.4);
    --highlight-border-top: rgba(0,0,0,0.04);
    --highlight-modal-inset: rgba(255,255,255,0.8);
    --logo-invert: 0;
    --toast-error-bg: #ffebe9;
    --toast-error-text: #82071e;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-canvas);
    color: var(--color-text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Top Nav ---- */
.top-nav {
    display: flex;
    align-items: center;
    height: 48px;
    background: var(--color-nav-bg);
    border-bottom: 1px solid var(--color-border);
    padding: 0 16px;
    flex-shrink: 0;
    z-index: 100;
    box-shadow: var(--shadow-nav);
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 32px;
}
.brand-icon { font-size: 22px; }
.brand-logo {
    height: 24px;
    width: auto;
    filter: invert(var(--logo-invert));
}
.brand-logo-lg {
    height: 40px;
}
.brand-name { font-size: 16px; font-weight: 700; color: var(--color-text); letter-spacing: 0.5px; }
.nav-links { display: flex; gap: 4px; }
.nav-link {
    padding: 6px 16px;
    border-radius: 6px;
    color: var(--color-text-muted);
    font-weight: 500;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--color-surface-hover); color: var(--color-text); text-decoration: none; }
.nav-link.active { background: var(--color-accent-subtle); color: var(--color-accent); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.nav-clock { font-size: 12px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

/* ---- Main Content ---- */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ============================================================
   SCHEDULE PAGE
   ============================================================ */
.schedule-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Controls bar */
.schedule-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--color-controls-bg);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.schedule-controls label {
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.schedule-controls .ctrl-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.schedule-controls input[type="date"],
.schedule-controls select {
    background: var(--color-input-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    font-family: inherit;
}
.schedule-controls select { cursor: pointer; }
.schedule-controls .ctrl-separator {
    width: 1px;
    height: 24px;
    background: var(--color-border);
    margin: 0 4px;
}

/* Zoom slider */
.ctrl-group-zoom {
    min-width: 100px;
}
.ctrl-group-zoom input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.ctrl-group-zoom input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-accent);
    border: none;
    cursor: pointer;
}
.ctrl-group-zoom input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-accent);
    border: none;
    cursor: pointer;
}
.ctrl-group-zoom input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--color-accent-hover);
}
.ctrl-group-zoom input[type="range"]::-moz-range-thumb:hover {
    background: var(--color-accent-hover);
}

/* ---- Schedule warnings button ---- */
.warnings-btn-wrapper {
    position: relative;
    display: inline-block;
}
.warnings-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: default;
    background: transparent;
    transition: all 0.15s;
    white-space: nowrap;
}
.warnings-btn-inactive {
    color: var(--color-border-hover);
    border-color: var(--color-surface-hover);
    cursor: default;
}
.warnings-btn-active {
    color: var(--color-warning);
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.08);
    cursor: pointer;
}
.warnings-btn-active:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.6);
}
.warnings-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    background: var(--color-warning);
    color: #000;
}
/* Popup */
.warnings-popup {
    display: none;
    position: absolute;
    top: calc(100% - 1px);
    right: 0;
    z-index: 100;
    width: 480px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--surface-glass);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    box-shadow: var(--shadow-md), var(--shadow-sm);
    backdrop-filter: blur(8px);
    padding: 0;
}
.warnings-btn-wrapper:hover .warnings-popup,
.warnings-btn-wrapper:focus-within .warnings-popup {
    display: block;
}
.warnings-popup-header {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 700;
    color: var(--color-warning-text);
    border-bottom: 1px solid rgba(245, 158, 11, 0.15);
    position: sticky;
    top: 0;
    background: var(--color-surface);
}
.warnings-popup-list {
    padding: 8px;
}
.warnings-popup-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.5;
    cursor: pointer;
    transition: background 0.15s;
}
.warnings-popup-item:hover {
    background: rgba(245, 158, 11, 0.12);
}
.warnings-popup-item:active {
    background: rgba(245, 158, 11, 0.2);
}
.warnings-popup-type {
    display: inline-block;
    flex-shrink: 0;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.35);
}
.warnings-popup-item .warnings-popup-type:first-child {
    margin-top: 2px;
}
.warnings-popup-desc {
    color: var(--color-text-muted);
}

/* ---- Conflict navigation confirm dialog ---- */
.nav-confirm-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}
.nav-confirm-overlay.visible { opacity: 1; }
.nav-confirm-dialog {
    background: var(--color-surface);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 24px 28px;
    max-width: 420px;
    width: 90%;
}
.nav-confirm-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-warning-text);
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-confirm-title svg { flex-shrink: 0; }
.nav-confirm-body {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin: 0 0 20px 0;
}
.nav-confirm-body ul {
    margin: 8px 0 0 0;
    padding: 0 0 0 20px;
    list-style: disc;
}
.nav-confirm-body li {
    margin: 4px 0;
    color: var(--color-text);
}
.nav-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.nav-confirm-actions button {
    padding: 7px 18px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s, transform 0.1s;
}
.nav-confirm-actions button:active { transform: scale(0.97); }
.btn-nav-cancel {
    background: var(--color-surface-hover);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border) !important;
}
.btn-nav-cancel:hover { background: var(--color-border); }
.btn-nav-go {
    background: var(--color-warning);
    color: #000;
}
.btn-nav-go:hover { background: var(--color-warning-text); }

/* ---- Conflict navigation toast ---- */
.gantt-toast {
    position: fixed;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    white-space: nowrap;
}
.gantt-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---- Schedule legend button ---- */
.legend-btn-wrapper {
    position: relative;
    display: inline-block;
}
.legend-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--color-surface-hover);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 12px;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.legend-btn:hover {
    color: var(--color-text-secondary);
    border-color: var(--color-border-hover);
    background: rgba(139, 148, 158, 0.08);
}
.legend-popup {
    display: none;
    position: absolute;
    top: calc(100% - 1px);
    right: 0;
    z-index: 300;
    background: var(--surface-glass);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    width: 260px;
    box-shadow: var(--shadow-md), var(--shadow-sm);
    backdrop-filter: blur(8px);
    padding: 12px 14px;
}
.legend-btn-wrapper:hover .legend-popup,
.legend-btn-wrapper:focus-within .legend-popup {
    display: block;
}
.legend-section-header {
    font-size: 10px;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--color-surface-hover);
}
.legend-section-header:first-child {
    padding-top: 0;
    border-top: none;
}
.legend-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}
.legend-swatch {
    width: 32px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
}
.legend-swatch-event {
    position: relative;
    overflow: hidden;
}
.legend-swatch-event::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: repeating-linear-gradient(
        -45deg,
        rgba(0, 0, 0, 0.13),
        rgba(0, 0, 0, 0.13) 3px,
        transparent 3px,
        transparent 6px
    );
}
.legend-label {
    font-size: 12px;
    color: var(--color-text-secondary);
}

/* Schedule body: gantt + detail panel side by side */
.schedule-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* Inset shadows on left & right edges of the timeline body (below header) */
.schedule-body::before,
.schedule-body::after {
    content: "";
    position: absolute;
    top: 44px;
    bottom: 0;
    width: 6px;
    pointer-events: none;
    z-index: 10;
}
.schedule-body::before {
    left: 200px;
    background: linear-gradient(to right, var(--shadow-gantt-edge), transparent);
}
.schedule-body::after {
    right: 0;
    background: linear-gradient(to left, var(--shadow-gantt-edge), transparent);
}
.schedule-body:has(.gantt-labels-header-dual)::before,
.schedule-body:has(.gantt-labels-header-dual)::after {
    top: 62px;
}
#gantt-container {
    flex: 1;
    display: flex;
    min-width: 0;
    overflow: hidden;
    position: relative;
}
#gantt-container::after {
    content: "";
    position: absolute;
    left: 200px;
    right: 0;
    top: 44px;
    height: 6px;
    pointer-events: none;
    z-index: 10;
    background: linear-gradient(to bottom, var(--shadow-gantt-edge), transparent);
}
#gantt-container:has(.gantt-labels-header-dual)::after {
    top: 62px;
}

/* ============================================================
   GANTT CHART
   ============================================================ */
.gantt-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-width: 0;
}

/* Left label column */
.gantt-labels {
    width: 200px;
    min-width: 200px;
    overflow: hidden;
    border-right: 1px solid var(--color-border);
    background: var(--color-labels-bg);
    display: flex;
    flex-direction: column;
}

.gantt-labels-header {
    height: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0 12px;
}
.gantt-labels-header-dual {
    height: 62px;
    min-height: 62px;
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--color-header-bg);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 5;
}
.gantt-labels-body {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
}
.gantt-labels-body::-webkit-scrollbar { display: none; }

.gantt-label-row {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 12px;
    border-bottom: 1px solid var(--color-surface-hover);
    cursor: pointer;
    box-sizing: border-box;
    box-shadow: var(--shadow-label-row);
}
.gantt-label-row:hover { background: var(--color-gantt-row-hover); }
.gantt-label-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gantt-label-meta {
    font-size: 11px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Right timeline area */
.gantt-timeline-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
    scrollbar-width: none;                        /* Firefox: hide native h-scrollbar */
}
.gantt-timeline-wrapper::-webkit-scrollbar { display: none; } /* Chrome/Edge */

/* Fixed horizontal scroll proxy — always at viewport bottom */
.gantt-hscroll-proxy {
    position: fixed;
    bottom: 0;
    overflow-x: auto;
    overflow-y: hidden;
    z-index: 20;
    background: var(--color-gantt-bg);
    border-top: 1px solid var(--color-border);
}
.gantt-hscroll-proxy-inner {
    height: 1px;
}
.gantt-h-scroll {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Time header */
.gantt-time-header {
    height: 44px;
    min-height: 44px;
    background: var(--color-header-bg);
    border-bottom: 1px solid var(--color-border);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
/* Taller header when showing dual timezones */
.gantt-time-header-dual {
    height: 62px;
    min-height: 62px;
}
.gantt-time-header-inner {
    height: 100%;
    width: 100%;
    position: relative;
}
.gantt-hour-marker {
    position: absolute;
    top: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-left: 1px solid transparent;
    padding-left: 4px;
    gap: 0;
    overflow: visible;
    box-sizing: border-box;
}
.gantt-hour-marker.gantt-day-boundary {
    border-left: 1px solid #3d6a9e;
}
.gantt-hour-label {
    display: none;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    white-space: nowrap;
    line-height: 1.2;
}
.gantt-day-label {
    display: none;
    font-size: 10px;
    color: var(--color-text-dimmed);
    white-space: nowrap;
    line-height: 1.2;
}
/* Hour label thinning: JS sets data-hour-step on the header,
   CSS nth-child rules show every Nth label + its tick mark. */
[data-hour-step="1"] > .gantt-hour-marker,
[data-hour-step="2"] > :nth-child(2n+1),
[data-hour-step="3"] > :nth-child(3n+1),
[data-hour-step="4"] > :nth-child(4n+1),
[data-hour-step="6"] > :nth-child(6n+1),
[data-hour-step="8"] > :nth-child(8n+1),
[data-hour-step="12"] > :nth-child(12n+1),
[data-hour-step="24"] > :nth-child(24n+1) {
    border-left-color: var(--color-border);
}
[data-hour-step="1"] > .gantt-hour-marker :is(.gantt-hour-label, .gantt-day-label),
[data-hour-step="2"] > :nth-child(2n+1) :is(.gantt-hour-label, .gantt-day-label),
[data-hour-step="3"] > :nth-child(3n+1) :is(.gantt-hour-label, .gantt-day-label),
[data-hour-step="4"] > :nth-child(4n+1) :is(.gantt-hour-label, .gantt-day-label),
[data-hour-step="6"] > :nth-child(6n+1) :is(.gantt-hour-label, .gantt-day-label),
[data-hour-step="8"] > :nth-child(8n+1) :is(.gantt-hour-label, .gantt-day-label),
[data-hour-step="12"] > :nth-child(12n+1) :is(.gantt-hour-label, .gantt-day-label),
[data-hour-step="24"] > :nth-child(24n+1) :is(.gantt-hour-label, .gantt-day-label) {
    display: block;
}

/* Dual timezone markers */
.gantt-hour-local {
    color: var(--color-text);
    font-weight: 700;
}
.gantt-day-local {
    color: var(--color-text-muted);
}
.gantt-hour-utc {
    color: var(--color-text-dimmed);
    font-size: 10px;
    font-weight: 500;
}

/* Timeline body (rows + bars) */
.gantt-timeline {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    background: var(--color-gantt-bg);
}
.gantt-timeline-inner {
    position: relative;
    width: 100%;
    min-height: 100%;
}

/* Resource rows */
.gantt-row {
    position: relative;
    border-bottom: 1px solid var(--color-gantt-row-border);
    box-sizing: border-box;
}
.gantt-row:hover { background: var(--color-gantt-row-hover); }

/* Now indicator */
#gantt-now-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-danger);
    z-index: 10;
    pointer-events: none;
    display: none;
}

/* ---- Bars ---- */
.gantt-bar {
    position: absolute;
    height: 22px;
    border-radius: 3px;
    font-size: 12px;
    line-height: 22px;
    padding: 0 6px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    cursor: pointer;
    z-index: 2;
    transition: filter 0.1s;
    color: #fff;
    container-type: inline-size;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: inset 0 1px 0 var(--highlight-bar);
}
.gantt-bar:hover { filter: brightness(1.2); z-index: 5; }

/* ── Scheduled bars (top row — always muted) ── */
.gantt-bar-scheduled {
    background: rgba(139, 148, 158, 0.2);
    border: 1px solid rgba(139, 148, 158, 0.4);
    color: var(--color-text-muted);
}
/* Event scheduled: unified red (same scheme as event est/act) */
.gantt-bar-event-scheduled {
    background: #7f1d1d;
    border: 1px solid #b91c1c;
    color: #fecaca;
}

/* ── Utilization Est/Act bar status colors ── */
.bar-status-none {
    background: rgba(139, 148, 158, 0.35);
    border: 1px solid rgba(139, 148, 158, 0.6);
    color: var(--color-text-secondary);
}
.bar-status-estimated {
    background: #854d0e;
    border: 1px solid #ca8a04;
    color: #fef08a;
}
.bar-status-in_progress {
    background: #166534;
    border: 1px solid #22c55e;
    color: #bbf7d0;
}
.bar-status-completed {
    background: #1e40af;
    border: 1px solid #3b82f6;
    color: #bfdbfe;
}
.bar-status-overdue {
    background: #991b1b;
    border: 1px solid #ef4444;
    color: #fecaca;
}
.bar-status-cancelled {
    background: rgba(139, 148, 158, 0.12);
    border: 1px dashed rgba(139, 148, 158, 0.4);
    color: var(--color-text-dimmed);
}
.bar-status-hold {
    background: rgba(163, 113, 247, 0.15);
    border: 1px dashed rgba(163, 113, 247, 0.5);
    color: #d2a8ff;
}

/* ── Ops status overrides (cancelled / hold) ── */
.gantt-bar.bar-ops-cancelled {
    opacity: 0.5;
}
.gantt-bar.bar-ops-cancelled .bar-name {
    text-decoration: line-through;
}
.gantt-bar.bar-ops-hold {
    opacity: 0.65;
}

/* ── Event Est/Act bars — unified red scheme + hatching ──
   Active states (scheduled/estimated/actual) share one red style;
   cancelled gets a distinct muted scheme. */
.gantt-bar-event {
    position: relative;
    z-index: 3;
}

/* Active event states: one red scheme (distinct from utilization overdue) */
.gantt-bar-event.bar-status-none,
.gantt-bar-event.bar-status-estimated,
.gantt-bar-event.bar-status-in_progress,
.gantt-bar-event.bar-status-completed,
.gantt-bar-event.bar-status-overdue {
    background: #7f1d1d;
    border: 1px solid #b91c1c;
    color: #fecaca;
}
/* Event cancelled: muted scheme */
.gantt-bar-event.bar-status-cancelled {
    background: rgba(139, 148, 158, 0.12);
    border: 1px dashed rgba(139, 148, 158, 0.5);
    color: var(--color-text-dimmed);
}
/* Event hold: purple dashed (distinct from active) */
.gantt-bar-event.bar-status-hold {
    background: rgba(163, 113, 247, 0.15);
    border: 1px dashed rgba(163, 113, 247, 0.5);
    color: #d2a8ff;
}
/* Event bar when ops-cancelled: use cancelled scheme (override status colors) */
.gantt-bar-event.bar-ops-cancelled {
    background: rgba(139, 148, 158, 0.12);
    border: 1px dashed rgba(139, 148, 158, 0.5);
    color: var(--color-text-dimmed);
}

.gantt-bar-event::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: repeating-linear-gradient(
        -45deg,
        rgba(0, 0, 0, 0.13),
        rgba(0, 0, 0, 0.13) 3px,
        transparent 3px,
        transparent 6px
    );
    pointer-events: none;
}

/* ── Conflict indicator ── */
.gantt-bar.conflict {
    box-shadow: inset 0 1px 0 var(--highlight-bar), 0 0 0 2px var(--color-warning), 0 0 8px rgba(245, 158, 11, 0.4);
}

/* ── Conflict pulse animation (triggered on warning click) ── */
@keyframes conflict-pulse {
    0%, 100% { box-shadow: inset 0 1px 0 var(--highlight-bar), 0 0 0 2px var(--color-warning), 0 0 8px rgba(245, 158, 11, 0.4); }
    50%      { box-shadow: inset 0 1px 0 var(--highlight-bar), 0 0 0 5px var(--color-warning), 0 0 20px rgba(245, 158, 11, 0.7); }
}
.gantt-bar.conflict-pulse {
    animation: conflict-pulse 0.8s ease-in-out 6;
    z-index: 10;
}

/* ── Staffing indicators ── */
.gantt-bar.staffing-understaffed {
    border: 2px dashed var(--color-warning);
}
.gantt-bar.staffing-overstaffed {
    border: 2px dashed #ef4444;
}
.gantt-bar.staffing-both {
    border: 2px dashed var(--color-warning);
    box-shadow: inset 0 1px 0 var(--highlight-bar), inset 0 0 0 1px rgba(239, 68, 68, 0.5);
}

/* ── Bar text/location labels ── */
.bar-loc-start, .bar-loc-end {
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}
.bar-name {
    font-weight: 600;
    flex: 1;
    text-align: center;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive bar labels via container queries.
   Priority: origin/dest > name.
   Wide (>100px):  [ORIG] name [DEST]  – full horizontal layout
   Medium (55-100px): [ORIG] [DEST]    – side-by-side, name hidden
   Small (30-55px):   ORIG stacked     – locations stacked vertically
                      DEST
   Tiny (<30px):      (blank bar)      – all text hidden */
@container (max-width: 90px) {
    .bar-name { display: none; }
    .bar-loc-end { margin-left: auto; }
}
@container (max-width: 45px) {
    .bar-loc-start, .bar-loc-end {
        position: absolute;
        font-size: 8px;
        font-weight: 700;
        line-height: 1;
        left: 0;
        right: 0;
        text-align: center;
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .bar-loc-start { top: 2px; }
    .bar-loc-end   { bottom: 2px; }
}
@container (max-width: 10px) {
    .bar-loc-start, .bar-loc-end { display: none; }
}

/* ---- Empty state ---- */
.gantt-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 24px;
    color: var(--color-text-muted);
    font-size: 14px;
}
.gantt-empty-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 24px 32px;
    max-width: 420px;
    text-align: left;
}
.gantt-empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 12px;
}
.gantt-empty-desc {
    margin-bottom: 12px;
    color: var(--color-text-muted);
}
.gantt-empty-steps {
    margin: 0 0 16px 20px;
    color: var(--color-text-muted);
}
.gantt-empty-steps a {
    color: var(--color-accent);
}
.gantt-empty-steps a:hover {
    text-decoration: underline;
}
.gantt-empty-hint {
    font-size: 12px;
    color: var(--color-text-dimmed);
}
.gantt-empty-hint code {
    background: var(--color-surface-hover);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}

/* ============================================================
   CONTEXT MENU (positioned by JS on bar click)
   ============================================================ */
.bar-context-menu {
    position: fixed;
    z-index: 250;
    background: var(--surface-glass);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    min-width: 140px;
    box-shadow: var(--shadow-md), var(--shadow-sm);
    backdrop-filter: blur(8px);
    overflow: hidden;
    padding: 4px 0;
}
.ctx-item {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
}
.ctx-item:hover {
    background: var(--color-accent-emphasis);
    color: #fff;
}
.ctx-divider {
    height: 1px;
    margin: 4px 8px;
    background: var(--color-border);
}

/* ============================================================
   BAR TOOLTIP (positioned by JS on bar hover)
   ============================================================ */
.bar-tooltip {
    position: fixed;
    z-index: 240;
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    border-top: 1px solid var(--highlight-border-top);
    border-radius: 8px;
    box-shadow: var(--shadow-md), var(--shadow-sm);
    padding: 8px 12px;
    max-width: 520px;
    pointer-events: none;
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.4;
    overflow: hidden;
}
.tooltip-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}
.tooltip-times {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 12px;
    margin-bottom: 4px;
}
.tooltip-time-pair {
    display: flex;
    align-items: baseline;
    gap: 5px;
    min-width: 0;
}
.tooltip-time-label {
    font-size: 10px;
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}
.tooltip-time-value {
    font-size: 11px;
    color: var(--color-text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tooltip-slots {
    border-top: 1px solid var(--color-border);
    padding-top: 4px;
    margin-top: 2px;
    display: flex;
    flex-wrap: wrap;
    gap: 1px 12px;
}
.tooltip-slot-row {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-size: 11px;
}
.tooltip-slot-title {
    color: var(--color-text-muted);
    font-weight: 600;
}
.tooltip-slot-resource {
    color: var(--color-accent);
}

/* ---- Tooltip: Origin / Destination route ---- */
.tooltip-route {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 12px;
}
.tooltip-route-origin,
.tooltip-route-dest {
    color: var(--color-text);
    font-weight: 600;
}
.tooltip-route-arrow {
    color: var(--color-text-muted);
    font-size: 11px;
}

/* ---- Tooltip: Custom fields ---- */
.tooltip-custom-fields {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1px 8px;
    margin-bottom: 4px;
    border-top: 1px solid var(--color-border);
    padding-top: 4px;
    margin-top: 2px;
}
.tooltip-cf-label {
    font-size: 10px;
    color: var(--color-text-muted);
    font-weight: 600;
}
.tooltip-cf-value {
    font-size: 11px;
    color: var(--color-text-secondary);
}

/* ---- Tooltip: Conflict warnings ---- */
.tooltip-conflicts {
    border-top: 1px solid var(--color-border);
    padding-top: 4px;
    margin-top: 2px;
}
.tooltip-conflicts-header {
    font-size: 10px;
    color: var(--color-warning-text);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 3px;
}
.tooltip-conflicts-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.tooltip-conflict-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px;
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    color: var(--color-text-secondary);
    line-height: 1.4;
}
.tooltip-conflict-badge {
    display: inline-block;
    flex-shrink: 0;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: rgba(245, 158, 11, 0.2);
    color: var(--color-warning-text);
    border: 1px solid rgba(245, 158, 11, 0.35);
}
.tooltip-conflict-item.tooltip-conflict-event_utilization_overlap .tooltip-conflict-badge,
.tooltip-conflict-item.tooltip-conflict-utilization_overlap .tooltip-conflict-badge {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.35);
}
.tooltip-conflict-item.tooltip-conflict-discontinuity .tooltip-conflict-badge {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.35);
}
.tooltip-conflict-desc {
    color: var(--color-text-muted);
}

/* ---- Hidden utility ---- */
.hidden { display: none !important; }

/* ---- Timezone badge (used in modals / tooltips) ---- */
.tz-badge {
    font-size: 10px;
    font-weight: 500;
    color: var(--color-accent);
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 8px;
}

/* ---- Delay preview ---- */
.delay-preview {
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 10px 14px;
    margin-top: 12px;
}
.delay-preview-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 2px 0;
}
.delay-preview-label { color: var(--color-text-muted); }
.delay-preview-value { color: var(--color-text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- Cascade preview table ---- */
.cascade-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.cascade-preview-table th {
    text-align: left;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-canvas);
}
.cascade-preview-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--color-surface-hover);
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}
.cascade-preview-table .cascade-name {
    color: var(--color-text);
    font-weight: 500;
}
.cascade-changed td {
    color: var(--color-text-secondary);
}
.cascade-new-time {
    color: var(--color-warning-text) !important;
    font-weight: 600;
}
.cascade-unchanged td {
    opacity: 0.6;
}

/* ---- Cascade toggle ---- */
.cascade-section {
    border-top: 1px solid var(--color-border);
    margin-top: 16px;
    padding-top: 12px;
}
.cascade-fields {
    display: none;
    margin-top: 10px;
}
.cascade-fields.active {
    display: block;
}

/* ---- Modal close button ---- */
.modal-close-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
}
.modal-close-btn:hover { background: var(--color-surface-hover); color: var(--color-text); }

/* ============================================================
   FORMS (shared by detail panel + config)
   ============================================================ */
.form-group {
    margin-bottom: 12px;
}
.form-group label {
    display: block;
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}
.form-control {
    width: 100%;
    padding: 6px 10px;
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    color: var(--color-text);
    font-size: 13px;
    font-family: inherit;
    box-shadow: var(--shadow-inset);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.2), 0 0 0 3px rgba(88,166,255,0.15);
}
textarea.form-control { resize: vertical; min-height: 60px; }
select.form-control { cursor: pointer; }

.form-row {
    display: flex;
    gap: 12px;
}
.form-row .form-group { flex: 1; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
    box-shadow: var(--shadow-sm);
}
.btn:active {
    transform: translateY(1px);
    box-shadow: none;
}
.btn-primary {
    background: var(--btn-primary-bg);
    border-color: rgba(0,0,0,0.2);
    color: #fff;
}
.btn-primary:hover { background: var(--btn-primary-hover-bg); }
.btn-danger {
    background: transparent;
    border-color: var(--color-danger);
    color: var(--color-danger);
}
.btn-danger:hover { background: rgba(248, 81, 73, 0.15); }
.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border-color: transparent;
    box-shadow: none;
}
.btn-ghost:hover { background: var(--color-surface-hover); color: var(--color-text); box-shadow: inset 0 1px 2px rgba(0,0,0,0.15); }
.btn-warning {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--color-warning);
    color: var(--color-warning-text);
}
.btn-warning:hover { background: rgba(245, 158, 11, 0.3); }
.btn-sm { padding: 3px 10px; font-size: 12px; }

/* ---- Conflict warnings panel ---- */
.conflict-warnings {
    background: var(--color-canvas);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    padding: 20px;
    margin: 12px 0;
}
.conflict-warnings-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: var(--color-warning-text);
    margin-bottom: 6px;
}
.conflict-warnings-subtitle {
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 0 0 16px 0;
}
.conflict-warning-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}
.conflict-warning-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.5;
}
.conflict-warning-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    flex-shrink: 0;
}
.conflict-warning-utilization_overlap .conflict-warning-badge,
.conflict-warning-event_overlap .conflict-warning-badge {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.35);
}
.conflict-warning-discontinuity_incoming .conflict-warning-badge,
.conflict-warning-discontinuity_outgoing .conflict-warning-badge,
.conflict-warning-discontinuity .conflict-warning-badge {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.35);
}
.conflict-warning-understaffed .conflict-warning-badge {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.35);
}
.conflict-warning-overstaffed .conflict-warning-badge {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.35);
}
.conflict-warning-resource {
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
}
.conflict-warning-desc {
    color: var(--color-text-muted);
}
.conflict-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid rgba(245, 158, 11, 0.15);
}

/* ---- Operational Notes ---- */
.notes-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 4px;
}
.note-item {
    padding: 8px 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-surface-hover);
    border-radius: 6px;
}
.note-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.note-author {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
}
.note-time {
    font-size: 11px;
    color: var(--color-text-dimmed);
    font-variant-numeric: tabular-nums;
}
.note-text {
    font-size: 13px;
    color: var(--color-text-muted);
    white-space: pre-wrap;
    line-height: 1.5;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--color-surface-hover);
}

/* ---- Event Impact Analysis ---- */
.impact-event-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-surface-hover);
    border-radius: 6px;
    font-size: 13px;
}
.impact-event-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.impact-event-label {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 72px;
    flex-shrink: 0;
}
.impact-event-value {
    color: var(--color-text);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}
.impact-resource-tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    background: var(--color-surface-hover);
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 500;
}
.impact-resource-tag-sm {
    display: inline-block;
    padding: 0 5px;
    border-radius: 8px;
    background: var(--color-surface-hover);
    color: var(--color-text-muted);
    font-size: 11px;
}
.impact-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    margin-bottom: 12px;
    border-radius: 6px;
    font-size: 13px;
    background: rgba(248, 81, 73, 0.08);
    border: 1px solid rgba(248, 81, 73, 0.25);
    color: #fca5a5;
}
.impact-summary-clear {
    background: rgba(63, 185, 80, 0.08);
    border: 1px solid rgba(63, 185, 80, 0.25);
    color: #7ee787;
}
.impact-summary-stat strong {
    color: var(--color-text);
}
.impact-summary-divider {
    color: var(--color-border-hover);
}
.impact-section-header {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

/* Impact table */
.impact-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 8px;
}
.impact-table th {
    text-align: left;
    padding: 5px 8px;
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-canvas);
}
.impact-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--color-surface-hover);
    vertical-align: top;
    color: var(--color-text-secondary);
}
.impact-util-name {
    font-weight: 600;
    color: var(--color-text);
}
.impact-time {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-size: 11px;
    color: var(--color-text-muted);
    line-height: 1.6;
}
.impact-route {
    white-space: nowrap;
}
.impact-reason {
    color: var(--color-text-muted);
    font-size: 11px;
    line-height: 1.5;
}
.impact-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
}
.impact-badge-direct {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.35);
}
.impact-badge-cascade {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.35);
}

/* Resource chain */
.impact-chain {
    margin-bottom: 14px;
    border: 1px solid var(--color-surface-hover);
    border-radius: 6px;
    overflow: hidden;
}
.impact-chain-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 8px 12px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-surface-hover);
}
.impact-chain-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}
.impact-chain-meta {
    font-size: 11px;
    color: var(--color-text-muted);
}
.impact-chain-entries {
    padding: 4px 0;
}
.impact-chain-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    font-size: 12px;
}
.impact-chain-entry:not(:last-child) {
    border-bottom: 1px solid var(--color-surface);
}
.impact-chain-status {
    display: inline-block;
    width: 60px;
    text-align: center;
    padding: 1px 0;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.impact-chain-entry-blocked_direct .impact-chain-status {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}
.impact-chain-entry-blocked_cascade .impact-chain-status {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}
.impact-chain-entry-ok .impact-chain-status {
    background: rgba(63, 185, 80, 0.1);
    color: #7ee787;
}
.impact-chain-util-name {
    color: var(--color-text);
    font-weight: 500;
    min-width: 100px;
}
.impact-chain-time {
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 110px;
}
.impact-chain-route {
    color: var(--color-text-muted);
    white-space: nowrap;
    min-width: 80px;
}
.impact-chain-disc {
    font-size: 11px;
    color: var(--color-warning);
    font-style: italic;
}

/* ============================================================
   CONFIG PAGE
   ============================================================ */
.config-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.config-tabs {
    display: flex;
    gap: 0;
    background: var(--color-nav-bg);
    border-bottom: 1px solid var(--color-border);
    padding: 0 16px;
    flex-shrink: 0;
    box-shadow: var(--shadow-section-bottom);
}
.config-tab {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
    transition: color 0.15s, border-color 0.15s;
}
.config-tab:hover { color: var(--color-text); }
.config-tab.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
    text-shadow: 0 0 12px rgba(88,166,255,0.4);
}

.config-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Config tables */
.config-table-wrapper {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
.config-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-canvas);
    box-shadow: var(--shadow-section-bottom);
}
.config-table-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
}
.config-error-banner {
    margin: 12px 16px;
    padding: 10px 14px;
    background: rgba(248, 81, 73, 0.12);
    border: 1px solid var(--color-danger);
    border-radius: 6px;
    color: var(--color-danger);
    font-size: 13px;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
}
table.data-table th {
    text-align: left;
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--color-canvas);
    border-bottom: 1px solid var(--color-border);
}
table.data-table td {
    padding: 7px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    transition: background 0.12s;
}
table.data-table tr {
    box-shadow: var(--shadow-row-depth);
}
table.data-table tr:nth-child(even) td {
    background: var(--zebra-stripe);
}
table.data-table tr:hover td { background: var(--color-surface-raised); }
table.data-table .actions-cell {
    text-align: right;
    white-space: nowrap;
}

/* Inline add row */
.inline-add-form {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    background: var(--color-canvas);
    border-bottom: 1px solid var(--color-border);
    align-items: flex-end;
    flex-wrap: wrap;
    box-shadow: var(--shadow-section-top);
}
.inline-add-form .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 120px;
}
.inline-add-form .form-group label {
    font-size: 10px;
    margin-bottom: 2px;
}

/* Expandable detail rows */
.expand-row td {
    padding: 0;
    background: var(--color-canvas);
    box-shadow: var(--shadow-section-top);
}
.expand-content {
    padding: 12px 20px;
}
.expand-content h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 10px;
}

/* Sub-tables (fields, slots) */
table.sub-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
}
table.sub-table th {
    text-align: left;
    padding: 6px 12px;
    font-size: 10px;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
table.sub-table td {
    padding: 5px 12px;
    font-size: 12px;
    border-bottom: 1px solid var(--color-border);
}

/* Tags / badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.badge-type {
    background: var(--color-accent-subtle);
    color: var(--color-accent);
}
.badge-required {
    background: var(--color-danger-subtle);
    color: var(--color-danger);
}
.badge-bool-true {
    background: var(--color-success-subtle);
    color: var(--color-success);
}
.badge-bool-false {
    background: var(--color-surface-hover);
    color: var(--color-text-muted);
}

/* Toggle switch */
.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    vertical-align: middle;
}
.toggle-input { display: none; }
.toggle-switch {
    display: inline-block;
    width: 36px;
    min-width: 36px;
    height: 20px;
    background: var(--color-border);
    border-radius: 10px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-switch::after {
    content: "";
    display: block;
    width: 16px;
    height: 16px;
    background: var(--color-text);
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}
.toggle-input:checked + .toggle-switch {
    background: var(--color-accent-emphasis);
}
.toggle-input:checked + .toggle-switch::after {
    transform: translateX(16px);
}

/* Enum options list */
.enum-options-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.enum-option-tag {
    background: var(--color-surface-hover);
    color: var(--color-text-muted);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
}

/* ---- Toast / flash messages ---- */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--color-success-emphasis);
    color: #fff;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 13px;
    z-index: 1000;
    animation: toast-in 0.3s ease, toast-out 0.3s ease 2.5s forwards;
}
.toast.error { background: var(--color-danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; } }

/* ---- Empty states ---- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-muted);
}
.empty-state-icon { font-size: 32px; margin-bottom: 12px; }
.empty-state-text { font-size: 14px; }

/* ---- Error pages ---- */
.error-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.error-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 48px;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--shadow-sm), 0 0 1px rgba(0,0,0,0.15);
}
.error-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 12px;
}
.error-text {
    font-size: 14px;
    color: var(--color-text-muted);
    margin-bottom: 24px;
}
.error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---- 404 fragment (HTMX swap) ---- */
.not-found-fragment {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 24px;
    color: var(--color-text-muted);
    font-size: 14px;
}
.not-found-icon { font-size: 18px; color: var(--color-danger); }
.not-found-text { font-style: italic; }

/* ---- HTMX loading indicators ---- */
.htmx-indicator {
    display: none;
    align-items: center;
    justify-content: center;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: flex;
}
.schedule-body-relative {
    position: relative;
}
.gantt-loading-overlay {
    position: absolute;
    inset: 0;
    background: var(--overlay-loading);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 6px;
}
#gantt-loading {
    display: none;
}
/* HTMX shows indicator when requesting element has htmx-request; use :has() to show our overlay */
.schedule-body-relative:has(#gantt-container.htmx-request) #gantt-loading {
    display: flex;
}
.htmx-indicator-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: htmx-spinner 0.7s linear infinite;
}
@keyframes htmx-spinner {
    to { transform: rotate(360deg); }
}
.config-content-wrapper {
    position: relative;
    flex: 1;
    overflow: auto;
}
.config-loading-overlay {
    position: absolute;
    inset: 0;
    background: var(--overlay-loading);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5;
}
.config-wrapper:has(.config-tab.htmx-request) #config-loading,
.config-wrapper:has(form.htmx-request) #config-loading {
    display: flex;
}

/* ---- Scrollbars (webkit) ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--color-canvas); }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 4px; border: 2px solid var(--color-canvas); }
::-webkit-scrollbar-thumb:hover { background: var(--color-border-hover); }

/* ---- Modal overlay ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    width: 520px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md), var(--shadow-lg), inset 0 1px 0 var(--highlight-modal-inset);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}
.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
}
.modal-body { padding: 20px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--color-border);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-canvas);
}
.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 40px;
    width: 380px;
    max-width: 95vw;
    box-shadow: var(--shadow-sm), var(--shadow-lg), 0 0 1px rgba(0,0,0,0.15);
}
.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
    color: var(--color-text);
}
.login-error {
    background: rgba(248, 81, 73, 0.15);
    border: 1px solid var(--color-danger);
    color: var(--color-danger);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}
.login-btn {
    width: 100%;
    justify-content: center;
    padding: 10px;
    font-size: 14px;
    margin-top: 8px;
}

/* ============================================================
   USER SETTINGS PAGE
   ============================================================ */
.settings-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    justify-content: center;
}
.settings-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 32px;
    width: 680px;
    max-width: 100%;
    box-shadow: var(--shadow-sm), 0 0 1px rgba(0,0,0,0.15);
}
.settings-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 24px;
}
.settings-section {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--color-surface-hover);
}
.settings-section:last-of-type {
    border-bottom: none;
}
.settings-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}
.settings-hint {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}
.settings-success {
    background: rgba(35, 134, 54, 0.15);
    border: 1px solid var(--color-success-emphasis);
    color: var(--color-success);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}
.settings-error {
    background: rgba(248, 81, 73, 0.15);
    border: 1px solid var(--color-danger);
    color: var(--color-danger);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ============================================================
   NAV USER MENU
   ============================================================ */
.nav-user-menu {
    position: relative;
    cursor: pointer;
}
.nav-user-name {
    font-size: 13px;
    color: var(--color-text);
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    transition: background 0.15s;
}
.nav-user-name:hover {
    background: var(--color-surface-hover);
}
.nav-user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% - 1px);
    right: 0;
    margin-top: 0;
    background: var(--surface-glass);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    min-width: 160px;
    box-shadow: var(--shadow-md), var(--shadow-sm);
    backdrop-filter: blur(8px);
    z-index: 200;
    overflow: hidden;
}
.nav-user-menu:hover .nav-user-dropdown {
    display: block;
}
.dropdown-item {
    display: block;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--color-text);
    transition: background 0.15s;
}
.dropdown-item:hover {
    background: var(--color-surface-hover);
    text-decoration: none;
}
.dropdown-item-btn {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
}

/* ============================================================
   PERMISSION GRID (Roles tab)
   ============================================================ */
.perm-grid {
    width: 100%;
    border-collapse: collapse;
}
.perm-grid th {
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    text-align: center;
    background: var(--color-canvas);
    border-bottom: 1px solid var(--color-border);
}
.perm-grid th:first-child {
    text-align: left;
}
.perm-grid td {
    padding: 6px 10px;
    font-size: 12px;
    border-bottom: 1px solid var(--color-surface-hover);
    text-align: center;
}
.perm-grid td:first-child {
    text-align: left;
    font-weight: 500;
    color: var(--color-text);
}
.perm-grid input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-accent-emphasis);
}
.perm-entity-label {
    text-transform: capitalize;
}

/* Badge additions */
.badge-system {
    background: #6e40c933;
    color: #d2a8ff;
}
.badge-active {
    background: var(--color-success-subtle);
    color: var(--color-success);
}
.badge-inactive {
    background: var(--color-surface-hover);
    color: var(--color-text-muted);
}
.badge-role {
    background: var(--color-accent-subtle);
    color: var(--color-accent);
    margin-right: 4px;
    margin-bottom: 2px;
}

/* ---- Global Error Toast ---- */
.global-error-toast {
    position: fixed;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.global-error-toast.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(-12px);
}
.global-error-toast-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--toast-error-bg);
    border: 1px solid var(--color-danger);
    border-radius: 8px;
    padding: 12px 18px;
    color: var(--toast-error-text);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    max-width: 560px;
    min-width: 280px;
}
.global-error-icon {
    color: var(--color-danger);
    font-size: 18px;
    flex-shrink: 0;
}
.global-error-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 0 0 0 8px;
    line-height: 1;
    flex-shrink: 0;
}
.global-error-close:hover {
    color: var(--color-danger);
}

/* ============================================================
   RESPONSIVE — mobile / small-screen overrides
   ============================================================ */
@media (max-width: 768px) {

    /* ---- Nav bar ---- */
    .top-nav {
        height: 40px;
        padding: 0 10px;
    }
    .brand-name { display: none; }
    .nav-brand { margin-right: 12px; }
    .nav-clock { display: none; }
    .nav-link { padding: 4px 10px; font-size: 12px; }
    .nav-right { gap: 8px; }

    /* ---- Schedule controls ---- */
    .schedule-controls {
        flex-wrap: wrap;
        gap: 6px 10px;
        padding: 8px 10px;
    }
    .schedule-controls .ctrl-separator { display: none; }
    .schedule-controls .ctrl-group label { display: none; }
    .schedule-controls input[type="date"],
    .schedule-controls select {
        padding: 3px 6px;
        font-size: 12px;
    }

    /* ---- Gantt inset shadow: match narrower labels ---- */
    .schedule-body::before { left: 120px; }
    #gantt-container::after { left: 120px; }

    /* ---- Gantt: restore native scrollbar on touch devices ---- */
    .gantt-timeline-wrapper {
        scrollbar-width: auto;
        -webkit-overflow-scrolling: touch;
    }
    .gantt-timeline-wrapper::-webkit-scrollbar { display: initial; }
    .gantt-hscroll-proxy { display: none !important; }

    /* ---- Gantt labels column ---- */
    .gantt-labels {
        width: 120px;
        min-width: 120px;
    }
    .gantt-label-row { padding: 0 6px; }
    .gantt-label-name { font-size: 11px; }
    .gantt-label-meta { font-size: 9px; }
    .gantt-labels-header,
    .gantt-labels-header-dual {
        padding: 0 6px;
        font-size: 10px;
    }

    /* ---- Config page ---- */
    .config-tabs {
        overflow-x: auto;
        scrollbar-width: none;
        padding: 0 8px;
    }
    .config-tabs::-webkit-scrollbar { display: none; }
    .config-tab { padding: 8px 12px; font-size: 12px; white-space: nowrap; }
    .config-content { padding: 12px; }
    .config-table-wrapper { overflow-x: auto; }
    .config-table-header { padding: 8px 10px; }

    /* ---- Forms ---- */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* ---- Settings page ---- */
    .settings-wrapper { padding: 12px; }
    .settings-card {
        width: 100%;
        padding: 16px;
    }

    /* ---- Modals ---- */
    .modal { width: 95vw; }

    /* ---- Popups: keep within viewport on mobile ---- */
    .warnings-popup {
        position: fixed;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        width: min(480px, calc(100vw - 24px));
        top: 140px;
    }
    .legend-popup { width: min(260px, 90vw); }
    .nav-user-dropdown { min-width: min(160px, 80vw); }
}
