/* Despacho — slick modern stylesheet.
 *
 * Linear/Notion-flavored design system. Single Inter typeface, neutral
 * grays, indigo accent, generous whitespace, soft borders, subtle shadows.
 *
 * Light + dark themes share one set of *semantic* tokens. Dark mode is
 * opted into via `<html data-theme="dark">` (set by inline script in
 * App.razor before render to avoid FOUC). Legacy token names (--accent-*,
 * --surface-*, --burgundy etc.) remain as aliases so component-scoped CSS
 * files inherit the new look without per-file edits.
 */

/* =====================================================================
   1. Design tokens — light theme
   ===================================================================== */

:root {
    color-scheme: light;

    /* Neutral palette */
    --gray-50:  #fafafa;
    --gray-100: #f4f5f7;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111418;

    /* Accent — electric indigo */
    --indigo-50:  #eef0ff;
    --indigo-100: #dde0ff;
    --indigo-500: #5b6cff;
    --indigo-600: #4956d6;
    --indigo-700: #3a44b0;

    /* Status palette (presence + queue states) */
    --green-500:  #16a34a;
    --green-50:   #f0fdf4;
    --amber-500:  #d97706;
    --amber-50:   #fffbeb;
    --rose-500:   #e11d48;
    --rose-50:    #fff1f2;
    --slate-500:  #64748b;
    --slate-50:   #f8fafc;

    /* ---------- Semantic surfaces ---------- */
    --bg:                #fbfbfc;
    --surface:           #ffffff;
    --surface-raised:    #ffffff;
    --surface-sunken:    var(--gray-50);
    --surface-hover:     var(--gray-100);

    /* ---------- Semantic text ---------- */
    --text:              var(--gray-900);
    --text-muted:        var(--gray-500);
    --text-subtle:       var(--gray-400);
    --text-inverse:      #ffffff;

    /* ---------- Semantic borders ---------- */
    --border:            var(--gray-200);
    --border-strong:     var(--gray-300);

    /* ---------- Accents ---------- */
    --accent:            var(--indigo-500);
    --accent-hover:      var(--indigo-600);
    --accent-soft:       var(--indigo-50);
    --accent-strong:     var(--indigo-700);
    --on-accent:         #ffffff;

    /* ---------- Status / signal ---------- */
    --success:           var(--green-500);
    --success-soft:      var(--green-50);
    --warning:           var(--amber-500);
    --warning-soft:      var(--amber-50);
    --danger:            var(--rose-500);
    --danger-soft:       var(--rose-50);
    --neutral:           var(--slate-500);
    --neutral-soft:      var(--slate-50);

    /* ---------- Focus ring ---------- */
    --focus-ring:        var(--indigo-500);
    --focus-ring-soft:   rgba(91, 108, 255, 0.25);

    /* ---------- Presence state colors ---------- */
    --status-working:    var(--success);
    --status-away:       var(--warning);
    --status-in-call:    var(--danger);
    --status-idle:       var(--neutral);

    /* ---------- Legacy token aliases (scoped CSS reads these) ---------- */
    --surface-page:           var(--bg);
    --surface-panel:          var(--surface);
    --surface-elevated:       var(--surface-raised);
    --surface-inset:          var(--surface-sunken);
    --text-primary:           var(--text);
    --accent-primary:         var(--accent);
    --accent-secondary:       var(--accent);
    --accent-danger:          var(--danger);
    --accent-danger-deep:     #be123c;
    --accent-ceremonial:      var(--accent);
    --accent-ceremonial-deep: var(--accent-hover);
    --accent-success:         var(--success);
    --accent-gold:            var(--accent);
    --accent-gold-soft:       var(--accent-soft);
    --border-default:         var(--border);
    --hairline:               var(--border);
    --ink:                    var(--text);
    --ink-soft:               var(--text-muted);
    --parchment:              var(--bg);
    --parchment-raised:       var(--surface);
    --parchment-deep:         var(--surface-sunken);
    --burgundy:               var(--accent);
    --burgundy-deep:          var(--accent-hover);
    --seal-red:               var(--danger);
    --shade-violet:           var(--accent);
    --wood-dark:              var(--gray-800);
    --wood-grain:             var(--gray-700);
    --gem-ruby:               var(--danger);
    --gem-emerald:            var(--success);
    --gem-sapphire:           var(--accent);

    /* ---------- Typography ---------- */
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
                 Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono",
                 "Fira Code", Menlo, Consolas, monospace;
    --font-body:    var(--font-sans);
    --font-display: var(--font-sans);
    --font-brand:   var(--font-sans);

    --type-1:     clamp(1.5rem, 2.6vw, 2rem);     /* page titles */
    --type-2:     clamp(1.125rem, 1.6vw, 1.375rem);
    --type-3:     1rem;
    --type-body:  0.9375rem;                       /* 15px base */
    --type-small: 0.8125rem;                       /* 13px */

    --text-xs:   0.75rem;
    --text-sm:   0.8125rem;
    --text-base: 0.9375rem;
    --text-lg:   1.0625rem;
    --text-xl:   1.25rem;
    --text-2xl:  1.5rem;

    --leading-tight: 1.25;
    --leading-snug:  1.4;
    --leading-base:  1.55;

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

    /* ---------- Radii ---------- */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 9999px;

    /* ---------- Shadows ---------- */
    --shadow-xs:        0 1px 2px rgba(17, 24, 39, 0.04);
    --shadow-sm:        0 1px 2px rgba(17, 24, 39, 0.04), 0 1px 3px rgba(17, 24, 39, 0.05);
    --shadow-md:        0 4px 6px -2px rgba(17, 24, 39, 0.04), 0 10px 15px -3px rgba(17, 24, 39, 0.06);
    --shadow-lg:        0 10px 25px -5px rgba(17, 24, 39, 0.08), 0 20px 40px -10px rgba(17, 24, 39, 0.12);
    --shadow-elevated:  var(--shadow-sm);

    /* ---------- Motion ---------- */
    --transition-fast: 120ms ease-out;
    --transition-base: 180ms ease-out;
    --transition-slow: 280ms ease-out;
}

