/* =========================================================
   Atlassian Design System tokens (Light + Dark)
   ========================================================= */
:root,
[data-theme="light"] {
    /* Surfaces — 3-step elevation for cards on columns on canvas */
    --ds-surface-default: #FFFFFF;            /* page/topbar */
    --ds-surface-sunken: #F7F8F9;             /* app canvas behind columns */
    --ds-surface-column: #F1F2F4;             /* columns — slightly darker than canvas */
    --ds-surface: #FFFFFF;                    /* cards */
    --ds-surface-raised: #FFFFFF;
    --ds-surface-overlay: #FFFFFF;
    --ds-surface-hovered: #F1F2F4;
    --ds-surface-pressed: #DCDFE4;

    --ds-background-neutral: #DCDFE4;
    --ds-background-neutral-hovered: #B3B9C4;
    --ds-background-neutral-subtle: transparent;
    --ds-background-neutral-subtle-hovered: rgba(9, 30, 66, 0.06);

    /* Text */
    --ds-text: #172B4D;
    --ds-text-subtle: #44546F;
    --ds-text-subtlest: #626F86;
    --ds-text-disabled: #8590A2;
    --ds-text-inverse: #FFFFFF;

    /* Brand — Atlassian blue */
    --ds-background-brand-bold: #0C66E4;
    --ds-background-brand-bold-hovered: #0055CC;
    --ds-background-brand-bold-pressed: #09326C;
    --ds-text-brand: #0C66E4;
    --ds-border-brand: #0C66E4;

    /* Semantic backgrounds (subtle) + text (saturated) */
    --ds-text-success: #216E4E;
    --ds-background-success: #DCFFF1;
    --ds-text-warning: #A54800;
    --ds-background-warning: #FFF7D6;
    --ds-text-danger: #AE2A19;
    --ds-background-danger: #FFEDEB;
    --ds-text-information: #0055CC;
    --ds-background-information: #E9F2FF;

    /* Borders — 1px thin for a corporate/tight feel */
    --ds-border: #DCDFE4;
    --ds-border-strong: #C1C7D0;
    --ds-border-bold: #A0A8B4;
    --ds-border-input: #DCDFE4;               /* 1px resting border for fields */
    --ds-border-input-hover: #C1C7D0;
    --ds-border-focused: #0C66E4;             /* focus ring color (brand blue) */
    --ds-focus-ring: rgba(12, 102, 228, 0.2); /* outer glow on focus */
    --ds-border-danger:  #AE2A19;
    --ds-border-disabled: rgba(9, 30, 66, 0.06);

    /* Form field backgrounds — consistent white, no ADS inversion */
    --ds-field-bg-idle:   #FFFFFF;
    --ds-field-bg-hover:  #FAFBFC;
    --ds-field-bg-focus:  #FFFFFF;
    --ds-field-bg-disabled: #F4F5F7;
    --ds-text-accent-red: #AE2A19;

    /* Shadows — disabled by design choice (flat surfaces) */
    --ds-shadow-raised: none;
    --ds-shadow-overflow: none;
    --ds-shadow-overlay: none;

    /* Issue type icons — SOLID colored squares, white glyph (Jira @atlaskit/icon-object) */
    --issue-task-solid:    #1868DB;
    --issue-story-solid:   #22A06B;
    --issue-bug-solid:     #C9372C;
    --issue-epic-solid:    #8270DB;
    --issue-chore-solid:   #626F86;
    --issue-feature-solid: #22A06B;

    /* Priority icons — colored arrows (no fill) */
    --prio-critical: #CA3521;
    --prio-high:     #E34935;
    --prio-medium:   #E56910;
    --prio-low:      #2898BD;
}

[data-theme="dark"] {
    /* Surfaces — Jira dark theme 3-step elevation */
    --ds-surface-default: #1D2125;
    --ds-surface-sunken: #161A1D;
    --ds-surface-column: #282E33;             /* columns sit visibly above canvas */
    --ds-surface: #22272B;                    /* cards */
    --ds-surface-raised: #22272B;
    --ds-surface-overlay: #2C333A;
    --ds-surface-hovered: #2C333A;
    --ds-surface-pressed: #454F59;

    --ds-background-neutral: #454F59;
    --ds-background-neutral-hovered: #596773;
    --ds-background-neutral-subtle: transparent;
    --ds-background-neutral-subtle-hovered: rgba(166, 197, 226, 0.08);

    --ds-text: #B6C2CF;
    --ds-text-subtle: #9FADBC;
    --ds-text-subtlest: #8C9BAB;
    --ds-text-disabled: #5D6B7A;
    --ds-text-inverse: #1D2125;

    --ds-background-brand-bold: #579DFF;
    --ds-background-brand-bold-hovered: #85B8FF;
    --ds-background-brand-bold-pressed: #CCE0FF;
    --ds-text-brand: #579DFF;
    --ds-border-brand: #579DFF;

    --ds-text-success: #7EE2B8;
    --ds-background-success: #164B35;
    --ds-text-warning: #F5CD47;
    --ds-background-warning: #533F04;
    --ds-text-danger: #FD9891;
    --ds-background-danger: #5D1F1A;
    --ds-text-information: #85B8FF;
    --ds-background-information: #09326C;

    --ds-border: #343B42;
    --ds-border-strong: #454F59;
    --ds-border-bold: #596773;
    --ds-border-input: #454F59;
    --ds-border-input-hover: #596773;
    --ds-border-focused: #579DFF;
    --ds-focus-ring: rgba(87, 157, 255, 0.25);
    --ds-border-danger:  #FD9891;
    --ds-border-disabled: rgba(166, 197, 226, 0.06);

    --ds-field-bg-idle:   #22272B;
    --ds-field-bg-hover:  #2C333A;
    --ds-field-bg-focus:  #22272B;
    --ds-field-bg-disabled: #1D2125;
    --ds-text-accent-red: #FD9891;

    --ds-shadow-raised: none;
    --ds-shadow-overflow: none;
    --ds-shadow-overlay: none;

    --issue-task-solid:    #388BFF;
    --issue-story-solid:   #4BCE97;
    --issue-bug-solid:     #F87168;
    --issue-epic-solid:    #B8ACF6;
    --issue-chore-solid:   #9FADBC;
    --issue-feature-solid: #4BCE97;

    --prio-critical: #F87168;
    --prio-high:     #F87168;
    --prio-medium:   #FEA362;
    --prio-low:      #6CC3E0;
}

/* =========================================================
   Base
   ========================================================= */
* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    font: 400 14px/20px "Inter", "Atlassian Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-feature-settings: "cv11", "ss01", "ss03";   /* Inter → looks closer to Atlassian Sans */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--ds-surface-sunken);
    color: var(--ds-text);
    letter-spacing: -0.003em;
}

code, pre, .mono, input.mono {
    font-family: "JetBrains Mono", "Atlassian Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-feature-settings: normal;
}

