/* ==========================================================================
   CasePloy — Components
   Depends on base.css for tokens. Organised: buttons, forms, data display,
   feedback, navigation, overlays.
   ========================================================================== */

/* ==========================================================================
   BUTTONS
   .btn + variant (.btn-primary/.btn-secondary/.btn-ghost/.btn-danger/.btn-light)
   Sizes: .btn-sm / default / .btn-lg   Modifiers: .btn-block .btn-icon
   ========================================================================== */

.password-control { display:block; position:relative; width:100%; min-width:0; }
.password-control .input { padding-right:72px; }
.password-toggle { position:absolute; right:5px; top:50%; transform:translateY(-50%); min-height:40px; padding:8px 12px; border:0; border-radius:6px; background:transparent; color:#0058d9; font:inherit; font-size:13px; cursor:pointer; }
.password-toggle:hover { background:#edf3ff; }
.password-toggle:focus-visible { outline:2px solid #0058d9; outline-offset:1px; }
.password-hint { display:block; margin-top:7px; color:#626e80; font-size:12px; line-height:1.5; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    height: 38px;
    padding: 0 var(--s-4);
    border: 0;
    border-radius: var(--r-md);
    font-size: var(--text-base);
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background var(--dur) var(--ease),
                box-shadow var(--dur) var(--ease),
                color var(--dur) var(--ease),
                opacity var(--dur) var(--ease);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn svg { flex-shrink: 0; }

/* Loading — swaps in a spinner without touching the label. `spin` is the one
   animation here that isn't an entrance or a colour: it reports progress. */
.btn.is-loading {
    pointer-events: none;
    opacity: 0.9;
}
.btn.is-loading::before {
    content: "";
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    border-radius: var(--r-full);
    border: 2px solid currentColor;
    border-top-color: transparent;
    opacity: 0.75;
    animation: spin 0.7s linear infinite;
}

/* -- Variants -- */
/* Primary carries the logo gradient. Hover and active are a wash layered on
   top rather than a second gradient, so the brand ramp never changes. */
.btn-primary {
    background: var(--brand-gradient);
    color: var(--on-accent);
    box-shadow: var(--shadow-glow);
}
.btn-primary:hover  { box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0.10), var(--shadow-glow); }
.btn-primary:active { box-shadow: inset 0 0 0 999px rgba(0, 0, 0, 0.10), var(--shadow-glow); }

.btn-secondary {
    background: var(--surface-3);
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--border-strong);
}
.btn-secondary:hover  { background: var(--surface-4); box-shadow: inset 0 0 0 1px var(--border-loud); }
.btn-secondary:active { background: var(--surface-3); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* Maximum-contrast button — inverts with the theme */
.btn-light {
    background: var(--contrast-bg);
    color: var(--contrast-text);
}
.btn-light:hover { background: var(--contrast-hover); }

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}
.btn-danger:hover { background: #f9868a; }

/* Outline — lighter than .btn-secondary. For social sign-in and any place a
   secondary action sits directly on a page background. */
.btn-outline {
    background: var(--surface-1);
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--border-strong);
}
.btn-outline:hover {
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--border-loud);
}

/* -- Sizes -- */
.btn-sm { height: 30px; padding: 0 var(--s-3); font-size: var(--text-sm); border-radius: var(--r-sm); }
.btn-lg { height: 46px; padding: 0 var(--s-6); font-size: var(--text-md); }

/* -- Modifiers -- */
.btn-block { width: 100%; }

.btn-icon {
    width: 38px;
    padding: 0;
    flex-shrink: 0;
}
.btn-icon.btn-sm { width: 30px; }
.btn-icon.btn-lg { width: 46px; }

/* Button group — joined segmented control */
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.btn-group .btn:last-child  { border-radius: 0 var(--r-md) var(--r-md) 0; }
.btn-group .btn + .btn { margin-left: 1px; }

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

.field { display: flex; flex-direction: column; gap: var(--s-2); }

.label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.005em;
}

