/* ============================================================================
   Outreach Operator Panel — "The Quiet Cockpit"
   Operator Slate design system. Single source of truth for shared .nd-* classes.
   Tokens live on :root so scoped .razor.css and overlays resolve them too.
   ========================================================================== */

/* ---- Reset ------------------------------------------------------------- */
html, body {
    margin: 0 !important;
    padding: 0 !important;
}

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

button {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    line-height: inherit;
}

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

/* ---- Design tokens ----------------------------------------------------- */
:root {
    /* Neutral slate-indigo field */
    --bg-base:        #0E1014;
    --bg-sunken:      #0B0D11;
    --surface:        #161922;
    --surface-raised: #1E2230;
    --surface-hover:  #252A39;
    --border-subtle:  #2A2F3C;
    --border-strong:  #3C4354;

    --text-primary:   #E6E8EE;
    --text-secondary: #A7ADBE;
    --text-muted:     #828A9E;

    /* The one warm accent — controls only */
    --accent:         #E8B341;
    --accent-hover:   #F4C45A;
    --accent-pressed: #D49E2C;
    --accent-ink:     #15171F;
    --accent-soft:    rgba(232, 179, 65, .13);
    --accent-ring:    rgba(232, 179, 65, .35);

    /* Semantic status set — information, never decoration */
    --success:        #34D399;
    --success-soft:   rgba(52, 211, 153, .14);
    --danger:         #FB7185;
    --danger-soft:    rgba(251, 113, 133, .14);
    --warning:        #E89B3D;
    --warning-soft:   rgba(232, 155, 61, .15);
    --info:           #5BA8E8;
    --info-soft:      rgba(91, 168, 232, .14);

    /* Radii */
    --radius-xs:  6px;
    --radius-sm:  8px;
    --radius-md:  10px;
    --radius-lg:  14px;
    --radius-xl:  18px;
    --radius-pill: 999px;

    /* Spacing scale */
    --sp-2xs: 4px;
    --sp-xs:  8px;
    --sp-sm:  12px;
    --sp-md:  16px;
    --sp-lg:  24px;
    --sp-xl:  32px;
    --sp-2xl: 48px;

    /* Elevation — flat at rest, shadow only when floating or hovered */
    --shadow-overlay: 0 24px 64px -16px rgba(0,0,0,.55), 0 0 0 1px rgba(0,0,0,.4);
    --shadow-lift:    0 6px 20px -8px rgba(0,0,0,.45);
    --shadow-inset:   inset 0 1px 0 rgba(255,255,255,.03);

    /* Motion */
    --ease-quart: cubic-bezier(.25, 1, .5, 1);
    --ease-expo:  cubic-bezier(.16, 1, .3, 1);
    --dur-fast:   140ms;
    --dur-base:   200ms;
    --dur-reveal: 240ms;

    /* Typography */
    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --font-mono: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

    /* ---- Back-compat aliases (old variable names → new values) --------- */
    --bg:          var(--bg-base);
    --bg-elevated: var(--surface);
    --surface-2:   var(--surface-hover);
    --text:        var(--text-secondary);
    --muted:       var(--text-muted);
    --ink:         var(--text-primary);
    --line:        var(--border-subtle);
    --shadow-1:    var(--shadow-overlay);
    --shadow-2:    var(--shadow-lift);
    --shadow-soft: var(--shadow-lift);
}

/* ---- Page shell -------------------------------------------------------- */
.nd-page {
    min-height: 100vh;
    background: var(--bg-base);
    color: var(--text-secondary);
    overflow-x: clip;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.nd-page ::selection { background: var(--accent-soft); color: var(--text-primary); }

.nd-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 28px;
}

/* ---- Motion primitives ------------------------------------------------- */
@keyframes nd-shimmer {
    0%   { background-position: -460px 0; }
    100% { background-position: 460px 0; }
}
@keyframes nd-fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}
@keyframes nd-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes nd-pop-in {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to   { opacity: 1; transform: none; }
}
@keyframes nd-spin { to { transform: rotate(360deg); } }