[data-theme="dark"] body { background: var(--ds-surface-default); }
a { color: var(--ds-text-brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; border: 0; font: inherit; background: none; color: inherit; }
hr { border: 0; border-top: 1px solid var(--ds-border); margin: 16px 0; }

/* Icon base — <i data-lucide="..."> gets replaced by an <svg class="icon"> */
.icon, [data-lucide] {
    width: 16px; height: 16px; stroke-width: 1.5;
    vertical-align: -2px; flex-shrink: 0; color: currentColor;
}
.icon--sm { width: 12px; height: 12px; }
.icon--md { width: 20px; height: 20px; }
.icon--lg { width: 24px; height: 24px; }

/* =========================================================
   Topbar
   ========================================================= */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    height: 56px; padding: 0 20px;
    background: var(--ds-surface-default);
    border-bottom: 1px solid var(--ds-border);
    position: sticky; top: 0; z-index: 10;
}
.brand a {
    display: inline-flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: 15px; color: var(--ds-text);
    letter-spacing: -0.005em;
}
.brand .brand-mark {
    width: 24px; height: 24px; border-radius: 4px;
    background: var(--ds-background-brand-bold); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
}
.brand .brand-logo {
    width: 28px; height: 28px; object-fit: contain; margin-top: -3px;
}

.nav-links { display: flex; gap: 2px; }
.nav-links a {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px; border-radius: 3px;
    color: var(--ds-text-subtle); font-weight: 500; font-size: 13px;
    transition: background-color 100ms ease, color 100ms ease;
}
.nav-links a:hover { color: var(--ds-text); background: var(--ds-surface-hovered); text-decoration: none; }
.nav-links a.active { color: var(--ds-text-brand); background: var(--ds-background-information); }

.user-box { display: flex; gap: 8px; align-items: center; }
#userName {
    color: var(--ds-text-subtle); font-size: 13px; font-weight: 500;
}

/* Icon button — clickable wrapper for icons */
.icon-button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 3px;
    color: var(--ds-text-subtle);
    transition: background-color 100ms ease, color 100ms ease;
}
.icon-button:hover { background: var(--ds-surface-hovered); color: var(--ds-text); }
.icon-button:active { background: var(--ds-surface-pressed); }

/* Theme switcher segmented control */
.theme-toggle {
    display: inline-flex; align-items: center;
    background: var(--ds-surface-sunken);
    border: 1px solid var(--ds-border); border-radius: 3px;
    padding: 2px;
}
.theme-toggle button {
    width: 26px; height: 26px; border-radius: 3px;
    color: var(--ds-text-subtle);
    display: inline-flex; align-items: center; justify-content: center;
    transition: background-color 100ms ease, color 100ms ease;
}
.theme-toggle button:hover { color: var(--ds-text); }
.theme-toggle button.active {
    background: var(--ds-surface); color: var(--ds-text);
    box-shadow: var(--ds-shadow-raised);
}

/* =========================================================
   Layout
   ========================================================= */
.main { padding: 20px 16px; max-width: 1600px; margin: 0 auto; }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px; padding: 0 12px; border-radius: 3px;
    font-size: 13px; font-weight: 500; line-height: 1;
    white-space: nowrap; letter-spacing: 0;
    border: 1px solid transparent;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.btn-primary {
    background: var(--ds-background-brand-bold); color: #fff;
    border-color: var(--ds-background-brand-bold);
}
.btn-primary:hover {
    background: var(--ds-background-brand-bold-hovered);
    border-color: var(--ds-background-brand-bold-hovered);
}
.btn-primary:active { background: var(--ds-background-brand-bold-pressed); }

.btn-secondary {
    background: var(--ds-surface); color: var(--ds-text);
    border-color: var(--ds-border-strong);
}
.btn-secondary:hover { background: var(--ds-surface-hovered); border-color: var(--ds-border-bold); }
.btn-secondary:active { background: var(--ds-surface-pressed); }

.btn-ghost {
    background: transparent; color: var(--ds-text);
}
.btn-ghost:hover { background: var(--ds-background-neutral-subtle-hovered); }
.btn-ghost:active { background: var(--ds-surface-pressed); }

.btn-danger {
    background: transparent; color: var(--ds-text-danger);
}
.btn-danger:hover { background: var(--ds-background-danger); }

.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ds-focus-ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* =========================================================
   Auth page
   ========================================================= */
.auth-body {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: var(--ds-surface-sunken);
}
.auth-card {
    width: 400px; background: var(--ds-surface);
    padding: 32px; border-radius: 4px;
    box-shadow: var(--ds-shadow-overflow);
    border: 1px solid var(--ds-border);
}
.auth-card h1 {
    margin: 0 0 4px; font-size: 20px; font-weight: 500; color: var(--ds-text);
    letter-spacing: -0.005em;
}
.muted { color: var(--ds-text-subtle); }
.small { font-size: 12px; line-height: 16px; }
.error { color: var(--ds-text-danger); min-height: 1em; margin-top: 8px; font-size: 12px; }

/* =========================================================
   Forms — Atlaskit textfield / select / textarea
   ========================================================= */
.form { display: flex; flex-direction: column; gap: 16px; }
.form > label { display: flex; flex-direction: column; gap: 4px; }

/* Label text: 12px / 600, subtle color, NOT uppercase. 4px to the control. */
.form label, .form-label {
    font-size: 12px; line-height: 16px; font-weight: 600;
    color: var(--ds-text-subtle);
}
/* Red asterisk helper — wrap label text in .label-text.is-required to show it */
.label-text.is-required::after {
    content: ' *'; color: var(--ds-text-accent-red); font-weight: 700;
}

/* Helper and error text below the input (margin-top 4px) */
.form .helper, .form .error-text {
    font-size: 12px; line-height: 16px; font-weight: 400;
    color: var(--ds-text-subtle); margin-top: 4px;
}
.form .error-text { color: var(--ds-text-accent-red); }

/* Core control styling — corporate 1px borders, subtle focus ring */
.form input, .form select, .form textarea,
select, input[type="text"], input[type="search"], input[type="email"],
input[type="password"], input[type="number"], input[type="date"], input[type="url"], textarea {
    height: 32px; min-height: 32px; padding: 0 10px;
    background: var(--ds-field-bg-idle);
    color: var(--ds-text);
    border: 1px solid var(--ds-border-input);
    border-radius: 3px;
    font: 400 13px/20px inherit;
    transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
    width: 100%;
}
.form textarea, textarea {
    height: auto; min-height: 80px;
    padding: 8px 10px; line-height: 20px; resize: vertical;
}

input::placeholder, textarea::placeholder { color: var(--ds-text-subtlest); }

/* Hover: darker border, no background change */
.form input:hover, .form select:hover, .form textarea:hover,
select:hover, input[type="text"]:hover, input[type="search"]:hover,
input[type="email"]:hover, input[type="password"]:hover, input[type="number"]:hover,
input[type="date"]:hover, input[type="url"]:hover, textarea:hover {
    border-color: var(--ds-border-input-hover);
}