.label .req { color: var(--danger); margin-left: 2px; }

.hint { font-size: var(--text-sm); color: var(--text-faint); }

.error-text {
    font-size: var(--text-sm);
    color: var(--danger);
    display: flex;
    align-items: center;
    gap: var(--s-1);
}

/* Filled with a weighted base rule — deliberately not the boxed-outline-plus-
   glow-ring treatment every default form ships with. Focus lifts the fill and
   thickens the base line to the accent; no halo. */
.input,
.select,
.textarea {
    width: 100%;
    height: 42px;
    padding: 0 var(--s-4);
    border: 0;
    border-radius: var(--r-md) var(--r-md) 2px 2px;
    /* background-color, never the `background` shorthand: the shorthand resets
       background-position, which makes .select's arrow animate in from the left. */
    background-color: var(--surface-2);
    box-shadow: inset 0 -1.5px 0 var(--border-loud);
    color: var(--text);
    font-size: var(--text-base);
    outline: none;
    transition: background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

/* Large — pairs with .btn-lg so inputs and buttons share one height */
.input-lg { height: 46px; font-size: var(--text-md); }

.textarea {
    height: auto;
    min-height: 100px;
    padding: var(--s-3) var(--s-4);
    resize: vertical;
    line-height: 1.6;
}

.input::placeholder,
.textarea::placeholder { color: var(--text-faint); }

.input:hover,
.select:hover,
.textarea:hover {
    background-color: var(--surface-3);
    box-shadow: inset 0 -1.5px 0 var(--text-faint);
}

.input:focus,
.select:focus,
.textarea:focus {
    background-color: var(--surface-3);
    box-shadow: inset 0 -2px 0 var(--accent);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input.is-error,
.select.is-error,
.textarea.is-error {
    background-color: var(--danger-soft);
    box-shadow: inset 0 -2px 0 var(--danger);
}

/* Native select arrow */
.select {
    appearance: none;
    padding-right: var(--s-10);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%238d94a5' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--s-4) center;
}
.select option { background: var(--surface-2); }

/* Input with a leading icon */
.input-group { position: relative; display: block; }

.input-group .input-icon {
    position: absolute;
    left: var(--s-4);
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-faint);
    pointer-events: none;
    transition: color var(--dur) var(--ease);
}

.input-group .input { padding-left: 42px; }
.input-group:focus-within .input-icon { color: var(--accent-bright); }

/* Checkbox & radio — fully custom, no native accent-color */
.choice {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    cursor: pointer;
    user-select: none;
    font-size: var(--text-base);
    color: var(--text-muted);
}
.choice:hover { color: var(--text); }

.choice input[type="checkbox"],
.choice input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin: 0;
    cursor: pointer;
    background-color: var(--surface-1);
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: inset 0 0 0 1px var(--border-loud);
    transition: background-color var(--dur) var(--ease),
                box-shadow var(--dur) var(--ease);
}

.choice input[type="checkbox"] { border-radius: var(--r-sm); }
.choice input[type="radio"]    { border-radius: var(--r-full); }

.choice:hover input:not(:checked) { box-shadow: inset 0 0 0 1px var(--accent); }

/* Tick drawn as an inline SVG background — pseudo-elements on inputs are unreliable */
.choice input[type="checkbox"]:checked {
    background-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none'%3E%3Cpath d='M2.5 6.3 4.9 8.7 9.6 3.5' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: 12px 12px;
}