.nd-reveal { animation: nd-fade-up var(--dur-reveal) var(--ease-quart) both; }
.nd-reveal-1 { animation-delay: 40ms; }
.nd-reveal-2 { animation-delay: 80ms; }
.nd-reveal-3 { animation-delay: 120ms; }
.nd-reveal-4 { animation-delay: 160ms; }

.nd-spin { animation: nd-spin .8s linear infinite; }

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

/* ---- Top brand bar ----------------------------------------------------- */
.nd-nav { position: relative; padding: 20px 0 8px; }
.nd-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.nd-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
.nd-brand-mark { width: 30px; height: 30px; display: grid; place-items: center; color: var(--accent); }
.nd-brand-mark svg { width: 30px; height: 30px; display: block; }
.nd-brand-text { display: grid; gap: 2px; }
.nd-brand-name {
    font-weight: 680;
    font-size: 15px;
    letter-spacing: -.01em;
    color: var(--text-primary);
}
.nd-brand-scribble {
    width: 64px;
    height: 2px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    opacity: .55;
}

.nd-menu { margin-left: auto; }

.nd-burger {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border-subtle);
    background: var(--surface-raised);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-quart), border-color var(--dur-fast);
}
.nd-burger:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.nd-burger span {
    display: block;
    height: 2px;
    width: 20px;
    background: var(--text-secondary);
    margin: 5px auto;
    border-radius: var(--radius-pill);
}

.nd-menu-links { display: flex; align-items: center; gap: 24px; }
.nd-menu-spacer { width: 16px; }

.nd-link {
    position: relative;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 13px;
    letter-spacing: .01em;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--dur-base) var(--ease-quart);
}
.nd-link:hover { color: var(--text-primary); }
.nd-link.is-active { color: var(--accent); }
.nd-link-ink {
    position: absolute;
    left: 0; right: 0;
    bottom: -6px;
    height: 2px;
    background: var(--accent);
    border-radius: var(--radius-pill);
}
.nd-link-ghost { color: var(--text-muted); }
.nd-link-cta { color: var(--accent); }

/* ---- Buttons ----------------------------------------------------------- */
.nd-btn, .nd-btn-primary {
    height: 38px;
    padding: 0 16px;
    border-radius: var(--radius-md);
    border: 0;
    cursor: pointer;
    color: var(--accent-ink);
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent);
    transition: background var(--dur-fast) var(--ease-quart),
                transform var(--dur-fast) var(--ease-quart);
}
.nd-btn:hover, .nd-btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.nd-btn:active, .nd-btn-primary:active { background: var(--accent-pressed); transform: translateY(0); }
.nd-btn:disabled, .nd-btn-primary:disabled,
.nd-btn[disabled], .nd-btn-primary[disabled] {
    opacity: .45; cursor: not-allowed; transform: none;
}

.nd-btn-ghost {
    height: 38px;
    padding: 0 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--surface-raised);
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background var(--dur-fast) var(--ease-quart),
                color var(--dur-fast) var(--ease-quart),
                border-color var(--dur-fast) var(--ease-quart),
                transform var(--dur-fast) var(--ease-quart);
}
.nd-btn-ghost:hover {
    border-color: var(--border-strong);
    background: var(--surface-hover);
    color: var(--text-primary);
}
.nd-btn-ghost:active { transform: translateY(1px); }
.nd-btn-ghost:disabled, .nd-btn-ghost[disabled] { opacity: .45; cursor: not-allowed; }

.nd-btn-ghost.danger,
.nd-icon-btn.danger {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 32%, transparent);
}
.nd-btn-ghost.danger:hover,
.nd-icon-btn.danger:hover {
    border-color: color-mix(in srgb, var(--danger) 55%, transparent);
    background: var(--danger-soft);
    color: var(--danger);
}

.nd-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--surface-raised);
    cursor: pointer;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--dur-fast) var(--ease-quart),
                color var(--dur-fast) var(--ease-quart),
                border-color var(--dur-fast) var(--ease-quart);
}
.nd-icon-btn:hover {
    background: var(--surface-hover);
    color: var(--accent);
    border-color: var(--border-strong);
}