/* =====================================================================
   2. Dark theme — same semantic names, dark values
   ===================================================================== */

[data-theme="dark"] {
    color-scheme: dark;

    --bg:                #0e1014;
    --surface:           #161a20;
    --surface-raised:    #1c2128;
    --surface-sunken:    #11141a;
    --surface-hover:     #1e242c;

    --text:              #e7e9ec;
    --text-muted:        #9ca3af;
    --text-subtle:       #6b7280;
    --text-inverse:      #0e1014;

    --border:            #232a33;
    --border-strong:     #2f3742;

    --accent:            #7c8aff;
    --accent-hover:      #9aa5ff;
    --accent-soft:       #1f2545;
    --accent-strong:     #b3bcff;
    --on-accent:         #0e1014;

    --success:           #22c55e;
    --success-soft:      #0c2515;
    --warning:           #f59e0b;
    --warning-soft:      #2a1d05;
    --danger:            #f43f5e;
    --danger-soft:       #2a0d15;
    --neutral:           #94a3b8;
    --neutral-soft:      #1a1f27;

    --focus-ring:        var(--accent);
    --focus-ring-soft:   rgba(124, 138, 255, 0.25);

    --status-working:    var(--success);
    --status-away:       var(--warning);
    --status-in-call:    var(--danger);
    --status-idle:       var(--neutral);

    --shadow-xs:         0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm:         0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md:         0 4px 6px -2px rgba(0, 0, 0, 0.35), 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-lg:         0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 20px 40px -10px rgba(0, 0, 0, 0.7);
}

/* =====================================================================
   3. Reduced motion
   ===================================================================== */

@media (prefers-reduced-motion: reduce) {
    :root {
        --transition-fast: 0ms;
        --transition-base: 0ms;
        --transition-slow: 0ms;
    }
    *, *::before, *::after {
        animation-duration: 0ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0ms !important;
        scroll-behavior: auto !important;
    }
}

