:root {
    --bg: #f5f5f7;
    --surface: rgba(255, 255, 255, 0.86);
    --surface-solid: #ffffff;
    --surface-muted: #f8f8fa;
    --surface-hover: #f0f1f4;
    --text: #1d1d1f;
    --text-soft: #6e6e73;
    --text-faint: #8e8e93;
    --border: rgba(60, 60, 67, 0.14);
    --border-strong: rgba(60, 60, 67, 0.24);
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-soft: rgba(0, 113, 227, 0.10);
    --success: #16843f;
    --success-soft: rgba(22, 132, 63, 0.11);
    --warning: #9a6400;
    --warning-soft: rgba(226, 153, 0, 0.14);
    --danger: #d92d20;
    --danger-soft: rgba(217, 45, 32, 0.10);
    --neutral-soft: rgba(110, 110, 115, 0.12);
    --sidebar-width: 264px;
    --topbar-height: 70px;
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 13px;
    --radius-sm: 9px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.03), 0 6px 22px rgba(0, 0, 0, 0.035);
    --shadow-lg: 0 18px 60px rgba(0, 0, 0, 0.13), 0 2px 12px rgba(0, 0, 0, 0.05);
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 92% -10%, rgba(0, 113, 227, 0.08), transparent 30rem),
        var(--bg);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