/* Shared focus-visible treatment for every interactive control */
.nd-page button:focus-visible,
.nd-page a:focus-visible,
.nd-page input:focus-visible,
.nd-page select:focus-visible,
.nd-page textarea:focus-visible,
.nd-page [tabindex]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-ring);
}
/* Inputs inside a wrapper that already shows the focus ring
   (search fields, etc.) must not draw a second inner ring. */
.nd-page .nd-search-input:focus,
.nd-page .nd-search-input:focus-visible {
    box-shadow: none;
    outline: none;
}

/* ---- Tabs -------------------------------------------------------------- */
.nd-tabs {
    margin-top: 14px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.nd-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: var(--radius-md);
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    position: relative;
    transition: background var(--dur-base) var(--ease-quart),
                color var(--dur-base) var(--ease-quart);
}
.nd-tab i { color: var(--text-muted); transition: color var(--dur-base) var(--ease-quart); }
.nd-tab:hover { background: var(--surface-raised); color: var(--text-secondary); }
.nd-tab:hover i { color: var(--text-secondary); }
.nd-tab.is-active {
    background: var(--surface-raised);
    color: var(--text-primary);
}
.nd-tab.is-active i { color: var(--accent); }
.nd-tab.is-active::after {
    content: "";
    position: absolute;
    left: 14px; right: 14px;
    bottom: 3px;
    height: 2px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    animation: nd-fade-in var(--dur-base) var(--ease-quart) both;
}
.nd-tabs-tight { gap: 4px; }
.nd-tabs-tight .nd-tab { padding: 7px 12px; }

/* ---- Cards ------------------------------------------------------------- */
.nd-card,
.nd-inbox-card {
    margin-top: 16px;
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    padding: 20px;
    animation: nd-fade-up var(--dur-reveal) var(--ease-quart) both;
}

.nd-card-head,
.nd-card-top,
.nd-inbox-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.nd-card-title,
.nd-inbox-title {
    font-weight: 650;
    color: var(--text-primary);
    font-size: 18px;
    letter-spacing: -.012em;
    margin: 0;
}
.nd-card-sub,
.nd-inbox-sub {
    margin-top: 4px;
    color: var(--text-muted);
    font-weight: 450;
    font-size: 13px;
}

.nd-divider,
.nd-divider-yellow {
    height: 1px;
    margin: 16px 0;
    background: var(--border-subtle);
    border: 0;
}

/* ---- Alerts ------------------------------------------------------------ */
.nd-alert {
    margin-top: 14px;
    padding: 11px 14px 11px 38px;
    position: relative;
    border-radius: var(--radius-md);
    border: 1px solid color-mix(in srgb, var(--danger) 32%, transparent);
    background: var(--danger-soft);
    color: var(--text-primary);
    font-weight: 500;
    font-size: 13px;
}
.nd-alert::before {
    content: "!";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-pill);
    background: var(--danger);
    color: var(--accent-ink);
    font-size: 12px;
    font-weight: 800;
}
.nd-alert.ok    { border-color: color-mix(in srgb, var(--success) 32%, transparent); background: var(--success-soft); }
.nd-alert.ok::before    { content: "\2713"; background: var(--success); }
.nd-alert.warn  { border-color: color-mix(in srgb, var(--warning) 32%, transparent); background: var(--warning-soft); }
.nd-alert.warn::before  { background: var(--warning); }
.nd-alert.info  { border-color: color-mix(in srgb, var(--info) 32%, transparent); background: var(--info-soft); }
.nd-alert.info::before  { content: "i"; background: var(--info); }

/* ---- Empty + skeleton states ------------------------------------------ */
.nd-empty {
    margin-top: 16px;
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-strong);
    padding: 32px 20px;
    text-align: center;
}
.nd-empty-title { font-weight: 650; color: var(--text-primary); font-size: 15px; }
.nd-empty-sub { margin-top: 6px; color: var(--text-muted); font-weight: 450; font-size: 13px; }