/* =====================================================================
   4. Base resets + document
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
    color: var(--text);
    background: var(--bg);
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--type-body);
    line-height: var(--leading-base);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "cv11" on, "ss01" on;   /* Inter humanist tweaks */
}

main {
    display: block;
    min-height: calc(100vh - 4rem);
    padding: clamp(1rem, 2vw, 2rem) clamp(0.75rem, 4vw, 2.5rem);
    width: 100%;
    max-width: min(100%, 1280px);
    margin: 0 auto;
    animation: page-rise 220ms ease-out both;
}
@media (min-width: 1600px) {
    main { max-width: 1360px; }
}
@keyframes page-rise {
    from { opacity: 0; }
    to   { opacity: 1; }
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-sans);
    color: var(--text);
    margin: 0 0 var(--space-3) 0;
    line-height: var(--leading-tight);
    letter-spacing: -0.011em;
    font-weight: 600;
}
h1 { font-size: var(--type-1);    font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: var(--type-2);    font-weight: 600; }
h3 { font-size: var(--type-3);    font-weight: 600; }

p { margin: 0 0 var(--space-3) 0; }

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover, a:focus-visible {
    color: var(--accent-hover);
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

::selection {
    background: var(--accent);
    color: var(--on-accent);
}

/* =====================================================================
   5. Status pill — used for presence (Working/Away/InCall/Idle) and
   also re-used by .name-ribbon--despacho (the page H1).
   ===================================================================== */

.name-ribbon {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    height: 1.75rem;
    border-radius: var(--radius-pill);
    background: var(--surface-sunken);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;
    border: 1px solid var(--border);
    text-transform: none;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
    cursor: default;
}

/* Coloured dot before the label */
.name-ribbon::before {
    content: '';
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
    flex-shrink: 0;
}

/* Status variants — neutral surface, coloured dot + matching text. */
.name-ribbon--working { color: var(--status-working); }
.name-ribbon--away    { color: var(--status-away); }
.name-ribbon--in-call { color: var(--status-in-call); }
.name-ribbon--idle    { color: var(--status-idle); }

/* Edit-mode prev/next ghosts */
.name-ribbon--ghost {
    opacity: 0.5;
    transform: scale(0.92);
}

.name-ribbon--clickable {
    cursor: pointer;
}
.name-ribbon--clickable:hover,
.name-ribbon--clickable:focus-visible {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    opacity: 1;
    transform: none;
}
.name-ribbon--clickable:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Despacho-name override — used for the page H1 heading. No pill bg; just
   big sans-serif text. */
.name-ribbon--despacho {
    background: transparent;
    border: none;
    color: var(--text);
    padding: 0;
    height: auto;
    font-family: var(--font-sans);
    font-size: clamp(1.75rem, 3.2vw, 2.25rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    text-transform: none;
    cursor: default;
}
.name-ribbon--despacho::before { display: none; }

/* =====================================================================
   6. Directory page (/despachos)
   ===================================================================== */

.despachos-page { width: 100%; }

.despachos-page__title-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: var(--space-5);
}

.despachos-page__title {
    font-size: var(--type-1);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}

.despachos-page {
    --despachos-page-width: 72rem;
}

.despachos-page__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    max-width: var(--despachos-page-width);
    margin: 0 auto var(--space-5);
    padding: 0.375rem 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.despachos-page__search {
    flex: 1 1 16rem;
    min-width: 0;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font: inherit;
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.despachos-page__search::placeholder { color: var(--text-subtle); }
.despachos-page__search:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring-soft);
}

.despachos-page__status-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    padding: 0.125rem;
    border: 0;
    background: var(--surface-sunken);
    border-radius: var(--radius-pill);
}