/* Focus: border turns brand blue + 3px soft glow ring */
.form input:focus, .form select:focus, .form textarea:focus,
select:focus, input[type="text"]:focus, input[type="search"]:focus,
input[type="email"]:focus, input[type="password"]:focus, input[type="number"]:focus,
input[type="date"]:focus, input[type="url"]:focus, textarea:focus {
    outline: none;
    border-color: var(--ds-border-focused);
    box-shadow: 0 0 0 3px var(--ds-focus-ring);
    background: var(--ds-field-bg-focus);
}

/* Invalid state: red border + red ring on focus */
.form input.is-invalid, .form select.is-invalid, .form textarea.is-invalid,
input.is-invalid, select.is-invalid, textarea.is-invalid,
input:user-invalid, select:user-invalid, textarea:user-invalid {
    border-color: var(--ds-border-danger);
}
input.is-invalid:focus, input:user-invalid:focus,
textarea.is-invalid:focus, textarea:user-invalid:focus,
select.is-invalid:focus, select:user-invalid:focus {
    box-shadow: 0 0 0 3px rgba(174, 42, 25, 0.15);
}

.form input:disabled, select:disabled, textarea:disabled {
    background: var(--ds-field-bg-disabled);
    border-color: var(--ds-border);
    color: var(--ds-text-disabled);
    cursor: not-allowed;
}

/* Native select caret: keep a visible chevron using inline SVG. */
select {
    appearance: none; -webkit-appearance: none;
    padding-right: 30px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23626F86' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
}
[data-theme="dark"] select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238C9BAB' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
}

/* Color input — match 32px control height */
input[type="color"] {
    height: 32px; width: 42px; padding: 2px; cursor: pointer;
    border: 1px solid var(--ds-border-input); border-radius: 3px;
    background: var(--ds-field-bg-idle);
    transition: border-color 120ms ease;
}
input[type="color"]:hover { border-color: var(--ds-border-input-hover); }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }

/* File input — match button aesthetics */
input[type="file"] {
    font-size: 13px; color: var(--ds-text-subtle);
    padding: 4px 0; border: 0; background: transparent; min-height: auto; height: auto;
}
input[type="file"]:focus, input[type="file"]:hover { box-shadow: none; border: 0; background: transparent; }
input[type="file"]::file-selector-button {
    height: 28px; padding: 0 12px; margin-right: 8px;
    background: var(--ds-surface); color: var(--ds-text);
    border: 1px solid var(--ds-border-strong); border-radius: 3px;
    font: 500 13px/1 inherit; cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease;
}
input[type="file"]::file-selector-button:hover { background: var(--ds-surface-hovered); border-color: var(--ds-border-bold); }

/* Range — slim track, blue accent */
input[type="range"] {
    accent-color: var(--ds-background-brand-bold);
    height: 20px; padding: 0; border: 0; background: transparent;
}