.nd-skeleton { margin-top: 14px; display: grid; gap: 8px; }
.nd-skeleton-row,
.nd-skel {
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(90deg,
        var(--surface-raised) 0%,
        var(--surface-hover) 50%,
        var(--surface-raised) 100%);
    background-size: 920px 100%;
    animation: nd-shimmer 1.25s linear infinite;
}
.nd-skel.sm { height: 16px; }
.nd-skel.lg { height: 64px; }

/* ---- Tables (dense) ---------------------------------------------------- */
.nd-table-wrap { margin-top: 14px; overflow-x: auto; }
.nd-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 6px;
    min-width: 700px;
}
.nd-table thead th {
    text-align: left;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding: 4px 12px;
}
.nd-table tbody tr {
    background: var(--bg-sunken);
    transition: background var(--dur-fast) var(--ease-quart),
                box-shadow var(--dur-fast) var(--ease-quart);
}
.nd-table tbody td {
    padding: 11px 12px;
    color: var(--text-primary);
    font-weight: 450;
    font-size: 13px;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}
.nd-table tbody tr td:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    border-left: 1px solid var(--border-subtle);
}
.nd-table tbody tr td:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-right: 1px solid var(--border-subtle);
}

.nd-col-actions { width: 64px; }
.nd-actions { display: flex; justify-content: flex-end; gap: 6px; }
.nd-mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.01em;
}
.nd-dim { color: var(--text-muted); font-weight: 450; }

/* ---- Mobile stacked cards (table → cards) ----------------------------- */
.nd-cards { display: none; margin-top: 14px; gap: 10px; }
.nd-mini-card {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-sunken);
    padding: 14px;
    animation: nd-fade-up var(--dur-reveal) var(--ease-quart) both;
}
.nd-mini-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; }
.nd-mini-label {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.nd-mini-value {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 13px;
    text-align: right;
    max-width: 62%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nd-mini-actions { margin-top: 12px; display: flex; justify-content: flex-end; gap: 6px; }

/* ---- Status badge (signature atom: icon + label + color) -------------- */
.nd-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--accent-ink);
    background: var(--accent);
}

.nd-state-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: var(--surface-raised);
    color: var(--text-secondary);
    white-space: nowrap;
}
.nd-state-badge::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: var(--radius-pill);
    background: currentColor;
    flex: 0 0 auto;
}
.nd-state-badge.is-active,  .nd-state-badge.ok,      .nd-state-badge.sent {
    color: var(--success); background: var(--success-soft);
}
.nd-state-badge.is-blocked, .nd-state-badge.is-spam, .nd-state-badge.failed, .nd-state-badge.is-mblocked {
    color: var(--danger); background: var(--danger-soft);
}
.nd-state-badge.is-sleep, .nd-state-badge.is-resting, .nd-state-badge.is-review, .nd-state-badge.pending {
    color: var(--warning); background: var(--warning-soft);
}
.nd-state-badge.info, .nd-state-badge.is-info {
    color: var(--info); background: var(--info-soft);
}

/* ---- Modals ------------------------------------------------------------ */
.nd-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(8, 9, 11, .66);
    display: grid;
    place-items: center;
    padding: 16px;
    animation: nd-fade-in var(--dur-base) var(--ease-quart) both;
}
.nd-modal {
    width: min(560px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-overlay);
    padding: 22px;
    animation: nd-pop-in var(--dur-reveal) var(--ease-expo) both;
}
.nd-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}
.nd-modal-title { font-weight: 650; color: var(--text-primary); font-size: 17px; letter-spacing: -.01em; }
.nd-modal-sub { margin-top: 4px; color: var(--text-muted); font-weight: 450; font-size: 13px; }

.nd-form { margin-top: 16px; display: grid; gap: 14px; }
.nd-field label,
.nd-auth-label {
    display: block;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.nd-input {
    width: 100%;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-sunken);
    color: var(--text-primary);
    padding: 0 12px;
    font-weight: 450;
    outline: none;
    box-shadow: var(--shadow-inset);
    transition: border-color var(--dur-base) var(--ease-quart),
                box-shadow var(--dur-base) var(--ease-quart);
}
.nd-input::placeholder { color: var(--text-muted); }
.nd-input:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-inset), 0 0 0 3px var(--accent-soft);
}
.nd-input.is-error { border-color: var(--danger); }
.nd-input.is-error:focus { box-shadow: var(--shadow-inset), 0 0 0 3px var(--danger-soft); }
.nd-input:disabled { background: var(--surface-raised); color: var(--text-muted); }