.despachos-page__status-radio {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius-pill);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast), background var(--transition-fast);
}
.despachos-page__status-radio input[type="radio"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.despachos-page__status-radio:hover {
    color: var(--text);
}
.despachos-page__status-radio:has(input:checked) {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-xs);
}
.despachos-page__status-radio:has(input:focus-visible) {
    box-shadow: 0 0 0 3px var(--focus-ring-soft);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.despachos-page__list {
    list-style: none;
    margin: 0 auto;
    padding: 0;
    max-width: var(--despachos-page-width);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
.despachos-page__list > li + li { border-top: 1px solid var(--border); }

.directory-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0.75rem 1rem;
    color: var(--text);
    text-decoration: none;
    transition: background var(--transition-fast);
}
.directory-row:hover,
.directory-row:focus-visible {
    background: var(--surface-hover);
    text-decoration: none;
}

.directory-row__name {
    flex: 1 1 auto;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.directory-row__closed {
    flex-shrink: 0;
    font-size: var(--text-xs);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-pill);
    background: var(--warning-soft);
    color: var(--warning);
    border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
}

/* "Currently working on" banner on each directory row */
.directory-row__working-banner {
    flex: 0 1 auto;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.125rem 0.5rem;
    max-width: 22rem;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: var(--text-xs);
    overflow: hidden;
}
.directory-row__working-banner-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.625rem;
    color: var(--text-subtle);
}
.directory-row__working-banner-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-style: normal;
}

.despachos-page__loading,
.despachos-page__empty {
    color: var(--text-muted);
}

/* =====================================================================
   7. Reusable dialog primitives (delegate, add-request, edit-notice,
   close-despacho, important-people)
   ===================================================================== */

.delegate-dialog__backdrop,
.add-work-dialog__backdrop,
.edict-dialog__backdrop,
.close-dialog__backdrop,
.important-people-dialog__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: 950;
}

.delegate-dialog,
.add-work-dialog,
.edict-dialog,
.close-dialog,
.important-people-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 32rem);
    max-height: min(88vh, 42rem);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    color: var(--text);
    z-index: 1000;
    overflow: hidden;
}

.delegate-dialog__header h2,
.add-work-dialog__header h2,
.edict-dialog header h2,
.close-dialog header h2,
.important-people-dialog__header h2 {
    margin: 0;
    font-size: var(--text-xl);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.delegate-dialog__subhead,
.add-work-dialog__subhead {
    margin: 0.125rem 0 0 0;
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-style: normal;
}

.delegate-dialog__search,
.important-people-dialog__search {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font: inherit;
    color: var(--text);
}
.delegate-dialog__search:focus-visible,
.important-people-dialog__search:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring-soft);
}

.delegate-dialog__list,
.important-people-dialog__list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}
.delegate-dialog__list > li + li,
.important-people-dialog__list > li + li {
    border-top: 1px solid var(--border);
}

.delegate-dialog__row,
.important-people-dialog__row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: left;
    color: inherit;
    transition: background var(--transition-fast);
}
.delegate-dialog__row:hover:not(:disabled),
.delegate-dialog__row:focus-visible,
.important-people-dialog__row:hover:not(:disabled),
.important-people-dialog__row:focus-visible {
    background: var(--surface-hover);
}
.delegate-dialog__row:disabled,
.important-people-dialog__row:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.delegate-dialog__row--selected,
.important-people-dialog__row--selected {
    background: var(--accent-soft);
    box-shadow: inset 2px 0 0 var(--accent);
}

.delegate-dialog__row-name,
.important-people-dialog__row-name { flex: 1 1 auto; }

.delegate-dialog__row-closed,
.important-people-dialog__row-closed {
    font-size: var(--text-xs);
    color: var(--warning);
}

.delegate-dialog__reason {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: var(--text-sm);
    color: var(--text-muted);
}
.delegate-dialog__reason textarea {
    min-height: 3.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font: inherit;
    color: var(--text);
    resize: vertical;
}

.delegate-dialog__error,
.add-work-dialog__error,
.edict-dialog__error,
.close-dialog__error,
.important-people-dialog__error {
    color: var(--danger);
    font-size: var(--text-sm);
    margin: 0;
}