.choice input[type="radio"]:checked {
    background-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
    background-image: radial-gradient(circle at center, #fff 0 3.2px, transparent 3.6px);
}

/* A small settle on check — no bounce */
.choice input:checked { animation: check-settle 0.18s var(--ease-out); }

@keyframes check-settle {
    from { transform: scale(0.88); }
    to   { transform: scale(1); }
}

.choice input:disabled { opacity: 0.45; cursor: not-allowed; }

/* Shared checkboxes: stable square geometry and first-line label alignment. */
.choice:has(input[type="checkbox"]) { align-items:flex-start; gap:10px; line-height:22px; min-height:28px; }
.choice input[type="checkbox"], input.checkbox[type="checkbox"] {
    appearance:none; -webkit-appearance:none; box-sizing:border-box;
    width:18px; height:18px; min-width:18px; min-height:18px; flex:0 0 18px;
    margin:2px 0 0; padding:0; border:1.5px solid #9aa7bc; border-radius:5px;
    background-color:var(--surface-1); background-repeat:no-repeat; background-position:center;
    box-shadow:0 1px 2px #14213a08; vertical-align:middle; cursor:pointer;
    transition:background-color 140ms ease,border-color 140ms ease,box-shadow 140ms ease;
    animation:none;
}
.choice:hover input[type="checkbox"]:not(:disabled), input.checkbox[type="checkbox"]:hover:not(:disabled) { border-color:#1465e9; box-shadow:0 0 0 3px #1465e90c; }
.choice input[type="checkbox"]:checked, input.checkbox[type="checkbox"]:checked {
    border-color:#1465e9; background-color:#1465e9; box-shadow:none;
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3.5 8 3 3 6-6' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-size:14px 14px;
}
.choice input[type="checkbox"]:indeterminate, input.checkbox[type="checkbox"]:indeterminate {
    border-color:#1465e9; background-color:#1465e9;
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); background-size:14px 14px;
}
.choice input[type="checkbox"]:focus-visible, input.checkbox[type="checkbox"]:focus-visible { outline:2px solid #1465e9; outline-offset:3px; }
.choice:has(input[type="checkbox"]:disabled) { cursor:default; }
.choice input[type="checkbox"]:disabled { opacity:.55; cursor:default; box-shadow:none; }
.choice:has(>input[type="checkbox"][aria-label]:only-child) { align-items:center; justify-content:center; }
.choice>input[type="checkbox"][aria-label]:only-child { margin-top:0; }
@media(max-width:700px) { .choice:has(input[type="checkbox"]) { min-height:44px; padding-block:11px; } .choice:has(>input[type="checkbox"][aria-label]:only-child) { min-width:44px; padding:0; } }
@media(prefers-reduced-motion:reduce) { .choice input[type="checkbox"],input.checkbox[type="checkbox"] { transition:none; animation:none; } }
@media(forced-colors:active) { .choice input[type="checkbox"],input.checkbox[type="checkbox"] { appearance:auto; -webkit-appearance:auto; background-image:none; forced-color-adjust:auto; } }

/* ---- Check list — for feature and requirement lists ---- */
.check-list { display: flex; flex-direction: column; gap: var(--s-3); }

.check-list li {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    font-size: var(--text-base);
}

.check-mark {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
    border-radius: var(--r-sm);
    display: grid;
    place-items: center;
    background: var(--success-soft);
    color: var(--success);
}
.check-mark.is-accent  { background: var(--accent-soft); color: var(--accent); }
.check-mark.is-neutral { background: var(--surface-3);   color: var(--text-faint); }
.check-mark svg { display: block; }

/* Switch */
.switch {
    display: inline-flex;
    align-items: center;
    gap: var(--s-3);
    cursor: pointer;
    user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch .track {
    position: relative;
    width: 38px;
    height: 22px;
    border-radius: var(--r-full);
    background: var(--surface-4);
    box-shadow: inset 0 0 0 1px var(--border-strong);
    transition: background var(--dur) var(--ease);
    flex-shrink: 0;
}
.switch .track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: var(--r-full);
    background: #fff;
}
.switch input:checked + .track { background: var(--accent); box-shadow: none; }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ==========================================================================
   DATA DISPLAY
   ========================================================================== */

/* -- Card -- */
.card {
    background: var(--surface-1);
    border-radius: var(--r-xl);
    box-shadow: inset 0 0 0 1px var(--border);
    overflow: hidden;
}

.card-header {
    padding: var(--s-5) var(--s-6);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
}

.card-body   { padding: var(--s-6); }

.card-footer {
    padding: var(--s-4) var(--s-6);
    border-top: 1px solid var(--border);
    background: var(--sunken-tint);
}

/* Glass card — for use over imagery or video */
.card-glass {
    position: relative;
    background:
        linear-gradient(160deg, rgba(255, 255, 255, 0.09) 0%, rgba(255, 255, 255, 0.025) 100%),
        rgba(12, 14, 19, 0.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    backdrop-filter: blur(20px) saturate(1.5);
    box-shadow: var(--shadow-xl);
}
/* Gradient hairline that catches light from the top-left */
.card-glass::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(145deg, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0.08) 40%, rgba(94,200,255,0.16) 100%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
    pointer-events: none;
}

/* -- Badge -- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 7px;
    border-radius: var(--r-sm);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: -0.005em;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Quieter variant for use inside tables — in-context components turn down,
   they don't reuse the loud standalone treatment. */
.badge-outline {
    background: transparent;
    color: var(--text-muted);
    box-shadow: inset 0 0 0 1px var(--border);
    padding: 0 6px;
}

.badge-neutral { background: var(--surface-3);   color: var(--text-muted); }
.badge-blue    { background: var(--accent-soft); color: var(--accent-text); }
.badge-green   { background: var(--success-soft);color: var(--success); }
.badge-amber   { background: var(--warning-soft);color: var(--warning); }
.badge-red     { background: var(--danger-soft); color: var(--danger); }

/* Status dot for use inside badges or lists */
.dot {
    width: 6px;
    height: 6px;
    border-radius: var(--r-full);
    background: currentColor;
    flex-shrink: 0;
}

/* -- Chip (removable / selectable tag) -- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    height: 28px;
    padding: 0 var(--s-3);
    border-radius: var(--r-md);
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--border);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.chip:hover { background: var(--surface-3); color: var(--text); }
.chip.is-selected {
    background: var(--accent-soft);
    color: var(--accent-text);
    box-shadow: inset 0 0 0 1px rgba(43, 140, 255, 0.4);
}

/* -- Avatar -- */
.avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    display: grid;
    place-items: center;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px var(--border-strong);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 26px; height: 26px; font-size: var(--text-xs); }
.avatar-lg { width: 44px; height: 44px; font-size: var(--text-md); }
.avatar-accent { background: var(--accent-soft); color: var(--accent-text); }

.avatar-stack { display: flex; }
.avatar-stack .avatar + .avatar { margin-left: -10px; box-shadow: 0 0 0 2px var(--bg); }

/* -- Table -- */
/* Rows land at ~42px. Headers are sentence case at body size — uppercase
   letter-spaced headers are a convention no current design system uses.
   Separation is an inset shadow rather than a border: it survives
   border-collapse, sticky headers and rounded wrappers without layout shift. */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }

.table th {
    text-align: left;
    padding: var(--s-2) var(--s-3);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    box-shadow: inset 0 -1px var(--border);
}

.table td {
    padding: 10px var(--s-3);   /* 22px line + 20px = a 42px row, the density every list shares */
    vertical-align: middle;
    box-shadow: inset 0 -1px var(--border);
}

/* Outer gutter stays constant regardless of inner density */
.table th:first-child,
.table td:first-child { padding-left: var(--s-4); }
.table th:last-child,
.table td:last-child  { padding-right: var(--s-4); }

.table tbody tr:last-child td { box-shadow: none; }
.table tbody tr { transition: background var(--dur) var(--ease); }
.table tbody tr:hover { background: var(--hover-tint); }

/* Denser variant for long case lists */
.table-compact th { padding: 6px var(--s-2); }
.table-compact td { padding: var(--s-2); }

.table-wrap { width: 100%; overflow-x: auto; }

.num { font-variant-numeric: tabular-nums; }
.table td.num, .table th.num { white-space: nowrap; }   /* a date or an amount never breaks across lines */

/* -- Stat tile --
   Chrome-free by default: whitespace separates metrics, not a box around each
   one. Add .stat-boxed only where a metric genuinely needs a container.
   Label and value differ on size, weight and colour at once — a one-channel
   jump reads as flat. */