/* Checkbox — tight 1px corporate look */
input[type="checkbox"] {
    appearance: none; -webkit-appearance: none;
    width: 16px; height: 16px; min-height: 16px; margin: 0;
    border: 1px solid var(--ds-border-input-hover); border-radius: 2px;
    background: var(--ds-field-bg-idle);
    cursor: pointer; flex-shrink: 0; padding: 0;
    position: relative;
    transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
input[type="checkbox"]:hover { border-color: var(--ds-border-bold); }
input[type="checkbox"]:checked {
    background: var(--ds-background-brand-bold);
    border-color: var(--ds-background-brand-bold);
}
input[type="checkbox"]:checked::after {
    content: '';
    position: absolute; left: 4px; top: 0;
    width: 4px; height: 8px;
    border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible {
    box-shadow: 0 0 0 3px var(--ds-focus-ring);
}

/* A label that wraps a checkbox + its text (horizontal, 8px gap) */
.form label.inline,
.form .checkbox-row {
    flex-direction: row; align-items: center; gap: 8px;
    font-size: 14px; font-weight: 400; color: var(--ds-text);
}

/* Input with leading icon (eg. search field) */
.input-with-icon {
    position: relative; display: inline-flex; align-items: center; width: 100%;
}
.input-with-icon .leading-icon {
    position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
    color: var(--ds-text-subtlest); pointer-events: none;
    display: inline-flex; align-items: center;
}
.input-with-icon input { padding-left: 32px; }

/* Search input — built-in leading icon via background image */
input[type="search"] {
    padding-left: 32px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23626F86' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>");
    background-repeat: no-repeat;
    background-position: left 8px center;
    background-color: var(--ds-field-bg-idle);
}
[data-theme="dark"] input[type="search"] {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238C9BAB' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>");
}

.hidden { display: none !important; }

/* =========================================================
   Board — toolbar + kanban
   ========================================================= */
.board-toolbar {
    display: flex; align-items: center;
    gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
    padding: 10px 12px;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: 3px;
    box-shadow: var(--ds-shadow-raised);
}
.board-toolbar__group {
    display: inline-flex; align-items: center; gap: 6px;
}
.board-toolbar__project { flex-shrink: 0; }
.board-toolbar__project .jselect { min-width: 200px; max-width: 280px; }
.board-toolbar__label {
    font-size: 11px; font-weight: 700; color: var(--ds-text-subtle);
    text-transform: uppercase; letter-spacing: 0;
    white-space: nowrap; padding-right: 2px;
}
.board-toolbar__search {
    flex: 0 1 300px; min-width: 180px;
}
.board-toolbar__search input[type="search"] { width: 100%; }
.board-toolbar__prio { min-width: 160px; }
.board-toolbar__right { margin-left: auto; }
.board-toolbar select, .board-toolbar input[type="search"] {
    height: 32px; min-height: 32px; font-size: 13px;
}
.board-toolbar #projectSelect { min-width: 200px; max-width: 320px; }

.board-toolbar__divider {
    width: 1px; height: 24px; background: var(--ds-border-strong);
    margin: 0 4px;
}

/* Icon-only button — square 32x32 */
.btn.btn-icon-only {
    width: 32px; padding: 0; justify-content: center;
}
.btn.btn-icon-only [data-lucide] { width: 16px; height: 16px; }

@media (max-width: 820px) {
    .board-toolbar { flex-wrap: wrap; gap: 6px; }
    .board-toolbar__divider { display: none; }

    /* El grupo de proyecto ocupa toda la fila y envuelve internamente */
    .board-toolbar__project {
        flex: 1 1 100%;
        flex-wrap: wrap;
        min-width: 0;
        order: 1;
    }
    /* El jselect llena el espacio disponible en la primera sub-fila */
    .board-toolbar__project .jselect {
        flex: 1 1 auto;
        min-width: 140px;
        max-width: none;
    }
    /* Los botones empujan a la siguiente sub-fila porque el jselect ya llenó la anterior */
    #editProjectBtn { flex-basis: auto; }
    #newProjectBtn  { flex: 1; }

    /* Buscador full width */
    .board-toolbar__search {
        flex: 1 1 100%;
        min-width: 0;
        order: 3;
    }

    .board-toolbar__right { order: 4; }
    #newTicketBtn          { order: 4; }
}

/* =========================================================
   Modal
   ========================================================= */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(9, 30, 66, 0.54);
    display: flex; align-items: center; justify-content: center; z-index: 50;
    padding: 16px;
}
.modal {
    width: min(640px, 100%); max-height: 90vh; overflow: auto;
    background: var(--ds-surface-overlay);
    border-radius: 4px;
    border: 1px solid var(--ds-border);
    box-shadow: var(--ds-shadow-overlay);
    padding: 24px;
}
.modal h2 {
    margin: 0 0 16px; font: 500 20px/24px inherit; color: var(--ds-text);
    letter-spacing: -0.005em;
}
.modal h3 { margin: 16px 0 8px; font: 600 14px/16px inherit; color: var(--ds-text); }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .actions {
    display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px;
    padding-top: 16px; border-top: 1px solid var(--ds-border);
}

/* =========================================================
   Flatpickr — Jira/corporate theme
   ========================================================= */
.flatpickr-calendar {
    background: var(--ds-surface-overlay);
    border: 1px solid var(--ds-border-strong);
    border-radius: 4px;
    box-shadow: var(--ds-shadow-overlay);
    font: 400 13px/20px "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--ds-text);
    width: 320px;
    padding: 8px;
}
.flatpickr-calendar.arrowTop::before,
.flatpickr-calendar.arrowTop::after,
.flatpickr-calendar.arrowBottom::before,
.flatpickr-calendar.arrowBottom::after { display: none; }

.flatpickr-months {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 2px 10px; margin: 0;
}
.flatpickr-months .flatpickr-month {
    color: var(--ds-text); background: transparent;
    height: auto; line-height: 1; overflow: visible;
}
.flatpickr-current-month {
    font-size: 14px; font-weight: 600; color: var(--ds-text);
    padding: 0;
    position: static;
    display: inline-flex; align-items: center; gap: 6px;
    width: auto; left: auto;
}
.flatpickr-current-month .flatpickr-monthDropdown-months {
    background: transparent; color: var(--ds-text); font-weight: 600;
    font-size: 14px; border: 0; padding: 2px 4px; height: 24px; min-height: 0;
    border-radius: 3px; appearance: none;
}
.flatpickr-current-month .flatpickr-monthDropdown-months:hover { background: var(--ds-surface-hovered); }
.flatpickr-current-month .cur-month {
    font-weight: 600; font-size: 14px; color: var(--ds-text);
    padding: 2px 2px; cursor: default;
}
.flatpickr-current-month input.cur-year {
    color: var(--ds-text); font-weight: 600; font-size: 14px;
    background: transparent; border: 0; padding: 0; margin: 0 0 0 4px;
    height: 24px;
}
.flatpickr-current-month .numInputWrapper:hover { background: var(--ds-surface-hovered); border-radius: 3px; }
.flatpickr-current-month .numInputWrapper span.arrowUp,
.flatpickr-current-month .numInputWrapper span.arrowDown { border: 0; }
.flatpickr-current-month .numInputWrapper span.arrowUp::after { border-bottom-color: var(--ds-text-subtle); }
.flatpickr-current-month .numInputWrapper span.arrowDown::after { border-top-color: var(--ds-text-subtle); }

.flatpickr-prev-month, .flatpickr-next-month {
    position: static; padding: 4px; height: 28px; width: 28px;
    color: var(--ds-text-subtle); border-radius: 3px;
    display: inline-flex; align-items: center; justify-content: center;
    fill: var(--ds-text-subtle);
}
.flatpickr-prev-month:hover, .flatpickr-next-month:hover {
    background: var(--ds-surface-hovered); color: var(--ds-text);
    fill: var(--ds-text);
}
.flatpickr-prev-month svg, .flatpickr-next-month svg { width: 14px; height: 14px; }

.flatpickr-weekdays {
    background: transparent; height: auto; padding: 4px 0;
}
.flatpickr-weekday {
    background: transparent !important; color: var(--ds-text-subtle) !important;
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em;
}

.flatpickr-days { width: 100%; border: 0; }
.dayContainer {
    width: 100%; min-width: 0; max-width: none;
    padding: 2px 0; gap: 0;
}

.flatpickr-day {
    background: transparent; border: 1px solid transparent; color: var(--ds-text);
    border-radius: 3px; font-size: 13px; font-weight: 400;
    max-width: none; height: 34px; line-height: 34px; flex-basis: 14.285%;
    margin: 1px 0;
}
.flatpickr-day:hover { background: var(--ds-surface-hovered); border-color: transparent; }
.flatpickr-day.today {
    border-color: var(--ds-border-focused); font-weight: 600; color: var(--ds-text-brand);
}
.flatpickr-day.today:hover { background: var(--ds-surface-hovered); }
.flatpickr-day.selected, .flatpickr-day.selected:hover,
.flatpickr-day.startRange, .flatpickr-day.endRange {
    background: var(--ds-background-brand-bold) !important;
    border-color: var(--ds-background-brand-bold);
    color: #fff;
}
.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay,
.flatpickr-day.flatpickr-disabled {
    color: var(--ds-text-disabled);
}

/* =========================================================
   Toasts
   ========================================================= */
#toastRoot {
    position: fixed; bottom: 16px; right: 16px;
    display: flex; flex-direction: column; gap: 8px; z-index: 100;
}
.toast {
    background: var(--ds-surface-overlay); color: var(--ds-text);
    padding: 10px 14px; border-radius: 3px;
    border: 1px solid var(--ds-border);
    border-left: 3px solid var(--ds-background-brand-bold);
    box-shadow: var(--ds-shadow-overlay);
    font-size: 13px; min-width: 220px;
}
.toast.error   { border-left-color: var(--ds-text-danger); }
.toast.success { border-left-color: var(--ds-text-success); }

/* =========================================================
   Metrics & data tables
   ========================================================= */
/* =========================================================
   Users — card layout (mobile)
   ========================================================= */
.user-cards { display: none; flex-direction: column; gap: 8px; }