.delegate-dialog__actions,
.add-work-dialog__actions,
.edict-dialog__actions,
.close-dialog__actions,
.important-people-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-top: auto;
}

.delegate-dialog__loading,
.delegate-dialog__empty,
.important-people-dialog__loading,
.important-people-dialog__empty {
    color: var(--text-muted);
    padding: var(--space-3);
    margin: 0;
    font-size: var(--text-sm);
}

/* Add-work form fields */
.add-work-dialog__kind {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    border: 0;
    padding: 0;
    margin: 0;
}
.add-work-dialog__kind-option {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: var(--space-3);
    padding: var(--space-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.add-work-dialog__kind-option:hover {
    background: var(--surface-hover);
}
.add-work-dialog__kind-option--selected {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.add-work-dialog__kind-option input[type="radio"] {
    grid-row: 1 / span 2;
    align-self: center;
    accent-color: var(--accent);
}
.add-work-dialog__kind-label {
    font-weight: 600;
    color: var(--text);
}
.add-work-dialog__kind-hint {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.add-work-dialog__body,
.close-dialog textarea,
.edict-dialog textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font: inherit;
    color: var(--text);
    resize: vertical;
}

.edict-dialog__row,
.close-dialog__row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: var(--text-sm);
    color: var(--text-muted);
}
.edict-dialog__row input[type="text"],
.edict-dialog__row input[type="number"],
.edict-dialog__row input[type="time"],
.edict-dialog__row select,
.close-dialog__row input,
.close-dialog__row select {
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font: inherit;
    color: var(--text);
}
.edict-dialog__row--check {
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    color: var(--text);
    font-size: var(--text-base);
}

.close-dialog__row textarea { min-height: 4rem; }

/* =====================================================================
   8. Notices panel (was Edicts)
   ===================================================================== */

.notices-panel,
.edicts-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-xs);
}
.notices-panel__header,
.edicts-panel__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}
.notices-panel__header h2,
.edicts-panel__header h2 {
    font-size: var(--text-lg);
    font-weight: 600;
    margin: 0;
}
.notices-panel__hint,
.edicts-panel__hint {
    flex: 1 1 auto;
    margin: 0;
    color: var(--text-muted);
    font-size: var(--text-sm);
}
.notices-panel__loading,
.notices-panel__empty,
.edicts-panel__loading,
.edicts-panel__empty {
    color: var(--text-muted);
    margin: 0;
    font-size: var(--text-sm);
}
.notices-panel__list,
.edicts-panel__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.notices-panel__row,
.edicts-panel__row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.notices-panel__row-main,
.edicts-panel__row-main {
    flex: 1 1 auto;
    min-width: 0;
}
.notices-panel__row-title,
.edicts-panel__row-title {
    font-weight: 600;
    color: var(--text);
}
.notices-panel__row-meta,
.edicts-panel__row-meta {
    color: var(--text-muted);
    font-size: var(--text-sm);
}
.notices-panel__row-actions,
.edicts-panel__row-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* =====================================================================
   9. Integration panels (AzDO, email, Teams)
   ===================================================================== */

.azdo-panel, .azdo-tray, .azdo-history,
.email-settings, .teams-settings {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    box-shadow: var(--shadow-xs);
}
.azdo-panel__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: var(--space-3);
    flex-wrap: wrap;
    gap: var(--space-2);
}
.azdo-panel__header h2,
.azdo-tray h3,
.email-settings__header h2,
.teams-settings__header h2 {
    font-size: var(--text-lg);
    font-weight: 600;
    margin: 0 0 var(--space-2) 0;
}
.azdo-panel__status {
    color: var(--text-muted);
    font-size: var(--text-sm);
}
.azdo-panel__row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: var(--space-3);
}
.azdo-panel__row--check {
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
}
.azdo-panel__row label {
    color: var(--text-muted);
    font-size: var(--text-sm);
}
.azdo-panel__row input[type="text"],
.azdo-panel__row input[type="url"],
.azdo-panel__row input[type="password"],
.azdo-panel__row input[type="number"],
.azdo-panel__row select {
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font: inherit;
    color: var(--text);
}
.azdo-panel__actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-top: var(--space-3);
}
.azdo-panel__error,
.azdo-panel__message {
    color: var(--danger);
    margin: var(--space-2) 0 0 0;
    font-size: var(--text-sm);
}