.stat { min-width: 0; }

.stat .stat-label {
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--text-muted);
}

.stat .stat-value {
    margin-top: 6px;
    font-size: var(--text-2xl);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.stat .stat-delta {
    margin-top: var(--s-2);
    font-size: var(--text-sm);
    font-weight: 500;
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    font-variant-numeric: tabular-nums;
}

.stat-boxed {
    padding: var(--s-5);
    border-radius: var(--r-xl);
    background: var(--surface-1);
    box-shadow: inset 0 0 0 1px var(--border);
}

/* ==========================================================================
   FEEDBACK
   ========================================================================== */

/* -- Alert -- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: var(--s-4);
    border-radius: var(--r-lg);
    font-size: var(--text-base);
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--border);
}
.alert .alert-icon { flex-shrink: 0; margin-top: 1px; }
.alert .alert-title { font-weight: 600; }
.alert .alert-body  { color: var(--text-muted); margin-top: 2px; }

.alert-info    { background: var(--info-soft);    box-shadow: inset 0 0 0 1px rgba(94,200,255,0.24); }
.alert-info    .alert-icon { color: var(--info); }
.alert-success { background: var(--success-soft); box-shadow: inset 0 0 0 1px rgba(52,211,153,0.24); }
.alert-success .alert-icon { color: var(--success); }
.alert-warning { background: var(--warning-soft); box-shadow: inset 0 0 0 1px rgba(240,181,63,0.24); }
.alert-warning .alert-icon { color: var(--warning); }
.alert-danger  { background: var(--danger-soft);  box-shadow: inset 0 0 0 1px rgba(244,103,108,0.24); }
.alert-danger  .alert-icon { color: var(--danger); }

/* -- Progress -- */
.progress {
    height: 6px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    overflow: hidden;
}
.progress .bar {
    height: 100%;
    border-radius: inherit;
    background: var(--brand-gradient-text);
}

/* -- Spinner -- */
.spinner {
    width: 18px;
    height: 18px;
    border-radius: var(--r-full);
    border: 2px solid var(--border-loud);
    border-top-color: var(--accent);
    animation: spin 0.7s linear infinite;
}
.spinner-lg { width: 28px; height: 28px; border-width: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* -- Empty state --
   One block for every empty list: .card > .empty > .empty-icon + .empty-title
   + .empty-body (one sentence) + one .empty-action (a quiet .card-link). */
.empty {
    text-align: center;
    padding: var(--s-12) var(--s-6);
}
.empty .empty-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto var(--s-4);
    border-radius: var(--r-xl);
    display: grid;
    place-items: center;
    background: var(--surface-3);
    color: var(--text-faint);
}
.empty .empty-icon .icon { width: 20px; height: 20px; }
.empty .empty-title { font-weight: 600; font-size: var(--text-md); }
.empty .empty-body  { max-width: 52ch; margin: var(--s-1) auto 0; color: var(--text-muted); }
.empty .empty-action,
.empty > .btn,
.empty > form,
.empty > .card-link { display: inline-flex; margin-top: var(--s-5); }   /* whatever comes after the words gets the same breathing room */
.empty > form { display: inline-block; }

/* ==========================================================================
   NAVIGATION
   ========================================================================== */

/* -- Tabs -- */
.tabs {
    display: flex;
    gap: var(--s-1);
    border-bottom: 1px solid var(--border);
}
.tab {
    position: relative;
    padding: var(--s-3) var(--s-4);
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: 0;
    cursor: pointer;
    transition: color var(--dur) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); font-weight: 600; }