.user-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: 6px;
    padding: 12px;
}
.user-card__avatar {
    width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 800; color: #fff;
    flex-shrink: 0; overflow: hidden;
}
.user-card__avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-card__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.user-card__name { font-weight: 700; font-size: 14px; color: var(--ds-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card__meta { font-size: 12px; color: var(--ds-text-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card__badges { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.user-card__actions { display: flex; gap: 4px; flex-shrink: 0; }

.users-table-wrap {
    display: block;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: 3px;
    padding: .75rem;
}

@media (max-width: 640px) {
    .users-table-wrap { display: none; }
    .user-cards       { display: flex; }
}

/* Metrics selects */
.metrics-sel-project .jselect { min-width: 220px; }
.metrics-sel-user .jselect    { min-width: 180px; }

/* KPI row */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}
.kpi-card {
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: 3px;
    padding: 18px 20px;
    display: flex; flex-direction: column; gap: 2px;
}
.kpi-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    color: var(--ds-text-subtle); letter-spacing: .04em;
}
.kpi-value {
    font-size: 32px; font-weight: 700; line-height: 1.1;
    color: var(--ds-text);
}
.kpi-value--success { color: var(--ds-text-success); }
.kpi-value--info    { color: #2684FF; }
.kpi-sub { font-size: 11px; color: var(--ds-text-subtlest); }

.table-scroll-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--ds-border-strong) transparent;
}
.table-scroll-wrap::-webkit-scrollbar { height: 5px; }
.table-scroll-wrap::-webkit-scrollbar-thumb { background: var(--ds-border-strong); border-radius: 99px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 600px; }
.data-table th, .data-table td {
    padding: 8px 10px; border-bottom: 1px solid var(--ds-border); text-align: left;
}
.data-table th {
    color: var(--ds-text-subtle);
    font-weight: 700 !important; font-size: 11px !important;
    text-transform: uppercase; letter-spacing: 0;
    line-height: 14px;
}
.data-table tbody tr:hover td { background: var(--ds-surface-hovered); }

/* =========================================================
   Badges (lozenges)
   ========================================================= */
.badge {
    display: inline-flex; align-items: center; padding: 2px 6px;
    border-radius: 3px; font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
    background: var(--ds-background-neutral); color: var(--ds-text-subtle);
}
.badge.role-superadmin { background: var(--issue-epic-bg); color: var(--issue-epic-fg); }
.badge.role-admin      { background: var(--ds-background-danger); color: var(--ds-text-danger); }
.badge.role-user       { background: var(--ds-background-success); color: var(--ds-text-success); }

.badge.severity-warning  { background: var(--ds-background-warning); color: var(--ds-text-warning); }
.badge.severity-critical { background: var(--ds-background-danger); color: var(--ds-text-danger); }

.badge.priority-low      { background: var(--ds-background-success); color: var(--ds-text-success); }
.badge.priority-medium   { background: var(--ds-background-information); color: var(--ds-text-information); }
.badge.priority-high     { background: var(--ds-background-warning); color: var(--ds-text-warning); }
.badge.priority-critical { background: var(--ds-background-danger); color: var(--ds-text-danger); }

.nav-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 6px;
    background: var(--ds-text-warning); color: #fff;
    border-radius: 9999px; font-size: 11px; font-weight: 600;
}
.nav-badge.critical { background: var(--ds-text-danger); }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1100px) {
    .kanban { grid-template-columns: repeat(5, 260px); }
}
/* Hamburger button — hidden on desktop */
.nav-hamburger {
    display: none;
    align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border-radius: 4px; border: none;
    background: transparent;
    color: var(--ds-text-subtle);
    cursor: pointer;
    transition: background-color 100ms ease, color 100ms ease;
    flex-shrink: 0;
}
.nav-hamburger:hover { background: var(--ds-surface-hovered); color: var(--ds-text); }
.nav-hamburger i, .nav-hamburger svg { pointer-events: none; }

/* =========================================================
   Mobile slide-in sidebar
   ========================================================= */
.nav-sidebar {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 280px; max-width: 90vw;
    background: var(--ds-surface-overlay, var(--ds-surface-default));
    border-left: 1px solid var(--ds-border);
    z-index: 300;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column;
    overflow-y: auto;
}
.nav-sidebar.is-open { transform: translateX(0); }
.nav-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 299;
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
}
.nav-overlay.is-open { opacity: 1; pointer-events: auto; }
.nav-sidebar__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--ds-border);
    flex-shrink: 0;
}
.nav-sidebar__user-info {
    display: flex; align-items: center; gap: 10px;
    min-width: 0; flex: 1;
}
.nav-sidebar__name {
    font-weight: 600; font-size: 14px; color: var(--ds-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-sidebar__role {
    font-size: 11px; color: var(--ds-text-subtle);
    text-transform: uppercase; letter-spacing: .04em; margin-top: 1px;
}
.nav-sidebar__links {
    display: flex; flex-direction: column;
    padding: 10px 8px;
    flex: 1;
    gap: 2px;
}
.nav-sidebar__links a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 6px;
    color: var(--ds-text-subtle);
    text-decoration: none;
    font-size: 14px; font-weight: 500;
    transition: background 0.1s, color 0.1s;
}
.nav-sidebar__links a:hover { background: var(--ds-surface-hovered); color: var(--ds-text); }
.nav-sidebar__links a.active { background: var(--ds-background-information); color: var(--ds-text-brand); }
.nav-sidebar__footer {
    padding: 14px 16px;
    border-top: 1px solid var(--ds-border);
    display: flex; flex-direction: column; gap: 10px;
    flex-shrink: 0;
}
.nav-sidebar__theme-row {
    display: flex; align-items: center; justify-content: space-between;
}
.nav-sidebar__theme-label {
    font-size: 13px; font-weight: 500; color: var(--ds-text-subtle);
}

@media (max-width: 640px) {
    /* Single-row topbar, vertically centered */
    .topbar {
        height: 56px; padding: 0 12px;
        flex-wrap: nowrap; align-items: center;
    }
    .brand { flex: 1; display: flex; align-items: center; }
    .brand .brand-logo { width: 20px; height: 20px; margin-top: -3px; margin-left: 6px; }
    .brand a { font-size: 13px; gap: 6px; }
    .user-box { height: 56px; align-items: center; gap: 8px; }

    .nav-hamburger { display: flex; }

    /* Hide desktop-only topbar elements */
    .nav-links,
    #userName,
    #logoutBtn,
    .user-box .theme-toggle { display: none !important; }
}

/* =========================================================
   Motion — only on state changes (modal, toast).
   Static page content does NOT animate on render.
   ========================================================= */

/* Standard Material/Atlassian easings. */
:root {
    --motion-enter: cubic-bezier(0.4, 0, 0.2, 1);   /* decelerate */
    --motion-exit:  cubic-bezier(0.4, 0, 1, 1);     /* accelerate */
    --motion-fast:  140ms;
    --motion-base:  180ms;
}

/* --- Modal --------------------------------------------------------------- */
@keyframes modalBackdropIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalBackdropOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes modalDialogIn    {
    from { opacity: 0; transform: translateY(-4px) scale(.98); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}
@keyframes modalDialogOut   {
    from { opacity: 1; transform: translateY(0)    scale(1); }
    to   { opacity: 0; transform: translateY(-4px) scale(.98); }
}

.modal-backdrop { animation: modalBackdropIn var(--motion-fast) var(--motion-enter) both; }
.modal          { animation: modalDialogIn   var(--motion-base) var(--motion-enter) both; }

.modal-backdrop.is-closing { animation: modalBackdropOut var(--motion-fast) var(--motion-exit) both; }
.modal-backdrop.is-closing .modal { animation: modalDialogOut var(--motion-fast) var(--motion-exit) both; }

/* --- Toasts -------------------------------------------------------------- */
@keyframes toastIn  { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0);   } to { opacity: 0; transform: translateX(8px); } }
.toast            { animation: toastIn  var(--motion-base) var(--motion-enter) both; }
.toast.is-closing { animation: toastOut var(--motion-fast) var(--motion-exit)  both; }

