:root {
    --bg-page: #F5F6F4;
    --bg-surface: #FFFFFF;
    --bg-secondary: #F0F2EF;
    --bg-accent-soft: #EAF7FC;
    --bg-danger-soft: #FDF0F0;
    --bg-success-soft: #EDF8F2;
    --bg-warning-soft: #FFF7E6;
    --bg-info-soft: #EAF4F8;

    --pattern-line-neutral: rgba(36, 41, 37, 0.035);
    --pattern-line-accent: rgba(20, 155, 215, 0.05);
    --pattern-size: 72px;

    --text-primary: #111411;
    --text-heading: #111411;
    --text-graphite: #242925;
    --text-navigation: #1B201C;
    --text-secondary: #626A64;
    --text-muted: #8B928D;
    --text-on-accent: #FFFFFF;
    --brand-ink: #0B0D0B;

    --border: #D9DEDA;
    --border-strong: #C8CEC9;
    --border-accent: #B9DEEE;
    --border-success: #B7DBC7;

    --accent: #149BD7;
    --accent-hover: #0E82B7;
    --accent-text: #0E82B7;
    --danger: #B44343;
    --success: #0D713D;
    --warning: #9A6818;
    --info: #147DAA;

    --focus-ring: rgba(20, 155, 215, 0.16);
    --surface-shadow: 0 16px 44px rgba(36, 41, 37, 0.07);

    --sidebar-bg: #0C1118;
    --sidebar-active: #182631;
    --sidebar-hover: rgba(255, 255, 255, 0.04);
    --sidebar-text: #F4F7FA;
    --sidebar-text-secondary: #D5DCE3;
    --sidebar-muted: #7F8B98;
    --sidebar-footer: #738091;
    --sidebar-border: #2A3543;
    --sidebar-edge: #26313D;
    --sidebar-accent: #149BD7;

    --font-sans: "Aptos", "Aptos Display", "Segoe UI", Arial, sans-serif;
    --radius-sm: 6px;
    --radius-md: 8px;
    --sidebar-width: 15rem;
    --topbar-height: 4.25rem;
    --content-max: 98rem;
    --transition: 150ms ease;
}

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

html { min-width: 20rem; background: var(--bg-page); }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text-primary);
    background-color: var(--bg-page);
    background-image: none;
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-hover); text-underline-offset: 0.18em; }
a:hover { color: var(--accent); }

button, input, select { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

h1, h2, h3, p, dl, dd { margin-top: 0; }

h1, h2, h3 {
    color: var(--text-heading);
    line-height: 1.12;
}

h1 {
    margin-bottom: 0.85rem;
    font-size: clamp(2rem, 3vw, 3.15rem);
    font-weight: 650;
    letter-spacing: -0.035em;
}

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

/* Application frame */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 1.65rem 1rem 1.25rem;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-edge);
    z-index: 10;
}

.brand {
    display: block;
    padding: 0 0.75rem 1.55rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-bottom: 1px solid var(--sidebar-border);
}

.brand::after {
    content: "";
    display: block;
    width: 1.65rem;
    height: 2px;
    margin-top: 0.85rem;
    background: var(--sidebar-accent);
}

.brand:hover { color: var(--sidebar-text); }

.brand-name {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--sidebar-text);
    font-size: 1.12rem;
    font-weight: 780;
    letter-spacing: 0.14em;
    line-height: 1.1;
}

.brand-product {
    color: var(--sidebar-muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.075em;
    text-transform: uppercase;
}

.sidebar-nav { margin-top: 1.4rem; counter-reset: nav-order; }

.nav-group {
    margin: 1.65rem 0 0.55rem;
    padding: 0 0.75rem;
    color: var(--sidebar-muted);
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.nav-link {
    position: relative;
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr);
    align-items: center;
    min-height: 2.65rem;
    padding: 0.55rem 0.7rem;
    color: var(--sidebar-text-secondary);
    font-size: 0.88rem;
    font-weight: 550;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}

.nav-link::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 3px;
    background: transparent;
}

.nav-link:hover { color: var(--sidebar-text); background: var(--sidebar-hover); }
.nav-link--active { color: var(--sidebar-text); background: var(--sidebar-active); font-weight: 600; }
.nav-link--active:hover { background: var(--sidebar-active); }
.nav-link--active::before { background: var(--sidebar-accent); }

.nav-subnav { display: grid; gap: 0.15rem; margin: 0.2rem 0 0.65rem 2.8rem; }
.nav-sublink { color: var(--sidebar-muted); font-size: 0.75rem; text-decoration: none; transition: color var(--transition); }
.nav-sublink:hover, .nav-sublink--active { color: var(--sidebar-text); }
.nav-sublink--active { font-weight: 650; }

.nav-number, .section-number {
    color: var(--accent);
    font-size: 0.73rem;
    font-weight: 750;
    letter-spacing: 0.09em;
}

.sidebar .nav-link { counter-increment: nav-order; }
.sidebar .nav-number { color: var(--sidebar-accent); font-size: 0; }
.sidebar .nav-number::before { content: counter(nav-order, decimal-leading-zero); font-size: .68rem; }

.sidebar-footnote {
    margin: auto 0.75rem 0;
    padding-top: 1rem;
    color: var(--sidebar-footer);
    font-size: 0.7rem;
    font-weight: 650;
    letter-spacing: 0.09em;
    line-height: 1.55;
    text-transform: uppercase;
}

.workspace { min-width: 0; }

.topbar {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--topbar-height);
    padding: 0.75rem clamp(1.25rem, 3vw, 3.5rem);
    background: var(--bg-surface);
    border-top: 2px solid var(--brand-ink);
    border-bottom: 1px solid var(--border-strong);
    z-index: 9;
}

.topbar::before {
    content: "";
    position: absolute;
    top: -2px;
    left: 0;
    width: 4.5rem;
    height: 2px;
    background: var(--accent);
}

.topbar-section {
    margin: 0;
    color: var(--text-primary);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.account-panel { display: flex; align-items: center; gap: 0.8rem; }
.account-panel form { margin: 0; }
.account-name { color: var(--text-heading); font-size: 0.87rem; font-weight: 650; }

.role-badge, .status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.55rem;
    padding: 0.16rem 0.48rem;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    font-size: 0.66rem;
    font-weight: 750;
    letter-spacing: 0.08em;
    line-height: 1;
    text-transform: uppercase;
}

.role-badge { color: var(--text-graphite); background: var(--bg-secondary); }
.role-badge--admin { color: var(--text-on-accent); background: var(--brand-ink); border-color: var(--brand-ink); }
.status-badge { color: var(--accent-text); background: var(--bg-accent-soft); border-color: var(--border-accent); }

.main-content {
    width: min(100%, var(--content-max));
    margin: 0 auto;
    padding: clamp(2rem, 4vw, 4.5rem) clamp(1.25rem, 3vw, 3.5rem) 5rem;
}

/* Headers and reusable content sections */
.page-header {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-strong);
}

.page-header--with-actions {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2rem;
}