.nd-modal-actions {
    margin-top: 18px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ---- Auth modal -------------------------------------------------------- */
.nd-modal-open { overflow: hidden; }
.nd-modal-open .nd-nav,
.nd-modal-open .nd-hero,
.nd-modal-open .nd-footer { filter: none; }

.nd-auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(8, 9, 11, .72);
    overflow: auto;
    animation: nd-fade-in var(--dur-base) var(--ease-quart) both;
}
.nd-auth-glow { display: none; }
.nd-auth-modal {
    position: relative;
    width: min(460px, 100%);
    max-height: calc(100vh - 36px);
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-overlay);
    animation: nd-pop-in var(--dur-reveal) var(--ease-expo) both;
}
.nd-auth-x {
    position: absolute;
    right: 16px;
    top: 14px;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--surface-raised);
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-secondary);
    transition: background var(--dur-fast) var(--ease-quart), color var(--dur-fast);
}
.nd-auth-x:hover { background: var(--surface-hover); color: var(--text-primary); }
.nd-auth-title { font-weight: 650; font-size: 18px; color: var(--text-primary); letter-spacing: -.012em; }
.nd-auth-sub { margin-top: 6px; color: var(--text-muted); font-weight: 450; font-size: 13px; }
.nd-auth-form { margin-top: 18px; display: grid; gap: 14px; }
.nd-auth-row { display: grid; gap: 8px; }

/* ---- Hero (public) ----------------------------------------------------- */
.nd-hero { padding: 32px 0 0; }
.nd-hero-inner {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    gap: 28px;
    align-items: start;
}

/* ---- Inbox ------------------------------------------------------------- */
.nd-inbox-table { min-width: 860px; }

.nd-row-click { cursor: pointer; transition: background var(--dur-fast) var(--ease-quart); }
.nd-row-click:hover td { background: var(--surface-hover); }

.nd-subject-line { display: flex; align-items: center; gap: 10px; }
.nd-dot {
    margin-left: 4px;
    margin-right: 8px;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    flex: 0 0 auto;
}
.nd-subject-text {
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 520px;
}
.nd-trim {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}
.nd-col-unread { width: 90px; }

.nd-inbox-cards { display: grid; gap: 10px; margin-top: 14px; }
.nd-inbox-mini {
    width: 100%;
    display: block;
    text-align: left;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-sunken);
    padding: 14px;
    cursor: pointer;
    min-width: 0;
    transition: background var(--dur-fast) var(--ease-quart),
                border-color var(--dur-fast) var(--ease-quart),
                box-shadow var(--dur-fast) var(--ease-quart);
    animation: nd-fade-up var(--dur-reveal) var(--ease-quart) both;
}
.nd-inbox-mini:hover {
    border-color: var(--border-strong);
    background: var(--surface-raised);
    box-shadow: var(--shadow-lift);
}
.nd-inbox-mini.unread {
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--accent) 38%, transparent);
}
.nd-inbox-mini-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.nd-inbox-mini-subject {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}
.nd-inbox-mini-meta {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-weight: 450;
    font-size: 12px;
    font-family: var(--font-mono);
}
.nd-inbox-mini-time {
    margin-top: 6px;
    color: var(--text-muted);
    font-weight: 450;
    font-size: 12px;
    font-family: var(--font-mono);
}

