/* =========================================================
   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 — rojo La Reforma */
    --ds-background-brand-bold: #DD3333;
    --ds-background-brand-bold-hovered: #C42727;
    --ds-background-brand-bold-pressed: #9E1F1F;
    --ds-text-brand: #C42727;
    --ds-border-brand: #DD3333;

    /* 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: #DD3333;             /* focus ring color (brand red) */
    --ds-focus-ring: rgba(221, 51, 51, 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: #E5484D;
    --ds-background-brand-bold-hovered: #F2555A;
    --ds-background-brand-bold-pressed: #FF8589;
    --ds-text-brand: #FF8589;
    --ds-border-brand: #E5484D;

    --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: #E5484D;
    --ds-focus-ring: rgba(229, 72, 77, 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); }

.nav-dropdown { position: relative; }
.nav-dropdown__trigger {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px; border-radius: 3px; border: 0; background: transparent; cursor: pointer;
    color: var(--ds-text-subtle); font: inherit; font-weight: 500; font-size: 13px;
    transition: background-color 100ms ease, color 100ms ease;
}
.nav-dropdown__trigger:hover, .nav-dropdown__trigger[aria-expanded="true"] { color: var(--ds-text); background: var(--ds-surface-hovered); }
.nav-dropdown__trigger.active { color: var(--ds-text-brand); background: var(--ds-background-information); }
.nav-dropdown__trigger:focus-visible, .nav-acc__trigger:focus-visible { outline: 2px solid var(--ds-text-brand); outline-offset: 1px; }
.nav-caret { width: 14px; height: 14px; transition: transform 150ms ease; }
[aria-expanded="true"] > .nav-caret { transform: rotate(180deg); }
.nav-dropdown__menu {
    position: absolute; top: calc(100% + 6px); left: 0; min-width: 220px; z-index: 60;
    display: flex; flex-direction: column; gap: 2px; padding: 6px;
    background: var(--ds-surface-default); border: 1px solid var(--ds-border); border-radius: 6px;
    box-shadow: 0 8px 24px rgba(9, 30, 66, .18);
}
.nav-dropdown__menu[hidden] { display: none; }
.nav-dropdown__menu a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 4px; white-space: nowrap; }
.nav-dropdown__menu a svg, .nav-dropdown__menu a i { width: 16px; height: 16px; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: #8993a4; margin-left: auto; flex-shrink: 0; display: none; }
.nav-dot[data-state] { display: inline-block; }
.nav-dot[data-state="connected"] { background: #22a06b; }
.nav-dot[data-state="disconnected"] { background: #e2830b; }
.nav-dot[data-state="unconfigured"] { background: #8993a4; }
.nav-acc__trigger {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 6px;
    background: transparent; cursor: pointer; color: var(--ds-text-subtle); font: inherit; font-size: 14px; font-weight: 500; text-align: left;
}
.nav-acc__trigger .nav-caret { margin-left: auto; }
.nav-acc__trigger:hover { background: var(--ds-surface-hovered); color: var(--ds-text); }
.nav-acc__trigger.active { color: var(--ds-text-brand); }
.nav-acc__panel { padding-left: 14px; display: flex; flex-direction: column; }
.nav-acc__panel[hidden] { display: none; }

.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 { white-space: nowrap; text-align: right; }
.row-actions > * + * { margin-left: 4px; }
.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; }
}
/* Menú: texto + icono desde 960px; por debajo solo iconos (con title/aria-label). Primero ceden el nombre de usuario y el título de la marca. */
@media (max-width: 959px) { .nav-links .label-text { display: none; } .nav-links a, .nav-dropdown__trigger { padding: 6px 9px; } }
@media (min-width: 960px) { .nav-links a, .nav-dropdown__trigger { padding: 6px 8px; white-space: nowrap; } }
@media (min-width: 1181px) { .nav-links a, .nav-dropdown__trigger { padding: 6px 12px; } }
.nav-links { flex-wrap: nowrap; min-width: 0; }
.nav-dropdown__trigger .label-text { white-space: nowrap; }
@media (max-width: 1179px) { .brand .brand-text { display: none; } #userName { display: none; } }
#userName { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.user-box { min-width: 0; flex-shrink: 1; }

/* =========================================================
   Barras de filtros (toolbar) y acciones masivas
   El ancho 100% de los controles solo aplica a formularios y modales, no a las barras de filtros.
   ========================================================= */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar > input[type="search"], .toolbar > input[type="text"] { flex: 1 1 260px; width: auto; min-width: 200px; max-width: 420px; }
.toolbar > select { flex: 0 0 auto; width: auto; min-width: 160px; max-width: 200px; }
.toolbar > .btn { flex: 0 0 auto; }
.toolbar > label.check { flex: 0 0 auto; }
.toolbar > .bulk-bar { order: -1; }
.bulk-bar { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; flex-wrap: wrap;
    padding: 0 10px 0 0; margin-right: 4px; border-right: 1px solid var(--ds-border); }
.bulk-bar:empty { display: none; }
.bulk-bar .bulk-count { min-width: 96px; }
.bulk-bar select { width: auto; min-width: 190px; max-width: 240px; flex: 0 0 auto; }
.bulk-bar .check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ds-text-subtle); }
/* Los checkbox usan appearance:none: sin tamaño explícito colapsan a una línea. */
.bulk-bar input[type="checkbox"], .bulk-cell input[type="checkbox"], input[type="checkbox"].bulk-check, input[type="checkbox"].bulk-all {
    width: 18px; height: 18px; min-width: 18px; min-height: 18px; flex: 0 0 18px; display: inline-block; vertical-align: middle;
}
.bulk-bar input[type="checkbox"]:checked::after, .bulk-cell input[type="checkbox"]:checked::after, input[type="checkbox"].bulk-check:checked::after, input[type="checkbox"].bulk-all:checked::after { left: 5px; top: 1px; }
.data-table th.bulk-cell, .data-table td.bulk-cell { width: 44px; min-width: 44px; max-width: 44px; padding-left: 12px; padding-right: 8px; text-align: center; }
.bulk-all-wrap { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.list-row .bulk-pick { flex: 0 0 auto; align-self: flex-start; margin-top: 3px; }
@media (max-width: 640px) {
    .toolbar { display: grid; grid-template-columns: 1fr 1fr; }
    .toolbar > input[type="search"], .toolbar > input[type="text"] { grid-column: 1 / -1; max-width: none; }
    .toolbar > select { width: 100%; min-width: 0; max-width: none; }
    .toolbar > .bulk-bar { grid-column: 1 / -1; border-right: 0; padding-right: 0; }
    .bulk-bar select { flex: 1 1 140px; max-width: none; }
}

/* Importar / Exportar */
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.cards .panel { margin: 0; }
.card-desc { color: var(--ds-text-subtle); font-size: 13px; margin: 0 0 12px; line-height: 1.45; }
.preview-scroll { max-height: 420px; overflow: auto; }
.row-chg { font-size: 12px; color: var(--ds-text-subtle); margin: 0; padding-left: 16px; }
.row-chg li b { color: var(--ds-text); }
.badge.act-create { background: var(--ds-background-success); color: var(--ds-text-success); }
.badge.act-update { background: var(--ds-background-information); color: var(--ds-text-information); }
.badge.act-unchanged { background: var(--ds-background-neutral); color: var(--ds-text-subtle); }
.badge.act-error { background: var(--ds-background-danger); color: var(--ds-text-danger); }
.inline-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.inline-fields label { display: flex; flex-direction: column; gap: 4px; flex: 0 1 170px; }

/* --- SearchSelect (selector con búsqueda) ------------------------------------ */
.ss { position: relative; }
.ss .ss-native { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; padding: 0; border: 0; }
.ss-input { width: 100%; padding-right: 28px; -webkit-appearance: none; appearance: none; }
.ss-input::-webkit-search-cancel-button, .ss-input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.ss-caret { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--ds-text-subtle); font-size: 12px; pointer-events: none; }
.ss.is-open .ss-input { border-color: var(--ds-border-focused, var(--ds-text-brand)); }
.ss-menu {
    position: fixed; z-index: 2000; overflow-y: auto; overscroll-behavior: contain;
    background: var(--ds-surface-overlay, var(--ds-surface)); color: var(--ds-text);
    border: 1px solid var(--ds-border); border-radius: 6px; padding: 4px;
    box-shadow: var(--ds-shadow-overlay, 0 8px 24px rgba(9, 30, 66, .25));
}
.ss-menu[hidden] { display: none; }
.ss-opt { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 4px; cursor: pointer; font-size: 14px; }
.ss-opt.is-active { background: var(--ds-surface-hovered); }
.ss-opt.is-selected .ss-opt__label { color: var(--ds-text-brand); font-weight: 600; }
.ss-opt--blank .ss-opt__label { color: var(--ds-text-subtle); }
.ss-opt__meta { font-size: 12px; color: var(--ds-text-subtle); }
.ss-empty, .ss-more { padding: 10px; font-size: 13px; color: var(--ds-text-subtle); text-align: center; }
@media (max-width: 640px) { .ss-opt { padding: 11px 10px; } }

/* --- Tarjeta de WhatsApp en Inicio ------------------------------------------- */
.wa-card { display: grid; grid-template-columns: 1.4fr 1.2fr 1fr auto; gap: 16px 24px; align-items: center; }
.wa-card__item { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.wa-card__state { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.wa-card__item b a { color: inherit; }
@media (max-width: 980px) { .wa-card { grid-template-columns: 1fr 1fr; } .wa-card__action { grid-column: 1 / -1; } .wa-card__action .btn { width: 100%; justify-content: center; } }
@media (max-width: 520px) { .wa-card { grid-template-columns: 1fr; } }

/* Casillas dentro de barras de filtros: el alto de 32px de los controles no debe estirarlas. */
.toolbar label.check { align-items: center; align-self: center; line-height: 1.2; cursor: pointer; }
.toolbar input[type="checkbox"] { width: 18px; height: 18px; min-width: 18px; min-height: 18px; flex: 0 0 18px; display: inline-block; vertical-align: middle; align-self: center; }
.toolbar input[type="checkbox"]:checked::after { left: 5px; top: 1px; }
/* Chip de filtro (Recordatorios) */
.chip-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--ds-border); background: var(--ds-surface); color: var(--ds-text-subtle); font: inherit; font-size: 13px; cursor: pointer; }
.chip-toggle:hover { background: var(--ds-surface-hovered); color: var(--ds-text); }
.chip-toggle[aria-pressed="true"] { background: var(--ds-background-information); color: var(--ds-text-brand); border-color: var(--ds-text-brand); }

/* Importar / Exportar: guía, reglas y formato desplegable */
.ie-guide { margin-bottom: 16px; align-items: flex-start; }
.ie-guide ol { margin: 6px 0 6px 18px; padding: 0; }
.ie-guide li { margin: 2px 0; }
.ie-rules { margin: 0 0 12px 18px; padding: 0; font-size: 13px; color: var(--ds-text-subtle); }
.ie-rules li { margin: 3px 0; }
.ie-format { margin: 0 0 14px; border: 1px solid var(--ds-border); border-radius: 6px; padding: 8px 12px; background: var(--ds-surface-sunken, transparent); }
.ie-format summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ds-text-brand, var(--ds-link)); }
.ie-format p { font-size: 13px; color: var(--ds-text-subtle); margin: 8px 0; }
.ie-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 6px 0; }
.ie-table th, .ie-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--ds-border); vertical-align: top; }
.ie-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--ds-text-subtlest); }
.ie-table td:first-child { font-weight: 600; white-space: nowrap; color: var(--ds-text); }
.ie-table .req { color: var(--ds-text-danger); }
@media (max-width: 640px) { .ie-table td:first-child { white-space: normal; } }

