/* Design tokens, reset, typography, and shared primitives */
/* ==== theme ==== */
/* The apps' shared theme: paste this block unchanged as the first section of static_extend/<app>/css/<app>.css (no separate file, so no extra request).
   One navy accent (#1a396f; dark mode a brighter #24508f fill and #9db9ea text) on neutral greys (shadcn-style: soft borders, 8px radius, clear focus ring). Dialog headers are filled --brand with white text; table and column headers use --brand-tint. Every colour in the app uses these tokens; status colours keep their meaning. */
:root {
  --brand: #1a396f;
  --brand-hover: #142c57;
  --brand-soft: #edf2fa;
  --brand-line: #b7c8e3;
  --brand-tint: #dce6f5;
  --brand-ink: #1a396f; /* the brand as text and icons; --brand is the fill under white text */
  --on-brand-soft: #dce6f5; /* a subtitle on a --brand header */
  --on-brand: #fff;
  --on-brand-line: rgba(255, 255, 255, .35);
  --on-brand-hover: rgba(255, 255, 255, .16);
  --bg: #f7f8fa;
  --surface: #fff;
  --surface-2: #f2f4f7;
  --ink: #1f2933;
  --muted: #5f6b7a;
  --faint: #8a94a3;
  --line: #e3e7ed;
  --line-strong: #cfd5de;
  --ring: 0 0 0 3px rgba(26, 57, 111, .22);
  --success: #2e7d4f;
  --success-soft: #e8f4ec;
  --warning: #9a6200;
  --warning-soft: #fdf3e1;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --info: #2f6bad;
  --info-soft: #eaf1f9;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --backdrop: rgba(16, 24, 40, .45);
  --toast-bg: #1f2933;
  --font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* sizes: every app takes its sizes from here (heights, paddings, type), so all pages line up */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs: 13px;
  --fs-lg: 17px;
  --topbar-h: 64px;
  --topbar-pad: 24px;
  --mark: 32px;
  --avatar: 36px;
  --control-h: 36px;
  --control-pad: 0 10px;
  --btn-h: 36px;
  --btn-pad: 0 14px;
  --btn-sm-h: 30px;
  --cell-pad: 10px 12px;
  --dialog-head-pad: 14px 20px;
  --dialog-pad: 18px 20px;
  --dialog-actions-pad: 12px 20px;
  color-scheme: light;
}
/* dark: <html data-theme="dark"> (js/settings.js sets it from Settings > Theme; Light is the default, System follows the computer); the same names, darker surfaces, lighter text */
:root[data-theme="dark"] {
  --brand: #24508f;
  --brand-hover: #2c5aa0;
  --brand-ink: #9db9ea;
  --brand-soft: #1b293d;
  --brand-line: #2f4a73;
  --brand-tint: #1d2e47;
  --on-brand-soft: #d6e0f2;
  --bg: #0e1216;
  --surface: #161b21;
  --surface-2: #1d232a;
  --ink: #e4e9ee;
  --muted: #9aa6b2;
  --faint: #6e7a86;
  --line: #283039;
  --line-strong: #38424d;
  --ring: 0 0 0 3px rgba(157, 185, 234, .3);
  --success: #5ec48d;
  --success-soft: #14301f;
  --warning: #e3a640;
  --warning-soft: #33270f;
  --danger: #f07470;
  --danger-soft: #3a1a1b;
  --info: #6ea9ea;
  --info-soft: #152639;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
  --backdrop: rgba(0, 0, 0, .6);
  --toast-bg: #2b343e;
  color-scheme: dark;
}
/* compact: <html data-density="compact"> (js/settings.js, Settings > Density); smaller rows, fields, buttons and bars, the same layout */
:root[data-density="compact"] {
  --topbar-h: 52px;
  --mark: 28px;
  --avatar: 30px;
  --control-h: 30px;
  --btn-h: 30px;
  --btn-pad: 0 12px;
  --btn-sm-h: 26px;
  --cell-pad: 6px 10px;
  --dialog-head-pad: 10px 16px;
  --dialog-pad: 14px 16px;
  --dialog-actions-pad: 10px 16px;
}
/* ==== Tokens ==== */
/* Quotation's own names, kept so the screens need no renaming: each one is a Pulse theme token above, so light, dark and compact follow the theme */
:root {
    /* Surfaces */
    --bg-main: var(--bg);
    --bg-surface: var(--surface);
    --bg-subtle: var(--surface-2);
    --bg-sunken: var(--surface-2);

    /* Sidebar */
    --sidebar-bg: var(--brand);
    --sidebar-text: var(--on-brand-soft);
    --sidebar-text-active: var(--on-brand);
    --sidebar-active-bg: var(--brand-hover);
    --sidebar-active-accent: var(--on-brand);

    /* Brand */
    --primary: var(--brand);
    --primary-hover: var(--brand-hover);
    --primary-soft: var(--brand-soft);
    --primary-soft-border: var(--brand-line);
    --primary-text: var(--brand-ink);

    /* Text */
    --text-dark: var(--ink);
    --text-body: var(--ink);
    --text-muted: var(--muted);
    --text-faint: var(--faint);

    /* Lines */
    --border: var(--line);
    --border-strong: var(--line-strong);

    /* Status: each colour on its -soft fill */
    --status-green: var(--success-soft);
    --status-green-text: var(--success);
    --status-green-border: color-mix(in srgb, var(--success) 30%, var(--surface));
    --status-yellow: var(--warning-soft);
    --status-yellow-text: var(--warning);
    --status-yellow-border: color-mix(in srgb, var(--warning) 30%, var(--surface));
    --status-red: var(--danger-soft);
    --status-red-text: var(--danger);
    --status-red-border: color-mix(in srgb, var(--danger) 30%, var(--surface));
    --status-blue: var(--info-soft);
    --status-blue-text: var(--info);
    --status-blue-border: color-mix(in srgb, var(--info) 30%, var(--surface));
    --status-gray: var(--surface-2);
    --status-gray-text: var(--muted);
    --status-gray-border: var(--line);

    /* Shape (--radius-lg is the theme's) */
    --radius-sm: 6px;
    --radius-md: var(--radius);
    --radius-xl: 16px;
    --radius-pill: 999px;

    /* Elevation (--shadow-lg and --ring are the theme's) */
    --shadow-xs: var(--shadow);
    --shadow-sm: var(--shadow);
    --shadow-md: var(--shadow-lg);
    --shadow-xl: var(--shadow-lg);
    --ring-danger: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent);

    /* Metrics (--topbar-h and --control-h are the theme's) */
    --control-h-sm: var(--btn-sm-h);
    --page-card-gap: 0.5rem;
    --page-pad-x: var(--topbar-pad);
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font: var(--font);
    background-color: var(--bg-main);
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4 {
    letter-spacing: -0.015em;
    font-weight: 650;
}