/* ---- Generic clickable list ------------------------------------------- */
.nd-list { margin-top: 20px; display: grid; gap: 8px; }
.nd-row {
    all: unset;
    cursor: pointer;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    transition: background var(--dur-fast) var(--ease-quart),
                border-color var(--dur-fast) var(--ease-quart),
                box-shadow var(--dur-fast) var(--ease-quart),
                transform var(--dur-fast) var(--ease-quart);
}
.nd-row:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-lift);
}
.nd-row:active { transform: translateY(1px); }
.nd-row.is-active {
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--accent) 40%, transparent);
    box-shadow: inset 2px 0 0 var(--accent);
}
.nd-row-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.nd-row-title { font-weight: 600; color: var(--text-primary); font-size: 14px; }
.nd-row-sub { font-size: 12px; font-weight: 450; color: var(--text-muted); line-height: 1.4; }
.nd-row-meta { font-size: 12px; font-weight: 600; color: var(--accent); font-family: var(--font-mono); }
.nd-row-right { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }

/* ---- Pager ------------------------------------------------------------- */
.nd-pager {
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.nd-pager-mid {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    font-family: var(--font-mono);
}

/* ---- Help hint --------------------------------------------------------- */
.nd-help {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--accent-soft);
    border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
    font-size: 13px;
    font-weight: 450;
    line-height: 1.55;
    color: var(--text-secondary);
}
.nd-help::before {
    content: "i";
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 11px;
    font-weight: 800;
    margin-top: 1px;
}

/* ---- Textarea ---------------------------------------------------------- */
.nd-textarea {
    width: 100%;
    min-height: 240px;
    resize: vertical;
    padding: 14px;
    margin-top: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-sunken);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.55;
    outline: none;
    box-shadow: var(--shadow-inset);
    transition: border-color var(--dur-base) var(--ease-quart),
                box-shadow var(--dur-base) var(--ease-quart);
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) var(--bg-sunken);
}
.nd-textarea:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-inset), 0 0 0 3px var(--accent-soft);
    scrollbar-color: var(--accent) var(--bg-sunken);
}
.nd-textarea::-webkit-scrollbar { width: 12px; height: 12px; }
.nd-textarea::-webkit-scrollbar-track {
    background: var(--bg-sunken);
    border-radius: var(--radius-pill);
}
.nd-textarea::-webkit-scrollbar-thumb {
    border-radius: var(--radius-pill);
    background: var(--border-strong);
    border: 3px solid var(--bg-sunken);
}
.nd-textarea::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.nd-textarea:focus::-webkit-scrollbar-thumb { background: var(--accent-pressed); }
.nd-textarea:focus::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---- Select ------------------------------------------------------------ */
/* Self-contained: the chevron is a background image so .nd-select works
   with or without a .nd-select-wrap parent. <option> colors must be
   literal hex — the OS-drawn popup does not resolve CSS custom props. */