.azdo-history { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.azdo-history th,
.azdo-history td {
    padding: var(--space-2);
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.azdo-history__row--failure { color: var(--danger); }
.azdo-history__row--partial { color: var(--warning); }

.azdo-tray__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.azdo-tray__item {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    padding: var(--space-2);
    background: var(--surface-sunken);
    border-radius: var(--radius-md);
    flex-wrap: wrap;
}
.azdo-tray__link {
    flex: 1 1 auto;
    color: var(--text);
    text-decoration: none;
}
.azdo-tray__link:hover { color: var(--accent); text-decoration: none; }
.azdo-tray__state {
    font-size: var(--text-xs);
    color: var(--text-muted);
    padding: 0.125rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
}

.email-settings__row,
.teams-settings__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    color: var(--text);
    margin-bottom: var(--space-2);
}
.email-settings__row input[type="text"] {
    padding: 0.4rem 0.6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font: inherit;
    color: var(--text);
}
.email-settings__row input[type="checkbox"],
.teams-settings__row input[type="checkbox"] {
    accent-color: var(--accent);
}
.email-settings__message,
.teams-settings__message,
.teams-settings__hint,
.teams-settings__last,
.teams-settings__pin {
    margin: var(--space-2) 0 0 0;
    color: var(--text-muted);
    font-size: var(--text-sm);
}
.teams-settings__pin { color: var(--text); }

/* =====================================================================
   10. Closed-Despacho banner
   ===================================================================== */

.closed-banner {
    background: var(--warning-soft);
    color: var(--text);
    border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}
.closed-banner__title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--space-2);
}
.closed-banner__message { margin: 0 0 var(--space-2) 0; }
.closed-banner__reason {
    display: inline-block;
    padding: 0.125rem 0.6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-right: var(--space-2);
    color: var(--warning);
}

/* =====================================================================
   11. Header nav + status caption
   ===================================================================== */

.despacho-header__nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: var(--text-sm);
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-md);
    transition: color var(--transition-fast), background var(--transition-fast);
}
.despacho-header__nav-link:hover,
.despacho-header__nav-link:focus-visible {
    color: var(--text);
    background: var(--surface-hover);
    text-decoration: none;
}

.despacho-status-caption {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* =====================================================================
   12. Theme toggle button (used by header)
   ===================================================================== */

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.theme-toggle:hover,
.theme-toggle:focus-visible {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    color: var(--text);
}
.theme-toggle__icon {
    width: 1rem;
    height: 1rem;
    stroke-width: 2;
}
/* Show the right icon for the current theme. */
.theme-toggle__icon--moon { display: inline-block; }
.theme-toggle__icon--sun  { display: none; }
[data-theme="dark"] .theme-toggle__icon--moon { display: none; }
[data-theme="dark"] .theme-toggle__icon--sun  { display: inline-block; }

/* Origin icon theme variants — unscoped because the [data-theme] attribute is
 * on <html>, outside any component scope. Only the GitHub icon ships both
 * variants today; others use a single shared image and ignore these rules. */
.work-offer-card__origin-img--dark  { display: none !important; }
[data-theme="dark"] .work-offer-card__origin-img--light { display: none !important; }
[data-theme="dark"] .work-offer-card__origin-img--dark  { display: inline-block !important; }

/* Monochrome line-art icons (notice, direct) render with stroke="currentColor"
 * which defaults to black inside an <img>-loaded SVG — CSS can't reach into the
 * SVG document. Invert them in dark mode so the strokes flip to white. Brand
 * icons (AzDO, GitHub, Outlook, Teams) opt out by not setting the --mono class. */
[data-theme="dark"] .work-offer-card__origin-img--mono { filter: invert(1); }