/* Filas con acciones (Inicio): si no cabe, los botones bajan a su propia línea en vez de aplastar el nombre */
.list-row.has-actions { flex-wrap: wrap; row-gap: 6px; }
.list-row.has-actions .grow { flex: 1 1 180px; }
.list-row .row-actions { display: flex; gap: 6px; flex: 0 0 auto; margin-left: auto; }

/* Logo de WhatsApp (Lucide no trae logos de marcas). Una sola definición: <i class="wa-ico"></i> */
:root { --wa-svg: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413Z'/></svg>"); }
.wa-ico {
    display: inline-block; width: 16px; height: 16px; flex: 0 0 16px; vertical-align: -3px;
    background-color: #25D366;
    -webkit-mask: var(--wa-svg) center / contain no-repeat; mask: var(--wa-svg) center / contain no-repeat;
}
.wa-ico--lg { width: 20px; height: 20px; flex-basis: 20px; vertical-align: -4px; }

/* Campos de nombre: se ven en mayúsculas también mientras se escribe/compone */
.input-upper { text-transform: uppercase; }
.input-upper::placeholder { text-transform: none; }

/* Aplicar dosis: historial en la columna izquierda, bajo el paciente */
.apply-left { min-width: 0; }
.apply-right { min-width: 0; }
.apply-history #pDoses { max-height: 62vh; overflow-y: auto; padding-right: 4px; }
@media (max-width: 980px) {
    /* En una sola columna el historial va DESPUÉS del formulario, no antes. */
    .apply-grid > .apply-left { display: contents; }
    .apply-patient { order: 1; }
    .apply-right { order: 2; }
    .apply-history { order: 3; }
    .apply-history #pDoses { max-height: none; overflow: visible; }
}

/* Frasco: select + botones de acción en una fila (formulario de dosis) */
.vial-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.vial-row select { flex: 1 1 auto; min-width: 0; }
.vial-row .btn { flex: 0 0 auto; }

/* Próxima dosis (formulario de dosis) */
.next-dose-block { border: 1px solid var(--ds-border); border-radius: 6px; padding: 12px; background: var(--ds-surface-sunken); display: flex; flex-direction: column; gap: 8px; }
.next-dose-block .checkbox-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }

.next-date-words { font-weight: 600; color: var(--ds-text); margin-top: 4px; min-height: 1.2em; }
.next-dose-block .wa-ico { vertical-align: -3px; }
.btn.disabled { opacity: .5; pointer-events: none; }

/* Formularios de tratamiento: con textos de ayuda, las filas necesitan aire entre sí */
#treatmentBlock .row + .row, #treatmentBlock .row + .row-3,
#treatmentForm .row + .row, #treatmentForm > .row + label, #treatmentForm > label + label { margin-top: 16px; }
#treatmentBlock .row, #treatmentBlock .row-3, #treatmentForm .row { align-items: start; }

/* Comprobación de duplicados (cédula bloquea; teléfono / correo solo avisan) */
.dup-note:empty { display: none; }
.dup-note { font-size: 12px; margin-top: 4px; line-height: 1.35; }
.dup-note--error { color: var(--ds-text-danger); font-weight: 500; }
.dup-note--warn { color: var(--ds-text-warning); }
.dup-note a { color: inherit; text-decoration: underline; }

/* Firma (SignaturePad). touch-action: none solo en el lienzo para no bloquear el desplazamiento de la página. */
.sigpad { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 100%; }
.sigpad--fill { height: 100%; }
/* UN solo recuadro: el borde punteado es del «stage» y el lienzo lo ocupa por completo (sin padding ni segundo marco). */
.sigpad__stage { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; box-sizing: border-box; border: 2px dashed var(--ds-border-bold, #8993a4); border-radius: 8px; background: #fff; overflow: hidden; }
.sigpad:not(.sigpad--fill) .sigpad__stage { flex: 0 0 auto; width: 100%; max-height: 60vh; }
.sigpad__canvas { position: absolute; inset: 0; width: 100%; height: 100%; background: transparent; border: 0; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: crosshair; display: block; }
.sigpad__canvas:focus-visible { outline: 2px solid var(--ds-border-focused, #DD3333); }
.sigpad__bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sigpad__hint { font-size: 12px; color: var(--ds-text-subtle); }
.sig-block { border: 1px solid var(--ds-border); border-radius: 6px; padding: 12px; background: var(--ds-surface-sunken); display: flex; flex-direction: column; gap: 10px; }
.sig-block.is-invalid { border-color: var(--ds-text-danger); }
.sig-err { color: var(--ds-text-danger); font-size: 12px; font-weight: 500; margin: 0; }
.late-note { color: var(--ds-text-warning); font-size: 12px; margin-top: 4px; }
.late-note:empty { display: none; }

/* Programas en Aplicar dosis */
.program-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin-bottom: 12px; }
.program-card { text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--ds-border); border-radius: 6px; background: var(--ds-surface); color: var(--ds-text); font: inherit; cursor: pointer; }
.program-card:hover { background: var(--ds-surface-hovered); }
.program-card.is-active { border-color: var(--ds-text-brand); box-shadow: inset 0 0 0 1px var(--ds-text-brand); background: var(--ds-background-information); }
.program-card__name { font-weight: 700; font-size: 14px; }
.program-card__meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.program-card__date { font-size: 12px; color: var(--ds-text-subtle); }
.program-summary__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 18px; margin-top: 8px; }
.program-summary__grid > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.program-summary__grid b { font-size: 15px; }
@media (max-width: 640px) { .program-summary__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stage-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ds-text-subtle); margin: 14px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--ds-border); }
.stage-head:first-child { margin-top: 0; }
.sig-chip { padding: 2px 8px; }