.overline {
    margin-bottom: 0.8rem;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.page-description, .section-description, .field-help {
    color: var(--text-secondary);
}

.page-description {
    max-width: 46rem;
    margin-bottom: 0;
    font-size: 1.03rem;
}

.section-description { max-width: 48rem; margin-bottom: 0; font-size: 0.9rem; }

.section-heading {
    display: grid;
    grid-template-columns: 2.4rem minmax(0, 1fr);
    align-items: start;
    gap: 0.75rem;
}

.section-number { padding-top: 0.18rem; }

.section-title {
    margin-bottom: 0.42rem;
    font-size: 0.86rem;
    font-weight: 750;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.work-sections { max-width: 70rem; }

.work-section {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 2rem;
    min-height: 9rem;
    padding: 2rem 0;
    border-top: 1px solid var(--border-strong);
}

.work-section:last-child { border-bottom: 1px solid var(--border-strong); }
.work-section .section-heading { align-self: start; }
.muted-status { margin: 0; color: var(--text-muted); font-size: 0.86rem; }

.text-link {
    display: inline-flex;
    gap: 0.45rem;
    align-items: center;
    color: var(--accent-hover);
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
}

.text-link:hover { color: var(--accent); }

.profile-data { margin: 0; min-width: 15rem; }
.profile-data > div { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding: 0.35rem 0; }
.profile-data dt { color: var(--text-secondary); font-size: 0.8rem; }
.profile-data dd { margin: 0; color: var(--text-heading); font-weight: 650; }

/* Buttons and messages */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.55rem;
    padding: 0.55rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.button--primary { color: var(--text-on-accent); background: var(--accent); border-color: var(--accent); }
.button--primary:hover { color: var(--text-on-accent); background: var(--accent-hover); border-color: var(--accent-hover); }
.button--secondary { color: var(--text-primary); background: var(--bg-surface); border-color: var(--border-strong); }
.button--secondary:hover { color: var(--text-primary); background: var(--bg-secondary); border-color: var(--text-muted); }
.button--quiet { min-height: 2rem; padding: 0.3rem 0.65rem; color: var(--text-secondary); background: transparent; border-color: var(--border); }
.button--quiet:hover { color: var(--text-primary); background: var(--bg-secondary); }
.button--danger { color: var(--danger); background: var(--bg-surface); border-color: var(--danger); }

.flash {
    margin: 0 0 1.5rem;
    padding: 0.8rem 1rem;
    border: 1px solid;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
}

.flash ul { margin: 0.55rem 0 0; padding-left: 1.25rem; }
.flash--success { color: var(--success); background: var(--bg-success-soft); border-color: var(--success); }
.flash--error { color: var(--danger); background: var(--bg-danger-soft); border-color: var(--danger); }
.flash--warning { color: var(--warning); background: var(--bg-warning-soft); border-color: var(--warning); }
.flash--info { color: var(--info); background: var(--bg-info-soft); border-color: var(--info); }

/* Forms */
.settings-form { display: block; }

.form-section {
    padding: 2.35rem 0 2.65rem;
    border-top: 1px solid var(--border-strong);
}

.form-section--muted { color: var(--text-muted); }
.form-section > .section-heading { margin-bottom: 1.65rem; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(12rem, 23rem));
    gap: 1.35rem 2rem;
    padding-left: 3.15rem;
}

.form-grid--wide { grid-template-columns: repeat(3, minmax(12rem, 1fr)); max-width: 80rem; }
.form-field { min-width: 0; }

.field-label {
    display: block;
    margin-bottom: 0.42rem;
    color: var(--text-heading);
    font-size: 0.82rem;
    font-weight: 650;
}

.field-help { margin: -0.7rem 0 1.2rem 3.15rem; font-size: 0.82rem; }

input:not([type="hidden"]):not([type="checkbox"]) {
    width: 100%;
    min-width: 0;
    height: 2.65rem;
    padding: 0.55rem 0.72rem;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

select {
    width: 100%;
    min-width: 0;
    height: 2.65rem;
    padding: 0.55rem 2rem 0.55rem 0.72rem;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    outline: none;
}

select:hover { border-color: var(--text-muted); }
select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }

input:not([type="hidden"]):not([type="checkbox"]):hover { border-color: var(--text-muted); }
input:not([type="hidden"]):not([type="checkbox"]):focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
input:disabled { color: var(--text-muted); background: var(--bg-secondary); }

.input-unit { position: relative; display: flex; align-items: center; }
.input-unit input { padding-right: 5.9rem !important; }
.input-unit > span {
    position: absolute;
    right: 0.72rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    pointer-events: none;
}

.readonly-value {
    min-height: 2.65rem;
    padding: 0.6rem 0;
    color: var(--text-heading);
    font-size: 1rem;
    font-weight: 650;
    border-bottom: 1px solid var(--border);
}

.readonly-value span { margin-left: 0.2rem; color: var(--text-secondary); font-size: 0.78rem; font-weight: 500; }

.repeatable-list { padding-left: 3.15rem; }
.repeatable-list + .button { margin-left: 3.15rem; }

.repeatable-row {
    display: grid;
    align-items: end;
    gap: 1rem;
    max-width: 68rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.repeatable-row:first-child { padding-top: 0; }
.repeatable-row--currency { grid-template-columns: minmax(10rem, 15rem) minmax(13rem, 21rem) auto; }
.repeatable-row--margin { grid-template-columns: repeat(3, minmax(10rem, 16rem)) auto; }

.remove-control {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.65rem;
    color: var(--danger);
    font-size: 0.78rem;
    cursor: pointer;
}

.remove-control input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--danger); }

.empty-inline {
    margin: 0 0 1.25rem 3.15rem;
    padding: 0.85rem 1rem;
    max-width: 45rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-left: 2px solid var(--accent);
    font-size: 0.85rem;
}

.form-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-top: 1rem;
    padding: 1rem 0;
    background: var(--bg-page);
    border-top: 1px solid var(--border-strong);
}

.form-actions p { max-width: 38rem; margin: 0; color: var(--text-secondary); font-size: 0.8rem; }

.checkbox-field {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding-top: 1.65rem;
    color: var(--text-heading);
    cursor: pointer;
}

.checkbox-field input { width: 1rem; height: 1rem; margin: 0.2rem 0 0; accent-color: var(--accent); }
.checkbox-field strong, .checkbox-field small { display: block; }
.checkbox-field strong { font-size: 0.82rem; }
.checkbox-field small { margin-top: 0.2rem; color: var(--text-secondary); font-size: 0.74rem; }

.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; }

.version-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(9rem, auto));
    gap: 0;
    margin: -1rem 0 2.4rem;
    padding: 1rem 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
}

.version-meta > div { padding: 0.2rem 1.25rem; border-right: 1px solid var(--border); }
.version-meta > div:last-child { border-right: 0; }
.version-meta dt { margin-bottom: 0.3rem; color: var(--text-muted); font-size: 0.65rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
.version-meta dd { margin: 0; color: var(--text-heading); font-size: 0.85rem; font-weight: 650; }
.version-meta dd > span:not(.status-badge) { color: var(--text-muted); font-size: 0.72rem; font-weight: 500; }

/* Tables */
.data-table-wrap { overflow-x: auto; background: var(--bg-surface); border: 1px solid var(--border); }
.form-section > .data-table-wrap { margin-left: 3.15rem; max-width: 68rem; }

.data-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 0.78rem 1rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th { color: var(--text-secondary); background: var(--bg-secondary); font-size: 0.68rem; font-weight: 750; letter-spacing: 0.075em; text-transform: uppercase; }
.data-table td { color: var(--text-primary); font-size: 0.84rem; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-accent-soft); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .numeric { text-align: right; }
.data-table .table-action { text-align: right; }
.history-table { min-width: 46rem; }
.calculations-history-wrap { max-width: 76rem; }
.calculations-history-table { min-width: 70rem; }
.calculation-number { color: var(--text-heading); font-weight: 750; letter-spacing: 0.035em; text-decoration: none; }
.calculation-number:hover { color: var(--accent); }
.history-actions, .dashboard-links { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem 1rem; }
.history-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; }
.history-page-header .page-description { margin-bottom: 0; }
.calculation-save-status { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 1rem; }
.calculation-save-status a { color: inherit; font-weight: 700; }
.table-muted { color: var(--text-muted); font-size: 0.75rem; }
.version-number { color: var(--text-heading); font-weight: 750; letter-spacing: 0.08em; }