.app-layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* Accessible focus ring everywhere, without the double-outline on mouse click */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

/* ==== Buttons ==== */
.btn {
    min-height: var(--control-h);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.45rem 0.9rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.btn i {
    font-size: 0.82em;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-brand);
    box-shadow: var(--shadow-xs);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-surface);
    border-color: var(--border-strong);
    color: var(--text-body);
    box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-subtle);
    border-color: var(--text-faint);
    color: var(--text-dark);
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--on-brand);
    box-shadow: var(--shadow-xs);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger);
    border-color: var(--danger);
}

.btn-filter-submit {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-brand);
    box-shadow: var(--shadow-xs);
}

.btn-filter-submit:hover:not(:disabled) {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-sm {
    min-height: var(--control-h-sm);
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

.btn:disabled {
    opacity: 0.5;
    box-shadow: none;
    cursor: not-allowed;
}

.clear-action-btn {
    background: var(--bg-surface);
    border-color: var(--line-strong);
    color: var(--ink);
    font-weight: 600;
}

.clear-action-btn i {
    font-size: 0.75rem;
    color: var(--muted);
}

.clear-action-btn:hover:not(:disabled) {
    border-color: var(--line-strong);
    background: var(--bg-subtle);
    color: var(--ink);
}

/* Small square icon button */
.icon-btn {
    width: var(--control-h);
    height: var(--control-h);
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.icon-btn:hover:not(:disabled) {
    border-color: var(--primary-soft-border);
    background: var(--primary-soft);
    color: var(--primary);
}

/* ==== Form controls ==== */
.form-control,
.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    min-height: var(--control-h);
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-dark);
    font: inherit;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

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

.form-control:hover:not(:focus),
.form-field input:hover:not(:focus),
.form-field select:hover:not(:focus),
.form-field textarea:hover:not(:focus) {
    border-color: var(--text-faint);
}

.form-control:focus,
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--primary);
    box-shadow: var(--ring);
}

/* Native select arrow replacement, shared by every select in the app */
select.form-control,
.form-field select,
.filter-field select,
.sales-rate-field select,
.rate-edit-grid select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.1rem;
    background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    background-size: 15px 15px;
    cursor: pointer;
}

.form-field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-field label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--ink);
    font-size: 0.8rem;
    font-weight: 700;
}

.form-field textarea {
    min-height: 80px;
    resize: vertical;
}

/* ==== Badges & pills ==== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.55rem;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.badge.transit {
    background: var(--status-blue);
    color: var(--status-blue-text);
    border-color: var(--status-blue-border);
}

.badge.delivered {
    background: var(--status-green);
    color: var(--status-green-text);
    border-color: var(--status-green-border);
}

.badge.exception {
    background: var(--status-red);
    color: var(--status-red-text);
    border-color: var(--status-red-border);
}

.badge.open {
    background: var(--status-yellow);
    color: var(--status-yellow-text);
    border-color: var(--status-yellow-border);
}

.badge.neutral {
    background: var(--status-gray);
    color: var(--status-gray-text);
    border-color: var(--status-gray-border);
}

/* ==== Utilities ==== */
.text-right {
    text-align: right;
}

.po-secondary {
    display: inline-block;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.45;
}

.tabular {
    font-variant-numeric: tabular-nums;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    from {
        background-position: -420px 0;
    }

    to {
        background-position: 420px 0;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}