/* ---- Avatar por sexo ---------------------------------------------------- */
.avatar { display: inline-flex; flex: 0 0 auto; border-radius: 50%; overflow: hidden; align-items: flex-end; justify-content: center; }
.avatar svg { width: 100%; height: 100%; display: block; }
.avatar .av-body, .avatar .av-head { fill: currentColor; }
.avatar .av-skin { fill: #F1C7A5; }
.avatar .av-hair { fill: #3B2F2A; }
[data-theme="dark"] .avatar .av-skin { fill: #E3B692; }
[data-theme="dark"] .avatar .av-hair { fill: #6A5446; }
.avatar--m { background: #DCE9FF; color: #4C9AFF; }
.avatar--f { background: #FCE4F1; color: #E774BB; }
.avatar--n { background: #E9EBEE; color: #8993A4; }
[data-theme="dark"] .avatar--m { background: #1C2B41; color: #579DFF; }
[data-theme="dark"] .avatar--f { background: #42212F; color: #F797D2; }
[data-theme="dark"] .avatar--n { background: #2C333A; color: #8C9BAB; }

/* ---- Línea de tiempo horizontal (Timeline.render) ----------------------------- */
.tl { --tl-d: 24px; --tl-w: 58px; --tl-buildup: #D97706; --tl-maintenance: #DD3333; --tl-line: var(--ds-border); }
[data-theme="dark"] .tl { --tl-buildup: #F5A524; --tl-maintenance: #579DFF; }
.tl--compact { --tl-d: 14px; --tl-w: 24px; }
.tl-scroll { overflow-x: auto; overflow-y: hidden; padding: 4px 4px 10px; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.tl-track { display: inline-flex; align-items: flex-end; gap: 0; min-width: 100%; }
.tl-stage { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; padding-right: 10px; margin-right: 4px; border-right: 1px dashed var(--ds-border); }
.tl-stage:last-child { border-right: 0; margin-right: 0; padding-right: 0; }
.tl-stage__label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--tl-c); position: sticky; left: 0; }
.tl-phase--buildup { --tl-c: var(--tl-buildup); }
.tl-phase--maintenance { --tl-c: var(--tl-maintenance); }
.tl-items { display: flex; align-items: flex-start; }
.tl-node { position: relative; flex: 0 0 auto; width: var(--tl-w); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; border: 0; background: transparent; color: var(--ds-text); font: inherit; cursor: pointer; }
.tl-node::before, .tl-node::after { content: ''; position: absolute; top: calc(var(--tl-d) / 2 - 1px); height: 2px; background: var(--tl-line); width: 50%; z-index: 0; }
.tl-node::before { left: 0; }
.tl-node::after { right: 0; }
.tl-node.tl-first::before, .tl-node.tl-last::after { display: none; }
.tl-node--done::before, .tl-node--current::before, .tl-node--done::after { background: var(--tl-c); }
.tl-dot { position: relative; z-index: 1; width: var(--tl-d); height: var(--tl-d); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; box-sizing: border-box; background: var(--ds-surface); border: 2px solid var(--tl-c); color: var(--tl-c); }
.tl-dot svg { width: 70%; height: 70%; }
.tl-node--done .tl-dot { background: var(--tl-c); color: #fff; }
.tl-node--current .tl-dot { background: var(--ds-surface); box-shadow: 0 0 0 3px var(--ds-surface), 0 0 0 5px var(--tl-c); }
.tl-node--pending .tl-dot { border-color: var(--ds-border-bold, #8993A4); color: var(--ds-text-subtle); }
.tl-node--extra .tl-dot { border-style: dashed; color: var(--ds-text-subtle); border-color: var(--tl-c); }
.tl--compact .tl-node--current .tl-dot { box-shadow: 0 0 0 2px var(--ds-surface), 0 0 0 4px var(--tl-c); }
.tl-date { font-size: 10px; color: var(--ds-text-subtle); white-space: nowrap; min-height: 12px; }
.tl-node--current .tl-date { color: var(--ds-text); font-weight: 700; }
.tl-delay { font-size: 10px; color: var(--ds-text-warning); font-weight: 600; margin-top: -2px; }
.tl-node:focus-visible { outline: 2px solid var(--ds-border-focused, #DD3333); outline-offset: 2px; border-radius: 6px; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11px; color: var(--ds-text-subtle); margin-top: 2px; }
.tl-key { display: inline-flex; align-items: center; gap: 5px; }
.tl-swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 2px solid var(--tl-c, var(--ds-text-subtle)); background: transparent; box-sizing: border-box; }
.tl-key.tl-phase--buildup .tl-swatch, .tl-key.tl-phase--maintenance .tl-swatch { background: var(--tl-c); }
.tl-swatch--done { background: var(--ds-text-subtle); }
.tl-swatch--current { box-shadow: 0 0 0 2px var(--ds-surface), 0 0 0 3px var(--ds-text-subtle); }
.tl-swatch--extra { border-style: dashed; }

/* Lista de pacientes: chips de programas */
.prog-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.prog-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; padding: 1px 6px; border-radius: 10px; font-size: 11px; font-weight: 700; background: var(--ds-background-information); color: var(--ds-text-brand); }
.prog-chip--sublingual { background: var(--ds-background-success); color: var(--ds-text-success); }
.prog-chip--mosquito { background: var(--ds-background-warning); color: var(--ds-text-warning); }
.prog-chip--inmunomodulacion { background: var(--ds-background-danger); color: var(--ds-text-danger); }
.scheme-summary { background: var(--ds-surface-sunken); border: 1px solid var(--ds-border); border-radius: 6px; padding: 8px 10px; font-size: 13px; }

/* ---- Ficha: cabecera con avatar y tarjetas de programa ------------------------- */
.page-head--ficha { align-items: center; gap: 12px; }
.ficha-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ficha-title h1 { margin: 0; overflow-wrap: anywhere; }
.ficha-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.program-card2 { border: 1px solid var(--ds-border); border-radius: 4px; background: var(--ds-surface); margin-bottom: 16px; min-width: 0; }
.programs-head { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--ds-text); }
.programs-head svg, .programs-head [data-lucide] { width: 16px; height: 16px; color: var(--ds-text-subtle); }
#pPrograms > .empty { background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: 4px; padding: 16px; }
.program-card2 > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; padding: 12px 14px; }
.program-card2 > summary::-webkit-details-marker { display: none; }
.program-card2 > summary::before { content: '▸'; color: var(--ds-text-subtle); transition: transform .15s; }
.program-card2[open] > summary::before { transform: rotate(90deg); }
.program-card2__name { font-weight: 700; font-size: 15px; }
.program-card2__body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 12px; }
.program-card2.is-inactive { opacity: .92; background: var(--ds-surface-sunken); }
.pc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 16px; }
.pc-grid > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pc-grid b { font-size: 14px; }
.pc-vial { border: 1px dashed var(--ds-border-bold, var(--ds-border)); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.pc-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.event-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.event-list li { border-left: 3px solid var(--ds-border); padding: 2px 0 2px 10px; font-size: 13px; }

/* Separación vertical entre filas (y entre filas y avisos/resúmenes) en los bloques de programa */
#treatmentBlock > * + *:not(.actions):not(.form-error),
#treatmentForm > * + *:not(.actions):not(.form-error) { margin-top: 16px; }
#treatmentBlock .row, #treatmentBlock .row-3, #treatmentForm .row { row-gap: 16px; }

/* Facturación (formulario de paciente) */
.billing-details { border: 1px solid var(--ds-border); border-radius: 6px; padding: 0 12px; background: var(--ds-surface-sunken); }
.billing-details > summary { cursor: pointer; padding: 10px 0; font-weight: 600; font-size: 13px; }
.billing-body { display: flex; flex-direction: column; gap: 14px; padding-bottom: 14px; }
.billing-body .checkbox-row { display: flex; align-items: center; gap: 8px; }

/* Documentos del paciente */
.docs-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.docs-toolbar select, .docs-toolbar input[type="text"] { height: 32px; font-size: 13px; width: auto; min-width: 0; }
.docs-drop { border: 2px dashed var(--ds-border-bold, var(--ds-border)); border-radius: 8px; padding: 14px; text-align: center; color: var(--ds-text-subtle); font-size: 13px; transition: background-color .12s, border-color .12s; }
.docs-drop.is-over { background: var(--ds-background-information); border-color: var(--ds-text-brand); color: var(--ds-text-brand); }
.docs-drop.is-busy { opacity: .6; pointer-events: none; }
.doc-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--ds-border); }
.doc-row:first-child { border-top: 0; }
.doc-thumb { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 6px; background: var(--ds-surface-sunken); border: 1px solid var(--ds-border); display: inline-flex; align-items: center; justify-content: center; color: var(--ds-text-subtle); overflow: hidden; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-main { flex: 1 1 auto; min-width: 0; }
.doc-name { font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.doc-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.doc-preview { width: 100%; height: min(70vh, 640px); border: 1px solid var(--ds-border); border-radius: 6px; background: var(--ds-surface-sunken); }
.doc-preview-img { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; }
.doc-counts { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }

/* Pagos (ficha y pantalla de pagos) */
.pay-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pay-big { font-size: 22px; font-weight: 800; }
.pay-big--due { color: var(--ds-text-warning); }
.pay-big--ok { color: var(--ds-text-success); }
.pay-big--credit { color: var(--ds-text-information, var(--ds-text-brand)); }
.pay-programs { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 10px; font-size: 13px; }
.pay-programs > div { display: flex; flex-direction: column; }
/* Subcutánea con frascos de 5 dosis: compras (frasco / dosis suelta) en la tarjeta Pagos y frascos en la tarjeta del programa */
.pay-purchases { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; padding: 8px 10px; border: 1px dashed var(--ds-border-bold, var(--ds-border)); border-radius: 6px; font-size: 13px; }
.pay-purchase { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.pay-purchase > div { min-width: 0; flex: 1 1 220px; }
.pc-vial-row { padding: 4px 0; border-bottom: 1px solid var(--ds-border); }
.pc-vial-row:last-of-type { border-bottom: 0; }
.reserve-block { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border: 1px solid var(--ds-border-warning, var(--ds-border)); border-radius: 6px; }
.pay-list { display: flex; flex-direction: column; }
.pay-row { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--ds-border); }
.pay-row:first-child { border-top: 0; }
.pay-row.is-voided { opacity: .55; }
.pay-row__main { flex: 1 1 auto; min-width: 0; font-size: 13px; }
.pay-row__amount { text-align: right; font-weight: 700; white-space: nowrap; font-size: 13px; }
.pay-row__amount.is-pay { color: var(--ds-text-success); }
.pay-row__actions { display: flex; gap: 2px; flex: 0 0 auto; }
.pay-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.pay-totals { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; margin: 10px 0; }

/* ---- Calendario del programa (schedule.js) ------------------------------------- */
.sched-config { display: flex; flex-direction: column; gap: 10px; }
.sched-box { margin-top: 2px; }
.sched-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 6px; }
.sched-list { display: flex; flex-direction: column; gap: 6px; max-height: 380px; overflow-y: auto; padding-right: 2px; }
.sched-row { display: grid; grid-template-columns: minmax(130px, 190px) minmax(170px, 1fr) auto; align-items: start; gap: 8px 12px; padding: 8px 10px; border: 1px solid var(--ds-border); border-left-width: 3px; border-radius: 6px; background: var(--ds-surface); }
.sched-n { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; }
.sched-date { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sched-date input[type=date] { max-width: 190px; }
.sched-words { font-size: 12px; color: var(--ds-text-subtle); min-height: 16px; }
.sched-msg:empty { display: none; }
.sched-flag { display: flex; align-items: center; gap: 6px; padding-top: 4px; }
.sched-row--pinned { border-left-color: var(--ds-text-warning); background: var(--ds-background-warning); }
.sched-row--invalid { border-color: var(--ds-text-danger); }
.sched-row--done { opacity: .75; background: var(--ds-surface-sunken); }
.sched-row--current { border-left-color: var(--ds-text-brand); }
.sched-done { display: flex; align-items: center; gap: 6px; padding-top: 6px; color: var(--ds-text-success); font-weight: 600; }
.sched-done svg, .sched-done [data-lucide] { width: 16px; height: 16px; }
.sched-badge { background: var(--ds-background-warning); color: var(--ds-text-warning); border: 1px solid var(--ds-text-warning); }
@media (max-width: 640px) {
    .sched-row { grid-template-columns: 1fr; }
    .sched-n { padding-top: 0; flex-direction: row; gap: 8px; align-items: baseline; }
}

/* ===== Pantalla de firma (/doses/{id}/sign): pantalla completa, táctil ===== */
.sign-body { margin: 0; background: var(--ds-surface-sunken); color: var(--ds-text); font-family: inherit; overscroll-behavior: none; }
.sign-page { box-sizing: border-box; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 10px; overflow: hidden;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.sign-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sign-info h1 { font-size: 18px; line-height: 24px; margin: 0; }
.sign-info .sub { color: var(--ds-text-subtle); font-size: 13px; }
.sign-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.sign-signer { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: end; }
.sign-signer label { min-width: 0; }
.sign-signer input[name="signed_by_name"] { width: min(320px, 100%); }
.sign-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sign-actions .btn { min-height: 44px; }
.sign-main { flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.sign-stage { flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; }
.sign-stage > .sigpad-host { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; }
.sign-stage .sigpad { flex: 1 1 auto; height: auto; }
.sign-hint { font-size: 12px; color: var(--ds-text-subtle); text-align: center; }
.sign-err { color: var(--ds-text-danger); font-size: 13px; font-weight: 500; min-height: 18px; }
.sign-view { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; flex: 1; min-height: 0; }
/* Firma guardada: un único marco (el de la imagen), completa y sin recortes (object-fit: contain). */
.sign-view__img { flex: 1 1 auto; align-self: stretch; min-height: 0; min-width: 0; background: #fff; border: 1px solid var(--ds-border); border-radius: 8px; display: flex; }
.sign-view__img img { flex: 1 1 auto; min-width: 0; min-height: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
/* Celular en horizontal: info y botones a la izquierda, firma a la derecha (el alto es lo escaso). */
@media (orientation: landscape) and (max-height: 540px) {
    .sign-page { display: grid; grid-template-columns: minmax(190px, 30%) minmax(0, 1fr); grid-template-rows: 1fr; gap: 12px; }
    .sign-side { overflow-y: auto; }
    .sign-info h1 { font-size: 15px; line-height: 20px; }
    .sign-signer { flex-direction: column; align-items: stretch; }
    .sign-signer input[name="signed_by_name"] { width: 100%; }
    .sign-actions { flex-direction: column; }
    .sign-actions .btn { width: 100%; justify-content: center; }
}
.phase-info { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--ds-border); border-radius: 6px; background: var(--ds-surface-sunken); font-weight: 600; font-size: 14px; }
.phase-info svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--ds-text-subtle); }
.toast a { margin-left: 8px; font-weight: 600; }
.sig-chip--todo { color: var(--ds-text-warning, #a54800); }

.pc-doses { margin: 10px 0; border: 1px solid var(--ds-border); border-radius: 6px; padding: 8px 12px; background: var(--ds-surface-sunken); }
.pc-doses > summary { cursor: pointer; font-size: 13px; }
.pc-doses__list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; }
.pc-doses__actions { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; }
.pc-doses__list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }

/* Uso en casa por frascos: campos de inicio / mantenimiento (esquema y programa) */
.hs-box { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--ds-border); border-radius: 6px; background: var(--ds-surface-sunken); }
.hs-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.hs-num { width: 72px; text-align: center; }
.pc-home__dates { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 8px 0 0; }
.pc-home__dates dt { font-size: 11px; color: var(--ds-text-secondary, #64748b); }
.pc-home__dates dd { margin: 0; font-weight: 600; }
.pc-home { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--ds-border-brand); background: var(--ds-surface-sunken); border-radius: 4px; font-size: 13px; }

/* Frascos de uso en casa: los números van en la misma línea que su texto, y los días se marcan como tarjetas */
.hs-box .hs-line input.hs-num { width: 76px; min-width: 0; flex: 0 0 auto; text-align: center; }
.hs-box .hs-days input[type="checkbox"] { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.hs-box .hs-days label { position: relative; cursor: pointer; min-width: 52px; justify-content: center; }
.hs-box .hs-days label:has(input:focus-visible) { outline: 2px solid var(--ds-border-focused, #2563eb); outline-offset: 2px; }


/* =========================================================
   Envíos La Reforma
   ========================================================= */
.brand .brand-logo, .brand-logo { height: 34px; width: auto; display: block; margin: 0; }
@media (max-width: 640px) { .brand .brand-logo, .brand-logo { height: 28px; } }
[data-theme="dark"] .brand-logo { filter: brightness(1.15); }
.auth-logo { display: block; height: 56px; margin: 0 auto 16px; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 15px; font-weight: 600; }
.btn-block { width: 100%; }
.btn-icon-only { width: 32px; padding: 0; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions > * + * { margin-left: 4px; }

.badge.st-visitado    { background: var(--ds-background-success); color: var(--ds-text-success); }
.badge.st-pendiente   { background: var(--ds-background-information); color: var(--ds-text-information); }
.badge.st-no_visitado { background: var(--ds-background-danger); color: var(--ds-text-danger); }
.badge.st-local       { background: var(--ds-background-warning); color: var(--ds-text-warning); }
.badge.origin-empleado { background: var(--ds-background-neutral); color: var(--ds-text-subtle); text-transform: none; letter-spacing: 0; }
.badge.flag-warn { background: var(--ds-background-warning); color: var(--ds-text-warning); }

.pct { font-weight: 700; }
.pct--good { color: var(--ds-text-success); }
.pct--mid  { color: var(--ds-text-warning); }
.pct--bad  { color: var(--ds-text-danger); }
.semaforo { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--ds-background-neutral); vertical-align: 0; }
.semaforo--good { background: #22A06B; } .semaforo--mid { background: #E2B203; } .semaforo--bad { background: #DD3333; }
.progress { height: 6px; border-radius: 99px; background: var(--ds-background-neutral); overflow: hidden; min-width: 60px; }
.progress > span { display: block; height: 100%; background: #22A06B; }

.map { height: 520px; border-radius: 4px; border: 1px solid var(--ds-border); z-index: 0; }
.map--sm { height: 300px; }
.map--pick { height: 260px; }
.leaflet-popup-content { font: 13px/1.4 "Inter", sans-serif; }
.leaflet-popup-content img { width: 220px; height: auto; border-radius: 4px; display: block; margin-bottom: 6px; cursor: zoom-in; }
.pin { width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.pin span { display: block; transform: rotate(45deg); color: #fff; font: 700 11px/22px Inter, sans-serif; text-align: center; }
.place-dot { width: 16px; height: 16px; border-radius: 3px; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--ds-text-subtle); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.thumb { position: relative; border-radius: 4px; overflow: hidden; border: 1px solid var(--ds-border); background: var(--ds-surface); cursor: pointer; text-align: left; padding: 0; }
.thumb img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--ds-background-neutral); }
.thumb__body { padding: 6px 8px; font-size: 12px; line-height: 16px; }
.thumb__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb__flag { position: absolute; top: 6px; right: 6px; }
.recent-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photo-view { width: 100%; max-height: 58vh; object-fit: contain; border-radius: 4px; background: #000; display: block; }
.kv-list { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; margin: 12px 0; }
.kv-list dt { color: var(--ds-text-subtle); }
.kv-list dd { margin: 0; }

.emp-group { margin-bottom: 14px; }
.emp-group__head { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 0 0 6px; }
.place-lines { font-family: inherit; min-height: 140px; }

/* ---------- Vista del empleado (móvil) ---------- */
.emp-main { max-width: 640px; margin: 0 auto; }
.net-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 4px; font-size: 13px; margin-bottom: 12px; background: var(--ds-background-success); color: var(--ds-text-success); }
.net-bar.is-offline { background: var(--ds-background-warning); color: var(--ds-text-warning); }
.net-bar .spacer { flex: 1; }
.day-progress { display: flex; align-items: baseline; gap: 8px; margin: 4px 0 12px; }
.day-progress b { font-size: 28px; }
.place-card { background: var(--ds-surface); border: 1px solid var(--ds-border); border-left: 4px solid var(--ds-border-strong); border-radius: 4px; padding: 12px; margin-bottom: 10px; }
.place-card.is-visitado { border-left-color: #22A06B; }
.place-card.is-pendiente { border-left-color: var(--ds-border-brand); }
.place-card__head { display: flex; align-items: flex-start; gap: 8px; }
.place-card__name { font-weight: 600; font-size: 15px; flex: 1; min-width: 0; }
.place-card__meta { font-size: 12px; color: var(--ds-text-subtle); margin-top: 2px; }
.place-card__photos { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; }
.place-card__photos img { width: 56px; height: 56px; object-fit: cover; border-radius: 3px; flex: 0 0 auto; }
.place-card__actions { display: flex; gap: 8px; margin-top: 10px; }
.place-card__actions .btn-primary { flex: 1; }
.fab-row { display: flex; gap: 8px; margin: 12px 0 24px; }
.fab-row .btn { flex: 1; }

.cam { position: fixed; inset: 0; background: #000; z-index: 100; display: flex; flex-direction: column; }
.cam video, .cam canvas.preview { flex: 1; width: 100%; min-height: 0; object-fit: contain; background: #000; }
.cam__top { position: absolute; top: 0; left: 0; right: 0; padding: 12px; display: flex; align-items: center; gap: 8px; color: #fff; background: linear-gradient(rgba(0,0,0,.6), transparent); font-size: 13px; z-index: 2; }
.cam__top .spacer { flex: 1; }
.cam__place { font-weight: 600; font-size: 15px; }
.cam__gps { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.15); }
.cam__gps.is-ok { background: rgba(34,160,107,.85); }
.cam__gps.is-bad { background: rgba(221,51,51,.85); }
.cam__bar { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: center; gap: 24px; background: #000; }
.cam__shutter { width: 72px; height: 72px; border-radius: 50%; background: #fff; border: 5px solid rgba(255,255,255,.4); background-clip: padding-box; }
.cam__shutter:disabled { opacity: .35; }
.cam__btn { color: #fff; background: rgba(255,255,255,.15); height: 44px; padding: 0 16px; border-radius: 22px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.cam__btn--primary { background: #DD3333; }
.cam__note { width: calc(100% - 32px); margin: 0 16px 8px; padding: 10px; border-radius: 6px; border: 0; font: inherit; }
.cam__msg { color: #fff; text-align: center; padding: 24px; margin: auto; max-width: 420px; }
.hist-day { margin-bottom: 16px; }
.hist-day__head { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 6px; }
body.is-employee .nav-links .admin-link, body.is-employee .nav-sidebar__links .admin-link { display: none !important; }
body:not(.is-employee) .emp-link { display: none !important; }
@media (max-width: 640px) { .map { height: 420px; } .main { padding-left: 10px; padding-right: 10px; } }

.date-sm, input.date-sm + input, .flatpickr-input.date-sm { width: 140px !important; flex: 0 0 140px !important; min-width: 0 !important; max-width: 140px !important; }
.page-head > input, .page-head > .btn { flex: 0 0 auto; }

[hidden] { display: none !important; }
.place-card__actions [data-photo] { flex: 1; }

/* Visor de fotos en popup */
.pv__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pv__head h2 { margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv__stage { position: relative; }
.pv__nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; display: inline-flex; align-items: center; justify-content: center; z-index: 1; }
.pv__nav:hover { background: rgba(0,0,0,.75); }
.pv__nav svg { width: 22px; height: 22px; }
.pv__nav--prev { left: 8px; } .pv__nav--next { right: 8px; }
.modal .thumbs { max-height: 65vh; overflow-y: auto; }
a.photo-link, button.photo-link { color: var(--ds-text-brand); cursor: pointer; padding: 0; background: none; border: 0; font: inherit; }
button.photo-link:hover { text-decoration: underline; }

.badge.st-no_pudo { background: var(--ds-background-warning); color: var(--ds-text-warning); }
.place-card.is-no_pudo { border-left-color: #E2B203; }
.skip-note { margin-top: 8px; padding: 8px 10px; border-radius: 4px; background: var(--ds-background-warning); color: var(--ds-text); font-size: 13px; }
.skip-note b { color: var(--ds-text-warning); }
.skip-list { display: flex; flex-direction: column; gap: 8px; }
.skip-item { border-left: 3px solid #E2B203; padding: 4px 10px; font-size: 13px; }
.skip-item__head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.reason-bars { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.reason-bars .row { display: grid; grid-template-columns: minmax(140px, 1fr) 3fr 40px; gap: 8px; align-items: center; }
.reason-bars .bar { height: 10px; border-radius: 99px; background: #E2B203; }

/* Buscador dentro del mapa */
.map-search { background: var(--ds-surface); border: 1px solid var(--ds-border-strong); border-radius: 4px; width: min(320px, 70vw); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.map-search input { width: 100%; border: 0; padding: 7px 10px; font: inherit; font-size: 13px; background: transparent; color: var(--ds-text); outline: none; }
.map-search__res { max-height: 200px; overflow-y: auto; border-top: 1px solid var(--ds-border); }
.map-search__res button { display: block; width: 100%; text-align: left; padding: 6px 10px; font-size: 12px; line-height: 16px; border-bottom: 1px solid var(--ds-border); color: var(--ds-text); }
.map-search__res button:hover { background: var(--ds-surface-hovered); }
.map-search__res .muted { padding: 6px 10px; font-size: 12px; }
.leaflet-container .map-search { margin-left: 50px; }