.tab.is-active::after {
    content: "";
    position: absolute;
    left: var(--s-3);
    right: var(--s-3);
    bottom: -1px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
}

/* -- Breadcrumb -- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-size: var(--text-sm);
    color: var(--text-faint);
    flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { color: var(--text-faint); }
.breadcrumb .current { color: var(--text); font-weight: 500; }

/* -- Pagination -- */
.pagination { display: flex; align-items: center; gap: var(--s-1); }
.pagination .page {
    min-width: 32px;
    height: 32px;
    padding: 0 var(--s-2);
    border: 0;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.pagination .page:hover { background: var(--surface-2); color: var(--text); }
.pagination .page.is-active { background: var(--accent); color: var(--on-accent); }

/* -- Menu / dropdown panel -- */
.menu {
    min-width: 200px;
    padding: var(--s-1);
    border-radius: var(--r-lg);
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-lg);
}
.menu-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    width: 100%;
    padding: var(--s-2) var(--s-3);
    border: 0;
    border-radius: var(--r-md);
    background: none;
    color: var(--text-muted);
    font-size: var(--text-base);
    text-align: left;
    cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.menu-item:hover { background: var(--surface-3); color: var(--text); }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; margin: var(--s-1) 0; background: var(--border); }

/* -- Sidebar nav -- */
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    font-size: var(--text-base);
    color: var(--text-muted);
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

/* ==========================================================================
   OVERLAYS
   ========================================================================== */

/* -- Tooltip (CSS-only, wraps the trigger) -- */
.tooltip { position: relative; display: inline-flex; }
.tooltip .tip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: var(--s-1) var(--s-2);
    border-radius: var(--r-sm);
    background: var(--contrast-bg);
    color: var(--contrast-text);
    box-shadow: var(--shadow-md);
    font-size: var(--text-xs);
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
}
.tooltip:hover .tip,
.tooltip:focus-within .tip { opacity: 1; }

/* -- Modal -- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: var(--s-6);
    background: rgba(4, 6, 10, 0.72);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
.modal-backdrop[hidden] { display: none; }

.modal {
    width: 100%;
    max-width: 460px;
    border-radius: var(--r-2xl);
    background: var(--surface-1);
    box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-xl);
    overflow: hidden;
}

/* -- Toast -- */
.toast-region {
    position: fixed;
    right: var(--s-6);
    bottom: var(--s-6);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-lg);
    background: var(--surface-3);
    box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-lg);
    font-size: var(--text-base);
    pointer-events: auto;
    animation: rise-in 0.24s var(--ease-out) both;
}

/* -- Exclusive choices --
   A short list of exclusive options (Yes / No, Driver / Passenger / Pedestrian)
   as one strip, instead of a row of radio dots. Markup: .seg > label.seg-opt >
   input[type=radio] + span. Add .seg-sm for the compact yes/no version. */