/* Reduced motion: respect user preference. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =========================================================
   Jira-style select (custom dropdown)
   ========================================================= */
.jselect {
    position: relative;
    display: inline-block;
    width: 100%;
    font: inherit;
}
/* Native <select> stays in DOM (so FormData works) but is invisible. */
.jselect > select.jselect__native {
    position: absolute !important;
    top: 0; left: 0;
    width: 1px !important; height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    border: 0 !important; padding: 0 !important;
    margin: 0 !important;
    clip: rect(0 0 0 0);
    overflow: hidden;
}

.jselect__trigger {
    width: 100%;
    min-height: 32px;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 4px 8px 4px 10px;
    background: var(--ds-field-bg-idle);
    border: 1px solid var(--ds-border-input);
    border-radius: 3px;
    color: var(--ds-text);
    font: 400 14px/20px inherit;
    text-align: left;
    cursor: pointer;
    transition: background-color 120ms var(--motion-enter), border-color 120ms var(--motion-enter);
}
.jselect__trigger:hover {
    background: var(--ds-field-bg-hover);
    border-color: var(--ds-border-input-hover);
}
.jselect__trigger:focus-visible,
.jselect__trigger[aria-expanded="true"] {
    outline: none;
    border-color: var(--ds-border-focused);
    box-shadow: 0 0 0 2px var(--ds-focus-ring);
}
.jselect__trigger[disabled] {
    background: var(--ds-field-bg-disabled);
    color: var(--ds-text-disabled);
    cursor: not-allowed;
}
.jselect__value {
    flex: 1;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.jselect__value.is-placeholder {
    color: var(--ds-text-subtlest);
}
.jselect__caret {
    flex: 0 0 auto;
    width: 16px; height: 16px;
    color: var(--ds-text-subtle);
    transition: transform 160ms var(--motion-enter);
    pointer-events: none;
}
.jselect__trigger[aria-expanded="true"] .jselect__caret { transform: rotate(180deg); }

@keyframes jselectIn  { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes jselectOut { from { opacity: 1; transform: translateY(0); }    to { opacity: 0; transform: translateY(-4px); } }

.jselect__menu {
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    min-width: 100%;
    max-width: min(360px, 100vw);
    background: var(--ds-surface-overlay);
    border: 1px solid var(--ds-border);
    border-radius: 4px;
    z-index: 200;
    overflow: hidden;
    animation: jselectIn 140ms var(--motion-enter) both;
}
.jselect__menu.is-above {
    top: auto; bottom: calc(100% + 4px);
    animation-name: jselectIn;
}
.jselect__menu.is-closing { animation: jselectOut 120ms var(--motion-exit) both; }

.jselect__search {
    width: 100%;
    height: 32px;
    padding: 0 10px;
    border: 0;
    border-bottom: 1px solid var(--ds-border);
    border-radius: 0;
    background: transparent;
    color: var(--ds-text);
    font: inherit;
}
.jselect__search:focus { outline: none; box-shadow: none; border-bottom-color: var(--ds-border-focused); }

.jselect__list {
    max-height: 240px;
    overflow-y: auto;
    padding: 4px;
}
.jselect__option {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px;
    border-radius: 3px;
    color: var(--ds-text);
    font: 400 14px/20px inherit;
    cursor: pointer;
    user-select: none;
}
.jselect__option:hover,
.jselect__option.is-highlighted {
    background: var(--ds-surface-hovered);
}
.jselect__option.is-selected {
    background: var(--ds-background-information);
    color: var(--ds-text-information);
    font-weight: 600;
}
.jselect__option.is-selected.is-highlighted {
    /* Slight tint when selected + highlighted simultaneously. */
    filter: brightness(.97);
}
.jselect__check {
    width: 14px; height: 14px;
    flex: 0 0 auto;
    color: var(--ds-text-information);
    visibility: hidden;
}
.jselect__option.is-selected .jselect__check { visibility: visible; }
.jselect__empty {
    padding: 12px; text-align: center;
    color: var(--ds-text-subtlest);
    font-size: 13px;
}

/* =========================================================
   Subtasks (ticket detail)
   ========================================================= */
.subtasks-counter {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--ds-background-neutral);
    color: var(--ds-text-subtle);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    min-width: 24px;
    text-align: center;
}
.subtasks-counter:empty { display: none; }

.subtasks {
    display: flex; flex-direction: column;
    border-top: 1px solid var(--ds-border);
}
.subtasks:empty { border-top: 0; }

.subtask {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 4px;
    border-bottom: 1px solid var(--ds-border);
    transition: background-color 120ms var(--motion-enter);
}
.subtask:last-child { border-bottom: 0; }
.subtask:hover { background: var(--ds-surface-hovered); }

.subtask__check {
    flex: 0 0 auto;
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--ds-text-subtle);
    background: transparent;
    border-radius: 3px;
    cursor: pointer;
    transition: color 120ms var(--motion-enter), background-color 120ms var(--motion-enter);
}
.subtask__check:hover:not([disabled]) {
    background: var(--ds-background-neutral-subtle-hovered);
    color: var(--ds-text);
}
.subtask__check[disabled] { cursor: not-allowed; opacity: .5; }
.subtask.is-done .subtask__check { color: var(--ds-text-success); }
.subtask__check [data-lucide] { width: 18px; height: 18px; stroke-width: 2; }

.subtask__title {
    flex: 1;
    color: var(--ds-text);
    font-size: 14px; line-height: 20px;
    cursor: text;
    word-break: break-word;
}
.subtask.is-done .subtask__title {
    color: var(--ds-text-subtlest);
    text-decoration: line-through;
}
.subtask__title-input {
    flex: 1;
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--ds-border-input);
    border-radius: 3px;
    background: var(--ds-field-bg-idle);
    color: var(--ds-text);
    font: inherit;
}
.subtask__title-input:focus {
    outline: none;
    border-color: var(--ds-border-focused);
    box-shadow: 0 0 0 2px var(--ds-focus-ring);
}

.subtask__delete {
    flex: 0 0 auto;
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--ds-text-subtlest);
    background: transparent;
    border-radius: 3px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 120ms var(--motion-enter), color 120ms var(--motion-enter), background-color 120ms var(--motion-enter);
}
.subtask:hover .subtask__delete { opacity: 1; }
.subtask__delete:hover { color: var(--ds-text-danger); background: var(--ds-background-danger); }

.subtask-add {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 4px;
    border-top: 1px solid var(--ds-border);
    margin-top: 0;
}
.subtasks:empty + .subtask-add { border-top: 0; }
.subtask-add__icon { color: var(--ds-text-subtlest); flex: 0 0 auto; }
.subtask-add input {
    flex: 1;
    height: 32px;
    padding: 0 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ds-text);
    font: inherit;
    border-radius: 3px;
    transition: background-color 120ms var(--motion-enter), border-color 120ms var(--motion-enter);
}
.subtask-add input::placeholder { color: var(--ds-text-subtlest); }
.subtask-add input:hover { background: var(--ds-surface-hovered); }
.subtask-add input:focus {
    outline: none;
    background: var(--ds-field-bg-focus);
    border-color: var(--ds-border-focused);
    box-shadow: 0 0 0 2px var(--ds-focus-ring);
}