/* Customs Knowledge Base: scoped additions, existing layout stays unchanged. */
.customs-search { display: flex; align-items: end; gap: 0.75rem; max-width: 58rem; margin-bottom: 1.5rem; }
.customs-search .form-field { flex: 1; }
.customs-table { min-width: 88rem; }
.customs-table__wrap { min-width: 15rem; white-space: normal !important; }
.customs-form textarea {
    width: 100%;
    padding: 0.65rem 0.72rem;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    resize: vertical;
    outline: none;
}
.customs-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.customs-textareas { display: grid; grid-template-columns: repeat(3, minmax(12rem, 1fr)); gap: 1.35rem 2rem; max-width: 80rem; margin-top: 1.35rem; padding-left: 3.15rem; }
.customs-detail-section { max-width: 82rem; margin-bottom: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border-strong); }
.customs-metadata { display: grid; grid-template-columns: repeat(2, minmax(15rem, 1fr)); margin: 1.2rem 0 0; border: 1px solid var(--border); }
.customs-metadata > div { min-width: 0; padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); }
.customs-metadata > div:nth-child(odd):not(.customs-metadata__wide) { border-right: 1px solid var(--border); }
.customs-metadata dt { margin-bottom: 0.25rem; color: var(--text-muted); font-size: 0.67rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.customs-metadata dd { margin: 0; color: var(--text-primary); font-size: 0.86rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.customs-metadata__wide { grid-column: 1 / -1; }
.customs-scope-form { margin-top: 1.5rem; padding: 1.25rem; background: var(--bg-surface); border: 1px solid var(--border); }
.customs-scope-form .form-grid { padding-left: 0; }
.customs-scope-notes { display: block; max-width: 80rem; margin: 1.2rem 0; padding-left: 3.15rem; }
.customs-scope-form .customs-scope-notes { padding-left: 0; }
.customs-empty-inline { margin-left: 0; }
.customs-stats { display: grid; grid-template-columns: repeat(3, minmax(10rem, 1fr)); gap: 1px; margin-top: 1.4rem; background: var(--border); border: 1px solid var(--border); }
.customs-stats > div { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 1rem; background: var(--bg-surface); }
.customs-stats span { color: var(--text-secondary); font-size: 0.78rem; }
.customs-stats strong { color: var(--text-heading); font-size: 1.2rem; }
.customs-signal-note { margin-top: 1.2rem; }
.customs-subheading { margin-top: 1.8rem; font-size: 0.86rem; }
.customs-small-table { max-width: 28rem; }
.status-badge--expired, .status-badge--revoked { color: var(--danger); background: var(--bg-danger-soft); border-color: var(--danger); }
.status-badge--historical, .status-badge--unknown { color: var(--warning); background: var(--bg-warning-soft); border-color: var(--warning); }

/* First shipment calculation */
.calculation-form { display: block; }
.excel-import-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    margin: 0 0 1.15rem 3.15rem;
    padding: 0.85rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
}

.excel-import-copy { display: flex; flex-direction: column; min-width: 15rem; margin-right: auto; }
.excel-import-copy strong { color: var(--text-heading); font-size: 0.82rem; }
.excel-import-copy span, .file-name { color: var(--text-secondary); font-size: 0.74rem; }
.file-name { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-control { position: relative; overflow: hidden; }
.file-control > span {
    display: inline-flex;
    align-items: center;
    min-height: 2.55rem;
    padding: 0.55rem 1rem;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
}
.file-control input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.import-mode { display: flex; gap: 0.7rem; color: var(--text-secondary); font-size: 0.76rem; }
.import-mode label { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; }
.import-mode input { margin: 0; accent-color: var(--accent); }

.form-section > .item-table-wrap { width: 100%; max-width: none; margin-left: 0; max-height: 34rem; overflow: auto; }
.items-table { min-width: 68rem; table-layout: fixed; }
.items-table th { position: sticky; top: 0; z-index: 1; }
.items-table th, .items-table td { padding: 0.48rem 0.55rem; }
.items-table th:nth-child(1), .items-table td:nth-child(1) { width: 11rem; }
.items-table th:nth-child(2), .items-table td:nth-child(2) { width: 10rem; }
.items-table th:nth-child(3), .items-table td:nth-child(3) { width: 5.5rem; }
.items-table th:nth-child(4), .items-table td:nth-child(4) { width: 8rem; }
.items-table th:nth-child(5), .items-table td:nth-child(5) { width: 5rem; }
.items-table th:nth-child(6), .items-table td:nth-child(6) { width: 7rem; }
.items-table th:nth-child(7), .items-table td:nth-child(7) { width: 7rem; }
.items-table th:nth-child(8), .items-table td:nth-child(8) { width: 7rem; }
.items-table th:nth-child(9), .items-table td:nth-child(9) { width: 6rem; }
.items-table input:not([type="hidden"]):not([type="checkbox"]), .items-table select { height: 2.3rem; font-size: 0.8rem; }
.items-table tbody tr:hover { background: transparent; }
.items-table .button--quiet { color: var(--danger); }
.calculated-value {
    display: flex;
    align-items: center;
    min-height: 2.65rem;
    padding: 0.55rem 0.72rem;
    color: var(--text-heading);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.calculated-value-help { display: block; margin-top: 0.35rem; color: var(--text-muted); font-size: 0.72rem; }
.item-weight-value { color: var(--text-heading); font-size: 0.8rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.add-item-button { margin: 1rem 0 0 3.15rem; }
.item-empty-state { margin-top: 1rem; }
.calculation-actions .button:disabled { color: var(--text-muted); background: var(--bg-secondary); border-color: var(--border); cursor: not-allowed; }

.result-section { margin-top: 1rem; }
.result-section > .section-heading { margin-bottom: 1.65rem; }
.calculation-version-meta { margin-left: 3.15rem; max-width: 70rem; }
.cost-table-wrap, .result-items-wrap { margin-left: 3.15rem; max-width: 82rem; }
.pricing-view-switch { display: flex; gap: 0.55rem; margin: 0 0 2rem 3.15rem; }
.result-subtitle {
    margin: 2rem 0 0.85rem 3.15rem;
    color: var(--text-heading);
    font-size: 0.95rem;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}
.cost-table { min-width: 52rem; }
.cost-table td:nth-child(2), .cost-table td:nth-child(3) { font-variant-numeric: tabular-nums; }
.subtotal-row td { font-weight: 700; background: var(--bg-secondary); }
.total-row td { color: var(--text-heading); background: var(--bg-accent-soft); border-top: 2px solid var(--accent); font-size: 0.92rem; font-weight: 780; text-transform: uppercase; }
.result-items-table { min-width: 76rem; }
.internal-items-table { min-width: 162rem; }
.manager-items-table { min-width: 76rem; }
.result-weight-note { margin: -0.35rem 0 0.85rem 3.15rem; color: var(--text-secondary); font-size: 0.82rem; }
.pricing-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(15rem, 1fr));
    max-width: 82rem;
    margin: 1.5rem 0 0 3.15rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
}
.pricing-summary > div { padding: 1rem 1.15rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.pricing-summary > div:nth-child(2n) { border-right: 0; }
.pricing-summary dt { margin-bottom: 0.25rem; color: var(--text-muted); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; }
.pricing-summary dd { margin: 0; color: var(--text-heading); font-size: 1rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.pricing-summary .pricing-summary-total { background: var(--bg-accent-soft); border-left: 2px solid var(--accent); }
.manager-logistics-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    max-width: 82rem;
    margin: 1.5rem 0 0 3.15rem;
    padding: 1.1rem 1.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
}
.manager-logistics-row span, .manager-logistics-row strong { color: var(--text-heading); font-weight: 750; }
.manager-logistics-row small { display: block; margin-top: 0.2rem; color: var(--text-muted); font-size: 0.72rem; }
.manager-logistics-row strong { font-size: 1.05rem; white-space: nowrap; }
.manager-pricing-summary { grid-template-columns: repeat(2, minmax(12rem, 1fr)); }
.manager-pricing-summary > div:nth-child(2n) { border-right: 1px solid var(--border); }
.manager-pricing-summary > div:last-child { border-right: 0; }
.client-quote {
    max-width: 74rem;
    margin-left: 3.15rem;
    padding: clamp(1.5rem, 4vw, 3.25rem);
    color: #DCE5ED;
    background-color: #0B1017;
    background-image:
        linear-gradient(rgba(20, 155, 215, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(20, 155, 215, 0.04) 1px, transparent 1px);
    background-size: 64px 64px;
    border: 1px solid #263441;
    box-shadow: 0 24px 60px rgba(7, 12, 18, 0.24);
}
.quote-download-bar { display: flex; align-items: center; justify-content: flex-end; gap: 1rem; margin-bottom: 1rem; color: #9EADB9; font-size: 0.75rem; }
.quote-download-bar .button { color: #F4F8FB; border-color: #3B566A; background: #172532; }
.quote-download-bar .button:hover { background: #203747; }
.quote-brandline { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; color: #8B9AA8; border-bottom: 1px solid #273440; font-size: 0.64rem; font-weight: 750; letter-spacing: 0.13em; }
.quote-brandline span:first-child { color: #F4F8FB; font-size: 0.78rem; letter-spacing: 0.16em; }
.quote-header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.45rem 1.5rem; margin: 3rem 0 2rem; }
.client-quote .quote-header h2 { width: 100%; margin: 0; color: #F5F8FA; font-size: clamp(2rem, 4vw, 3.6rem); font-weight: 620; letter-spacing: -0.045em; }
.quote-eyebrow { width: 100%; margin: 0; color: #2FB5EC; font-size: 0.66rem; font-weight: 750; letter-spacing: 0.16em; }
.quote-reference { margin: 0.5rem 0 0; color: #9EADB9; font-size: 0.85rem; }
.quote-table-wrap { border-color: #2A3744; background: rgba(10, 16, 23, 0.72); }
.quote-table { min-width: 58rem; }
.client-quote .quote-table th { color: #8EA0AE; background: #111923; border-bottom-color: #2B3845; }
.client-quote .quote-table td { color: #E2E8ED; background: rgba(11, 16, 23, 0.88); border-bottom-color: #25313D; }
.client-quote .quote-table tbody tr:hover td { background: #101A24; }
.client-quote .quote-table tfoot th { padding: 1.1rem 1rem; color: #F7FBFD; background: #102330; border-top: 2px solid #23A8E0; font-size: 0.92rem; }
.client-quote .quote-logistics-row td { color: #F0F7FA; background: #13212B; font-weight: 700; }
.client-quote .quote-logistics-row td:nth-last-child(-n+2) { color: #5EC8F3; }
.quote-notes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.quote-note-card { min-height: 11rem; padding: 1.35rem 1.4rem; background: rgba(17, 25, 35, 0.94); border: 1px solid #2A3946; border-top: 2px solid #1B94C8; }
.client-quote .quote-note-card h3 { margin-bottom: 0.75rem; color: #F1F6F9; font-size: 1rem; letter-spacing: 0.01em; }
.quote-note-card p { margin-bottom: 0.75rem; color: #ABB8C2; font-size: 0.82rem; }
.quote-note-card p:last-child { margin-bottom: 0; }
.quote-note-label { color: #52BFEA !important; font-size: 0.62rem !important; font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; }
.quote-duty-list { display: grid; gap: 0.45rem; margin: 0; padding: 0; list-style: none; }
.quote-duty-list li { display: flex; justify-content: space-between; gap: 1rem; padding-top: 0.45rem; color: #DCE6ED; border-top: 1px solid #2A3743; font-size: 0.82rem; }
.quote-duty-list strong { color: #5EC8F3; font-variant-numeric: tabular-nums; }
.quote-footer { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.5rem; padding-top: 1rem; color: #748391; border-top: 1px solid #273440; font-size: 0.62rem; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase; }
.quote-footer span:first-child { color: #DCE6ED; }
.result-notices { display: grid; gap: 0.65rem; margin: 1rem 0 0 3.15rem; max-width: 70rem; }
.notice { margin: 0; padding: 0.85rem 1rem; color: var(--text-secondary); background: var(--bg-surface); border-left: 2px solid var(--accent); font-size: 0.82rem; }
.notice--warning { background: var(--bg-warning-soft); border-left-color: var(--warning); }
.result-duty-notice { margin: 1rem 0 0 3.15rem; max-width: 70rem; }
.result-empty { margin-left: 3.15rem; max-width: 48rem; }
.result-empty p { margin: 0; }

/* Public and login pages */
.public-shell { min-height: 100vh; padding: 2rem; }

.login-page .public-shell {
    display: grid;
    place-items: center;
    background-color: var(--bg-page);
    background-image:
        linear-gradient(to right, var(--pattern-line-neutral) 1px, transparent 1px),
        linear-gradient(to bottom, var(--pattern-line-accent) 1px, transparent 1px);
    background-position: -1px -1px;
    background-size: var(--pattern-size) var(--pattern-size);
}

.login-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.18fr) minmax(24rem, 0.82fr);
    width: min(100%, 72rem);
    min-height: 40rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    box-shadow: var(--surface-shadow);
}

.login-brand, .login-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(3rem, 6vw, 6rem); }
.login-brand { background: var(--bg-accent-soft); border-right: 1px solid var(--border); }
.login-brand .brand-name { margin-bottom: 4.75rem; }
.brand-rule { display: block; width: 3.25rem; height: 2px; margin-bottom: 1.5rem; background: var(--accent); }
.login-brand h1 { margin-bottom: 1.4rem; font-size: clamp(2.5rem, 4.5vw, 4.5rem); text-transform: uppercase; }
.login-intro { max-width: 25rem; margin-bottom: 2.8rem; color: var(--text-secondary); font-size: 1.08rem; }
.brand-caption { margin: 0; color: var(--text-muted); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }

.login-panel { padding-right: clamp(2.5rem, 5vw, 5rem); padding-left: clamp(2.5rem, 5vw, 5rem); }
.login-panel h2 { margin-bottom: 0.75rem; font-size: 2rem; letter-spacing: -0.025em; }
.login-form { margin-top: 2rem; }
.login-form .form-field + .form-field { margin-top: 1.2rem; }
.button--login { width: 100%; margin-top: 1.5rem; }

.service-status { max-width: 50rem; margin: 12vh auto 0; padding: clamp(2rem, 6vw, 5rem); background: var(--bg-surface); border-top: 3px solid var(--accent); }
.service-status .brand-name { margin-bottom: 4rem; }
.service-status .lead { color: var(--text-secondary); font-size: 1.12rem; }
.status-line { display: flex; align-items: center; gap: 0.55rem; margin: 2.4rem 0; color: var(--success); font-size: 0.84rem; font-weight: 700; }
.status-line span { width: 0.52rem; height: 0.52rem; background: var(--success); border-radius: 50%; }

.empty-state { padding: 2rem; background: var(--bg-surface); border: 1px solid var(--border); }
.empty-state h2 { margin-bottom: 0.6rem; font-size: 1.35rem; }
.empty-state p { color: var(--text-secondary); }
.empty-state code { display: inline-block; padding: 0.6rem 0.75rem; color: var(--text-heading); background: var(--bg-secondary); border: 1px solid var(--border); }

@media (max-width: 74rem) {
    .form-grid--wide { grid-template-columns: repeat(2, minmax(12rem, 1fr)); }
    .customs-textareas, .customs-stats { grid-template-columns: repeat(2, minmax(12rem, 1fr)); }
    .repeatable-row--margin { grid-template-columns: repeat(3, minmax(9rem, 1fr)); }
    .repeatable-row--margin .remove-control { grid-column: 1 / -1; min-height: auto; }
    .version-meta { grid-template-columns: repeat(2, minmax(9rem, 1fr)); }
    .version-meta > div:nth-child(2) { border-right: 0; }
    .version-meta > div:nth-child(-n+2) { padding-bottom: 0.85rem; margin-bottom: 0.85rem; border-bottom: 1px solid var(--border); }
}

@media (max-width: 58rem) {
    :root { --sidebar-width: 13.5rem; }
    .page-header--with-actions { align-items: flex-start; flex-direction: column; }
    .header-actions { justify-content: flex-start; }
    .work-section { grid-template-columns: 1fr; gap: 1rem; }
    .profile-data { max-width: 24rem; }
    .form-grid, .form-grid--wide { grid-template-columns: repeat(2, minmax(10rem, 1fr)); }
    .repeatable-row--currency { grid-template-columns: minmax(9rem, 0.7fr) minmax(12rem, 1fr); }
    .repeatable-row--currency .remove-control { grid-column: 1 / -1; min-height: auto; }
    .login-layout { grid-template-columns: 1fr 24rem; }
}

@media (max-width: 48rem) {
    .app-shell { display: block; }
    .sidebar { position: relative; width: 100%; height: auto; padding: 1.1rem 1rem; border-right: 0; border-bottom: 1px solid var(--sidebar-edge); }
    .brand { padding-bottom: 1rem; }
    .sidebar-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.15rem; margin-top: 0.8rem; }
    .nav-subnav { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0.15rem 0 0.5rem 2.8rem; }
    .nav-group { grid-column: 1 / -1; margin-top: 0.8rem; }
    .sidebar-footnote { display: none; }
    .topbar { position: relative; padding: 0.65rem 1rem; }
    .topbar-section { display: none; }
    .main-content { padding: 2rem 1rem 4rem; }
    .public-shell { padding: 1rem; }
    .login-layout { display: block; min-height: 0; }
    .login-brand, .login-panel { padding: 2.25rem; }
    .login-brand { border-right: 0; border-bottom: 1px solid var(--border); }
    .login-brand .brand-name { margin-bottom: 2.75rem; }
    .login-brand h1 { font-size: 2.5rem; }
    .form-grid, .form-grid--wide { grid-template-columns: 1fr; padding-left: 0; }
    .customs-textareas, .customs-stats, .customs-metadata { grid-template-columns: 1fr; }
    .customs-textareas, .customs-scope-notes { padding-left: 0; }
    .customs-metadata > div:nth-child(odd):not(.customs-metadata__wide) { border-right: 0; }
    .customs-search { align-items: stretch; flex-direction: column; }
    .repeatable-list, .form-section > .data-table-wrap { margin-left: 0; padding-left: 0; }
    .repeatable-list + .button, .empty-inline, .field-help { margin-left: 0; }
    .repeatable-row--currency, .repeatable-row--margin { grid-template-columns: 1fr; }
    .repeatable-row .remove-control { grid-column: auto; }
    .form-actions { align-items: stretch; flex-direction: column; }
    .form-actions .button { width: 100%; }
    .version-meta { grid-template-columns: 1fr; }
    .version-meta > div { border-right: 0; border-bottom: 1px solid var(--border); }
    .version-meta > div:nth-child(-n+2) { margin-bottom: 0; }
    .version-meta > div:last-child { border-bottom: 0; }
    .excel-import-bar, .item-table-wrap, .add-item-button, .calculation-version-meta,
    .cost-table-wrap, .result-items-wrap, .result-notices, .result-duty-notice,
    .pricing-view-switch, .result-subtitle, .result-weight-note, .pricing-summary, .manager-logistics-row, .client-quote,
    .result-empty { margin-left: 0; }
    .pricing-summary { grid-template-columns: 1fr; }
    .pricing-summary > div { border-right: 0; }
    .manager-pricing-summary > div:nth-child(2n) { border-right: 0; }
    .quote-notes { grid-template-columns: 1fr; }
    .excel-import-copy { width: 100%; }
}

@media (max-width: 34rem) {
    .sidebar-nav { grid-template-columns: 1fr; }
    .account-panel { width: 100%; }
    .account-name { margin-right: auto; }
    .page-header { margin-bottom: 2rem; }
    .header-actions { width: 100%; }
    .header-actions .button { flex: 1; }
    .section-heading { grid-template-columns: 2rem minmax(0, 1fr); }
    .login-brand, .login-panel { padding: 1.65rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}

/* Отдельный workflow сохраняет существующие поверхности и палитру NOMENCORE. */
.request-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }
.request-action { display: grid; gap: .8rem; padding: 1.5rem; color: var(--text-primary); background: var(--bg-surface); border: 1px solid var(--border); text-decoration: none; }
.request-action:hover, .request-action:focus-visible { border-color: var(--accent); }
.request-action > span:last-child { color: var(--text-muted); }
.request-row { margin: 0 0 1.5rem; padding: 1.25rem; border: 1px solid var(--border); background: var(--bg-surface); min-width: 0; }
.request-row legend { padding: 0 .5rem; font-weight: 600; }
.request-row [data-remove-row] { margin-top: .8rem; }
.request-form textarea { width: 100%; padding: .7rem; border: 1px solid var(--border); background: var(--bg-surface); color: inherit; font: inherit; resize: vertical; }
.request-note { margin: 1.5rem 0; }
.request-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.request-result { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.request-result-fields { border: 0; padding: 0; margin: 0; min-width: 0; }
.request-result-fields:disabled { opacity: .8; }
@media (min-width: 64rem) { .sidebar { overflow-y: auto; } }
@media (max-width: 48rem) { .request-actions { grid-template-columns: 1fr; } }

/* CRM Kanban keeps the existing NOMENCORE palette and remains desktop-first. */
.crm-filters { display: grid; grid-template-columns: minmax(18rem, 2fr) minmax(12rem, 1fr) minmax(14rem, 1fr) auto; gap: .75rem; align-items: end; margin-bottom: 1.25rem; padding: 1rem; background: var(--bg-surface); border: 1px solid var(--border); }
.crm-filters label, .crm-actions label { display: grid; gap: .35rem; color: var(--text-secondary); font-size: .78rem; font-weight: 700; }
.crm-filters input, .crm-filters select, .crm-actions input, .crm-actions select { min-height: 2.5rem; padding: .55rem .65rem; border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-primary); }
.crm-kanban { display: flex; gap: 1rem; align-items: flex-start; overflow-x: auto; padding: .25rem 0 1.25rem; }
.crm-column { flex: 0 0 18.5rem; min-height: 28rem; background: #f4f7f9; border-top: 3px solid #149bd7; }
.crm-column > header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1rem; border-bottom: 1px solid var(--border); }
.crm-column > header h2 { margin: 0; font-size: .92rem; }
.crm-column > header span { min-width: 1.7rem; padding: .18rem .45rem; text-align: center; color: #0e82b7; background: #eaf7fc; border-radius: 999px; font-size: .75rem; font-weight: 800; }
.crm-column__cards { min-height: 24rem; padding: .7rem; }
.crm-card { margin-bottom: .65rem; background: var(--bg-surface); border: 1px solid var(--border); box-shadow: 0 2px 8px rgb(21 43 56 / 7%); cursor: grab; }
.crm-card:hover { border-color: #149bd7; }
.crm-card--dragging { opacity: .45; }
.crm-card a { display: grid; gap: .4rem; padding: .85rem; color: var(--text-primary); text-decoration: none; }
.crm-card strong { color: var(--text-heading); font-size: .8rem; }
.crm-card small { color: var(--text-muted); }
.crm-card__item { display: -webkit-box; overflow: hidden; color: var(--text-heading); font-size: .82rem; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.crm-card__amount { color: #0e82b7; font-size: .78rem; font-weight: 800; }
.crm-badges { display: flex; flex-wrap: wrap; gap: .3rem; }
.crm-badges em { padding: .18rem .4rem; color: #0e82b7; background: #eaf7fc; border-radius: 2px; font-size: .65rem; font-style: normal; font-weight: 800; }
.crm-detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(17rem, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.crm-detail-grid .form-card { margin: 0; }
.crm-detail-grid form + form { margin-top: 1rem; }
.crm-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.crm-links { margin: 1rem 0 0; padding-left: 1.25rem; }
.crm-history { display: grid; gap: .65rem; padding-left: 1.4rem; }
.crm-history li { display: grid; grid-template-columns: 9rem minmax(10rem, .7fr) 1fr; gap: .75rem; padding-bottom: .65rem; border-bottom: 1px solid var(--border); }
.crm-history time, .crm-history span { color: var(--text-muted); font-size: .78rem; }
.crm-order-total { border-left: 3px solid #149bd7; padding-left: .65rem; }
.crm-order-total dd { color: #0e82b7; font-weight: 800; }
.crm-comment-form { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .75rem; align-items: end; }
.crm-comment-form textarea { width: 100%; padding: .65rem .75rem; border: 1px solid var(--border); resize: vertical; }
.crm-comments { display: grid; gap: .75rem; padding: 0; list-style: none; }
.crm-comments > li { padding: .85rem 1rem; background: #f4f7f9; border-left: 3px solid #149bd7; }
.crm-comments > li > div { display: flex; justify-content: space-between; gap: 1rem; }
.crm-comments time, .crm-comments small { color: var(--text-muted); font-size: .72rem; }
@media (max-width: 58rem) { .crm-filters { grid-template-columns: 1fr 1fr; } .crm-detail-grid, .crm-comment-form { grid-template-columns: 1fr; } }

/* CRM deal form and append-only order workbook. */
.crm-new-page { width: min(100%, 78rem); margin: 0 auto; }
.crm-deal-form { display: grid; gap: 1rem; }
.crm-form-section { padding: 1.15rem 1.25rem; background: var(--bg-surface); border: 1px solid var(--border); }
.crm-form-section__heading { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: 1rem; }
.crm-form-section__heading > span { min-width: 2.2rem; color: #149bd7; font-size: .72rem; font-weight: 800; letter-spacing: .08em; }
.crm-form-section__heading h2 { margin: 0; font-size: 1rem; }
.crm-form-section__heading p { margin: .2rem 0 0; color: var(--text-muted); font-size: .78rem; }
.crm-client-grid, .crm-item-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem 1rem; }
.crm-client-search { display: grid; grid-template-columns: minmax(16rem, 1fr) auto; gap: .75rem; align-items: end; margin-bottom: 1rem; padding: 1rem; background: var(--bg-surface); border: 1px solid var(--border); }
.crm-client-search label { display: grid; gap: .35rem; color: var(--text-secondary); font-size: .78rem; font-weight: 700; }
.crm-client-search input { width: 100%; min-height: 2.65rem; padding: .65rem .75rem; border: 1px solid var(--border); background: #fff; color: var(--text-primary); }
.crm-client-results { display: grid; gap: .5rem; margin-bottom: 1rem; }
.crm-client-results > a, .crm-client-results > form { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .8rem 1rem; color: var(--text-primary); background: #f4f7f9; border: 1px solid var(--border); text-decoration: none; }
.crm-client-results > a:hover { border-color: #149bd7; }
.crm-client-results strong, .crm-client-results span, .crm-selected-client strong, .crm-selected-client span { display: block; }
.crm-client-results span, .crm-selected-client span { margin-top: .2rem; color: var(--text-muted); font-size: .75rem; }
.crm-selected-client { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: 1rem; padding: 1rem; background: #f4fbfe; border-left: 3px solid #149bd7; }
.crm-deal-form label, .crm-version-form label { display: grid; gap: .35rem; color: var(--text-secondary); font-size: .78rem; font-weight: 700; }
.crm-deal-form input:not([type=file]), .crm-deal-form textarea { width: 100%; min-height: 2.65rem; padding: .65rem .75rem; border: 1px solid var(--border); background: #fff; color: var(--text-primary); font: inherit; }
.crm-deal-form textarea { min-height: 4.5rem; resize: vertical; }
.crm-comment { width: 100%; }
.crm-file-actions { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; margin: .75rem 0; }
.crm-file-picker { display: inline-flex !important; grid-template-columns: auto 1fr; align-items: center; gap: .6rem !important; min-height: 2.65rem; padding: .55rem .75rem; border: 1px dashed #149bd7; background: #f4fbfe; color: #0e82b7 !important; }
.crm-file-picker input { max-width: 18rem; font-size: .75rem; }
.crm-file-picker output { max-width: 22rem; overflow: hidden; color: var(--text-secondary); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.crm-import-result { margin-top: .85rem; padding: .85rem 1rem; color: var(--success); background: var(--bg-success-soft); border-left: 3px solid var(--success); }
.crm-import-result.is-error { color: var(--danger); background: var(--bg-danger-soft); border-color: var(--danger); }
.crm-import-result p { margin: .3rem 0 0; color: var(--text-secondary); }
.crm-import-result ul { margin: .6rem 0 0; color: var(--text-primary); }
.crm-items-section { overflow: visible; }
.crm-item-row { margin: 0 0 .85rem; padding: 1rem; border: 1px solid var(--border); }
.crm-item-row legend { padding: 0 .4rem; color: var(--text-heading); font-size: .78rem; font-weight: 800; }
.crm-item-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .75rem; align-items: end; margin-top: .75rem; }
.crm-items--large { display: grid; gap: .35rem; }
.crm-items--large .crm-item-row { display: grid; grid-template-columns: 4.5rem minmax(0, 3fr) minmax(12rem, 1fr); gap: .55rem; align-items: end; margin: 0; padding: .55rem; }
.crm-items--large .crm-item-row legend { grid-column: 1; align-self: center; }
.crm-items--large .crm-item-grid { grid-column: 2; grid-template-columns: 1.3fr 1fr 1fr 7rem; gap: .4rem; }
.crm-items--large .crm-item-footer { grid-column: 3; grid-template-columns: minmax(8rem, 1fr) auto; gap: .4rem; margin: 0; }
.crm-items--large label { gap: .15rem; font-size: .65rem; }
.crm-items--large input, .crm-items--large textarea { min-height: 2.25rem; padding: .4rem .5rem; }
.crm-items--large textarea { height: 2.25rem; min-height: 2.25rem; resize: vertical; }
.crm-form-actions { display: flex; gap: .75rem; align-items: center; padding: .25rem 0 2rem; }
.crm-workbook-section { border-top: 3px solid #149bd7; }
.crm-workbook-current { display: grid; grid-template-columns: .55fr 1.35fr 1fr 1fr 1fr; gap: 1rem; padding: 1rem; background: #f4f7f9; }
.crm-workbook-current > div { display: grid; gap: .25rem; min-width: 0; }
.crm-workbook-current small, .crm-version-form small { color: var(--text-muted); font-size: .7rem; }
.crm-workbook-current strong { color: #149bd7; font-size: 1.15rem; }
.crm-workbook-current span { overflow-wrap: anywhere; font-size: .8rem; }
.crm-version-form { display: grid; grid-template-columns: minmax(12rem, 1fr) minmax(18rem, 1.4fr) auto; gap: .75rem; align-items: end; margin-top: 1rem; padding: 1rem; border: 1px solid var(--border); }
.crm-version-form > div { display: grid; gap: .25rem; }
.crm-workbook-hint { margin: 1rem 0; padding: .8rem 1rem; border-left: 3px solid #149bd7; background: #f4fbfe; color: var(--text-secondary); font-size: .8rem; }
.crm-version-history summary { cursor: pointer; color: var(--text-heading); font-weight: 800; }
.crm-version-history ol { display: grid; gap: .45rem; padding-left: 1.5rem; }
.crm-version-history li { padding-bottom: .45rem; border-bottom: 1px solid var(--border); }
.crm-version-history li span { display: block; color: var(--text-muted); font-size: .72rem; }
.queue-header { margin-bottom: 1rem; }
.queue-counters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .65rem; margin-bottom: 1rem; }
.queue-counter { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .8rem 1rem; color: var(--text-secondary); background: var(--bg-surface); border: 1px solid var(--border); text-decoration: none; }
.queue-counter:hover, .queue-counter--active { border-color: #149bd7; box-shadow: inset 0 3px #149bd7; }
.queue-counter span { font-size: .7rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.queue-counter strong { color: #149bd7; font-size: 1.2rem; }
.queue-filter { display: flex; gap: .65rem; align-items: end; margin-bottom: 1rem; }
.queue-filter .form-field { min-width: 15rem; }
.queue-filter select { min-height: 2.5rem; padding: .5rem .65rem; border: 1px solid var(--border); background: #fff; }
.queue-table td { vertical-align: top; }
.queue-table td small { display: block; margin-top: .2rem; color: var(--text-muted); }
.queue-status { display: inline-block; padding: .25rem .45rem; color: #0e82b7; background: #eaf7fc; font-size: .7rem; font-weight: 800; }
.crm-workflow-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.crm-workflow-summary article { padding: 1rem; background: var(--bg-surface); border-top: 3px solid #149bd7; }
.crm-workflow-summary h2 { margin: 0 0 .6rem; font-size: .85rem; text-transform: uppercase; }
.crm-workflow-summary p { margin: .35rem 0; color: var(--text-secondary); font-size: .78rem; }
@media (max-width: 48rem) { .crm-client-grid, .crm-item-grid, .crm-item-footer, .crm-workbook-current, .crm-version-form, .crm-client-search { grid-template-columns: 1fr; } .crm-form-actions { flex-direction: column; align-items: stretch; } .crm-selected-client, .crm-client-results > form { align-items: stretch; flex-direction: column; } }
@media (max-width: 58rem) { .queue-counters { grid-template-columns: repeat(2, minmax(0, 1fr)); } .crm-workflow-summary { grid-template-columns: 1fr; } }

/* Customs AI workspace: full-width result cards and compact audit details. */
.customs-work-page { width: min(100%, 92rem); margin: 0 auto; }
.customs-work-page > .work-section { display: block; min-height: 0; }
.customs-items { display: grid; gap: 1.5rem; }
.customs-item-card { min-width: 0; padding: 1.5rem; background: var(--bg-surface); border: 1px solid var(--border-strong); box-shadow: var(--surface-shadow); }
.customs-item-header { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) auto; gap: 1rem; align-items: start; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.customs-item-number { color: var(--accent); font-size: .78rem; font-weight: 800; letter-spacing: .1em; }
.customs-item-header h2 { margin: 0 0 .35rem; font-size: 1.3rem; overflow-wrap: anywhere; }
.customs-item-header p { margin: .15rem 0 0; color: var(--text-secondary); }
.customs-start-form { margin-top: 1.25rem; }
.customs-progress { display: flex; gap: 1rem; align-items: center; margin-top: 1.25rem; padding: 1rem; color: var(--info); background: var(--bg-info-soft); border: 1px solid var(--border-accent); }
.customs-progress p { margin: .2rem 0 0; color: var(--text-secondary); font-size: .8rem; }
.customs-spinner { width: 1.2rem; height: 1.2rem; flex: 0 0 auto; border: 2px solid var(--border-accent); border-top-color: var(--accent); border-radius: 50%; animation: customs-spin .8s linear infinite; }
@keyframes customs-spin { to { transform: rotate(360deg); } }
.customs-current-result { margin-top: 1.25rem; padding: 1.25rem; background: #f7faf8; border-left: 4px solid var(--success); }
.customs-result-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: end; }
.customs-result-heading span { color: var(--text-muted); font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.customs-result-heading h3 { margin: .25rem 0 0; font-size: 1.05rem; }
.customs-result-heading p { margin: 0; color: var(--text-secondary); font-size: .78rem; }
.customs-result-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 1rem 0 0; border: 1px solid var(--border); background: var(--bg-surface); }
.customs-result-grid > div { min-width: 0; padding: .8rem; border-right: 1px solid var(--border); }
.customs-result-grid > div:last-child { border-right: 0; }
.customs-result-grid dt, .customs-detail-list dt { color: var(--text-muted); font-size: .65rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.customs-result-grid dd { margin: .25rem 0 0; font-size: .9rem; font-weight: 700; overflow-wrap: anywhere; }
.customs-result-actions { display: flex; flex-wrap: wrap; gap: .65rem; align-items: start; margin-top: 1rem; }
.customs-result-actions form { margin: 0; }
.customs-edit > summary { list-style: none; }
.customs-edit > summary::-webkit-details-marker { display: none; }
.customs-edit[open] { width: min(100%, 52rem); }
.customs-edit > form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin-top: .8rem; padding: 1rem; background: var(--bg-surface); border: 1px solid var(--border); }
.customs-edit label { display: grid; gap: .3rem; color: var(--text-secondary); font-size: .74rem; font-weight: 700; }
.customs-edit input, .customs-edit select, .customs-edit textarea { width: 100%; min-height: 2.45rem; padding: .55rem .65rem; border: 1px solid var(--border); background: #fff; font: inherit; }
.customs-edit textarea { resize: vertical; }
.customs-edit-wide { grid-column: 1 / -1; }
.customs-failed { display: grid; grid-template-columns: minmax(10rem, 1fr) auto auto; gap: .75rem 1rem; align-items: center; margin-top: 1.25rem; padding: 1rem; background: var(--bg-danger-soft); border-left: 4px solid var(--danger); }
.customs-failed span, .customs-failed time { color: var(--danger); font-size: .78rem; }
.customs-failed details { grid-column: 1 / -1; }
.customs-analysis-current, .customs-history { margin-top: 1.25rem; border-top: 1px solid var(--border); }
.customs-secondary-heading, .customs-manual { display: flex; justify-content: space-between; gap: 1rem; padding: .9rem 0; }
.customs-secondary-heading span, .customs-manual span { color: var(--text-secondary); font-size: .78rem; }
.customs-analysis-current > details, .customs-history > details { border-top: 1px solid var(--border); }
.customs-analysis-current summary, .customs-history summary { cursor: pointer; padding: .85rem 0; color: var(--text-heading); font-weight: 750; }
.customs-analysis-current > details > p, .customs-analysis-current > details > div, .customs-analysis-current > details > dl, .customs-history details > p { margin: 0 0 1rem; }
.customs-detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); }
.customs-detail-list > div { min-width: 0; padding: .8rem; background: var(--bg-surface); }
.customs-detail-list dd { margin: .25rem 0 0; overflow-wrap: anywhere; }
.customs-alternatives { display: grid; gap: .5rem; }
.customs-alternatives article { display: grid; grid-template-columns: 10rem 1fr; padding: .75rem; background: var(--bg-secondary); }
.customs-alternatives p { grid-column: 1 / -1; margin: .3rem 0 0; color: var(--text-secondary); }
.customs-source-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.customs-source-columns h4 { margin: 0 0 .5rem; }
.customs-source-columns article { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .75rem; min-width: 0; padding: .65rem 0; border-bottom: 1px solid var(--border); }
.customs-source-columns article strong, .customs-source-columns article span, .customs-source-columns article small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customs-source-columns article span, .customs-source-columns article small { grid-column: 1; color: var(--text-secondary); font-size: .72rem; }
.customs-source-columns article a { grid-column: 2; grid-row: 1 / 4; align-self: center; font-size: .76rem; font-weight: 700; }
.customs-all-sources { margin-top: .75rem; padding: .75rem; background: var(--bg-secondary); }
.customs-history h3 { margin: 1rem 0 .25rem; font-size: .85rem; }
.customs-history summary { display: grid; grid-template-columns: minmax(10rem, 1fr) auto auto; gap: 1rem; }
.customs-history summary span, .customs-history summary time { color: var(--text-secondary); font-size: .76rem; font-weight: 500; }
@media (max-width: 78rem) { .customs-result-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .customs-result-grid > div { border-bottom: 1px solid var(--border); } }
@media (max-width: 48rem) { .customs-item-header, .customs-failed { grid-template-columns: 2.5rem minmax(0, 1fr); } .customs-item-header .status-badge, .customs-failed time { grid-column: 2; } .customs-result-grid, .customs-detail-list, .customs-source-columns, .customs-edit > form { grid-template-columns: 1fr; } .customs-result-heading, .customs-secondary-heading, .customs-manual { align-items: start; flex-direction: column; } .customs-edit-wide { grid-column: auto; } }

@media print {
    @page { margin: 14mm; }
    body, .app-page { color: #111; background: #fff !important; }
    .app-shell, .workspace, .main-content { display: block; width: auto; min-height: 0; margin: 0; padding: 0; background: #fff !important; }
    .sidebar, .topbar, .page-header, .calculation-form, .result-section > .section-heading,
    .pricing-view-switch, .quote-download-bar, #internal-pricing, #manager-result, .flash { display: none !important; }
    .result-section { margin: 0; padding: 0; border: 0; }
    #client-quote, #client-quote[hidden] { display: block !important; max-width: none; margin: 0; padding: 0; color: #111; background: #fff !important; border: 0; box-shadow: none; }
    .client-quote .quote-header h2, .client-quote .quote-note-card h3 { color: #111; }
    .quote-brandline, .quote-footer, .quote-note-card p, .quote-reference { color: #444; }
    .quote-brandline span:first-child, .quote-footer span:first-child { color: #111; }
    .quote-table-wrap { overflow: visible; border: 0; }
    .quote-table { min-width: 0; }
    .quote-table th, .quote-table td { color: #111; background: #fff !important; border-color: #bbb; }
    .quote-table tr { break-inside: avoid; }
    .quote-notes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .quote-note-card { min-height: 0; background: #fff; border-color: #bbb; break-inside: avoid; }
    .quote-duty-list li, .quote-duty-list strong { color: #111; border-color: #ccc; }
}
.customs-mode-tabs { display: flex; gap: .75rem; margin: 0 0 1.25rem; flex-wrap: wrap; }
.customs-manual-summary { margin-bottom: 1.25rem; }
.customs-manual-summary .crm-comment-form { margin-top: 1rem; }
.customs-comparison-table { display: grid; margin-top: 1rem; border: 1px solid var(--border); }
.customs-comparison-table > div { display: grid; grid-template-columns: minmax(9rem,.8fr) repeat(2,minmax(11rem,1fr)) minmax(8rem,.65fr); gap: 1px; background: var(--border); }
.customs-comparison-table > div > * { min-width: 0; padding: .7rem .75rem; overflow-wrap: anywhere; background: var(--bg-surface); }
.customs-comparison-head > * { color: var(--text-secondary); background: var(--bg-secondary) !important; font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; }
.comparison-status { font-size: .75rem; font-weight: 750; }
.comparison-status--match { color: var(--success); }
.comparison-status--different { color: var(--warning); }
@media (max-width: 48rem) {
  .customs-comparison-table { overflow-x: auto; }
  .customs-comparison-table > div { min-width: 47rem; }
}

/* NOMENCORE operational UI kit. */
.deal-workspace, .queue-workspace { width: 100%; min-width: 0; }
.entity-id { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap !important; overflow-wrap: normal !important; word-break: normal !important; font-variant-numeric: tabular-nums; }
.section-block { margin: 1.25rem 0; scroll-margin-top: 6rem; }
.section-card, .workflow-card, .request-card { min-width: 0; padding: 1.25rem; background: var(--bg-surface); border: 1px solid var(--border); box-shadow: 0 4px 18px rgba(36, 41, 37, .045); }
.section-title-row { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1rem; }
.section-title-row h2 { margin: 0; font-size: 1.2rem; }
.section-title-row .overline { margin-bottom: .35rem; }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem; margin: 0 0 1rem; }
.metric-card { display: grid; align-content: center; min-width: 0; min-height: 6.4rem; margin: 0; padding: 1rem 1.1rem; color: inherit; background: var(--bg-surface); border: 1px solid var(--border); border-top: 3px solid var(--accent); text-decoration: none; }
.metric-card span, .metric-card dt { color: var(--text-secondary); font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.metric-card strong, .metric-card dd { margin: .35rem 0 0; overflow: hidden; color: var(--text-heading); font-size: 1.35rem; font-weight: 700; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.metric-card small { color: var(--text-muted); }
.metric-card.is-active { background: var(--bg-accent-soft); border-color: var(--accent); }
.status-badge--accent { color: var(--text-on-accent); background: var(--accent); border-color: var(--accent); }
.deal-header { display: grid; grid-template-columns: minmax(18rem, 1fr) auto auto; gap: 2rem; align-items: end; margin-bottom: 1rem; padding-bottom: 1.25rem; }
.deal-header h1 { margin: .65rem 0 .2rem; font-size: clamp(1.85rem, 2.6vw, 2.65rem); }
.deal-header__client { margin: 0; color: var(--text-secondary); font-size: 1.05rem; }
.deal-header__meta { display: grid; grid-template-columns: repeat(3, auto); gap: 1.4rem; margin: 0; }
.deal-header__meta div { min-width: 6rem; }
.deal-header__meta dt, .detail-list dt { color: var(--text-muted); font-size: .65rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.deal-header__meta dd, .detail-list dd { margin: .2rem 0 0; }
.header-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.action-menu { position: relative; }
.action-menu summary { list-style: none; cursor: pointer; }
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu > div { position: absolute; z-index: 5; right: 0; display: grid; width: 14rem; margin-top: .4rem; padding: .45rem; background: #fff; border: 1px solid var(--border-strong); box-shadow: var(--surface-shadow); }
.action-menu a, .danger-link { padding: .65rem .75rem; color: var(--text-primary); background: none; border: 0; font: inherit; font-size: .82rem; text-align: left; text-decoration: none; cursor: pointer; }
.action-menu a:hover { background: var(--bg-accent-soft); }
.danger-link { width: 100%; color: var(--danger); border-top: 1px solid var(--border); }
.section-tabs, .workspace-tabs { display: flex; gap: .15rem; overflow-x: auto; margin: 0 0 1.25rem; padding: .35rem; background: var(--bg-surface); border: 1px solid var(--border); }
.section-tabs { position: sticky; top: calc(var(--topbar-height) + .5rem); z-index: 4; }
.section-tabs a, .workspace-tabs a { flex: 0 0 auto; padding: .65rem .85rem; color: var(--text-secondary); font-size: .78rem; font-weight: 750; text-decoration: none; }
.section-tabs a:hover, .section-tabs a:focus-visible, .workspace-tabs a:hover, .workspace-tabs a.is-active { color: var(--accent-hover); background: var(--bg-accent-soft); }
.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(18rem, .8fr); gap: 1rem; }
.section-card h3, .workflow-card h3, .request-card h3 { margin: 0 0 1rem; font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 0; }
.detail-list dd { overflow-wrap: anywhere; }
.action-bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: 1rem; }
.action-panel { display: grid; gap: .75rem; align-content: start; }
.action-panel form { display: grid; gap: .45rem; margin: 0; }
.action-panel label, .calculation-actions label, .filter-bar label, .comment-form label { display: grid; gap: .3rem; color: var(--text-secondary); font-size: .74rem; font-weight: 700; }
.action-panel select, .calculation-actions input, .filter-bar input, .filter-bar select, .comment-form textarea { width: 100%; min-height: 2.5rem; padding: .55rem .65rem; background: #fff; border: 1px solid var(--border-strong); color: inherit; font: inherit; }
.entity-table-wrap { width: 100%; overflow-x: auto; }
.entity-table { width: 100%; min-width: 66rem; border-collapse: collapse; table-layout: auto; }
.entity-table th, .entity-table td { padding: .75rem .7rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.entity-table th { color: var(--text-secondary); background: var(--bg-secondary); font-size: .65rem; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.entity-table td { font-size: .79rem; }
.entity-table td:first-child { min-width: 13rem; }
.entity-table td:nth-child(2) { min-width: 9rem; }
.entity-table td strong, .entity-table td small { display: block; }
.entity-table td small { margin-top: .2rem; color: var(--text-muted); }
.entity-table__detail td { padding: .35rem .7rem .7rem; background: #fafbfa; }
.entity-table__detail summary { cursor: pointer; color: var(--accent-hover); font-weight: 700; }
.offer-list { display: grid; gap: .4rem; margin-top: .6rem; }
.offer-list form { display: flex; justify-content: space-between; gap: .75rem; align-items: center; padding: .5rem; background: #fff; }
.deal-items-editor__rows { display: grid; gap: .75rem; }
.deal-item-edit-row { display: grid; grid-template-columns: minmax(11rem, 1.5fr) minmax(9rem, 1fr) minmax(9rem, 1fr) 7rem minmax(13rem, 1.5fr) auto; gap: .75rem; align-items: end; margin: 0; padding: .85rem; border: 1px solid var(--border); border-radius: .7rem; min-width: 0; }
.deal-item-edit-row label, .manager-document-form label { min-width: 0; }
.deal-item-edit-row input, .deal-item-edit-row textarea { width: 100%; }
.customs-manager-result { display: grid; gap: .85rem; padding: .5rem 0; }
.customs-manager-result h3, .customs-manager-result h4 { margin: 0; }
.manager-document-form { display: grid; grid-template-columns: minmax(13rem, 1fr) minmax(9rem, .45fr) minmax(15rem, 1.2fr) auto; gap: .75rem; align-items: end; padding: .85rem; border-radius: .7rem; background: #eaf7fc; }
.manager-document-form h4, .manager-document-form p { grid-column: 1 / -1; }
.item-status { display: inline-flex; padding: .2rem .45rem; border-radius: 999px; font-size: .68rem; font-weight: 750; white-space: nowrap; }
.item-status.is-ready { color: var(--success); background: var(--bg-success-soft); }
.item-status.is-pending { color: var(--warning); background: var(--bg-warning-soft); }
.readiness-dots { display: flex; gap: .3rem; }
.readiness-dots i { width: .58rem; height: .58rem; background: var(--border-strong); border-radius: 50%; }
.readiness-dots i.on { background: var(--accent); }
.workflow-grid, .request-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.workflow-card { display: grid; gap: .7rem; align-content: start; min-height: 13rem; border-top: 3px solid var(--accent); }
.workflow-card header, .request-card header, .info-request-card header { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.workflow-card header h3 { margin: 0; }
.workflow-card > strong { font-size: 1.05rem; }
.workflow-card > p { margin: 0; color: var(--text-secondary); }
.empty-state { display: grid; gap: .2rem; padding: .85rem 0; color: var(--text-muted); font-size: .82rem; }
.empty-state strong { color: var(--text-secondary); }
.calculation-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(24rem, .9fr); gap: 1.5rem; margin-top: 1rem; }
.info-box { padding: .8rem 1rem; background: var(--bg-info-soft); border-left: 3px solid var(--info); color: var(--text-secondary); }
.info-box p:last-child { margin-bottom: 0; }
.info-box--warning { background: var(--bg-warning-soft); border-color: var(--warning); }
.info-box--success { background: var(--bg-success-soft); border-color: var(--success); }
.calculation-actions { display: grid; gap: .65rem; }
.calculation-actions form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; align-items: end; }
.info-request-list { display: grid; gap: 1rem; }
.comment-form { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .75rem; align-items: end; margin-bottom: 1.25rem; }
.comment-form textarea { resize: vertical; }
.file-picker { min-height: 2.5rem; padding: .55rem .7rem; border: 1px dashed var(--accent); background: var(--bg-accent-soft); }
.file-picker input { max-width: 14rem; font-size: .72rem; }
.file-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.file-chip { max-width: 20rem; overflow: hidden; padding: .3rem .55rem; color: var(--accent-hover); background: var(--bg-accent-soft); border: 1px solid var(--border-accent); border-radius: 999px; font-size: .72rem; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.activity-feed, .timeline { display: grid; gap: 0; margin: 1rem 0 0; padding: 0; list-style: none; }
.activity-feed > li { padding: 1rem 0; border-top: 1px solid var(--border); }
.activity-feed header { display: flex; justify-content: space-between; gap: 1rem; }
.activity-feed time, .timeline time { color: var(--text-muted); font-size: .72rem; }
.activity-feed p { margin: .45rem 0; white-space: pre-wrap; }
.timeline > li { position: relative; display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 1rem; padding: 0 0 1.1rem 1rem; border-left: 2px solid var(--border); }
.timeline > li::before { position: absolute; top: .25rem; left: -.35rem; width: .6rem; height: .6rem; content: ''; background: var(--accent); border-radius: 50%; }
.timeline div { display: grid; gap: .15rem; }
.timeline span, .timeline small { color: var(--text-muted); font-size: .73rem; }
.timeline small { opacity: .65; }
.filter-bar { display: grid; grid-template-columns: minmax(18rem, 1.6fr) minmax(13rem, .8fr) auto; gap: .75rem; align-items: end; margin-bottom: 1rem; padding: 1rem; background: var(--bg-surface); border: 1px solid var(--border); }
.filter-bar .action-bar { margin: 0; }
.queue-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.queue-kpis .metric-card { min-height: 5.5rem; }
.request-card { display: grid; gap: .8rem; border-top: 3px solid var(--accent); }
.request-card header p { margin: .3rem 0 0; color: var(--text-muted); font-size: .72rem; }
.request-card__count { display: flex; justify-content: space-between; padding: .65rem .75rem; background: var(--bg-secondary); }
.request-card h3 { margin: .2rem 0 0; color: var(--text-muted); font-size: .68rem; }
.progress-list { display: grid; margin: 0; border-top: 1px solid var(--border); }
.progress-list div { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.progress-list dt { color: var(--text-secondary); }
.progress-list dd { margin: 0; font-weight: 800; }
.import-summary, .confirmed-items { margin: 1rem 0; }
.confirmed-items summary { cursor: pointer; font-weight: 750; }
.customs-history ol { display: grid; gap: .35rem; padding: .5rem 0; list-style: none; }
.customs-history li { display: grid; grid-template-columns: 4rem minmax(8rem, 1fr) auto auto; gap: .65rem; padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .76rem; }
.customs-history li span, .customs-history li time { color: var(--text-secondary); }
.customs-history li em { color: var(--accent); font-style: normal; }

@media (max-width: 82rem) {
  .deal-header { grid-template-columns: minmax(16rem, 1fr) auto; }
  .deal-header .header-actions { grid-column: 1 / -1; }
  .overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .action-panel { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .action-panel h3 { grid-column: 1 / -1; }
  .crm-workbook-current { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 64rem) {
  .summary-grid, .queue-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .deal-header, .overview-grid, .workflow-grid, .request-grid, .calculation-card { grid-template-columns: 1fr; }
  .deal-header__meta { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .comment-form, .filter-bar { grid-template-columns: 1fr; }
  .section-tabs { position: static; }
  .deal-item-edit-row, .manager-document-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 42rem) {
  .deal-header__meta, .detail-list, .crm-workbook-current, .action-panel { grid-template-columns: 1fr; }
  .timeline > li { grid-template-columns: 1fr; }
  .customs-history li { grid-template-columns: 3rem 1fr; }
  .deal-item-edit-row, .manager-document-form { grid-template-columns: 1fr; }
}
.buyer-item-name {
    display: -webkit-box;
    max-width: 34rem;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.buyer-queue-table td:nth-child(2) { max-width: 34rem; }

.discussion-tabs { display: flex; gap: .45rem; margin: .75rem 0 1rem; border-bottom: 1px solid var(--border); }
.discussion-tab { padding: .7rem .9rem; color: var(--text-secondary); text-decoration: none; border-bottom: 2px solid transparent; font-weight: 750; }
.discussion-tab--active { color: var(--accent); border-bottom-color: var(--accent); }
.discussion-badge { display: inline-grid; min-width: 1.35rem; height: 1.35rem; padding: 0 .3rem; place-items: center; border-radius: 999px; background: var(--accent); color: #fff; font-size: .72rem; }
.discussion-messages { display: grid; gap: .7rem; max-height: 34rem; overflow: auto; padding: 0; list-style: none; }
.discussion-message { padding: .85rem 1rem; border: 1px solid var(--border); border-radius: .55rem; background: #fff; }
.discussion-message--system { border-left: 3px solid var(--accent); background: #f2f8fb; }
.discussion-message header { display: flex; justify-content: space-between; gap: 1rem; color: var(--text-secondary); font-size: .78rem; }
.discussion-message header strong { color: var(--text-primary); }
.discussion-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.discussion-item { margin: .45rem 0; color: var(--text-secondary); font-size: .82rem; }
.discussion-form { margin-top: 1rem; }