.seg {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
.seg-opt { position: relative; }
.seg-opt input {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
    cursor: pointer;
}
.seg-opt span {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 6px 0;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.seg-opt:hover span { color: var(--text); }
.seg-opt input:checked + span {
    background: transparent;
    color: #145bd8;
    border-bottom-color: #1465e9;
    font-weight: 500;
    box-shadow: none;
}
.seg-opt input:focus-visible + span { outline: 2px solid #4384ee; outline-offset: 3px; box-shadow: none; }
.seg-sm .seg-opt span { height: 32px; padding: 4px 0; }
.field-choices .seg { align-self: flex-start; }

/* ==========================================================================
   PROGRESS
   ========================================================================== */

/* -- Steps — where someone is in a multi-step flow (onboarding, wizards) --
   Markup: ol.steps > li.step[.is-done|.is-current] > .step-num + .step-label */
.steps {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--text-sm);
    color: var(--text-faint);
}
.step {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-weight: 500;
    white-space: nowrap;
}
.step + .step::before {
    content: "";
    width: 20px;
    height: 1px;
    margin-right: var(--s-1);
    background: var(--border-strong);
}
.step-num {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: var(--r-sm);
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.step.is-current { color: var(--text); font-weight: 600; }
.step.is-current .step-num { background: var(--accent); color: var(--on-accent); }
.step.is-done { color: var(--text-muted); }
.step.is-done .step-num { background: var(--accent-soft); color: var(--accent-text); }

@media (max-width: 560px) {
    .step:not(.is-current) .step-label { display: none; }
    .step + .step::before { width: 12px; }
}

/* A leading icon in a button: same colour as its label, a touch lighter on outline buttons */
.btn .icon { width: 16px; height: 16px; flex-shrink: 0; }
.btn-outline .icon, .btn-ghost .icon { color: var(--text-muted); }
.btn-primary .icon { color: inherit; }

/* -- Address suggestions: a street (or one-line place) input with a menu under it, then city / state / ZIP -- */
.address { display: flex; flex-direction: column; gap: var(--s-3); }
.address-street { position: relative; }
.address-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 30;
    max-height: 280px;
    overflow-y: auto;
}
.address-menu .address-item { align-items: center; gap: var(--s-3); padding: 6px var(--s-3); text-align: left; }
.address-menu .address-item.is-active { background: var(--surface-2); }
.address-item-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-muted); }
.address-item-icon .icon { width: 14px; height: 14px; }
.address-item.is-active .address-item-icon { background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--border); }
.address-item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.address-main { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.address-secondary { font-size: var(--text-xs); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -- Rows never clip. Short cells (numbers, dates, badges, actions) stay on one
   line; text cells wrap; a table wider than its card scrolls inside it. A cell
   with a muted second line makes a two-line row, the same height everywhere. -- */
.table td.text-right, .table th.text-right { white-space: nowrap; }
.table td .badge { white-space: nowrap; }
.table td > .text-sm { display: block; margin-top: 1px; line-height: 1.3; }
.table tr:has(> td > .text-sm) > td { padding-top: 6px; padding-bottom: 6px; }
.table td.font-medium:not(.num) { min-width: 180px; overflow-wrap: anywhere; }   /* a name column keeps room; a bold total does not */

/* ==========================================================================
   DROP ZONE — the one file control: choose or drag, then the file in place
   ========================================================================== */
.dropzone {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 112px;
    padding: var(--s-4);
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-md);
    background: var(--surface-2);
    cursor: pointer;
    transition: background var(--dur) var(--ease);
}
.dropzone:hover { background: var(--surface-3); }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.is-error { border-color: var(--danger); background: var(--danger-soft); }
.dropzone:focus-within { border-color: var(--accent); }
.dropzone-empty { display: flex; flex-direction: column; align-items: center; gap: var(--s-1); text-align: center; }
.dropzone-empty[hidden] { display: none; }
.dropzone-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 32px;
    height: 32px;
    margin-bottom: var(--s-1);
    border-radius: var(--r-sm);
    background: var(--surface-1);
    box-shadow: inset 0 0 0 1px var(--border);
    color: var(--text-muted);
}
.dropzone-icon .icon { width: 16px; height: 16px; }
.dropzone-text { font-size: var(--text-sm); color: var(--text-muted); }
.dropzone-choose { padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: var(--accent-text); cursor: pointer; }
.dropzone-choose:hover { text-decoration: underline; }
.dropzone-hint { font-size: var(--text-xs); color: var(--text-faint); }
.dropzone.has-file { justify-content: flex-start; min-height: 0; padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4); border-style: solid; cursor: default; }
.dropzone.has-file:hover { background: var(--surface-2); }
.dropzone-file { display: flex; align-items: center; gap: var(--s-3); width: 100%; min-width: 0; }
.dropzone-file[hidden] { display: none; }
.dropzone-file .dropzone-icon { margin: 0; }
.dropzone-file-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.dropzone-file-name { font-size: var(--text-sm); font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone-file-size { font-size: var(--text-xs); color: var(--text-muted); }