.nd-select-wrap { position: relative; display: inline-block; width: 100%; }
.nd-select {
    width: 100%;
    height: 40px;
    padding: 0 36px 0 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-sunken);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23828A9E' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    color: var(--text-primary);
    box-shadow: var(--shadow-inset);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: border-color var(--dur-base) var(--ease-quart),
                box-shadow var(--dur-base) var(--ease-quart);
}
.nd-select:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-inset), 0 0 0 3px var(--accent-soft);
}
.nd-select:disabled { opacity: .5; cursor: not-allowed; }
.nd-select option { background-color: #0B0D11; color: #E6E8EE; }
.nd-select option:checked,
.nd-select option:hover { background-color: #1E2230; color: #E6E8EE; }

/* ---- Detail field rows (rendered via RenderTreeBuilder, must be global) */
.nd-dfield { display: flex; flex-direction: column; gap: 5px; padding: 6px 0; }
.nd-dfield-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-left: 2px;
}
.nd-dfield-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 6px 6px 6px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-sunken);
    transition: border-color var(--dur-fast) var(--ease-quart),
                background var(--dur-fast) var(--ease-quart);
}
.nd-dfield-row:hover { border-color: var(--border-strong); background: var(--surface-raised); }
.nd-dfield-row:focus-within { border-color: var(--accent); background: var(--surface-raised); }
.nd-dfield-value {
    flex: 1;
    font-size: 13px;
    font-weight: 450;
    font-family: var(--font-mono);
    color: var(--text-primary);
    overflow-wrap: anywhere;
    line-height: 1.4;
    min-width: 0;
}
.nd-dfield-value.is-masked { letter-spacing: 2px; color: var(--text-secondary); }
.nd-dfield-value.is-dim { color: var(--text-muted); font-weight: 450; }
.nd-dfield-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    opacity: .7;
    transition: opacity var(--dur-fast) var(--ease-quart);
}
.nd-dfield-row:hover .nd-dfield-actions,
.nd-dfield-row:focus-within .nd-dfield-actions { opacity: 1; }
.nd-dfield-btn {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: color var(--dur-fast) var(--ease-quart),
                background var(--dur-fast) var(--ease-quart),
                border-color var(--dur-fast) var(--ease-quart);
}
.nd-dfield-btn:hover {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.nd-dfield-btn.is-copied,
.nd-dfield-btn.is-copied:hover {
    color: var(--success);
    background: var(--success-soft);
    border-color: color-mix(in srgb, var(--success) 40%, transparent);
}

/* ---- Page header (used by every authed page) -------------------------- */
.nd-pm { display: block; min-width: 0; }
.nd-pm-title {
    font-weight: 680;
    font-size: 1.625rem;
    line-height: 1.15;
    letter-spacing: -.018em;
    color: var(--text-primary);
    margin: 0;
}
.nd-pm-sub {
    margin-top: 6px;
    color: var(--text-muted);
    font-weight: 450;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.nd-pm-back {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    background: transparent;
    border: 0;
    padding: 0;
    transition: color var(--dur-fast) var(--ease-quart);
}
.nd-pm-back:hover { color: var(--accent); }
.nd-pm-back::before { content: "\2190"; font-size: 15px; }

/* ---- System pages (Error / 404) --------------------------------------- */
.nd-status-page {
    min-height: calc(100vh - 140px);
    display: grid;
    place-items: center;
    padding: 24px 0 48px;
}
.nd-status-card {
    width: min(440px, 100%);
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    padding: 36px 32px;
    text-align: center;
    animation: nd-pop-in var(--dur-reveal) var(--ease-expo) both;
}
.nd-status-code {
    width: 52px;
    height: 52px;
    margin: 0 auto 18px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--accent);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 20px;
}
.nd-status-title {
    font-weight: 680;
    font-size: 22px;
    letter-spacing: -.018em;
    color: var(--text-primary);
    margin: 0;
}
.nd-status-text { margin-top: 8px; color: var(--text-secondary); font-size: 14px; }
.nd-status-meta { margin-top: 12px; color: var(--text-muted); font-size: 13px; }
.nd-status-card .nd-btn { margin-top: 24px; width: 100%; text-decoration: none; }

/* ---- Responsive -------------------------------------------------------- */
@media (max-width: 980px) {
    .nd-hero-inner { grid-template-columns: 1fr; gap: 16px; }
}

@media (max-width: 860px) {
    .nd-table-wrap { display: none; }
    .nd-cards { display: grid; }
}

@media (max-width: 760px) {
    .nd-container { padding: 0 16px; }
    .nd-burger { display: grid; place-items: center; }
    .nd-menu-links {
        position: absolute;
        right: 16px;
        top: 70px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        background: var(--surface);
        border: 1px solid var(--border-strong);
        border-radius: var(--radius-lg);
        padding: 12px;
        box-shadow: var(--shadow-overlay);
        display: none;
        min-width: 220px;
        z-index: 50;
        animation: nd-pop-in var(--dur-base) var(--ease-expo) both;
    }
    .nd-menu-links.is-open { display: flex; }
    .nd-menu-spacer { display: none; }
    .nd-footer-cols { flex-direction: column; gap: 18px; }
}

@media (max-width: 740px) {
    .nd-card, .nd-inbox-card { padding: 16px; }
    .nd-card-head, .nd-card-top, .nd-inbox-head { flex-direction: column; align-items: stretch; }
    .nd-btn, .nd-btn-primary { width: 100%; }
    .nd-pager { flex-direction: column; align-items: stretch; }
    .nd-pager-mid { justify-content: center; }
    .nd-btn-ghost { justify-content: center; }
}