/* Lock state on the progress field when subtasks exist. */
.is-readonly { cursor: help !important; opacity: .96; }
.is-readonly:hover { background: transparent !important; }
.detail-progress__hint {
    margin-left: 8px;
    font-size: 11px; font-weight: 600;
    color: var(--ds-text-subtle);
    letter-spacing: 0.02em;
}

/* =========================================================
   Notifications bell & dropdown
   ========================================================= */
.notif-bell-wrap { position: relative; }

.notif-badge {
    position: absolute; top: 2px; right: 2px;
    min-width: 16px; height: 16px; padding: 0 4px;
    background: var(--ds-text-danger); color: #fff;
    border-radius: 9999px; font-size: 10px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    pointer-events: none;
}

.notif-dropdown {
    display: none;
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 340px; max-height: 440px;
    background: var(--ds-surface-default);
    border: 1px solid var(--ds-border-default);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    z-index: 1000;
    overflow: hidden;
    flex-direction: column;
}
.notif-dropdown.open { display: flex; }

.notif-dropdown__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--ds-border-default);
    flex-shrink: 0;
}
.notif-dropdown__title { font-size: 14px; font-weight: 600; color: var(--ds-text); }

.notif-list { overflow-y: auto; flex: 1; }

.notif-empty {
    text-align: center; padding: 32px 16px;
    font-size: 13px; color: var(--ds-text-subtle);
}

.notif-item {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 11px 16px;
    border-bottom: 1px solid var(--ds-border-default);
    cursor: pointer; transition: background .12s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--ds-background-neutral-subtle-hovered); }
.notif-item.unread { background: var(--ds-background-information-subtle); }
.notif-item.unread:hover { background: var(--ds-background-information-subtle-hovered, #e8f0fc); }

.notif-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--ds-brand); flex-shrink: 0; margin-top: 5px;
}
.notif-item.read .notif-dot { visibility: hidden; }

.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: 13px; font-weight: 600; color: var(--ds-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item.read .notif-title { font-weight: 400; }
.notif-body  { font-size: 12px; color: var(--ds-text-subtle); margin-top: 1px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-time  { font-size: 11px; color: var(--ds-text-subtlest); flex-shrink: 0; margin-top: 2px; }

/* =========================================================
   Vacunas — componentes propios del consultorio
   ========================================================= */
.brand .brand-mark { width: 26px; height: 26px; border-radius: 6px; }
.brand .brand-mark svg { width: 15px; height: 15px; }

.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 20px; font-weight: 600; color: var(--ds-text); letter-spacing: -0.005em; }
.page-head .spacer { flex: 1; }
.page-head .sub { color: var(--ds-text-subtle); font-size: 13px; }

.panel {
    background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: 4px;
    padding: 16px; margin-bottom: 16px; min-width: 0;
}
.panel > h2, .panel-title {
    margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--ds-text);
    display: flex; align-items: center; gap: 8px;
}
.panel-title .count { margin-left: auto; }
.panel-title [data-lucide], .panel-title svg { width: 16px; height: 16px; color: var(--ds-text-subtle); }
.panel--flush { padding: 0; overflow: hidden; }
.panel--flush > .panel-title { padding: 14px 16px 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.grid-ficha { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); align-items: start; }
@media (max-width: 980px) { .grid-2, .grid-3, .grid-main, .grid-ficha { grid-template-columns: 1fr; } }

.kpi-row.kpi-row--6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1200px) { .kpi-row.kpi-row--6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { .kpi-row.kpi-row--6 { grid-template-columns: repeat(2, 1fr); } }
.kpi-card { position: relative; }
a.kpi-card { color: inherit; text-decoration: none; transition: border-color 100ms ease, background-color 100ms ease; }
a.kpi-card:hover { border-color: var(--ds-border-bold); background: var(--ds-surface-hovered); }
.kpi-value--danger { color: var(--ds-text-danger); }
.kpi-value--warning { color: var(--ds-text-warning); }
.kpi-card .kpi-value { font-size: 28px; }

/* Insignias de adherencia / estado */
.badge.adh-on_time  { background: var(--ds-background-success); color: var(--ds-text-success); }
.badge.adh-due_soon { background: var(--ds-background-warning); color: var(--ds-text-warning); }
.badge.adh-overdue  { background: var(--ds-background-danger);  color: var(--ds-text-danger); }
.badge.adh-no_date  { background: var(--ds-background-neutral); color: var(--ds-text-subtle); }
.badge.st-active    { background: var(--ds-background-success); color: var(--ds-text-success); }
.badge.st-paused    { background: var(--ds-background-warning); color: var(--ds-text-warning); }
.badge.st-finished  { background: var(--ds-background-information); color: var(--ds-text-information); }
.badge.st-dropped, .badge.st-cancelled, .badge.st-suspended { background: var(--ds-background-neutral); color: var(--ds-text-subtle); }
.badge.st-pending   { background: var(--ds-background-information); color: var(--ds-text-information); }
.badge.st-sent      { background: var(--ds-background-success); color: var(--ds-text-success); }
.badge.st-failed    { background: var(--ds-background-danger); color: var(--ds-text-danger); }
.badge.st-in_stock  { background: var(--ds-background-success); color: var(--ds-text-success); }
.badge.st-in_use    { background: var(--ds-background-information); color: var(--ds-text-information); }
.badge.st-depleted, .badge.st-discarded, .badge.st-sent_out { background: var(--ds-background-neutral); color: var(--ds-text-subtle); }
.badge.st-expired   { background: var(--ds-background-danger); color: var(--ds-text-danger); }
.badge.alert-expired  { background: var(--ds-background-danger); color: var(--ds-text-danger); }
.badge.alert-expiring { background: var(--ds-background-warning); color: var(--ds-text-warning); }
.badge.alert-low      { background: var(--ds-background-warning); color: var(--ds-text-warning); }
.badge.reaction-none { background: var(--ds-background-success); color: var(--ds-text-success); }
.badge.reaction-local { background: var(--ds-background-warning); color: var(--ds-text-warning); }
.badge.reaction-systemic { background: var(--ds-background-danger); color: var(--ds-text-danger); }
.badge.phase-buildup { background: var(--ds-background-information); color: var(--ds-text-information); }
.badge.phase-maintenance { background: var(--ds-background-neutral); color: var(--ds-text-subtle); }
.badge.no-phone { background: var(--ds-background-danger); color: var(--ds-text-danger); gap: 4px; text-transform: none; letter-spacing: 0; }
.badge .icon--sm, .badge svg { width: 12px; height: 12px; }

.btn.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-wa { color: #128C4A; border-color: rgba(18, 140, 74, .45); }
.btn-wa:hover { background: rgba(37, 211, 102, .12); text-decoration: none; }
[data-theme="dark"] .btn-wa { color: #4FE39A; }
.btn [data-lucide], .btn svg { width: 15px; height: 15px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--ds-border); margin-bottom: 14px; overflow-x: auto; }
.tabs button {
    padding: 8px 14px; font-size: 13px; font-weight: 500; color: var(--ds-text-subtle);
    border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 6px;
}
.tabs button:hover { color: var(--ds-text); }
.tabs button.active { color: var(--ds-text-brand); border-bottom-color: var(--ds-border-brand); }
.tabs .count {
    background: var(--ds-background-neutral); color: var(--ds-text-subtle); border-radius: 9999px;
    font-size: 11px; font-weight: 600; padding: 0 7px; min-width: 20px; text-align: center; line-height: 18px;
}
.tabs button.active .count { background: var(--ds-background-information); color: var(--ds-text-information); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type="search"], .toolbar input[type="text"] { min-width: 220px; }
.toolbar select, .toolbar input { height: 32px; font-size: 13px; }
.toolbar .spacer { flex: 1; }
.toolbar label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ds-text-subtle); }