button, summary { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; }
code, kbd, .tabular { font-variant-numeric: tabular-nums; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
::selection { background: rgba(0, 113, 227, 0.2); }
:focus-visible { outline: 3px solid rgba(0, 113, 227, 0.28); outline-offset: 2px; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    padding: 18px 14px 14px;
    border-right: 1px solid var(--border);
    background: rgba(248, 248, 250, 0.82);
    backdrop-filter: saturate(180%) blur(28px);
    -webkit-backdrop-filter: saturate(180%) blur(28px);
}
.sidebar-backdrop { display: none; }
.brand-row { display: flex; min-height: 44px; align-items: center; justify-content: space-between; padding: 2px 8px 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-mark {
    display: inline-grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 10px;
    color: #fff;
    background: linear-gradient(145deg, #0a84ff, #0063c9 72%, #004c9f);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 6px 14px rgba(0,113,227,.22);
    font-size: 18px;
    font-weight: 750;
    letter-spacing: -0.04em;
}
.brand-mark.large { width: 46px; height: 46px; border-radius: 14px; font-size: 24px; }
.brand > span:last-child, .auth-brand > span:last-child { display: flex; line-height: 1.05; flex-direction: column; }
.brand strong, .auth-brand strong { font-size: 16px; letter-spacing: -0.025em; }
.brand small, .auth-brand small { margin-top: 3px; color: var(--text-soft); font-size: 10px; font-weight: 650; letter-spacing: .16em; }
.sidebar-close { display: none !important; }

.organization-switcher { position: relative; margin: 2px 0 12px; }
.organization-switcher > summary {
    display: flex;
    min-height: 57px;
    align-items: center;
    gap: 10px;
    padding: 8px 9px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    list-style: none;
    transition: background .16s ease, border-color .16s ease;
}
.organization-switcher > summary::-webkit-details-marker, .notification-menu > summary::-webkit-details-marker, .inline-disclosure > summary::-webkit-details-marker { display: none; }
.organization-switcher > summary:hover, .organization-switcher[open] > summary { border-color: var(--border); background: var(--surface); }
.organization-avatar, .user-avatar {
    display: inline-grid;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, #6e6e73, #3a3a3c);
    font-size: 12px;
    font-weight: 750;
    text-transform: uppercase;
}
.organization-avatar { border-radius: 10px; background: linear-gradient(145deg, #bf5af2, #8e44bd); }
.organization-avatar.small { width: 30px; height: 30px; border-radius: 9px; }
.organization-copy, .menu-row > span:nth-child(2), .user-compact > span:nth-child(2) { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.organization-copy strong, .menu-row strong, .user-compact strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.organization-copy small, .menu-row small, .user-compact small { overflow: hidden; margin-top: 2px; color: var(--text-soft); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.chevron { color: var(--text-faint); font-size: 13px; }
.surface-popover {
    position: absolute;
    z-index: 100;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255,255,255,.94);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
}
.organization-menu { top: calc(100% + 5px); left: 0; width: 300px; }
.menu-row { display: flex; align-items: center; gap: 10px; padding: 9px; border-radius: 11px; color: var(--text); }
.menu-row:hover, .menu-row.selected { color: var(--text); background: var(--surface-hover); }

.nav-scroll { flex: 1; overflow-x: hidden; overflow-y: auto; padding: 0 3px 20px; scrollbar-width: thin; }
.nav-group { margin: 10px 0 17px; }
.nav-group-label { padding: 0 10px 6px; color: var(--text-faint); font-size: 10px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.nav-item {
    display: flex;
    min-height: 38px;
    align-items: center;
    gap: 10px;
    margin: 1px 0;
    padding: 7px 10px;
    border-radius: 10px;
    color: #3a3a3c;
    font-size: 13px;
    font-weight: 540;
    transition: background .14s ease, color .14s ease, transform .14s ease;
}
.nav-item:hover { color: var(--text); background: rgba(118,118,128,.09); }
.nav-item.active { color: var(--accent); background: var(--accent-soft); font-weight: 650; }
.nav-icon { display: grid; width: 20px; height: 20px; place-items: center; color: var(--text-soft); font-size: 15px; line-height: 1; }
.nav-item.active .nav-icon { color: var(--accent); }
.sidebar-footer { display: flex; align-items: center; gap: 8px; padding: 12px 4px 0; border-top: 1px solid var(--border); }
.user-compact { display: flex; min-width: 0; flex: 1; align-items: center; gap: 9px; }
.user-compact .user-avatar { width: 32px; height: 32px; }

.main-area { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
    position: sticky;
    top: 0;
    z-index: 45;
    display: flex;
    height: var(--topbar-height);
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(20px, 3vw, 44px);
    border-bottom: 1px solid var(--border);
    background: rgba(245,245,247,.76);
    backdrop-filter: saturate(180%) blur(28px);
    -webkit-backdrop-filter: saturate(180%) blur(28px);
}
.topbar-left { display: flex; min-width: 0; flex: 1; align-items: center; gap: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-button {
    display: inline-grid;
    width: 38px;
    height: 38px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: var(--text);
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: background .14s ease, transform .14s ease;
}
.icon-button:hover { color: var(--text); background: rgba(118,118,128,.11); }
.icon-button:active { transform: scale(.95); }
.mobile-menu { display: none; }
.global-search {
    display: flex;
    width: min(560px, 100%);
    height: 40px;
    align-items: center;
    gap: 8px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,.72);
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.global-search:focus-within { border-color: rgba(0,113,227,.45); background: var(--surface-solid); box-shadow: 0 0 0 4px rgba(0,113,227,.08); }
.global-search > span { color: var(--text-faint); font-size: 18px; }
.global-search input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--text); background: transparent; }
.global-search input::placeholder { color: var(--text-faint); }
kbd { padding: 2px 6px; border: 1px solid var(--border); border-bottom-color: var(--border-strong); border-radius: 6px; color: var(--text-faint); background: var(--surface-muted); font-size: 10px; }
.top-avatar { width: 34px; height: 34px; margin-left: 3px; }
.notification-menu { position: relative; }
.notification-menu > summary { list-style: none; }
.notification-dot { position: absolute; top: -1px; right: -1px; display: grid; min-width: 17px; height: 17px; padding: 0 4px; place-items: center; border: 2px solid var(--bg); border-radius: 10px; color: #fff; background: var(--danger); font-size: 9px; font-weight: 750; }
.notifications-panel { top: calc(100% + 8px); right: 0; width: min(360px, calc(100vw - 24px)); }
.popover-heading { display: flex; align-items: center; justify-content: space-between; padding: 7px 9px 10px; }
.popover-heading a, .popover-heading .link-button { font-size: 12px; }
.link-button { appearance: none; border: 0; background: transparent; color: var(--accent); padding: 0; font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.notification-row { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 11px; color: var(--text); }
.notification-row:hover { color: var(--text); background: var(--surface-hover); }
.notification-row strong { font-size: 13px; }
.notification-row span { color: var(--text-soft); font-size: 12px; }
.notification-row small { color: var(--text-faint); font-size: 10px; }

.content-wrap { width: min(1540px, 100%); margin: 0 auto; padding: 34px clamp(20px, 3vw, 44px) 72px; }
.mobile-tabbar { display: none; }
.surface {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.eyebrow { display: block; margin-bottom: 5px; color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.eyebrow.light { color: rgba(255,255,255,.72); }
.muted { color: var(--text-soft); }
.page-heading-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading-row.compact { align-items: center; }
.page-heading { min-width: 0; }
.page-heading h1 { margin: 0; font-size: clamp(28px, 3vw, 42px); font-weight: 700; letter-spacing: -.045em; line-height: 1.08; }
.page-heading p { max-width: 700px; margin: 9px 0 0; color: var(--text-soft); font-size: 14px; }
.page-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.breadcrumb { display: inline-block; margin-bottom: 9px; color: var(--text-soft); font-size: 13px; font-weight: 550; }
.breadcrumb:hover { color: var(--accent); }
.title-with-status { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.title-with-status h1 { overflow-wrap: anywhere; }

.button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 15px;
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.1;
    text-align: center;
    transition: transform .14s ease, background .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.button:active { transform: scale(.975); }
.button-primary { color: #fff; background: var(--accent); box-shadow: 0 4px 12px rgba(0,113,227,.16); }
.button-primary:hover { color: #fff; background: var(--accent-hover); }
.button-secondary { color: var(--text); border-color: var(--border); background: rgba(255,255,255,.72); }
.button-secondary:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-solid); }
.button-ghost { color: var(--text-soft); background: transparent; }
.button-ghost:hover { color: var(--text); background: var(--surface-hover); }
.button-danger { color: var(--danger); border-color: rgba(217,45,32,.20); background: var(--danger-soft); }
.button-danger:hover { color: #fff; background: var(--danger); }
.button-small { min-height: 30px; padding: 5px 10px; font-size: 11px; }
.button-large { min-height: 48px; padding: 12px 22px; font-size: 15px; }

.message-stack { display: grid; gap: 8px; margin-bottom: 18px; }
.alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 15px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-solid); box-shadow: var(--shadow-sm); font-size: 13px; }
.alert button { border: 0; color: inherit; background: transparent; cursor: pointer; font-size: 18px; }
.alert-success { color: var(--success); border-color: rgba(22,132,63,.22); background: var(--success-soft); }
.alert-error, .alert-danger { color: var(--danger); border-color: rgba(217,45,32,.22); background: var(--danger-soft); }
.alert-warning { color: var(--warning); border-color: rgba(154,100,0,.24); background: var(--warning-soft); }

.form-surface { padding: clamp(20px, 3vw, 34px); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 22px; }
.form-field { min-width: 0; }
.form-field.span-2 { grid-column: span 2; }
.form-field label { display: block; margin-bottom: 7px; color: #3a3a3c; font-size: 12px; font-weight: 650; }
.form-field label span { margin-left: 2px; color: var(--danger); }
.form-field small { display: block; margin-top: 6px; color: var(--text-faint); font-size: 11px; }
.form-control, .compact-select, .form-field input, .form-field select, .form-field textarea, .line-table input, .line-table select, .line-table textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--border-strong);
    border-radius: 11px;
    outline: 0;
    color: var(--text);
    background: rgba(255,255,255,.82);
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.form-field textarea, .line-table textarea { min-height: 96px; resize: vertical; }
.form-control:focus, .compact-select:focus, .form-field input:focus, .form-field select:focus, .form-field textarea:focus, .line-table input:focus, .line-table select:focus, .line-table textarea:focus { border-color: rgba(0,113,227,.55); background: var(--surface-solid); box-shadow: 0 0 0 4px rgba(0,113,227,.09); }
.form-field input[type="checkbox"], .form-field input[type="radio"] { width: 18px; min-height: 18px; accent-color: var(--accent); }
.form-field input[type="file"] { padding: 7px; }
.form-field ul { margin: 7px 0 0; padding: 0; list-style: none; }
.form-field ul li { margin: 4px 0; }
.form-field ul label { display: flex; align-items: center; gap: 7px; font-weight: 500; }
.field-error, .form-errors { color: var(--danger); font-size: 12px; }
.field-error { margin-top: 5px; }
.form-errors { margin-bottom: 18px; padding: 11px 13px; border: 1px solid rgba(217,45,32,.20); border-radius: 11px; background: var(--danger-soft); }
.form-errors ul { margin: 0; padding-left: 18px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; margin-top: 28px; }
.sticky-actions { position: sticky; bottom: 18px; z-index: 20; width: max-content; margin-left: auto; padding: 8px; border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.88); box-shadow: 0 12px 40px rgba(0,0,0,.10); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }

.list-surface { overflow: hidden; }
.list-toolbar { display: flex; min-height: 66px; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.search-field { display: flex; width: min(380px, 100%); align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-muted); }
.search-field span { color: var(--text-faint); font-size: 17px; }
.search-field input { width: 100%; height: 38px; border: 0; outline: 0; background: transparent; }
.compact-select { width: auto; min-width: 140px; min-height: 40px; padding: 7px 30px 7px 10px; }
.toolbar-submit { display: none; }
.record-count { margin-left: auto; color: var(--text-faint); font-size: 11px; white-space: nowrap; }
.data-table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; border-spacing: 0; font-size: 13px; }
.data-table th { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-faint); background: rgba(248,248,250,.7); font-size: 10px; font-weight: 720; letter-spacing: .055em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { max-width: 380px; padding: 13px 14px; border-bottom: 1px solid var(--border); color: #3a3a3c; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .12s ease; }
.data-table tbody tr[data-href] { cursor: pointer; }
.data-table tbody tr:hover { background: rgba(0,113,227,.035); }
.data-table a { font-weight: 600; }
.primary-cell-link { color: var(--text); }
.primary-cell-link:hover { color: var(--accent); }
.row-action { width: 34px; text-align: right !important; }
.row-action a { color: var(--text-faint); font-size: 21px; font-weight: 400; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--border); color: var(--text-soft); font-size: 12px; }
.pagination > div { display: flex; gap: 8px; }
.empty-state { display: grid; min-height: 270px; place-items: center; align-content: center; padding: 30px; color: var(--text-soft); text-align: center; }
.empty-state > span { margin-bottom: 8px; color: var(--text-faint); font-size: 38px; }
.empty-state h3 { margin: 0; color: var(--text); font-size: 18px; }
.empty-state p { margin: 7px 0 16px; }
.empty-compact { padding: 24px 10px; color: var(--text-soft); font-size: 12px; text-align: center; }

.status-pill { display: inline-flex; max-width: 180px; min-height: 23px; align-items: center; padding: 3px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; line-height: 1.1; white-space: nowrap; }
.status-pill.large { min-height: 28px; padding: 5px 10px; font-size: 11px; }
.status-positive { color: var(--success); background: var(--success-soft); }
.status-warning { color: var(--warning); background: var(--warning-soft); }
.status-negative { color: var(--danger); background: var(--danger-soft); }
.status-neutral { color: var(--text-soft); background: var(--neutral-soft); }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { min-height: 140px; padding: 18px; }
.metric-label { display: block; color: var(--text-soft); font-size: 11px; font-weight: 650; }
.metric-card > strong { display: block; overflow: hidden; margin-top: 15px; font-size: clamp(20px, 2vw, 29px); font-weight: 680; letter-spacing: -.04em; text-overflow: ellipsis; white-space: nowrap; }
.metric-card > small { display: block; margin-top: 11px; color: var(--text-faint); font-size: 10px; line-height: 1.35; }
.dashboard-grid { display: grid; gap: 18px; margin-bottom: 18px; }
.dashboard-primary-grid { grid-template-columns: minmax(0, 1.7fr) minmax(300px, .8fr); }
.dashboard-three-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-panel, .detail-surface { padding: 20px; }
.section-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.section-heading-row h2 { margin: 0; font-size: 18px; font-weight: 680; letter-spacing: -.025em; }
.section-heading-row > a { font-size: 12px; font-weight: 600; white-space: nowrap; }
.section-heading-row .eyebrow { margin-bottom: 3px; }
.chart-panel { min-height: 350px; }
.bar-chart { display: flex; height: 260px; align-items: flex-end; gap: clamp(12px, 3vw, 34px); padding: 26px 12px 0; }
.bar-column { display: flex; min-width: 0; flex: 1; height: 100%; flex-direction: column; align-items: center; justify-content: flex-end; gap: 7px; }
.bar-track { position: relative; width: min(48px, 76%); height: 185px; overflow: hidden; border-radius: 11px 11px 5px 5px; background: rgba(118,118,128,.08); }
.bar-fill { position: absolute; right: 0; bottom: 0; left: 0; min-height: 4px; border-radius: 11px 11px 5px 5px; background: linear-gradient(180deg, #0a84ff, #0071e3); box-shadow: inset 0 1px 0 rgba(255,255,255,.35); transition: height .5s ease; }
.bar-column > span { color: var(--text-soft); font-size: 11px; font-weight: 600; }
.bar-value { width: 100%; overflow: hidden; color: var(--text-faint); font-size: 9px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.compact-list { display: grid; }
.compact-row { display: flex; min-height: 56px; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border); color: var(--text); }
.compact-row:last-child { border-bottom: 0; }
.compact-row:hover { color: var(--text); }
.compact-row:hover strong { color: var(--accent); }
.row-icon { display: grid; flex: 0 0 auto; width: 32px; height: 32px; place-items: center; border-radius: 10px; color: var(--accent); background: var(--accent-soft); }
.row-main { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.row-main strong { overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { overflow: hidden; margin-top: 2px; color: var(--text-soft); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.row-value, .row-meta { color: var(--text-soft); font-size: 10px; font-weight: 650; white-space: nowrap; }
.priority-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--text-faint); }
.priority-low { background: #64d2ff; }
.priority-medium, .priority-normal { background: #0a84ff; }
.priority-high { background: #ff9f0a; }
.priority-urgent { background: #ff453a; box-shadow: 0 0 0 4px rgba(255,69,58,.10); }
.low-stock-panel { padding: 20px; }
.stock-chip-row { display: flex; overflow-x: auto; gap: 10px; padding-bottom: 2px; }
.stock-chip { display: flex; min-width: 190px; flex-direction: column; padding: 12px; border: 1px solid var(--border); border-radius: 13px; color: var(--text); background: var(--surface-muted); }
.stock-chip:hover { color: var(--text); border-color: rgba(0,113,227,.25); background: var(--accent-soft); }
.stock-chip strong { font-size: 12px; }
.stock-chip span { margin-top: 3px; color: var(--text-soft); font-size: 10px; }

.detail-heading { align-items: flex-end; }
.detail-actions form { display: inline-flex; }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; border-top: 1px solid var(--border); border-left: 1px solid var(--border); border-radius: 13px; overflow: hidden; }
.detail-grid > div { min-width: 0; padding: 14px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: rgba(248,248,250,.55); }
.detail-grid dt { margin-bottom: 5px; color: var(--text-faint); font-size: 9px; font-weight: 720; letter-spacing: .06em; text-transform: uppercase; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; color: var(--text); font-size: 13px; font-weight: 540; }
.record-id { color: var(--text-faint); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.long-field { margin-top: 18px; padding: 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-muted); }
.long-field h3 { margin: 0 0 7px; color: var(--text-soft); font-size: 11px; }
.long-field div { color: #3a3a3c; font-size: 13px; }
.detail-surface { margin-bottom: 18px; }
.document-totals { width: min(390px, 100%); margin: 18px 0 0 auto; padding-top: 8px; }
.document-totals > div { display: flex; align-items: center; justify-content: space-between; padding: 7px 4px; color: var(--text-soft); font-size: 12px; }
.document-totals > div strong { color: var(--text); }
.document-totals .grand-total { margin-top: 5px; padding-top: 13px; border-top: 1px solid var(--border-strong); color: var(--text); font-size: 15px; }
.document-totals .grand-total strong { font-size: 18px; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 24px; padding: 16px 18px; border: 1px solid rgba(217,45,32,.18); border-radius: var(--radius-lg); background: var(--danger-soft); }
.danger-zone > div { display: flex; flex-direction: column; }
.danger-zone strong { color: var(--danger); font-size: 13px; }
.danger-zone span { margin-top: 3px; color: var(--text-soft); font-size: 11px; }

.document-form { display: grid; gap: 18px; }
.document-actions { margin-top: 0; }
.line-editor { padding: 20px; }
.line-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 13px; }
.line-table { min-width: 880px; }
.line-table th { background: var(--surface-muted); }
.line-table td { min-width: 110px; padding: 8px; vertical-align: top; }
.line-table td:nth-child(1), .line-table td:nth-child(2) { min-width: 175px; }
.line-table input, .line-table select { min-height: 37px; padding: 7px 8px; border-radius: 9px; font-size: 12px; }
.line-table textarea { min-height: 60px; padding: 7px 8px; border-radius: 9px; font-size: 12px; }
.line-remove { width: 46px; min-width: 46px !important; text-align: center; }
.danger-icon { color: var(--danger); }
.delete-field { display: none; }
.formset-row.is-deleted { display: none; }
.document-total-preview { display: flex; width: min(330px, 100%); align-items: center; justify-content: space-between; margin: 16px 0 0 auto; padding: 12px 14px; border-radius: 12px; background: var(--surface-muted); }
.document-total-preview span { color: var(--text-soft); font-size: 11px; }
.document-total-preview strong { font-size: 16px; }

.segmented-control { display: inline-flex; max-width: 100%; overflow-x: auto; padding: 4px; border: 1px solid var(--border); border-radius: 13px; background: rgba(118,118,128,.08); }
.segmented-control a { padding: 7px 13px; border-radius: 9px; color: var(--text-soft); font-size: 11px; font-weight: 650; white-space: nowrap; }
.segmented-control a.active { color: var(--text); background: var(--surface-solid); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.report-tabs { margin-bottom: 18px; }
.report-metrics { grid-template-columns: repeat(4, minmax(0,1fr)); }
.report-sheet { max-width: 920px; margin-right: auto; margin-left: auto; }
.report-table { width: 100%; border-collapse: collapse; }
.report-table td, .report-table th { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.report-table td:last-child, .report-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.report-section th { padding-top: 22px; color: var(--text-soft); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.report-total th { padding-top: 13px; border-top: 1px solid var(--border-strong); }
.report-grand-total th { padding-top: 16px; border-top: 2px solid var(--text); font-size: 16px; }
.aging-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 8px; }
.aging-grid > div { padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-muted); }
.aging-grid span { display: block; color: var(--text-soft); font-size: 10px; }
.aging-grid strong { display: block; margin-top: 7px; font-size: 14px; }
.aging-grid.wide { margin-bottom: 18px; }

.settings-layout { display: grid; grid-template-columns: 210px minmax(0,1fr); gap: 18px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--topbar-height) + 20px); display: grid; padding: 9px; }
.settings-nav a { padding: 9px 10px; border-radius: 9px; color: var(--text-soft); font-size: 12px; font-weight: 600; }
.settings-nav a:hover { color: var(--text); background: var(--surface-hover); }
.settings-content { min-width: 0; }
.secret-reveal { display: grid; grid-template-columns: minmax(0,1fr) minmax(300px, .8fr); gap: 20px; margin-bottom: 18px; padding: 20px; border-color: rgba(0,113,227,.22); background: linear-gradient(135deg, rgba(0,113,227,.08), rgba(255,255,255,.88)); }
.secret-reveal h2 { margin: 0; font-size: 20px; }
.secret-reveal p { margin: 6px 0 0; color: var(--text-soft); font-size: 12px; }
.secret-row { display: flex; align-items: center; gap: 8px; }
.secret-row code { min-width: 0; flex: 1; overflow: hidden; padding: 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-solid); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.section-intro { margin: -6px 0 16px; color: var(--text-soft); font-size: 12px; }
.api-example { margin-bottom: 16px; padding: 13px; border-radius: 12px; color: #d1e8ff; background: #17233a; font-size: 11px; line-height: 1.7; }
.inline-disclosure { margin-top: 15px; }
.inline-disclosure > summary { width: max-content; list-style: none; }
.inline-disclosure[open] > summary { margin-bottom: 15px; }
.compact-form { margin-top: 14px; padding: 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-muted); }
.compact-form.action-field { align-self: end; }
.module-directory { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }
.module-directory a, .operations-grid a { display: flex; min-width: 0; flex-direction: column; padding: 13px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); background: var(--surface-muted); }
.module-directory a:hover, .operations-grid a:hover { color: var(--text); border-color: rgba(0,113,227,.25); background: var(--accent-soft); }
.module-directory strong, .operations-grid strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.module-directory span, .operations-grid span { margin-top: 3px; color: var(--text-soft); font-size: 10px; }
.operations-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }

.narrow-page { width: min(920px, 100%); margin: 0 auto; }
.onboarding-page { padding-top: 25px; }
.page-heading.centered { margin-bottom: 22px; text-align: center; }
.page-heading.centered p { margin-right: auto; margin-left: auto; }
.search-page { width: min(980px, 100%); }
.search-hero { display: flex; align-items: center; gap: 10px; margin: 20px 0 24px; padding: 9px 10px 9px 15px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface-solid); box-shadow: var(--shadow-sm); }
.search-hero > span { color: var(--text-faint); font-size: 24px; }
.search-hero input { min-width: 0; flex: 1; height: 42px; border: 0; outline: 0; background: transparent; font-size: 16px; }
.search-group { margin-bottom: 14px; padding: 18px; }
.search-results { display: grid; }
.search-results > a { display: flex; align-items: center; gap: 11px; padding: 10px 4px; border-bottom: 1px solid var(--border); color: var(--text); }
.search-results > a:last-child { border-bottom: 0; }
.search-results > a > span:nth-child(2) { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.search-results strong { font-size: 13px; }
.search-results small { margin-top: 2px; color: var(--text-soft); font-size: 10px; }

.auth-page { overflow-x: hidden; background: #0c1424; }
.auth-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(0, 1.2fr) minmax(420px, .8fr); }
.auth-visual { position: relative; display: flex; min-height: 100vh; overflow: hidden; flex-direction: column; justify-content: space-between; padding: clamp(36px, 6vw, 84px); color: #fff; background: radial-gradient(circle at 15% 15%, rgba(10,132,255,.55), transparent 32rem), radial-gradient(circle at 90% 95%, rgba(191,90,242,.34), transparent 31rem), linear-gradient(145deg, #0a162c, #142f58 60%, #10213e); }
.auth-visual::after { position: absolute; right: -12%; bottom: -18%; width: 58%; aspect-ratio: 1; border: 1px solid rgba(255,255,255,.16); border-radius: 35%; box-shadow: 0 0 0 50px rgba(255,255,255,.035), 0 0 0 100px rgba(255,255,255,.025); content: ""; transform: rotate(26deg); }
.auth-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; }
.auth-brand small { color: rgba(255,255,255,.62); }
.auth-hero-copy { position: relative; z-index: 1; max-width: 720px; }
.auth-hero-copy h1 { max-width: 680px; margin: 0; font-size: clamp(48px, 6vw, 82px); font-weight: 680; letter-spacing: -.06em; line-height: .98; }
.auth-hero-copy p { max-width: 620px; margin: 24px 0 0; color: rgba(255,255,255,.72); font-size: clamp(16px, 2vw, 21px); line-height: 1.5; }
.auth-feature-grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.auth-feature-grid > div { display: flex; flex-direction: column; padding: 15px; border: 1px solid rgba(255,255,255,.13); border-radius: 15px; background: rgba(255,255,255,.06); backdrop-filter: blur(15px); }
.auth-feature-grid strong { font-size: 13px; }
.auth-feature-grid span { margin-top: 3px; color: rgba(255,255,255,.58); font-size: 10px; }
.auth-form-panel { display: grid; min-height: 100vh; place-items: center; padding: 34px; background: var(--bg); }
.auth-form-card { width: min(390px, 100%); }
.auth-form-card h2 { margin: 0; font-size: 38px; letter-spacing: -.045em; }
.auth-form-card > p { margin: 8px 0 24px; }
.stack-form { display: grid; }
.stack-form label { margin: 12px 0 6px; font-size: 12px; font-weight: 650; }
.stack-form .button { margin-top: 20px; width: 100%; }
.auth-note { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: 10px; line-height: 1.5; text-align: center; }
.mobile-auth-brand { display: none; }

@media (max-width: 1500px) {
    .metric-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 1280px) {
    .dashboard-three-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .dashboard-three-grid > :last-child { grid-column: span 2; }
    .detail-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 1040px) {
    :root { --sidebar-width: 238px; }
    .dashboard-primary-grid { grid-template-columns: 1fr; }
    .chart-panel { min-height: 330px; }
    .module-directory, .operations-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .auth-shell { grid-template-columns: minmax(0,1fr) 440px; }
    .auth-feature-grid { grid-template-columns: 1fr; max-width: 300px; }
    .auth-feature-grid > div:nth-child(n+2) { display: none; }
}

@media (max-width: 900px) {
    :root { --topbar-height: 62px; }
    body.sidebar-open { overflow: hidden; }
    .sidebar { width: min(320px, 88vw); transform: translateX(-105%); box-shadow: var(--shadow-lg); transition: transform .22s cubic-bezier(.2,.8,.2,1); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 55; display: block; visibility: hidden; background: rgba(0,0,0,.25); opacity: 0; transition: opacity .2s ease, visibility .2s ease; }
    body.sidebar-open .sidebar-backdrop { visibility: visible; opacity: 1; }
    .sidebar-close, .mobile-menu { display: inline-grid !important; }
    .main-area { margin-left: 0; }
    .content-wrap { padding-bottom: 98px; }
    .mobile-tabbar { position: fixed; right: 12px; bottom: max(10px, env(safe-area-inset-bottom)); left: 12px; z-index: 50; display: grid; height: 62px; grid-template-columns: repeat(4,1fr); padding: 6px; border: 1px solid var(--border); border-radius: 20px; background: rgba(255,255,255,.86); box-shadow: 0 12px 40px rgba(0,0,0,.16); backdrop-filter: blur(26px); -webkit-backdrop-filter: blur(26px); }
    .mobile-tabbar a, .mobile-tabbar button { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 1px; border: 0; border-radius: 14px; color: var(--text-soft); background: transparent; font: inherit; }
    .mobile-tabbar a:hover, .mobile-tabbar button:hover { color: var(--accent); background: var(--accent-soft); }
    .mobile-tabbar span { font-size: 17px; }
    .mobile-tabbar small { font-size: 9px; font-weight: 650; }
    .settings-layout { grid-template-columns: 1fr; }
    .settings-nav { position: static; display: flex; overflow-x: auto; }
    .settings-nav a { white-space: nowrap; }
    .auth-shell { grid-template-columns: 1fr; background: var(--bg); }
    .auth-visual { display: none; }
    .auth-form-panel { padding: 24px; }
    .mobile-auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 40px; }
}

@media (max-width: 720px) {
    button, .button, .icon-button, .mobile-tabbar a, .mobile-tabbar button { min-height: 44px; }
    .button-small { min-height: 44px; }
    input:not([type="checkbox"]):not([type="radio"]), select { min-height: 44px; }
    .topbar { padding: 0 13px; }
    .topbar-actions > a.icon-button { display: none; }
    .global-search kbd { display: none; }
    .global-search { height: 38px; }
    .content-wrap { padding: 24px 13px 94px; }
    .page-heading-row { align-items: flex-start; flex-direction: column; margin-bottom: 19px; }
    .page-heading h1 { font-size: 31px; }
    .page-actions { width: 100%; justify-content: flex-start; }
    .page-actions .button { flex: 1; }
    .detail-actions { overflow-x: auto; flex-wrap: nowrap; justify-content: flex-start; padding-bottom: 3px; }
    .detail-actions .button { flex: 0 0 auto; }
    .metric-grid, .report-metrics { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
    .metric-card { min-height: 125px; padding: 15px; }
    .metric-card > strong { font-size: 21px; }
    .dashboard-three-grid { grid-template-columns: 1fr; }
    .dashboard-three-grid > :last-child { grid-column: auto; }
    .bar-chart { gap: 8px; padding-right: 0; padding-left: 0; }
    .bar-track { width: 64%; }
    .bar-value { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .form-field.span-2 { grid-column: auto; }
    .form-surface { padding: 18px; }
    .sticky-actions { right: 13px; bottom: 82px; left: 13px; width: auto; justify-content: stretch; }
    .sticky-actions .button { flex: 1; }
    .list-toolbar { align-items: stretch; flex-wrap: wrap; }
    .search-field { width: 100%; }
    .compact-select { flex: 1; }
    .record-count { display: none; }
    .detail-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .danger-zone { align-items: stretch; flex-direction: column; }
    .danger-zone .button { width: 100%; }
    .aging-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .aging-grid > div:last-child { grid-column: span 2; }
    .module-directory, .operations-grid { grid-template-columns: 1fr; }
    .secret-reveal { grid-template-columns: 1fr; }
    .secret-row { align-items: stretch; flex-direction: column; }
    .search-hero { align-items: stretch; flex-wrap: wrap; }
    .search-hero input { flex-basis: calc(100% - 40px); }
    .search-hero .button { width: 100%; }
    .line-editor { padding: 15px; }
}

@media (max-width: 480px) {
    .metric-grid { grid-template-columns: 1fr 1fr; }
    .metric-card > strong { font-size: 18px; }
    .detail-grid { grid-template-columns: 1fr; }
    .notification-menu { display: none; }
    .auth-form-panel { place-items: start center; padding-top: max(48px, env(safe-area-inset-top)); }
    .auth-form-card h2 { font-size: 34px; }
    .button { padding-right: 13px; padding-left: 13px; }
}

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

@media print {
    .sidebar, .topbar, .mobile-tabbar, .page-actions, .danger-zone, .message-stack, .report-tabs { display: none !important; }
    .main-area { margin: 0; }
    .content-wrap { width: 100%; padding: 0; }
    body { background: #fff; }
    .surface { break-inside: avoid; border: 0; box-shadow: none; }
}

/* Sales portal, contracts and delivery proof */
.workflow-guide { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; padding: 17px 19px; }
.workflow-guide-icon { display: grid; flex: 0 0 38px; height: 38px; place-items: center; border-radius: 12px; color: var(--accent); background: var(--accent-soft); font-size: 20px; font-weight: 750; }
.workflow-guide strong { display: block; margin-bottom: 3px; font-size: 15px; }
.workflow-guide p { margin: 0; color: var(--text-soft); }
.portal-link-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 18px; padding: 21px 23px; border-color: rgba(0,113,227,.22); background: linear-gradient(135deg, rgba(255,255,255,.94), rgba(0,113,227,.055)); }
.portal-link-card h2 { margin: 3px 0 4px; letter-spacing: -.025em; }
.portal-link-card p { max-width: 720px; margin: 0 0 11px; color: var(--text-soft); }
.portal-link-card code { display: block; max-width: min(760px, 70vw); overflow: hidden; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: rgba(255,255,255,.75); text-overflow: ellipsis; white-space: nowrap; }
.portal-link-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.file-link::before { content: "⇩ "; }
.delivery-upload-card { max-width: 780px; margin: 0 auto; padding: 24px; }
.upload-hero { display: flex; align-items: center; gap: 17px; margin-bottom: 23px; padding: 17px; border: 1px dashed rgba(0,113,227,.35); border-radius: 17px; background: var(--accent-soft); }
.upload-icon { display: grid; flex: 0 0 48px; height: 48px; place-items: center; border-radius: 14px; color: #fff; background: var(--accent); font-size: 24px; }
.upload-hero h2 { margin: 0 0 3px; letter-spacing: -.025em; }
.upload-hero p { margin: 0; color: var(--text-soft); }
.delivery-upload-card input[type="file"] { min-height: 76px; padding: 20px; border-style: dashed; background: var(--surface-muted); }

.portal-body { min-height: 100vh; background: radial-gradient(circle at 50% -10%, rgba(0,113,227,.16), transparent 34rem), #f5f5f7; }
.portal-shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 26px 0 54px; }
.portal-header { display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 16px; padding: 6px 4px 22px; }
.portal-brand { display: flex; align-items: center; gap: 11px; }
.portal-brand > span, .portal-brand > img { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; color: #fff; background: linear-gradient(145deg, #0a84ff, #005bbb); box-shadow: 0 9px 22px rgba(0,113,227,.2); object-fit: cover; font-size: 20px; font-weight: 750; }
.portal-brand > div, .portal-reference { display: flex; flex-direction: column; }
.portal-brand strong { letter-spacing: -.015em; }
.portal-brand small, .portal-reference small { color: var(--text-soft); font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.portal-reference { align-items: flex-end; }
.portal-reference strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.portal-intro { max-width: 760px; padding: 32px 4px 27px; }
.portal-eyebrow { color: var(--accent); font-size: 12px; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
.portal-intro h1, .portal-result-card h1 { margin: 8px 0 10px; font-size: clamp(36px, 6vw, 64px); line-height: 1.02; letter-spacing: -.055em; }
.portal-intro > p, .portal-result-card > p { max-width: 700px; margin: 0; color: var(--text-soft); font-size: 18px; }
.portal-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.portal-meta > div { min-width: 140px; padding: 11px 14px; border: 1px solid var(--border); border-radius: 13px; background: rgba(255,255,255,.65); }
.portal-meta small, .result-summary small { display: block; margin-bottom: 2px; color: var(--text-soft); font-size: 11px; font-weight: 650; text-transform: uppercase; }
.portal-card { margin-bottom: 16px; padding: 25px; border: 1px solid var(--border); border-radius: 24px; background: rgba(255,255,255,.9); box-shadow: var(--shadow-sm); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }
.portal-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.portal-section-heading small { color: var(--accent); font-size: 11px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.portal-section-heading h2 { margin: 2px 0 0; font-size: 25px; letter-spacing: -.035em; }
.portal-section-heading > span { padding: 5px 9px; border-radius: 999px; color: var(--text-soft); background: var(--neutral-soft); font-size: 11px; font-weight: 700; white-space: nowrap; }
.portal-lines { display: grid; gap: 2px; }
.portal-line { display: grid; grid-template-columns: minmax(220px,1fr) 150px 190px; align-items: center; gap: 18px; padding: 16px 3px; border-top: 1px solid var(--border); }
.portal-line:first-child { border-top: 0; }
.portal-line-copy, .portal-line-price { display: flex; flex-direction: column; }
.portal-line-copy strong { font-size: 16px; }
.portal-line-copy small, .portal-line-price small { color: var(--text-soft); }
.portal-line-quantity label { display: block; margin-bottom: 5px; color: var(--text-soft); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.portal-quantity { width: 100%; min-height: 43px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 11px; background: #fff; text-align: right; font-variant-numeric: tabular-nums; }
.portal-quantity:disabled { border-color: transparent; color: var(--text); background: var(--surface-muted); opacity: 1; }
.portal-line-price { align-items: flex-end; text-align: right; }
.portal-line-price strong { margin-top: 2px; font-size: 17px; font-variant-numeric: tabular-nums; }
.portal-options-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.portal-option { padding: 17px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface-muted); transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.portal-option:hover { transform: translateY(-1px); }
.portal-option.selected { border-color: rgba(0,113,227,.42); background: var(--accent-soft); }
.portal-option-selector { display: flex; min-height: 50px; align-items: flex-start; gap: 11px; cursor: pointer; }
.portal-option-selector input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.option-check { display: grid; flex: 0 0 26px; height: 26px; place-items: center; border: 1px solid var(--border-strong); border-radius: 8px; color: transparent; background: #fff; font-weight: 800; }
.portal-option-selector input:checked + .option-check { border-color: var(--accent); color: #fff; background: var(--accent); }
.portal-option-selector > span:last-child { display: flex; flex-direction: column; }
.portal-option-selector small { color: var(--text-soft); }
.portal-option-footer { display: grid; grid-template-columns: 120px 1fr; align-items: end; gap: 14px; margin-top: 17px; }
.portal-summary-card { display: flex; align-items: center; justify-content: space-between; gap: 30px; color: #fff; border-color: transparent; background: linear-gradient(135deg, #1d1d1f, #343438); }
.portal-summary-copy { display: flex; flex-direction: column; }
.portal-summary-copy small { color: rgba(255,255,255,.66); font-weight: 650; text-transform: uppercase; }
.portal-summary-copy > strong { margin: 4px 0; font-size: clamp(30px, 5vw, 49px); line-height: 1.05; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.portal-summary-copy span { color: rgba(255,255,255,.68); }
.portal-total-breakdown { min-width: 280px; }
.portal-total-breakdown > div { display: flex; justify-content: space-between; gap: 30px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.12); }
.portal-total-breakdown > div:last-child { border-bottom: 0; }
.portal-terms { margin: 0 0 16px; padding: 16px 20px; border: 1px solid var(--border); border-radius: 16px; background: rgba(255,255,255,.65); }
.portal-terms summary { cursor: pointer; font-weight: 700; }
.portal-terms > div { margin-top: 12px; color: var(--text-soft); }
.portal-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.portal-fields label { display: block; margin-bottom: 6px; font-weight: 650; }
.portal-field-wide { grid-column: 1 / -1; }
.portal-control { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 12px; color: var(--text); background: #fff; }
textarea.portal-control { min-height: 94px; resize: vertical; }
.portal-terms-check { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0; padding: 13px 14px; border-radius: 13px; background: var(--surface-muted); cursor: pointer; }
.portal-terms-check input { width: 19px; height: 19px; margin-top: 1px; accent-color: var(--accent); }
.portal-field-error { display: block; margin-top: 5px; color: var(--danger); font-size: 12px; }
.portal-error-box { margin-bottom: 14px; padding: 13px 15px; border-radius: 12px; color: var(--danger); background: var(--danger-soft); }
.portal-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.portal-button, .portal-link-button { min-height: 46px; padding: 11px 17px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 700; }
.portal-button.primary { color: #fff; background: var(--accent); }
.portal-button.pay { color: #fff; background: #16843f; }
.portal-button.secondary { color: var(--text); background: var(--surface-hover); }
.portal-link-button { color: var(--danger); background: transparent; }
.portal-payment-note { margin: 12px 0 0; color: var(--text-soft); font-size: 12px; }
.portal-footer { padding: 22px 4px 0; color: var(--text-soft); text-align: center; font-size: 12px; }
.portal-messages { margin-bottom: 12px; }
.portal-alert { padding: 12px 15px; border-radius: 12px; color: var(--success); background: var(--success-soft); }
.portal-result-shell { max-width: 860px; }
.portal-result-card { padding: clamp(28px, 6vw, 60px); border: 1px solid var(--border); border-radius: 28px; background: rgba(255,255,255,.92); box-shadow: var(--shadow-lg); text-align: center; }
.portal-result-card h1 { font-size: clamp(34px, 6vw, 56px); }
.portal-result-card > p { margin-right: auto; margin-left: auto; }
.result-icon { display: grid; width: 62px; height: 62px; place-items: center; margin: 0 auto 20px; border-radius: 50%; color: var(--text-soft); background: var(--neutral-soft); font-size: 31px; font-weight: 800; }
.result-icon.success { color: var(--success); background: var(--success-soft); }
.result-summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 28px; text-align: left; }
.result-summary > div, .payment-state, .bank-instructions { padding: 14px; border-radius: 14px; background: var(--surface-muted); }
.payment-state { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.payment-state.paid { color: var(--success); background: var(--success-soft); }
.bank-instructions { margin-top: 12px; text-align: left; }
.bank-instructions p { margin: 6px 0 0; color: var(--text-soft); }

@media (max-width: 760px) {
    .portal-link-card { align-items: stretch; flex-direction: column; }
    .portal-link-card code { max-width: 100%; }
    .portal-link-actions { width: 100%; }
    .portal-link-actions .button { flex: 1; }
    .portal-shell { width: min(100% - 20px, 1120px); padding-top: max(12px, env(safe-area-inset-top)); }
    .portal-intro { padding-top: 22px; }
    .portal-intro h1 { font-size: 41px; }
    .portal-card { padding: 18px; border-radius: 20px; }
    .portal-line { grid-template-columns: minmax(0,1fr) 110px; gap: 12px; }
    .portal-line-price { grid-column: 1 / -1; align-items: center; flex-direction: row; justify-content: space-between; }
    .portal-options-grid { grid-template-columns: 1fr; }
    .portal-summary-card { align-items: stretch; flex-direction: column; }
    .portal-total-breakdown { min-width: 0; }
    .portal-fields { grid-template-columns: 1fr; }
    .portal-field-wide { grid-column: auto; }
    .portal-actions { display: grid; grid-template-columns: 1fr; }
    .portal-button, .portal-link-button { width: 100%; }
    .result-summary { grid-template-columns: 1fr; }
    .delivery-upload-card { padding: 17px; }
}

@media (max-width: 440px) {
    .portal-reference { display: none; }
    .portal-intro h1 { font-size: 36px; }
    .portal-meta > div { flex: 1 1 130px; }
    .portal-line { grid-template-columns: 1fr; }
    .portal-line-quantity { max-width: none; }
    .portal-line-price { grid-column: auto; }
    .portal-option-footer { grid-template-columns: 1fr; }
    .portal-option-footer .portal-line-price { align-items: center; flex-direction: row; }
    .upload-hero { align-items: flex-start; }
}
.portal-result-action { margin-top: 14px; }
.payment-resume { display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.payment-resume:hover { color: #fff; }

/* Point of sale */
.pos-layout{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(330px,.75fr);gap:20px;align-items:start}.pos-products,.pos-cart{min-width:0}.pos-product-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(165px,1fr));gap:12px}.pos-product{border:1px solid var(--border);background:var(--surface);border-radius:16px;padding:16px;text-align:left;min-height:130px;display:flex;flex-direction:column;gap:6px;justify-content:flex-start;cursor:pointer;transition:.16s ease}.pos-product:hover,.pos-product:focus-visible{transform:translateY(-2px);border-color:var(--accent);box-shadow:var(--shadow-sm)}.pos-product strong{margin-top:auto;font-size:1rem}.pos-product small{color:var(--muted)}.pos-cart{position:sticky;top:84px}.pos-cart-lines{display:flex;flex-direction:column;gap:10px;max-height:42vh;overflow:auto}.pos-cart-line{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:10px;align-items:center;padding:12px 0;border-bottom:1px solid var(--border)}.pos-cart-line small{display:block;color:var(--muted)}.quantity-stepper{display:flex;align-items:center;border:1px solid var(--border);border-radius:12px;overflow:hidden}.quantity-stepper button{border:0;background:var(--surface-muted);width:34px;height:34px;font-size:18px}.quantity-stepper input{width:58px;border:0;text-align:center;padding:6px}.pos-totals{display:grid;gap:8px;padding:16px 0}.pos-totals>div{display:flex;justify-content:space-between}.pos-totals .grand{font-size:1.2rem;padding-top:10px;border-top:1px solid var(--border)}.stack-form{display:grid;gap:12px}.stack-form label{display:grid;gap:6px}.button-large{min-height:52px;font-size:1rem}.pos-close{margin-top:16px;border-top:1px solid var(--border);padding-top:14px}.pos-close summary{cursor:pointer;color:var(--muted)}.pos-receipt{margin-bottom:20px}.receipt-lines{display:grid;gap:8px;margin:14px 0}.receipt-lines>div{display:flex;justify-content:space-between}.narrow-card{max-width:720px}
@media(max-width:900px){.pos-layout{grid-template-columns:1fr}.pos-cart{position:static}.pos-product-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.pos-cart-lines{max-height:none}}
@media(max-width:520px){.pos-product-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.pos-product{min-height:112px;padding:12px}.pos-cart-line{grid-template-columns:minmax(0,1fr) auto}.pos-cart-line>strong{grid-column:1/-1;text-align:right}.quantity-stepper input{width:48px}}
@media print{.sidebar,.topbar,.mobile-tabbar,.page-heading,.pos-layout,.message-stack{display:none!important}.pos-receipt{box-shadow:none;border:0}}

/* Enterprise 2.0 command, operations and mobile execution */
.enterprise-metric-grid{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:12px;margin-bottom:20px}.enterprise-metric-grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}.enterprise-metric{min-height:132px;padding:18px;display:flex;flex-direction:column;gap:7px;border-top:3px solid var(--accent)}.enterprise-metric>span{color:var(--text-soft);font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.05em}.enterprise-metric>strong{font-size:32px;letter-spacing:-.035em}.enterprise-metric>small{margin-top:auto;color:var(--text-soft)}.enterprise-metric.tone-orange{border-top-color:#f59e0b}.enterprise-metric.tone-purple{border-top-color:#8b5cf6}.enterprise-metric.tone-red{border-top-color:#ef4444}.enterprise-metric.tone-green{border-top-color:#16a34a}.enterprise-metric.tone-gray{border-top-color:#64748b}.enterprise-grid{display:grid;gap:18px;margin-bottom:18px}.enterprise-grid.two-column{grid-template-columns:repeat(2,minmax(0,1fr))}.enterprise-grid.three-column{grid-template-columns:repeat(3,minmax(0,1fr))}.enterprise-panel{padding:20px;min-width:0}.enterprise-list{display:flex;flex-direction:column}.enterprise-row{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:12px;align-items:center;min-height:61px;padding:11px 0;border-bottom:1px solid var(--border);color:var(--text)}.enterprise-row:last-child{border-bottom:0}.enterprise-row.compact{grid-template-columns:minmax(0,1fr) auto}.enterprise-row span:not(.enterprise-badge){display:flex;min-width:0;flex-direction:column}.enterprise-row strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.enterprise-row small,.enterprise-row em{color:var(--text-soft);font-size:12px;font-style:normal}.enterprise-badge{display:inline-flex;align-items:center;justify-content:center;min-height:28px;padding:5px 9px;border-radius:999px;color:var(--accent);background:var(--accent-soft);font-size:10px;font-weight:750;letter-spacing:.04em;text-transform:uppercase}.enterprise-badge.danger{color:var(--danger);background:var(--danger-soft)}.operation-counters{display:flex;flex-wrap:wrap;gap:8px}.operation-counters>span{display:flex;align-items:center;gap:5px;min-height:42px;padding:8px 12px;border:1px solid var(--border);border-radius:13px;background:var(--surface);color:var(--text-soft);font-size:12px}.operation-counters strong{color:var(--text);font-size:18px}.mobile-filter-bar,.enterprise-search{display:grid;grid-template-columns:minmax(0,1fr) 180px auto;gap:10px;margin-bottom:16px;padding:12px}.enterprise-search{grid-template-columns:minmax(0,1fr) auto}.mobile-filter-bar input,.mobile-filter-bar select,.enterprise-search input{min-height:48px;padding:10px 13px;border:1px solid var(--border-strong);border-radius:12px;background:var(--surface);font:inherit}.mobile-task-stack{display:grid;grid-template-columns:repeat(auto-fill,minmax(310px,1fr));gap:14px}.mobile-task-card{padding:18px}.mobile-task-top,.service-card-head{display:flex;align-items:center;justify-content:space-between;gap:10px}.task-number{color:var(--text-soft);font-size:12px;font-weight:750;letter-spacing:.06em;text-transform:uppercase}.mobile-task-card h2{margin:16px 0 2px;font-size:22px}.task-sku,.task-due{margin:0;color:var(--text-soft)}.movement-route{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);gap:10px;align-items:center;margin:17px 0;padding:13px;border-radius:14px;background:var(--surface-muted)}.movement-route div{display:flex;flex-direction:column}.movement-route small{color:var(--text-soft)}.movement-route>span{color:var(--accent);font-size:22px}.task-quantity{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.task-quantity span{color:var(--text-soft)}.task-quantity strong{font-size:25px}.mobile-action{width:100%;min-height:50px;margin-top:15px}.empty-operation{padding:44px;text-align:center}.empty-operation strong{font-size:22px}.empty-operation p{color:var(--text-soft)}.trace-layout{display:grid;grid-template-columns:minmax(260px,.65fr) minmax(0,1.8fr);gap:18px;align-items:start}.trace-lot-list{position:sticky;top:84px;max-height:calc(100vh - 110px);overflow:auto;padding:18px}.trace-lot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px;border-radius:12px;color:var(--text)}.trace-lot:hover,.trace-lot.selected{background:var(--accent-soft)}.trace-lot span{display:flex;min-width:0;flex-direction:column}.trace-lot small,.trace-lot em{color:var(--text-soft);font-size:11px;font-style:normal}.trace-detail{display:flex;min-width:0;flex-direction:column;gap:18px}.trace-timeline{display:flex;flex-direction:column}.trace-event{display:grid;grid-template-columns:110px minmax(0,1fr);gap:16px;padding:14px 0;border-bottom:1px solid var(--border)}.trace-event>span{color:var(--accent);font-size:11px;font-weight:750;text-transform:uppercase}.trace-event div{display:flex;flex-direction:column}.trace-event small{color:var(--text-soft)}.responsive-table{width:100%;overflow:auto}.responsive-table table{width:100%;border-collapse:collapse}.responsive-table th,.responsive-table td{padding:11px 12px;border-bottom:1px solid var(--border);text-align:left;white-space:nowrap}.responsive-table th{color:var(--text-soft);font-size:10px;letter-spacing:.05em;text-transform:uppercase}.production-board,.service-board{display:grid;gap:12px}.production-card,.service-card{padding:16px;border:1px solid var(--border);border-radius:16px;background:var(--surface-muted)}.production-card>div:first-child{display:flex;align-items:center;justify-content:space-between}.production-card h3,.service-card h2{margin:12px 0 4px}.production-card p,.service-card p{margin:0;color:var(--text-soft)}.yield-row,.service-deadlines{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin:15px 0}.yield-row span,.service-deadlines>div{display:flex;flex-direction:column;padding:10px;border-radius:11px;background:var(--surface)}.yield-row span,.service-deadlines small{color:var(--text-soft);font-size:11px}.card-actions{display:flex;flex-wrap:wrap;gap:8px}.card-actions form{display:contents}.service-card.breached{border-color:rgba(239,68,68,.42);background:var(--danger-soft)}.machine-summary{display:flex;align-items:center;justify-content:space-between;gap:20px}.machine-summary h2{margin:4px 0}.machine-summary p{margin:0;color:var(--text-soft)}.finance-big-number{display:block;margin:18px 0 7px;font-size:34px;letter-spacing:-.04em}
@media(max-width:1380px){.enterprise-metric-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.enterprise-grid.three-column{grid-template-columns:repeat(2,minmax(0,1fr))}.enterprise-grid.three-column>:last-child{grid-column:span 2}}
@media(max-width:900px){.enterprise-grid.two-column,.enterprise-grid.three-column,.trace-layout{grid-template-columns:1fr}.enterprise-grid.three-column>:last-child{grid-column:auto}.trace-lot-list{position:static;max-height:360px}.yield-row,.service-deadlines{grid-template-columns:repeat(2,minmax(0,1fr))}.mobile-task-stack{grid-template-columns:1fr}.machine-summary{align-items:stretch;flex-direction:column}}
@media(max-width:620px){.enterprise-metric-grid,.enterprise-metric-grid.three{grid-template-columns:repeat(2,minmax(0,1fr))}.enterprise-metric{min-height:116px;padding:14px}.enterprise-metric>strong{font-size:25px}.mobile-filter-bar{grid-template-columns:1fr}.enterprise-search{grid-template-columns:1fr}.operation-counters{width:100%}.operation-counters>span{flex:1;justify-content:center}.mobile-operation-heading{gap:12px}.movement-route{grid-template-columns:1fr}.movement-route>span{transform:rotate(90deg);text-align:center}.trace-event{grid-template-columns:1fr;gap:4px}.yield-row,.service-deadlines{grid-template-columns:1fr 1fr}.card-actions{display:grid;grid-template-columns:1fr}.card-actions .button{width:100%;min-height:46px}}

/* Customer-centred coffee machine placement and profitability */
.customer-machine-heading{align-items:flex-start}.section-copy{margin:5px 0 0;color:var(--text-soft);font-size:12px}.machine-program-strip{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-bottom:16px}.machine-program-strip>div{display:flex;min-width:0;flex-direction:column;padding:13px 14px;border:1px solid var(--border);border-radius:13px;background:var(--surface-muted)}.machine-program-strip span{color:var(--text-soft);font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em}.machine-program-strip strong{margin-top:5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px}.profitability-filter{display:grid;grid-template-columns:190px 190px auto;gap:10px;align-items:end;margin:0 0 16px;padding:13px;border:1px solid var(--border);border-radius:14px;background:var(--surface-muted)}.profitability-filter .form-field{margin:0}.profitability-filter .button{min-height:44px}.customer-profitability-metrics{grid-template-columns:repeat(6,minmax(0,1fr));margin:0 0 16px}.customer-profitability-metrics .metric-card{min-height:128px;border:1px solid var(--border);box-shadow:none}.customer-profitability-metrics .profit-positive{border-top:3px solid var(--success)}.customer-profitability-metrics .profit-negative{border-top:3px solid var(--danger)}.customer-profitability-grid{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(280px,.55fr);gap:14px}.profitability-breakdown,.profitability-target-card{padding:16px;border:1px solid var(--border);border-radius:15px;background:var(--surface-muted)}.profitability-breakdown>div{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 0;border-bottom:1px solid var(--border);font-size:12px}.profitability-breakdown>div:last-child{border-bottom:0}.profitability-breakdown span{color:var(--text-soft)}.profitability-total{margin-top:4px;padding-top:12px!important;color:var(--text);font-size:14px!important}.profitability-total span{color:var(--text)!important;font-weight:700}.profitability-target-card{display:flex;flex-direction:column;gap:10px}.profitability-target-card>strong{font-size:38px;letter-spacing:-.04em}.profitability-target-card p{margin:0;color:var(--text-soft);font-size:12px;line-height:1.55}.profitability-target-card form{margin-top:4px}.profitability-target-card small{color:var(--text-faint)}.target-progress{height:9px;overflow:hidden;border-radius:999px;background:var(--neutral-soft)}.target-progress span{display:block;height:100%;border-radius:inherit;background:linear-gradient(90deg,var(--accent),#34c759)}.calculation-note{margin:13px 0 0;color:var(--text-faint);font-size:10px;line-height:1.5}.machine-row-actions{display:flex;align-items:center;gap:9px;white-space:nowrap}.machine-row-actions form{display:inline}.link-button{padding:0;border:0;background:none;color:var(--accent);font:inherit;font-size:12px;font-weight:600;cursor:pointer}.danger-link{color:var(--danger)}
@media(max-width:1180px){.machine-program-strip{grid-template-columns:repeat(2,minmax(0,1fr))}.customer-profitability-metrics{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:760px){.customer-machine-heading{flex-direction:column}.customer-machine-heading .card-actions{width:100%;display:grid;grid-template-columns:1fr}.customer-machine-heading .button{width:100%;min-height:46px}.profitability-filter{grid-template-columns:1fr}.customer-profitability-grid{grid-template-columns:1fr}.customer-profitability-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:520px){.machine-program-strip,.customer-profitability-metrics{grid-template-columns:1fr}.customer-profitability-metrics .metric-card{min-height:110px}.machine-row-actions{min-width:90px}}

.consumption-target-row { display:flex; justify-content:space-between; gap:16px; padding:10px 0; border-top:1px solid var(--border); }
.consumption-target-row span { color:var(--muted); }
.consumption-target-row strong { font-variant-numeric:tabular-nums; }