.data-table td { vertical-align: middle; }
.data-table.is-clickable tbody tr { cursor: pointer; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.data-table .name-cell { font-weight: 600; color: var(--ds-text); }
.data-table .name-cell small { display: block; font-weight: 400; color: var(--ds-text-subtlest); font-size: 11px; }
.data-table tr.no-phone-row td:first-child { box-shadow: inset 3px 0 0 var(--ds-text-danger); }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--ds-text); }
.data-table th .sort { opacity: .6; font-size: 10px; }
.text-danger { color: var(--ds-text-danger); }
.text-warning { color: var(--ds-text-warning); }
.text-success { color: var(--ds-text-success); }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

.empty { text-align: center; padding: 28px 12px; color: var(--ds-text-subtlest); font-size: 13px; }
.empty [data-lucide], .empty svg { width: 28px; height: 28px; display: block; margin: 0 auto 8px; opacity: .6; }

.banner {
    display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; margin-bottom: 14px;
    border-radius: 4px; border: 1px solid var(--ds-border); font-size: 13px; line-height: 1.45;
    background: var(--ds-background-information); color: var(--ds-text-information);
}
.banner [data-lucide], .banner svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.banner--warning { background: var(--ds-background-warning); color: var(--ds-text-warning); }
.banner--danger { background: var(--ds-background-danger); color: var(--ds-text-danger); }
.banner--success { background: var(--ds-background-success); color: var(--ds-text-success); }
.banner a { color: inherit; text-decoration: underline; font-weight: 600; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--ds-text-subtle); }
.kv dd { margin: 0; color: var(--ds-text); word-break: break-word; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: 8px; } }

.list-row {
    display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--ds-border);
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; color: var(--ds-text); font-size: 13px; }
.list-row .title a { color: inherit; }
.list-row .meta { font-size: 12px; color: var(--ds-text-subtle); }
.list-row .side { text-align: right; white-space: nowrap; font-size: 12px; }

.timeline { position: relative; margin: 0; padding: 0 0 0 18px; list-style: none; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--ds-border); }
.timeline li { position: relative; padding: 0 0 14px 10px; }
.timeline li::before {
    content: ''; position: absolute; left: -17px; top: 4px; width: 10px; height: 10px; border-radius: 50%;
    background: var(--ds-background-brand-bold); border: 2px solid var(--ds-surface);
}
.timeline li.reaction-local::before { background: var(--ds-text-warning); }
.timeline li.reaction-systemic::before { background: var(--ds-text-danger); }
.timeline .t-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--ds-text); }
.timeline .t-head strong { font-weight: 600; }
.timeline .t-meta { font-size: 12px; color: var(--ds-text-subtle); margin-top: 2px; }
.timeline .t-actions { margin-left: auto; }

.form .row, .modal .form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form .row label, .form .row-3 label { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
@media (max-width: 560px) { .form .row, .form .row-3, .modal .row { grid-template-columns: 1fr; } }
.modal--wide { width: min(820px, 100%); }
.field-error { color: var(--ds-text-danger); font-size: 12px; margin-top: 2px; }
.form input.is-invalid, .form select.is-invalid, .form textarea.is-invalid { border-color: var(--ds-border-danger); }
.form-error { color: var(--ds-text-danger); font-size: 13px; min-height: 1em; }

.search-results { border: 1px solid var(--ds-border); border-radius: 4px; background: var(--ds-surface); margin-top: 6px; max-height: 340px; overflow: auto; }
.search-results .item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--ds-border); }
.search-results .item:last-child { border-bottom: 0; }
.search-results .item:hover, .search-results .item.is-focus { background: var(--ds-surface-hovered); }
.search-results .item .grow { flex: 1; min-width: 0; }
.big-search input { height: 44px; font-size: 16px; padding-left: 40px; }

.observation-note {
    display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 4px;
    background: var(--ds-background-warning); color: var(--ds-text-warning); font-size: 13px; line-height: 1.45;
}
.observation-note svg { width: 20px; height: 20px; flex-shrink: 0; }
.radio-cards { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-cards label {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--ds-border-input);
    border-radius: 4px; cursor: pointer; font-size: 13px; background: var(--ds-field-bg-idle); color: var(--ds-text);
}
.radio-cards label:has(input:checked) { border-color: var(--ds-border-brand); background: var(--ds-background-information); color: var(--ds-text-information); }
.radio-cards input { width: auto; height: auto; }

.vial-bar { height: 6px; border-radius: 99px; background: var(--ds-background-neutral); overflow: hidden; min-width: 70px; }
.vial-bar > i { display: block; height: 100%; background: var(--ds-text-success); }
.vial-bar.is-low > i { background: var(--ds-text-warning); }

.import-drop { border: 2px dashed var(--ds-border-strong); border-radius: 6px; padding: 18px; text-align: center; color: var(--ds-text-subtle); }
.import-result { font-size: 13px; }
.import-result ul { max-height: 220px; overflow: auto; padding-left: 18px; margin: 6px 0 0; color: var(--ds-text-subtle); }
.template-preview {
    background: var(--ds-surface-sunken); border: 1px solid var(--ds-border); border-radius: 12px 12px 12px 2px;
    padding: 12px 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; color: var(--ds-text); max-width: 460px;
}
.chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; background: var(--ds-background-neutral); color: var(--ds-text-subtle); font-size: 12px; font-family: ui-monospace, monospace; cursor: pointer; border: 0; }
.chip:hover { background: var(--ds-surface-pressed); }
.msg-box { font-size: 12px; color: var(--ds-text-subtle); background: var(--ds-surface-sunken); border-radius: 4px; padding: 6px 8px; margin-top: 4px; white-space: pre-wrap; }

@media (max-width: 640px) {
    .brand .brand-text { display: none; }
    .main { padding: 14px 10px; }
    .list-row { flex-wrap: wrap; }
    #userName { display: none; }
}
@media (max-width: 1180px) { .nav-links .label-text { display: none; } .nav-links a { padding: 6px 9px; } }
@media (min-width: 1181px) { .nav-links a { padding: 6px 12px; } }
