/* ==========================================================================
   Storagile shell and list components (the inFlow-style "A" layout).
   Pages opt in by extending layouts/list_page.html or using the sg-* classes;
   older pages keep their Tailwind markup inside .sg-main-padded.
   ========================================================================== */

:root {
    --sg-rail: #1e2140;
    --sg-rail-ink: #b8bcd9;
    --sg-accent: #4f46e5;
    --sg-accent-ink: #3730a3;
    --sg-accent-soft: #eef0fb;
    --sg-ink: #1f2433;
    --sg-muted: #5f6673;
    --sg-faint: #8a909c;
    --sg-rule: #e3e6eb;
    --sg-rule-soft: #eef0f3;
    --sg-field: #cfd4dc;
    --sg-bg: #ffffff;
    --sg-bg-soft: #f7f8fa;
    --sg-low: #a15c00;
    --sg-out: #b42318;
    --sg-reorder: #f2b33d;
    --sg-rail-width: 56px;
    --sg-row: 44px;
    --sg-font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --sg-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

html { background: var(--sg-bg); }
/* Utility classes like Tailwind's `flex` would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }
body.sg-body {
    margin: 0;
    min-height: 100vh;
    background: var(--sg-bg);
    color: var(--sg-ink);
    font-family: var(--sg-font);
}

/* --- Shell --------------------------------------------------------------- */

.sg-content {
    margin-left: var(--sg-rail-width);
    min-height: 100vh;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.sg-main-padded { padding: 24px; background: #f9fafb; flex: 1; }

.sg-progress {
    position: fixed;
    top: 0;
    left: var(--sg-rail-width);
    right: 0;
    height: 2px;
    z-index: 60;
    background: linear-gradient(90deg, transparent, var(--sg-accent), transparent);
    background-size: 50% 100%;
    animation: sg-progress 1s linear infinite;
}
@keyframes sg-progress {
    from { background-position: -50% 0; }
    to { background-position: 150% 0; }
}

.sg-rail {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--sg-rail-width);
    background: var(--sg-rail);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 0;
    box-sizing: border-box;
}
.sg-rail-logo {
    width: 32px;
    height: 32px;
    margin-bottom: 10px;
    border-radius: 8px;
    background: var(--sg-accent);
    color: #ffffff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.sg-rail-spacer { flex: 1; }
.sg-rail-item { position: relative; }
.sg-rail-link {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sg-rail-ink);
}
.sg-rail-link:hover,
.sg-rail-item:focus-within .sg-rail-link { background: #2c3058; color: #ffffff; }
.sg-rail-item.is-active .sg-rail-link { background: var(--sg-accent); color: #ffffff; }
.sg-rail-link:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }

/* Hover or keyboard focus opens the group's flyout; the padding bridges the
   gap so the pointer can travel from icon to menu without it closing. */
.sg-rail-flyout {
    position: absolute;
    left: 100%;
    top: -4px;
    padding-left: 10px;
    display: none;
    flex-direction: column;
    min-width: 190px;
}
.sg-rail-item:hover .sg-rail-flyout,
.sg-rail-item:focus-within .sg-rail-flyout { display: flex; }
.sg-rail-flyout-panel {
    display: flex;
    flex-direction: column;
    padding-bottom: 6px;
    background: #ffffff;
    border: 1px solid var(--sg-rule);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(20, 24, 40, 0.14);
}
.sg-rail-flyout-title {
    padding: 10px 14px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--sg-muted);
}
.sg-rail-flyout-title:only-child { padding-bottom: 4px; }
.sg-rail-flyout a {
    display: block;
    padding: 7px 14px;
    font-size: 13px;
    color: var(--sg-ink);
    text-decoration: none;
    white-space: nowrap;
}
.sg-rail-flyout a:hover,
.sg-rail-flyout a:focus-visible { background: var(--sg-accent-soft); color: var(--sg-accent-ink); outline: none; }
.sg-rail-flyout a.is-active { color: var(--sg-accent); font-weight: 600; }

/* --- Page header and toolbar -------------------------------------------- */

.sg-page { display: flex; flex-direction: column; min-width: 0; flex: 1; font-size: 13px; }
.sg-page #messages-region:not(:empty) { padding: 10px 16px 0; }
.sg-page-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px 6px;
}
.sg-page-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--sg-accent); }
.sg-page-meta { font-size: 12px; color: var(--sg-muted); }

.sg-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 16px 10px;
    border-bottom: 1px solid var(--sg-rule);
}
.sg-toolbar-spacer { flex: 1; }

.sg-search {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    width: 260px;
    max-width: 100%;
    padding: 0 8px;
    border: 1px solid var(--sg-field);
    border-radius: 6px;
    background: #ffffff;
    color: var(--sg-muted);
    box-sizing: border-box;
}
.sg-search:focus-within { border-color: var(--sg-accent); box-shadow: 0 0 0 1px var(--sg-accent); }
.sg-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    padding: 0;
    background: transparent;
    font: 13px var(--sg-font);
    color: var(--sg-ink);
}
.sg-search input:focus { box-shadow: none; }
.sg-search .sg-icon { width: 14px; height: 14px; flex-shrink: 0; }

.sg-chip,
.sg-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--sg-field);
    border-radius: 6px;
    background: #ffffff;
    color: var(--sg-ink);
    font: 13px var(--sg-font);
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    box-sizing: border-box;
}
.sg-chip:hover,
.sg-btn:hover { border-color: #aeb4bf; }
.sg-chip:focus-visible,
.sg-btn:focus-visible { outline: 2px solid var(--sg-accent); outline-offset: 1px; }
.sg-chip .sg-icon,
.sg-btn .sg-icon { width: 14px; height: 14px; }
select.sg-chip { max-width: 190px; padding-right: 28px; text-overflow: ellipsis; }
select.sg-chip:focus { box-shadow: none; border-color: var(--sg-accent); }
.sg-chip.is-set,
select.sg-chip.is-set { border-color: var(--sg-accent); color: var(--sg-accent-ink); background-color: var(--sg-accent-soft); }

/* A checkbox styled as a chip: <label class="sg-chip-toggle"><input type="checkbox"><span>Label</span></label> */
.sg-chip-toggle { position: relative; display: inline-flex; }
.sg-chip-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sg-chip-toggle span {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--sg-field);
    border-radius: 6px;
    background: #ffffff;
    font-size: 13px;
    cursor: pointer;
    box-sizing: border-box;
}
.sg-chip-toggle input:checked + span { background: var(--sg-accent); border-color: var(--sg-accent); color: #ffffff; font-weight: 500; }
.sg-chip-toggle input:focus-visible + span { outline: 2px solid var(--sg-accent); outline-offset: 1px; }

.sg-btn-primary { background: var(--sg-accent); border-color: var(--sg-accent); color: #ffffff; font-weight: 600; }
.sg-btn-primary:hover { background: var(--sg-accent-ink); border-color: var(--sg-accent-ink); color: #ffffff; }
.sg-btn-outline { border-color: var(--sg-accent); color: var(--sg-accent); font-weight: 500; }
.sg-btn-outline:hover { background: var(--sg-accent-soft); border-color: var(--sg-accent); }
.sg-btn-reorder { background: var(--sg-reorder); border-color: var(--sg-reorder); font-weight: 600; }
.sg-btn-reorder:hover { background: #e6a52c; border-color: #e6a52c; }

/* Dropdown menu (Columns chooser). */
.sg-menu { position: relative; }
.sg-menu-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 30;
    min-width: 200px;
    padding: 6px 0;
    background: #ffffff;
    border: 1px solid var(--sg-rule);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(20, 24, 40, 0.12);
}
.sg-menu-panel label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
}
.sg-menu-panel label:hover { background: var(--sg-bg-soft); }
.sg-menu-panel a { display: block; padding: 6px 12px; color: var(--sg-ink); font-size: 13px; text-decoration: none; }
.sg-menu-panel a:hover { background: var(--sg-bg-soft); }
/* A <details> menu: the summary is the button, the panel shows while open. */
details.sg-menu > summary { list-style: none; }
details.sg-menu > summary::-webkit-details-marker { display: none; }
details.sg-menu:not([open]) > .sg-menu-panel { display: none; }
.sg-actionbar > .sg-print-menu { margin-right: auto; }

/* --- Compact list table ------------------------------------------------- */

.sg-list { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sg-table-wrap { overflow-x: auto; }
.sg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.sg-table th {
    height: 32px;
    padding: 0 10px;
    border-bottom: 1px solid var(--sg-rule);
    color: var(--sg-muted);
    font-size: 12px;
    font-weight: 400;
    text-align: left;
    white-space: nowrap;
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 1;
}
.sg-table th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 2px; }
.sg-table th a:hover { color: var(--sg-ink); }
.sg-table th[aria-sort] a { color: var(--sg-ink); font-weight: 500; }
.sg-table th .sg-icon { width: 12px; height: 12px; }
.sg-table th .sg-sort-idle { opacity: 0; }
.sg-table th a:hover .sg-sort-idle { opacity: 0.6; }
.sg-table td {
    height: var(--sg-row);
    padding: 0 10px;
    border-bottom: 1px solid var(--sg-rule-soft);
    vertical-align: middle;
}
.sg-table th:first-child,
.sg-table td:first-child { padding-left: 16px; }
.sg-table th:last-child,
.sg-table td:last-child { padding-right: 16px; }
.sg-table tbody tr:hover { background: #fafbfd; }
.sg-table tr.is-inactive td { color: var(--sg-faint); }
.sg-table .sg-num { text-align: right; white-space: nowrap; }
.sg-table .sg-nowrap { white-space: nowrap; }

.sg-item { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sg-item-text { min-width: 0; line-height: 1.25; }
.sg-item-name {
    display: block;
    max-width: 420px;
    font-weight: 600;
    color: var(--sg-ink);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
a.sg-item-name:hover { color: var(--sg-accent); }
.sg-item-name-plain { font-weight: 400; max-width: 280px; }
.sg-item-sub { font: 11px var(--sg-mono); color: var(--sg-muted); white-space: nowrap; }
.sg-item-sub.sg-sans { font-family: var(--sg-font); }
.sg-item-sub .sg-extra { font-family: var(--sg-font); color: var(--sg-accent); margin-left: 6px; }

.sg-thumb {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 4px;
    object-fit: cover;
    background: var(--sg-bg-soft);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.sg-thumb-empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--sg-faint);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.sg-tag {
    display: inline-block;
    max-width: 200px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--sg-accent-soft);
    color: #3b3f8f;
    font-size: 11px;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}
a.sg-tag:hover { background: #e0e3f8; }

.sg-link { color: var(--sg-accent); text-decoration: none; }
.sg-link:hover { text-decoration: underline; }
.sg-link-btn { border: 0; background: none; padding: 0 4px; color: var(--sg-accent); font: 13px var(--sg-font); cursor: pointer; white-space: nowrap; }
.sg-link-btn:hover { text-decoration: underline; }
.sg-unit { color: var(--sg-faint); font-size: 11px; font-weight: 400; }
.sg-mono { font-family: var(--sg-mono); font-size: 12px; color: var(--sg-muted); }
.sg-qty-strong { font-weight: 600; }
.sg-qty-low { color: var(--sg-low); }
.sg-qty-out { color: var(--sg-out); }
.sg-qty-in { color: #067647; }
.sg-dim { color: var(--sg-faint); }

.sg-list-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 16px;
    font-size: 12px;
    color: var(--sg-muted);
}
.sg-pager { display: flex; gap: 6px; }

.sg-empty { padding: 48px 16px; text-align: center; color: var(--sg-muted); }
.sg-empty strong { display: block; color: var(--sg-ink); font-size: 14px; margin-bottom: 4px; }

@media (max-width: 640px) {
    .sg-search { width: 100%; }
    .sg-item-name { max-width: 220px; }
}

/* --- Split page: list pane + detail ------------------------------------- */

.sg-split { display: flex; min-height: 100vh; font-size: 13px; }
.sg-sidelist {
    width: 290px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--sg-rule);
    background: #ffffff;
}
.sg-sidelist-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px; }
.sg-sidelist-head .sg-page-title { text-decoration: none; }
.sg-sidelist-search { padding: 4px 12px 10px; border-bottom: 1px solid var(--sg-rule); }
.sg-sidelist-search .sg-search { width: 100%; }
.sg-sidelist-rows { flex: 1; overflow-y: auto; }
.sg-side-row {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--sg-row);
    padding: 0 12px;
    border-bottom: 1px solid var(--sg-rule-soft);
    color: var(--sg-ink);
    text-decoration: none;
}
.sg-side-row:hover { background: #fafbfd; }
.sg-side-row.is-current { background: var(--sg-accent-soft); box-shadow: inset 3px 0 0 var(--sg-accent); }
.sg-side-row .sg-item-name { max-width: 220px; }
.sg-side-row .sg-item-sub { display: block; }

.sg-detail { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sg-detail #messages-region:not(:empty) { padding: 10px 28px 0; }
.sg-actionbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--sg-rule-soft);
}
.sg-actionbar form { margin: 0; }
.sg-btn-icon { width: 30px; padding: 0; justify-content: center; }
.sg-btn-quiet { border-color: transparent; background: transparent; color: var(--sg-muted); }
.sg-btn-quiet:hover { border-color: var(--sg-field); }
.sg-btn-danger { color: var(--sg-out); }
.sg-btn-danger:not(.sg-btn-quiet) { border-color: #f1b8b2; }

.sg-order-head { display: flex; flex-direction: column; gap: 12px; }
.sg-order-head .sg-attributes { border-top: 0; padding-top: 0; }
.sg-attributes a { color: var(--sg-accent); text-decoration: none; }
.sg-attributes a:hover { text-decoration: underline; }
.sg-grow { flex: 1; }
.sg-block { display: block; }
.sg-side-meta { flex-shrink: 0; font-size: 11px; color: var(--sg-muted); }
.sg-order-cards { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.sg-order-card-grid {
    flex: 999 1 640px;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    align-items: start;
}
.sg-order-cards > :last-child { flex: 1 1 260px; min-width: 0; }

/* .sg-compact tightens older Tailwind cards and form fields placed inside
   the new layout (order pages) without rewriting their markup. */
.sg-compact .shadow { box-shadow: 0 0 0 1px var(--sg-rule); }
.sg-compact [data-header-card] > div:first-child,
.sg-compact .bg-white > .border-b:first-child { padding: 10px 16px; }
.sg-compact [data-header-card] > div + div { padding: 12px 16px; }
.sg-compact h2.text-base, .sg-compact h3.text-base { font-size: 14px; }
.sg-compact .gap-y-5 { row-gap: 10px; }
.sg-compact dt.text-sm, .sg-compact label.text-sm, .sg-compact .text-sm.font-medium.text-gray-500 { font-size: 12px; }
.sg-compact input:not([type="checkbox"]):not([type="radio"]):not([type="search"]),
.sg-compact select,
.sg-compact textarea { padding-top: 4px; padding-bottom: 4px; font-size: 13px; }
.sg-inline-form { display: inline; margin: 0; }
.sg-inline-note { display: inline-flex; align-items: center; gap: 6px; }
.sg-badge-warn { background: #fdf1dc; color: #8a5300; }
.sg-detail-body { display: flex; flex-direction: column; gap: 18px; padding: 20px 28px 40px; width: 100%; box-sizing: border-box; }

.sg-hero { display: flex; gap: 24px; align-items: flex-start; }
.sg-photo {
    width: 140px;
    height: 140px;
    flex-shrink: 0;
    border-radius: 10px;
    background: #f2f3f6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: var(--sg-faint);
    font-size: 44px;
    font-weight: 600;
    text-transform: uppercase;
}
.sg-photo img { width: 100%; height: 100%; object-fit: contain; }
.sg-hero-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.sg-hero-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.sg-hero-title h1 { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 700; color: #2a3a8f; }
.sg-hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 24px; }
.sg-facts { margin: 0; display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 6px 10px; }
.sg-facts dt { color: var(--sg-muted); }
.sg-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.sg-description { color: #3d4350; line-height: 1.5; }
.sg-attributes {
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px 16px;
    padding-top: 10px;
    border-top: 1px solid var(--sg-rule-soft);
}
.sg-attributes dt { font-size: 11px; color: var(--sg-muted); }
.sg-attributes dd { margin: 0; overflow-wrap: anywhere; }
.sg-mono-ink { font-family: var(--sg-mono); font-size: 12px; }

.sg-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f2f3f6;
    color: var(--sg-muted);
    font-size: 11px;
    font-weight: 500;
    vertical-align: middle;
}
.sg-badge-soft { background: var(--sg-accent-soft); color: #3b3f8f; }

.sg-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-self: flex-start;
    padding: 3px;
    border-radius: 999px;
    background: #f2f3f6;
}
.sg-tabs a {
    padding: 6px 14px;
    border-radius: 999px;
    color: #3d4350;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}
.sg-tabs a:hover { background: #e7e9ee; }
.sg-tabs a[aria-current="page"] { background: var(--sg-accent); color: #ffffff; }
.sg-count { font-weight: 400; opacity: 0.75; margin-left: 2px; }

.sg-overview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.sg-stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sg-card {
    background: var(--sg-bg-soft);
    border-radius: 10px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sg-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.sg-card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.sg-card-head a { font-size: 12px; color: var(--sg-accent); text-decoration: none; }
.sg-card-head a:hover { text-decoration: underline; }
.sg-card a:not(.sg-btn) { color: var(--sg-accent); }

.sg-bignum { display: flex; flex-wrap: wrap; gap: 6px 20px; align-items: baseline; }
.sg-bignum > span:first-child { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sg-bignum small { font-size: 14px; font-weight: 400; color: var(--sg-muted); }
.sg-bar-row { display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.sg-bar-label { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.sg-bar-label strong { font-weight: 600; }
.sg-bar { height: 8px; border-radius: 4px; background: #e3e6eb; overflow: hidden; }
.sg-bar > div { height: 100%; border-radius: 4px; background: #3d5bc9; }

.sg-kv-grid { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sg-kv-grid dt { font-size: 11px; color: var(--sg-muted); }
.sg-kv-grid dd { margin: 0; font-weight: 600; }
.sg-kv-rows { margin: 0; display: flex; flex-direction: column; }
.sg-kv-rows > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--sg-rule); font-variant-numeric: tabular-nums; }
.sg-kv-rows > div:last-child { border-bottom: 0; }
.sg-kv-rows dd { margin: 0; }
.sg-kv-total { margin-top: 4px; }
.sg-kv-total dt { color: var(--sg-muted); }

.sg-mini-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sg-mini-table th { text-align: left; font-size: 11px; font-weight: 500; color: var(--sg-muted); padding: 4px 0; border-bottom: 1px solid var(--sg-rule); }
.sg-mini-table td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--sg-rule); vertical-align: middle; }
.sg-mini-table tr:last-child td { border-bottom: 0; }
.sg-mini-table .sg-num { text-align: right; padding-right: 0; }

.sg-summary {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 28px;
    padding: 12px 18px;
    border-radius: 10px;
    background: var(--sg-bg-soft);
    font-variant-numeric: tabular-nums;
}
.sg-summary dt { font-size: 11px; color: var(--sg-muted); }
.sg-summary dd { margin: 0; font-size: 16px; font-weight: 600; }

.sg-progress-cell { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.sg-progress-cell .sg-bar { width: 72px; height: 6px; }

.sg-hint { margin: 0; font-size: 12px; color: var(--sg-muted); }
.sg-note-warn { margin: 0; padding: 8px 10px; border-radius: 6px; background: #fdf1dc; color: #8a5300; font-size: 12px; }

@media (max-width: 1100px) {
    .sg-overview { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
    .sg-sidelist { display: none; }
    .sg-hero { flex-direction: column; }
    .sg-hero-grid { grid-template-columns: minmax(0, 1fr); }
    .sg-detail-body { padding: 16px; }
}

/* --- Toasts ------------------------------------------------------------ */

.sg-toasts {
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 70;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(420px, calc(100vw - 32px));
}
.sg-toast {
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--sg-ink);
    color: #ffffff;
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(20, 24, 40, 0.2);
    transition: opacity 0.3s;
}
.sg-toast-error { background: #8f1d14; }
.sg-toast.is-leaving { opacity: 0; }

/* --- HTMX loading indicator (legacy spinners) ---------------------------- */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}
.sg-progress.htmx-request { display: block; }

/* Spinner animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.animate-spin {
    animation: spin 1s linear infinite;
}

/* Print styles */
@media print {
    .no-print { display: none !important; }
    .sg-content { margin-left: 0; }
}

/* Small right-aligned number field for editable table cells (reorder points, order quantities). */
.sg-num-input {
    width: 6.5rem;
    padding: 4px 8px;
    border: 1px solid var(--sg-field);
    border-radius: 6px;
    background: var(--sg-bg);
    color: var(--sg-ink);
    font: inherit;
    font-size: 13px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.sg-num-input::placeholder { color: var(--sg-faint); }
.sg-num-input:focus { outline: 2px solid var(--sg-accent); outline-offset: -1px; border-color: var(--sg-accent); }
.sg-num-input.is-dirty { background: #fffbeb; font-weight: 600; }

/* Reorder screen. */
.sg-reorder-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 8px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--sg-rule);
    border-radius: 8px;
    background: var(--sg-bg-soft);
    font-size: 13px;
    color: var(--sg-muted);
}
.sg-reorder-bar strong { color: var(--sg-ink); }
.sg-table .sg-check { width: 32px; padding-right: 0; }
.sg-cell-select {
    max-width: 14rem;
    padding: 4px 24px 4px 8px;
    border: 1px solid var(--sg-field);
    border-radius: 6px;
    background-color: var(--sg-bg);
    color: var(--sg-ink);
    font: inherit;
    font-size: 13px;
}
.sg-cell-select.is-missing { border-color: var(--sg-out); color: var(--sg-out); }
.sg-cell-select:focus { outline: 2px solid var(--sg-accent); outline-offset: -1px; }

/* Filters above a table inside an item tab (Movement / Order history). */
.sg-tab-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sg-segmented {
    display: inline-flex;
    gap: 0;
    border: 1px solid var(--sg-field);
    border-radius: 6px;
    overflow: hidden;
    width: max-content;
    max-width: 100%;
}
.sg-segmented a {
    padding: 4px 12px;
    font-size: 13px;
    color: var(--sg-ink);
    text-decoration: none;
    border-left: 1px solid var(--sg-field);
}
.sg-segmented a:first-child { border-left: 0; }
.sg-segmented a:hover { background: var(--sg-bg-soft); }
.sg-segmented a[aria-current="page"] { background: var(--sg-accent-soft); color: var(--sg-accent-ink); font-weight: 600; }

/* Loader row at the end of a list; replaced by the next page as it scrolls into view. */
.sg-table tr.sg-more-row td { text-align: center; padding: 14px; color: var(--sg-muted); cursor: pointer; }

/* List pages fill the window: the title and filter strip stay put and the
   list scrolls under its sticky header (the table wrapper must not become a
   scroll container itself, or the header would stick to it instead). */
.sg-page:has(> #list-results) { flex: none; height: 100vh; height: 100dvh; }
#list-results.sg-list { flex: 1; min-height: 0; overflow: auto; }
#list-results.sg-list .sg-table-wrap { overflow: visible; }

/* Dashboard: clickable key figures, then panels that link into each screen. */
.sg-dash-body { padding: 4px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.sg-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sg-kpi {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    border: 1px solid var(--sg-rule);
    border-radius: 10px;
    background: var(--sg-bg);
    color: var(--sg-ink);
    text-decoration: none;
    font-variant-numeric: tabular-nums;
}
.sg-kpi:hover { border-color: var(--sg-accent); }
.sg-kpi:focus-visible { outline: 2px solid var(--sg-accent); outline-offset: 1px; }
.sg-kpi-label { font-size: 12px; color: var(--sg-muted); }
.sg-kpi-value { font-size: 22px; font-weight: 600; line-height: 1.2; }
.sg-kpi-sub { font-size: 11px; color: var(--sg-faint); }
.sg-kpi.is-warn { border-left: 3px solid var(--sg-reorder); }
.sg-kpi.is-alert { border-left: 3px solid var(--sg-out); }
.sg-kpi.is-alert .sg-kpi-value { color: var(--sg-out); }
.sg-dash-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.sg-dash-panels .sg-card p { margin: 0; font-size: 13px; }
.sg-table-plain td { padding: 7px 8px; }
.sg-table-plain tr:last-child td { border-bottom: 0; }
.sg-table-plain td:first-child { padding-left: 0; }
.sg-table-plain td:last-child { padding-right: 0; }

/* A list toolbar inside a detail page (warehouse locations). */
.sg-toolbar-inset { padding-left: 0; padding-right: 0; border-bottom: 0; }
.sg-toolbar-title { margin: 0 8px 0 0; font-size: 15px; font-weight: 600; }
.sg-flags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.sg-locations { display: flex; flex-direction: column; }

/* Label/value rows edited in place: fields look like text until hovered or focused. */
.sg-fields { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 14px; align-items: center; }
.sg-fields > div { display: contents; }
.sg-fields dt { font-size: 12px; color: var(--sg-muted); }
.sg-fields dd { margin: 0; min-width: 0; }
.sg-fields .sg-fields-wide dt { align-self: start; padding-top: 6px; }
.sg-inline {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--sg-ink);
    font: inherit;
    font-size: 13px;
}
.sg-inline:hover { border-color: var(--sg-field); background: var(--sg-bg); }
.sg-inline:focus { outline: 2px solid var(--sg-accent); outline-offset: -1px; background: var(--sg-bg); }
.sg-inline::placeholder { color: var(--sg-faint); }
textarea.sg-inline { resize: vertical; }
.sg-inline-unit { display: flex; align-items: center; gap: 4px; }
.sg-inline-num { width: 5rem; text-align: right; }
.sg-small { font-size: 12px; }
.sg-address { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--sg-rule-soft); font-size: 13px; }
.sg-address:first-of-type { border-top: 0; }
.sg-address p { margin: 0; }
.sg-address-actions { display: flex; align-items: flex-start; gap: 2px; }
.sg-address-actions form { margin: 0; }
.sg-fields-read { gap: 8px 14px; font-size: 13px; align-items: baseline; }
.sg-mono { font-family: var(--sg-mono); font-size: 12px; }
.sg-prewrap { white-space: pre-wrap; }
.sg-table tfoot td { border-bottom: 0; padding-top: 6px; padding-bottom: 2px; }
.sg-buildable { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 20px; font-size: 13px; }
.sg-buildable > div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--sg-rule-soft); padding: 4px 0; }

/* Item Inventory tab: steppers, location rows and the save bar. */
.sg-stack { display: flex; flex-direction: column; gap: 12px; }
.sg-card-flush .sg-table-wrap { margin: 0 -2px; }
.sg-stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--sg-field); border-radius: 6px; overflow: hidden; background: var(--sg-bg); }
.sg-stepper button { border: 0; background: var(--sg-bg-soft); color: var(--sg-muted); padding: 0 9px; font: inherit; cursor: pointer; }
.sg-stepper button:hover { background: var(--sg-rule-soft); color: var(--sg-ink); }
.sg-stepper button:disabled { opacity: 0.4; cursor: default; }
.sg-stepper input {
    width: 5.5rem; border: 0; border-left: 1px solid var(--sg-field); border-right: 1px solid var(--sg-field);
    padding: 4px 8px; text-align: right; font: inherit; font-size: 13px; font-variant-numeric: tabular-nums;
    -moz-appearance: textfield; appearance: textfield;
}
.sg-stepper input::-webkit-inner-spin-button, .sg-stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.sg-stepper input:focus { outline: 2px solid var(--sg-accent); outline-offset: -2px; }
.sg-stepper input.is-dirty { background: #fffbeb; font-weight: 600; }
.sg-tag-muted { background: var(--sg-rule-soft); color: var(--sg-muted); }
.sg-tag-warn { background: #fdf1dc; color: #8a5300; }
.sg-tag-alert { background: #fde7e5; color: var(--sg-out); }
.sg-new-location { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sg-new-location .sg-cell-select { max-width: none; min-width: 12rem; }
.sg-grow { flex: 1; }
.sg-btn-accent { color: var(--sg-accent); }
.sg-savebar {
    position: sticky; bottom: 0; z-index: 2;
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
    padding: 10px 12px; margin-bottom: env(safe-area-inset-bottom, 0px);
    border: 1px solid #c7c4f5; border-radius: 10px; background: var(--sg-bg);
    box-shadow: 0 6px 20px rgba(31, 36, 51, 0.12);
    font-size: 13px;
}
.sg-savebar p { margin: 0; }
.sg-savebar-reason { flex: 1; min-width: 12rem; padding: 6px 8px; border: 1px solid var(--sg-field); border-radius: 6px; font: inherit; font-size: 13px; }

/* Stock counts */
.sg-page-form { max-width: 760px; }
.sg-form-card { display: flex; flex-direction: column; gap: 14px; padding: 4px 16px 24px; }
.sg-form-fields { gap: 10px 16px; }
.sg-form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.sg-input {
    width: 100%;
    min-height: 30px;
    padding: 5px 8px;
    border: 1px solid var(--sg-field);
    border-radius: 6px;
    background: var(--sg-bg);
    color: var(--sg-ink);
    font: 13px var(--sg-font);
    box-sizing: border-box;
}
.sg-input:focus { outline: 2px solid var(--sg-accent); outline-offset: -1px; border-color: var(--sg-accent); }
.sg-multi { margin-top: 6px; padding: 4px; }
.sg-add-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sg-add-line .sg-input { width: auto; min-width: 160px; flex: 0 1 220px; }
.sg-summary-bar { flex: 1 1 160px; min-width: 120px; }
.sg-summary-bar dd { padding-top: 8px; }
.sg-count-table tr.is-counted td { background: #f6fbf8; }
.sg-count-loc-inline { display: none; }
@media (max-width: 640px) {
    .sg-count-table .sg-count-loc, .sg-count-table .sg-thumb { display: none; }
    .sg-count-loc-inline { display: inline; }
    .sg-count-table .sg-count-input { width: 4.5rem; }
    .sg-count-table .sg-count-diff { display: none; }
    .sg-count-table .sg-item-name { white-space: normal; }
    .sg-count-table tr.is-off td { background: #fdf3f2; }
    .sg-count-table td, .sg-count-table th { padding-left: 6px; padding-right: 6px; }
}

/* Pick screen and shipping station */
.sg-pick-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 4px 16px 10px; }
.sg-scan-form { flex: 1 1 320px; display: flex; }
.sg-scan { flex: 1; height: 40px; }
.sg-scan input { font-size: 15px; }
.sg-pick-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 4px 16px 10px; font-size: 13px; }
.sg-pick-progress .sg-bar { flex: 0 1 240px; }
.sg-pick-progress .sg-btn { margin-left: auto; }
.sg-thumb-lg { width: 40px; height: 40px; }
.sg-wrap { white-space: normal; }
.sg-pick-table tr.is-current td { background: var(--sg-accent-soft); }
.sg-pick-table tr.is-counted td { background: #f6fbf8; }
.sg-pick-table tr.is-flash td { animation: sg-flash 1s ease-out; }
.sg-pick-table .sg-pick-loc { font-size: 14px; font-weight: 600; color: var(--sg-ink); }
.sg-pick-input { width: 5rem; }
@keyframes sg-flash { from { background: #fff3c4; } }
@media (max-width: 640px) {
    .sg-pick-table .sg-thumb { display: none; }
    .sg-pick-table td, .sg-pick-table th { padding-left: 6px; padding-right: 6px; }
}
.sg-ship-page { padding-bottom: 32px; }
.sg-ship-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; padding: 0 16px; align-items: start; }
.sg-ship-columns .sg-toolbar-title { margin: 14px 0 6px; }
.sg-ship-left .sg-card { margin-bottom: 4px; }
.sg-card-title { margin: 0; font-size: 13px; font-weight: 600; color: var(--sg-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.sg-ship-done { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 16px 10px; padding: 10px 14px; border-radius: 8px; background: #e7f6ee; color: #075e35; }
.sg-ship-done .sg-btn { margin-left: auto; }
.sg-ship-alert { display: flex; align-items: center; gap: 8px; margin: 0 16px 8px; }
.sg-box-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.sg-box-card { position: relative; cursor: pointer; }
.sg-box-card input { position: absolute; opacity: 0; }
.sg-box-card span { display: flex; flex-direction: column; gap: 2px; padding: 7px 9px; border: 1px solid var(--sg-field); border-radius: 6px; background: var(--sg-bg); font-size: 12px; }
.sg-box-card small { color: var(--sg-muted); font-size: 11px; }
.sg-box-card input:checked + span { border-color: var(--sg-accent); background: var(--sg-accent-soft); box-shadow: inset 0 0 0 1px var(--sg-accent); }
.sg-box-card input:focus-visible + span { outline: 2px solid var(--sg-accent); }
.sg-dims { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sg-dims label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--sg-muted); }
.sg-dims .sg-input { width: 5.5rem; }
.sg-weight { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.sg-weight .sg-input { width: 8rem; font-size: 18px; min-height: 40px; }
.sg-btn-big { height: 40px; font-size: 14px; justify-content: center; }
.sg-manual-ship { font-size: 12px; color: var(--sg-muted); }
.sg-manual-ship summary { cursor: pointer; padding: 4px 0; }
.sg-manual-ship[open] { display: flex; flex-direction: column; gap: 8px; }
.sg-rates-form { max-width: 620px; margin: 0 16px; }
.sg-rate { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--sg-field); border-radius: 6px; background: var(--sg-bg); cursor: pointer; }
.sg-rate:has(input:checked) { border-color: var(--sg-accent); background: var(--sg-accent-soft); }
.sg-rate-name { flex: 1; }
.sg-rate-price { font-weight: 600; font-variant-numeric: tabular-nums; }
.sg-buying { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.8); font-size: 18px; font-weight: 600; }
.sg-buying[hidden] { display: none; }
@media (max-width: 900px) { .sg-ship-columns { grid-template-columns: minmax(0, 1fr); } }
.sg-btn:disabled, .sg-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.sg-scale { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--sg-muted); }
.sg-scale .sg-btn { margin-left: auto; }
.sg-scale-dot { width: 8px; height: 8px; border-radius: 50%; background: #ced4da; flex: none; }
.sg-scale-dot.ok { background: #0e7c4a; }
.sg-scale-dot.motion { background: #a8480b; animation: sg-pulse 0.8s ease-in-out infinite; }
.sg-scale-dot.err { background: #b3261e; }
@keyframes sg-pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .sg-scale-dot.motion { animation: none; } }
.sg-scale-reading { font-weight: 600; color: var(--sg-ink); font-variant-numeric: tabular-nums; }
.sg-input.is-scale-filled { background: #d1e7dd; transition: background-color 0.1s; }
.sg-autobuy-hint { margin: 0; font-size: 12px; font-weight: 600; color: #0e7c4a; }
.sg-box-actions { display: flex; flex-wrap: wrap; gap: 10px 24px; padding: 0 16px 12px; }
.sg-small-input { width: 5rem; flex: none !important; min-width: 0 !important; }
.sg-pad { padding: 0 16px; }
.sg-box-edit .sg-menu-panel { left: auto; right: 0; width: 280px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.sg-box-edit-form label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--sg-muted); }
.sg-check { flex-direction: row !important; align-items: center; gap: 6px !important; }
.sg-add-line .sg-small-input { width: 5rem; }
.sg-new-key code { padding: 4px 8px; background: #ffffff; border-radius: 4px; word-break: break-all; }
.sg-report-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; padding: 0 16px; }
.sg-report-card { text-decoration: none; color: inherit; }
.sg-report-card h2 { margin: 0; font-size: 15px; color: var(--sg-accent); }
.sg-report-card p { margin: 0; font-size: 13px; color: var(--sg-muted); }
.sg-report-card:hover { box-shadow: inset 0 0 0 1px var(--sg-accent); }
.sg-report-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 0 16px 10px; }
.sg-report-head .sg-summary { flex: 1; }
.sg-date { border: 0; background: transparent; font: inherit; color: inherit; padding: 0; }
.sg-labels-menu .sg-menu-panel { left: auto; right: 0; width: 240px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.sg-savebar-why { width: auto; flex: 0 0 auto; }

/* --- Older pages ---------------------------------------------------------
   Pages still built from Tailwind utility classes (forms, settings) render
   inside .sg-main-padded. These rules bring them to the compact look of the
   rest of the app; the .sg-main-padded prefix makes them win over Tailwind's
   utilities, which load after this stylesheet. */
.sg-main-padded { padding: 10px 16px 32px; font-size: 13px; }
.sg-main-padded .space-y-6 > * + * { margin-top: 14px; }
.sg-main-padded h1.text-2xl, .sg-main-padded h1.text-xl { font-size: 16px; line-height: 1.3; font-weight: 600; color: var(--sg-accent); }
.sg-main-padded h1 + p.text-sm, .sg-main-padded .mt-1.text-sm.text-gray-500 { font-size: 12px; margin-top: 2px; }
.sg-main-padded h2.text-base, .sg-main-padded h3.text-base { font-size: 14px; }
.sg-main-padded div.shadow, .sg-main-padded div.shadow-sm, .sg-main-padded a.shadow-sm, .sg-main-padded section.shadow { box-shadow: none; }
.sg-main-padded .bg-white.shadow, .sg-main-padded .bg-white.shadow-sm { background: var(--sg-bg); border: 1px solid var(--sg-rule); }
.sg-main-padded .sm\:rounded-lg, .sg-main-padded .rounded-lg { border-radius: 8px; }
.sg-main-padded .px-4.py-5, .sg-main-padded .sm\:px-6.py-5 { padding: 10px 16px; }
.sg-main-padded .gap-y-5 { row-gap: 10px; }
.sg-main-padded .gap-x-6 { column-gap: 16px; }
.sg-main-padded .p-6 { padding: 14px 16px; }
.sg-main-padded label.block.text-sm, .sg-main-padded label.text-sm.font-medium { font-size: 12px; font-weight: 500; color: var(--sg-muted); margin-bottom: 3px; }
.sg-main-padded input:not([type=checkbox]):not([type=radio]):not([type=file]), .sg-main-padded select, .sg-main-padded textarea {
    min-height: 30px; padding-top: 5px; padding-bottom: 5px; font-size: 13px; line-height: 1.35; border-radius: 6px;
}
.sg-main-padded textarea { min-height: 60px; }
.sg-main-padded .text-sm { font-size: 13px; }
.sg-main-padded table.min-w-full th { padding-top: 6px; padding-bottom: 6px; font-size: 11px; }
.sg-main-padded table.min-w-full td { padding-top: 7px; padding-bottom: 7px; }
.sg-main-padded button.rounded-md, .sg-main-padded a.rounded-md.px-3, .sg-main-padded a.rounded-md.px-4 { padding-top: 6px; padding-bottom: 6px; font-size: 13px; }
.sg-settings-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px 24px; padding: 0 16px; align-items: start; }
.sg-settings-groups section { display: flex; flex-direction: column; }
.sg-settings-groups .sg-card-title { margin-bottom: 6px; }
.sg-settings-row { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; border-bottom: 1px solid var(--sg-rule-soft); text-decoration: none; color: var(--sg-ink); }
.sg-settings-row:hover { background: var(--sg-bg-soft); }
.sg-settings-row strong { font-weight: 600; color: var(--sg-accent); }
.sg-settings-row span { font-size: 12px; color: var(--sg-muted); }

/* The X that closes an open record and goes back to its list. */
.sg-detail { position: relative; }
.sg-detail-close {
    position: absolute; top: 9px; left: 12px; z-index: 11;
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%;
    color: var(--sg-muted); background: var(--sg-bg-soft); text-decoration: none;
}
.sg-detail-close:hover { color: var(--sg-ink); background: #e3e6eb; }
.sg-detail-close:focus-visible { outline: 2px solid var(--sg-accent); outline-offset: 1px; }
.sg-detail .sg-actionbar { padding-left: 52px; }

/* Warehouses that open to show their locations (item Overview and Inventory tabs). */
.sg-wh-group > summary { list-style: none; cursor: pointer; border-radius: 6px; margin: 0 -6px; padding: 4px 6px; }
.sg-wh-group > summary::-webkit-details-marker { display: none; }
.sg-wh-group > summary .sg-bar-label > span:first-child::before { content: "▸"; display: inline-block; width: 1em; color: var(--sg-muted); transition: transform 0.15s; }
.sg-wh-group[open] > summary .sg-bar-label > span:first-child::before { transform: rotate(90deg); }
.sg-wh-group > summary:hover { background: #eef0f4; }
.sg-wh-locations { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 8px 1em; padding-left: 10px; border-left: 2px solid var(--sg-rule); }
.sg-bar-thin { height: 5px; }
.sg-wh-card > summary { list-style: none; cursor: pointer; }
.sg-wh-card > summary::-webkit-details-marker { display: none; }
.sg-wh-card > summary h2::before { content: "▸"; display: inline-block; width: 1em; color: var(--sg-muted); transition: transform 0.15s; }
.sg-wh-card[open] > summary h2::before { transform: rotate(90deg); }

/* Clickable rows ([data-row-links]): the whole row opens the record. */
.sg-table[data-row-links] tbody tr:has(a.sg-item-name[href], a[data-row-link]) { cursor: pointer; }

/* --- Editing in place (core/inline.py) ----------------------------------
   Fields read as text until hovered or focused, like inFlow. A changed field
   is tinted, and the action bar swaps its buttons for Save / Cancel. */
.sg-in {
    width: calc(100% + 7px);
    box-sizing: border-box;
    min-height: 26px;
    margin: -3px 0 -3px -7px;
    padding: 2px 6px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: 1.4;
    -webkit-appearance: none;
    appearance: none;
    resize: none;
    text-overflow: ellipsis;
}
.sg-in::placeholder { color: var(--sg-faint); opacity: 1; }
.sg-in:hover { border-color: var(--sg-rule); background-color: #fff; }
.sg-in:focus { outline: none; border-color: var(--sg-accent); background-color: #fff; box-shadow: 0 0 0 2px var(--sg-accent-soft); }
.sg-in:disabled { cursor: default; border-color: transparent; background-color: transparent; }
select.sg-in { padding-right: 22px; cursor: pointer; }
select.sg-in:hover, select.sg-in:focus, .sg-modal select.sg-in, .sg-dialog select.sg-in {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235f6673' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}
.sg-in.is-changed, .sg-in.is-changed:hover { background-color: #fff8e1; }
.sg-in.is-saved { background-color: #e6f4ea; transition: background-color 0.6s; }
textarea.sg-in { display: block; overflow: hidden; }
.sg-in-title { font-size: 26px; font-weight: 700; line-height: 1.2; color: #2a3a8f; }
/* The order number edited in place: as big as the heading (outweighs .sg-compact input:not(…)). */
.sg-doc-id h1 input.sg-in-title:not([type="checkbox"]):not([type="radio"]):not([type="search"]) { font-size: inherit; width: min(100%, 20ch); }
.sg-hero-title h1 { min-width: 0; }
.sg-in-num { text-align: right; font-variant-numeric: tabular-nums; }
.sg-in-button { display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer; }
.sg-in-button > :first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-in-edit { margin-left: auto; color: var(--sg-accent); font-size: 12px; opacity: 0; }
.sg-in-button:hover .sg-in-edit, .sg-in-button:focus .sg-in-edit { opacity: 1; }
.sg-in-pair { display: flex; gap: 6px; }
.sg-in-pair .sg-in:first-child { flex: 0 0 3.2rem; width: 3.2rem; }
.sg-in-pair .sg-in + .sg-in { margin-left: 0; width: auto; flex: 1; }
.sg-in-error { margin-top: 4px; color: var(--sg-out); font-size: 12px; }
.sg-facts-edit { align-items: center; row-gap: 4px; }
.sg-facts-edit dt label { cursor: pointer; }
.sg-description .sg-in { min-height: 60px; }
.sg-attributes-edit dt label { cursor: pointer; }
.sg-attributes-edit dd { margin-top: 2px; }
.sg-attributes-manage { display: flex; align-items: flex-end; font-size: 12px; }
.sg-check-input { accent-color: var(--sg-accent); }
.sg-price-rows dd { flex: 0 0 9rem; }
.sg-price-rows .sg-in { width: 9rem; margin: -3px -7px -3px 0; }
.sg-remarks { margin-top: 18px; }
.sg-remarks h2 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.sg-remarks .sg-in { min-height: 40px; }

.sg-save-group { display: flex; align-items: center; gap: 6px; margin-right: auto; }
.sg-save-note { color: var(--sg-low); font-size: 12px; margin-right: 4px; }
.sg-actionbar.is-dirty > :not(.sg-save-group) { display: none; }

/* A dialog whose fields belong to the page's form: Update keeps the changes
   (still unsaved), Cancel puts them back. */
.sg-dialog {
    width: min(440px, calc(100vw - 32px));
    box-sizing: border-box;
    padding: 20px 24px;
    border: 0;
    border-radius: 10px;
    box-shadow: 0 20px 50px rgba(20, 24, 40, 0.25);
    color: var(--sg-ink);
    font: 13px var(--sg-font);
}
.sg-dialog::backdrop { background: rgba(20, 24, 40, 0.35); }
.sg-dialog h2 { margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--sg-rule); font-size: 14px; font-weight: 600; }
.sg-dialog h2 + .sg-dialog-grid { margin-bottom: 16px; }
.sg-dialog-grid { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px 12px; align-items: center; }
.sg-dialog .sg-in { width: 100%; margin: 0; border-color: var(--sg-field); background-color: #fff; min-height: 30px; }
.sg-dialog .sg-in:disabled { color: var(--sg-muted); background-color: var(--sg-bg-soft); }
.sg-dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Centered modal (partials/_modal.html), loaded into #modal-container. */
.sg-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 8vh 16px;
    overflow-y: auto;
    background: rgba(20, 24, 40, 0.35);
}
.sg-modal { font: 13px/1.45 var(--sg-font); color: var(--sg-ink); width: min(560px, 100%); border-radius: 10px; background: #fff; box-shadow: 0 20px 50px rgba(20, 24, 40, 0.25); }
.sg-modal-form { margin: 0; }
.sg-modal-body { display: flex; flex-direction: column; gap: 12px; padding: 20px 24px; }
.sg-modal-body h2 { margin: 0; font-size: 16px; font-weight: 600; }
.sg-modal-body p { margin: 0; }
.sg-modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px; border-top: 1px solid var(--sg-rule-soft); background: var(--sg-bg-soft); border-radius: 0 0 10px 10px; }
.sg-cf-rows { display: flex; flex-direction: column; }
.sg-cf-row {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) 120px auto;
    gap: 6px 8px;
    align-items: center;
    margin: 0;
    padding: 8px 0;
    border: 0;
    border-bottom: 1px solid var(--sg-rule-soft);
}
.sg-cf-row.is-inactive .sg-input:first-of-type { color: var(--sg-muted); }
.sg-cf-options { grid-column: 2 / -1; }
.sg-cf-remove { cursor: pointer; color: var(--sg-muted); font-size: 18px; line-height: 1; text-align: center; }
.sg-cf-remove input { position: absolute; opacity: 0; pointer-events: none; }
.sg-cf-row:has(.sg-cf-remove input:checked) > :not(.sg-cf-remove) { opacity: 0.4; text-decoration: line-through; }
.sg-cf-row:has(.sg-cf-remove input:checked) .sg-cf-remove { color: var(--sg-out); }
.sg-fields-edit { gap: 4px 14px; font-size: 13px; }
.sg-fields-edit dt label { cursor: pointer; }
.sg-fields-edit .sg-in-pair .sg-check { flex: 0 0 auto; white-space: nowrap; }
.sg-fields-edit .sg-in-pair .sg-check + .sg-in { flex: 1; width: auto; margin-left: 4px; }
.sg-fields-edit textarea.sg-in { min-height: 40px; }
.sg-compact .sg-in { padding-top: 2px; padding-bottom: 2px; }
.sg-compact .sg-in-title { font-size: 26px; }
.sg-inline-unit .sg-in { flex: 0 0 5rem; width: 5rem; }
.sg-in[type="number"] { -moz-appearance: textfield; }
.sg-in[type="number"]::-webkit-inner-spin-button, .sg-in[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.sg-attributes-wide { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.sg-attr-span2 { grid-column: span 2; }
.sg-dialog p { margin: 0 0 12px; }
@media (max-width: 640px) { .sg-attr-span2 { grid-column: auto; } }
.sg-modal .sg-in { width: 100%; margin: 0; border-color: var(--sg-field); background-color: #fff; min-height: 30px; }
.sg-modal .sg-in-title { font-size: 13px; font-weight: 400; color: inherit; }
.sg-req { color: var(--sg-out); }

/* --- Older slide-over modals, shown as centered modals ------------------
   Forms in #modal-container that still use the Tailwind slide-over markup
   (partials/_form_modal.html and its copies) render like partials/_modal.html:
   centered, compact fields, the footer on a soft band. */
#modal-backdrop.fixed { overflow-y: auto; font: 13px/1.45 var(--sg-font); color: var(--sg-ink); }
#modal-backdrop.fixed > .absolute.inset-0 { position: fixed; background: rgba(20, 24, 40, 0.35); opacity: 1; }
#modal-backdrop.fixed > .fixed.inset-y-0 {
    position: relative;
    inset: auto;
    min-height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 8vh 16px;
    box-sizing: border-box;
    pointer-events: none;
}
#modal-backdrop.fixed .w-screen.max-w-lg,
#modal-backdrop.fixed .w-screen.max-w-md,
#modal-backdrop.fixed .w-screen.max-w-xl,
#modal-backdrop.fixed .w-screen.max-w-2xl { width: min(560px, 100%); max-width: 560px; pointer-events: auto; }
#modal-backdrop.fixed .w-screen.max-w-2xl { width: min(720px, 100%); max-width: 720px; }
#modal-backdrop.fixed .h-full.flex-col { height: auto; border-radius: 10px; box-shadow: 0 20px 50px rgba(20, 24, 40, 0.25); overflow: hidden; }
#modal-backdrop.fixed .flex-1.overflow-y-auto { flex: none; overflow: visible; padding: 16px 24px; }
#modal-backdrop.fixed .border-b.px-6.py-4 { border-bottom: 0; padding: 20px 24px 0; }
#modal-backdrop.fixed h2.text-lg { font-size: 16px; font-weight: 600; }
#modal-backdrop.fixed .border-t.px-6.py-4 { padding: 12px 24px; border-top: 1px solid var(--sg-rule-soft); background: var(--sg-bg-soft); }
#modal-backdrop.fixed .space-y-5 > * + *, #modal-backdrop.fixed .space-y-6 > * + * { margin-top: 12px; }
#modal-backdrop.fixed label.text-sm { font-size: 12px; color: var(--sg-muted); font-weight: 500; margin-bottom: 4px; }
#modal-backdrop.fixed input:not([type="checkbox"]):not([type="radio"]),
#modal-backdrop.fixed select,
#modal-backdrop.fixed textarea {
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 13px;
    box-shadow: 0 0 0 1px var(--sg-field);
}
#modal-backdrop.fixed input:focus, #modal-backdrop.fixed select:focus, #modal-backdrop.fixed textarea:focus { box-shadow: 0 0 0 2px var(--sg-accent); outline: none; }
#modal-backdrop.fixed .border-t button, #modal-backdrop.fixed .border-t a { font-size: 13px; padding: 5px 12px; }
#modal-backdrop.fixed .border-t button[type="submit"] { background: var(--sg-accent); }
.sg-row-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.sg-row-item { display: flex; align-items: center; gap: 6px; }
.sg-row-item .sg-in { flex: 1; }
.sg-row-remove, .sg-star { border: 0; background: none; padding: 2px 6px; cursor: pointer; font-size: 16px; line-height: 1; color: var(--sg-faint); }
.sg-row-remove:hover { color: var(--sg-out); }
.sg-star:hover { color: var(--sg-reorder); }
.sg-row-list > :first-child .sg-star { color: var(--sg-reorder); cursor: default; }
.sg-pick { position: relative; }
.sg-pick-results:empty { display: none; }
.sg-pick-list { position: absolute; left: 0; right: 0; z-index: 5; margin-top: 4px; max-height: 260px; overflow-y: auto; border: 1px solid var(--sg-rule); border-radius: 6px; background: #fff; box-shadow: 0 8px 24px rgba(20, 24, 40, 0.15); }
.sg-pick-option { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 6px 10px; border: 0; border-bottom: 1px solid var(--sg-rule-soft); background: none; text-align: left; font: inherit; cursor: pointer; }
.sg-pick-option:hover, .sg-pick-option:focus { background: var(--sg-accent-soft); outline: none; }
.sg-pick-name { font-weight: 500; }
.sg-pick-option .sg-dim { font-size: 12px; }
.sg-pick-empty { margin-top: 4px; font-size: 12px; color: var(--sg-muted); }
.sg-order-foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 16px; align-items: start; }
@media (max-width: 900px) { .sg-order-foot { grid-template-columns: minmax(0, 1fr); } }
.sg-order-totals .sg-kv-total { font-weight: 600; }
.sg-badge-ok { background: #e6f4ec; color: #18794e; }
.sg-money-in { display: flex; }
.sg-money-in .sg-in { text-align: right; }

/* --- Order and transfer pages, inFlow style ------------------------------
   A plain header (status, title, a timeline), the lines as a light table
   with steppers and menus, and a search box under them that adds an item in
   one click (partials/lines/_search.html). */
.sg-doc-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 320px); gap: 16px 32px; align-items: start; padding-bottom: 16px; border-bottom: 1px solid var(--sg-rule); }
.sg-doc-id { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.sg-doc-id h1 { margin: 2px 0 0; font-size: 24px; font-weight: 700; line-height: 1.2; color: #2a3a8f; }
.sg-doc-id p { margin: 0; font-size: 13px; }
.sg-doc-notes { margin-top: 6px !important; color: var(--sg-ink); white-space: pre-line; }
@media (max-width: 700px) { .sg-doc-head { grid-template-columns: minmax(0, 1fr); } }

.sg-timeline { list-style: none; margin: 0; padding: 0; }
.sg-timeline li { position: relative; display: flex; flex-direction: column; padding: 0 0 10px 22px; font-size: 13px; }
.sg-timeline li::before { content: ""; position: absolute; left: 3px; top: 4px; width: 8px; height: 8px; border: 2px solid var(--sg-field); border-radius: 50%; background: #fff; }
.sg-timeline li:not(:last-child)::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 2px; background: var(--sg-rule); }
.sg-timeline li.is-done::before { border-color: var(--sg-accent); background: var(--sg-accent); }
.sg-timeline li.is-done:not(:last-child)::after { background: var(--sg-accent); }
.sg-timeline-label { font-weight: 600; }
.sg-timeline li:not(.is-done) .sg-timeline-label { color: var(--sg-faint); font-weight: 500; }
.sg-timeline-when { color: var(--sg-muted); font-size: 12px; }

.sg-lines-wrap { display: flex; flex-direction: column; gap: 12px; }
.sg-lines { width: 100%; }
.sg-lines td { padding-top: 8px; padding-bottom: 8px; vertical-align: middle; }
.sg-lines .sg-item-name { max-width: 420px; }
.sg-lines tr.is-short td { background: #fff7ed; }
.sg-lines-empty { margin: 4px 0; font-size: 13px; }
.sg-thumb-md { width: 32px; height: 32px; }
.sg-line-x { width: 28px; text-align: right; }
.sg-x { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: #fde8e8; color: var(--sg-out); font-size: 15px; line-height: 22px; cursor: pointer; opacity: 0.55; }
.sg-lines tr:hover .sg-x, .sg-x:focus { opacity: 1; }
.sg-line-warn { margin-top: 2px; color: var(--sg-low); font-size: 11px; }

.sg-qty-cell { display: inline-flex; align-items: center; gap: 4px; }
.sg-qstep { display: inline-flex; align-items: center; gap: 2px; }
.sg-qstep .sg-in { width: 4.5rem; margin: 0; text-align: center; }
.sg-qstep-btn { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 4px; background: #4a5578; color: #fff; font-size: 14px; line-height: 20px; cursor: pointer; opacity: 0; transition: opacity 0.1s; }
.sg-lines tr:hover .sg-qstep-btn, .sg-qstep:focus-within .sg-qstep-btn { opacity: 1; }
.sg-qstep-btn:hover { background: var(--sg-accent); }

.sg-qty-badge { flex-shrink: 0; padding: 1px 6px; border-radius: 4px; background: #e9ebef; color: var(--sg-ink); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sg-qty-badge.is-zero { background: var(--sg-bg-soft); color: var(--sg-faint); font-weight: 400; }

.sg-line-search { position: relative; max-width: 640px; }
.sg-line-search-box { width: 100%; height: 34px; }
.sg-line-results:empty { display: none; }
.sg-line-list { position: absolute; left: 0; right: 0; z-index: 25; margin-top: 4px; max-height: 360px; overflow-y: auto; border: 1px solid var(--sg-rule); border-radius: 8px; background: #fff; box-shadow: 0 8px 24px rgba(20, 24, 40, 0.15); }
.sg-line-option { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; border: 0; border-bottom: 1px solid var(--sg-rule-soft); background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.sg-line-option:hover, .sg-line-option:focus { background: var(--sg-accent-soft); outline: none; }
.sg-line-option-name { display: block; font-size: 13px; font-weight: 600; }
.sg-line-option .sg-price { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--sg-muted); white-space: nowrap; }
.sg-line-none { padding: 10px 12px; font-size: 13px; color: var(--sg-muted); }

.sg-loc-btn { display: inline-block; max-width: 220px; padding: 2px 8px; border-radius: 4px; background: var(--sg-accent-soft); color: #2a3a8f; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; cursor: pointer; }
.sg-loc-btn:hover, .sg-loc-menu[open] > .sg-loc-btn { background: #dfe3fa; }
.sg-loc-panel { width: 300px; padding: 6px 0 0; }
.sg-loc-filter { width: calc(100% - 12px); margin: 0 6px 4px; border-color: var(--sg-field); }
.sg-loc-list { max-height: 280px; overflow-y: auto; }
.sg-loc-head { display: flex; justify-content: space-between; padding: 2px 12px 4px; color: var(--sg-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.sg-loc-option { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 6px 12px; border: 0; background: none; text-align: left; font: inherit; font-size: 13px; color: inherit; cursor: pointer; }
.sg-loc-option:hover, .sg-loc-option:focus { background: var(--sg-accent-soft); outline: none; }
.sg-loc-option.is-current { font-weight: 600; box-shadow: inset 3px 0 0 var(--sg-accent); }
.sg-loc-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-loc-name .sg-tag { margin-left: 4px; }
.sg-loc-note { margin: 0; padding: 6px 12px 8px; color: var(--sg-muted); font-size: 12px; }
.sg-item-sub .sg-tag, .sg-item-sub .sg-sans { font-family: var(--sg-font); }
.sg-qstep .sg-in { width: 3.25rem; }
.sg-lines .sg-line-money .sg-in, .sg-lines .sg-line-pct .sg-in { width: 5.5rem; margin: 0; }
.sg-line-pct { display: inline-flex; align-items: center; gap: 2px; }
.sg-line-pct .sg-in { width: 3.5rem !important; }
.sg-line-unit select.sg-in { width: auto; margin: 0; }
.sg-line-note { color: var(--sg-faint); font-size: 11px; }
.sg-line-total { font-weight: 600; }
.sg-line-status { padding: 0 5px; border-radius: 3px; background: #e9ebef; color: var(--sg-muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.03em; }
.sg-line-status.is-backordered { background: #fff1db; color: var(--sg-low); }
.sg-line-status.is-fulfilled { background: #e7f6ee; color: #075e35; }

/* Sales order header: who and what (number, facts), the customer with addresses, terms and balance. */
.sg-doc-head-3 { grid-template-columns: minmax(200px, 1fr) minmax(240px, 1.3fr) minmax(220px, 1fr); }
@media (max-width: 1100px) { .sg-doc-head-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (max-width: 700px) { .sg-doc-head-3 { grid-template-columns: minmax(0, 1fr); } }
.sg-doc-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 6px 0 0; font-size: 13px; align-items: baseline; }
.sg-doc-facts > div { display: contents; }
.sg-doc-facts dt { color: var(--sg-muted); }
.sg-doc-facts dd { margin: 0; min-width: 0; }
.sg-doc-party { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding-top: 4px; font-size: 13px; }
.sg-doc-party-name { font-size: 15px; font-weight: 600; color: var(--sg-accent-ink); text-decoration: none; }
.sg-doc-party-name:hover { text-decoration: underline; }
.sg-doc-address { display: block; margin-top: 6px; line-height: 1.45; white-space: normal; }
.sg-doc-address.sg-in-button { display: flex; align-items: flex-start; height: auto; }
.sg-doc-address.sg-in-button > :first-child { white-space: normal; }
.sg-doc-address-label { display: block; margin-top: 4px; color: var(--sg-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.sg-doc-address-label:first-child { margin-top: 0; }
.sg-landed-in { display: inline-flex; align-items: center; gap: 4px; }
.sg-landed-in .sg-in { width: 6.5rem; margin: 0; }
.sg-landed-in select.sg-in { width: auto; }
.sg-receipt + .sg-receipt { border-top: 1px solid var(--sg-rule); padding-top: 8px; }
.sg-receipt-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 4px; }

/* --- Item page tabs in the order-page style (Selling SKUs, Vendors, Units, Costing) --- */
.sg-tab-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.sg-tab-head p { margin: 0; }
.sg-sku-table td { vertical-align: top; }
.sg-sku-cell { min-width: 220px; }
.sg-sku-in { font-family: var(--sg-mono); font-size: 12px; font-weight: 600; }
.sg-sku-name { display: block; margin-top: 2px !important; color: var(--sg-muted); font-size: 12px; }
.sg-lines select.sg-in { width: auto; margin: 0; }
.sg-lines td > .sg-in:not(select) { min-width: 7rem; }
.sg-toggle { padding: 1px 7px; border: 0; border-radius: 4px; background: var(--sg-rule-soft); color: var(--sg-muted); font: 11px var(--sg-font); cursor: pointer; }
.sg-toggle.is-on { background: #e7f6ee; color: #075e35; }
.sg-toggle:hover { box-shadow: inset 0 0 0 1px var(--sg-field); }
.sg-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 5px; color: var(--sg-muted); vertical-align: middle; }
.sg-icon-btn:hover { background: var(--sg-accent-soft); color: var(--sg-accent); }
.sg-icon-btn .sg-icon { width: 15px; height: 15px; }
.sg-line-x.sg-nowrap { width: 60px; }
.sg-in-short { max-width: 5rem; min-width: 0 !important; }
.sg-add-pick select.sg-in { width: auto; margin: 0; color: var(--sg-accent); cursor: pointer; }
.sg-vendor-links .sg-star { margin-right: 4px; }
.sg-star.is-on { color: #e6a52c; }
.sg-unit-add { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.sg-unit-add .sg-in { width: auto; margin: 0; border-color: var(--sg-field); background: #fff; }
.sg-unit-add select.sg-in { color: var(--sg-accent); }
.sg-layer-bar { width: 80px; height: 3px; margin: 3px 0 0 auto; border-radius: 2px; background: var(--sg-rule); overflow: hidden; }
.sg-layer-bar span { display: block; height: 100%; background: #2f9e6b; }
.sg-used-layers > summary { list-style: none; cursor: pointer; display: inline-block; }
.sg-used-layers > summary::-webkit-details-marker { display: none; }
.sg-used-layers[open] > summary { margin-bottom: 6px; }
/* Item Inventory tab: the same quiet inputs and − / + as order lines (changes still save together with Save). */
#inventory-adjust-form .sg-stepper { gap: 2px; align-items: center; border: 0; background: none; overflow: visible; }
#inventory-adjust-form .sg-stepper button { width: 20px; height: 20px; padding: 0; border-radius: 4px; background: #4a5578; color: #fff; font-size: 14px; line-height: 20px; opacity: 0; transition: opacity 0.1s; }
#inventory-adjust-form tr:hover .sg-stepper button, #inventory-adjust-form .sg-stepper:focus-within button, #inventory-adjust-form .sg-new-location .sg-stepper button { opacity: 1; }
#inventory-adjust-form .sg-stepper button:hover { background: var(--sg-accent); color: #fff; }
#inventory-adjust-form .sg-stepper button:disabled { opacity: 0 !important; }
#inventory-adjust-form .sg-stepper input,
#inventory-adjust-form .sg-num-input { width: 5rem; padding: 2px 6px; border: 1px solid transparent; border-radius: 5px; background: transparent; text-align: right; font-size: 13px; }
#inventory-adjust-form .sg-stepper input:hover, #inventory-adjust-form .sg-num-input:hover { border-color: var(--sg-rule); background: #fff; }
#inventory-adjust-form .sg-stepper input:focus, #inventory-adjust-form .sg-num-input:focus { outline: none; border-color: var(--sg-accent); background: #fff; box-shadow: 0 0 0 2px var(--sg-accent-soft); }
#inventory-adjust-form .is-dirty { background: #fff8e1 !important; }
.sg-sku-table .sg-line-money .sg-in { width: 4.5rem; }
.sg-sku-cell { min-width: 170px; }
.sg-sku-table td > .sg-in:not(select) { min-width: 0; width: 8.5rem; }
.sg-sku-table .sg-sku-cell > .sg-in { width: 100%; }
.sg-sku-table th, .sg-sku-table td { padding-left: 6px; padding-right: 6px; }
.sg-vendor-links .sg-item-name { display: inline; }

/* --- Customer page, laid out like inFlow's: contact details beside the balance and custom fields,
   then addresses and preferences beside purchasing info. --- */
.sg-party-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 420px); gap: 16px 40px; align-items: start; padding-bottom: 16px; border-bottom: 1px solid var(--sg-rule); }
.sg-contact-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; margin: 0; }
.sg-contact-grid dt { margin-bottom: 2px; font-size: 12px; font-weight: 600; color: var(--sg-ink); }
.sg-contact-grid dd { margin: 0; font-size: 13px; }
.sg-party-side { display: flex; flex-direction: column; gap: 12px; }
.sg-balance-card { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin: 0; padding: 12px 16px; border-radius: 10px; background: #e7f3f1; }
.sg-balance-card dt { font-size: 12px; font-weight: 600; color: #134e48; }
.sg-balance-card dd { margin: 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sg-custom-facts { margin: 0; }
.sg-custom-facts dt { font-weight: 600; color: var(--sg-ink); }
.sg-manage-fields { align-self: flex-start; padding: 0; }
.sg-party-overview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.sg-section-title { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.sg-party-overview .sg-card .sg-doc-facts { margin-top: 0; }
.sg-address-list { list-style: none; margin: 0 0 6px; padding: 0; }
.sg-address-list li { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--sg-rule-soft); font-size: 13px; }
.sg-address-type { font-weight: 600; }
.sg-address-list address { font-style: normal; line-height: 1.45; }
.sg-address-actions { display: flex; align-items: flex-start; gap: 4px; opacity: 0.4; }
.sg-address-list li:hover .sg-address-actions { opacity: 1; }
.sg-aging { display: flex; gap: 12px; align-items: stretch; }
.sg-aging .sg-summary { margin: 0; }
.sg-aging-total { grid-template-columns: 1fr; min-width: 160px; align-content: center; }
@media (max-width: 1000px) {
    .sg-party-top, .sg-party-overview { grid-template-columns: minmax(0, 1fr); }
    .sg-address-list li { grid-template-columns: minmax(0, 1fr) auto; }
    .sg-address-type { grid-column: 1 / -1; }
}
.sg-party-overview .sg-in-pair { display: flex; align-items: center; gap: 8px; }
.sg-party-overview .sg-check { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.sg-address-save { display: flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 13px; }
.sg-address-clear { margin-right: auto; }

/* Sales order header: the customer with their billing address, then shipping (like inFlow). */
.sg-party-contact { display: flex; flex-direction: column; font-size: 13px; line-height: 1.45; }
.sg-party-contact a { color: inherit; }
.sg-order-address { margin-top: 10px; font-size: 13px; }
.sg-order-address address, address.sg-doc-address { font-style: normal; line-height: 1.45; }
.sg-order-address .sg-doc-address { margin-top: 2px; }
.sg-add-address { padding: 0; }
.sg-doc-ship { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; font-size: 13px; }
.sg-doc-ship .sg-doc-facts { margin-top: 0; }
.sg-doc-ship-state { margin: 0; font-weight: 600; }
.sg-switch { display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; font: inherit; font-size: 13px; color: var(--sg-ink); cursor: pointer; }
.sg-switch > span { position: relative; width: 28px; height: 16px; border-radius: 8px; background: var(--sg-field); transition: background 0.15s; flex-shrink: 0; }
.sg-switch > span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.sg-switch.is-on > span { background: #e6a52c; }
.sg-switch.is-on > span::after { transform: translateX(12px); }
.sg-switch:disabled { opacity: 0.5; cursor: default; }

/* Quantity on order and transfer lines: centred, so the heading sits over the number like inFlow's. */
.sg-lines th.sg-qty-col, .sg-lines td.sg-qty-col { text-align: center; white-space: nowrap; }
.sg-lines td.sg-qty-col .sg-qty-cell { justify-content: center; }
.sg-lines td.sg-qty-col .sg-line-note, .sg-lines td.sg-qty-col .sg-line-warn { text-align: center; }

/* A sales line's discount: % or $ off each unit, like inFlow. */
.sg-disc { display: inline-flex; align-items: center; gap: 6px; }
.sg-disc .sg-in { width: 4.5rem !important; margin: 0; }
.sg-disc-kind { display: inline-flex; border: 1px solid var(--sg-field); border-radius: 5px; overflow: hidden; }
.sg-disc-kind button { width: 22px; height: 22px; padding: 0; border: 0; background: #fff; color: var(--sg-muted); font: 600 12px var(--sg-font); cursor: pointer; }
.sg-disc-kind button + button { border-left: 1px solid var(--sg-field); }
.sg-disc-kind button.is-on { background: #4a5578; color: #fff; cursor: default; }
.sg-disc-kind button:not(.is-on):hover { background: var(--sg-accent-soft); color: var(--sg-accent); }

/* --- Sales order steps and picking, like inFlow (sales/partials/_order_steps.html, _order_pick_panel.html) --- */
.sg-steps { display: flex; align-items: center; align-self: center; gap: 0; padding: 4px; border-radius: 24px; background: var(--sg-bg-soft); }
.sg-step { display: inline-flex; align-items: center; gap: 8px; padding: 4px 14px 4px 4px; border: 0; border-radius: 20px; background: none; color: var(--sg-muted); font: inherit; text-decoration: none; text-align: left; line-height: 1.15; cursor: pointer; }
.sg-step strong { display: block; font-size: 13px; color: var(--sg-ink); }
.sg-step small { display: block; font-size: 11px; color: var(--sg-muted); }
.sg-step-dot { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--sg-rule); color: var(--sg-muted); font-size: 11px; font-weight: 700; }
.sg-step.is-done .sg-step-dot { background: #2f9e6b; color: #fff; }
.sg-step.is-current { background: #fff; box-shadow: 0 1px 3px rgba(20, 24, 40, 0.12); }
.sg-step.is-current .sg-step-dot { background: var(--sg-accent); color: #fff; }
.sg-step.is-off { cursor: default; opacity: 0.55; }
a.sg-step:hover, .sg-step-start:hover { background: #fff; }
.sg-step-start small { color: var(--sg-accent); font-weight: 600; }
.sg-step-line { width: 24px; height: 2px; background: var(--sg-rule); }

.sg-pick-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border: 1px solid #bfe5d3; border-radius: 20px; background: #f1faf6; font-size: 13px; }
.sg-pick-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: #2f9e6b; }
.sg-pick-scan .sg-search { width: 100%; max-width: 640px; height: 34px; }
.sg-pick-lines td { vertical-align: middle; }
.sg-pick-check-col { width: 36px; }
.sg-pick-check { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; border: 1.5px solid #6bb59a; border-radius: 4px; background: #fff; color: #fff; font: 700 13px var(--sg-font); cursor: pointer; }
.sg-pick-check.is-on { border-color: #2f9e6b; background: #2f9e6b; }
.sg-pick-check.is-part { border-color: #2f9e6b; color: #2f9e6b; }
.sg-pick-check.is-missing { border-color: var(--sg-out); color: var(--sg-out); background: #fff; cursor: default; }
.sg-pick-lines tr.is-picked td { background: #f6fbf8; }
.sg-pick-lines tr.is-flash td { animation: sg-flash 1s ease-out; }
.sg-loc-static { cursor: default; }
/* The item's stock card (catalog/stock_card.py), like inFlow's: sublocations with a star and − / +. */
.sg-wh-summary { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px; margin: 0 -6px; border-radius: 6px; list-style: none; cursor: pointer; }
.sg-wh-summary::-webkit-details-marker { display: none; }
.sg-wh-summary > span:first-child::before { content: "▸"; display: inline-block; width: 1em; color: var(--sg-muted); transition: transform 0.15s; }
.sg-wh-group[open] > .sg-wh-summary > span:first-child::before { transform: rotate(90deg); }
.sg-wh-summary:hover { background: #eef0f4; }
.sg-subloc-list { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 10px; padding-top: 6px; border-top: 1px solid var(--sg-rule-soft); }
.sg-subloc { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 2px; border-radius: 6px; }
.sg-subloc.is-flash { animation: sg-flash 1s ease-out; }
.sg-star { width: 22px; height: 22px; padding: 0; border: 0; background: none; color: #b8bdc9; font-size: 16px; line-height: 1; cursor: pointer; }
.sg-star:hover { color: #e3a21a; }
.sg-star.is-on { color: #f0a91c; }
.sg-subloc-remove { padding: 0 4px; color: var(--sg-muted); font-size: 16px; opacity: 0; }
.sg-subloc:hover .sg-subloc-remove, .sg-subloc-remove:focus { opacity: 1; }
.sg-subloc-qty { margin: 0; gap: 0; }
.sg-subloc-qty .sg-in { width: 4.5rem; height: 26px; min-height: 26px; margin: 0; border: 1px solid var(--sg-field); border-width: 1px 0; border-radius: 0; background: #fff; text-align: center; font-weight: 600; }
.sg-subloc-qty .sg-qstep-btn { border-radius: 4px 0 0 4px; }
.sg-subloc-qty .sg-qstep-btn + .sg-in + .sg-qstep-btn { border-radius: 0 4px 4px 0; }
.sg-subloc-add > summary { list-style: none; width: fit-content; padding: 4px 2px; }
.sg-subloc-add > summary::-webkit-details-marker { display: none; }
.sg-loc-new .sg-loc-name { color: var(--sg-accent); font-weight: 600; }
.sg-loc-option.is-disabled { color: var(--sg-muted); cursor: default; }
.sg-loc-option.is-disabled:hover { background: none; }
.sg-pick-state { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 14px; background: #fff7e0; color: #8a5a00; font-size: 12px; font-weight: 600; }
.sg-pick-state.is-done { background: #e3f4ee; color: #1f6b56; }
/* Pick state on an order line's photo, like inFlow: an empty, half or full circle. */
.sg-thumb-wrap { position: relative; display: inline-flex; flex: none; }
.sg-pick-pie { position: absolute; left: -5px; bottom: -4px; width: 14px; height: 14px; border: 2px solid #2f7d6b; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1.5px #fff; }
.sg-pick-pie.is-part { background: linear-gradient(to top, #2f7d6b 50%, #fff 50%); }
.sg-pick-pie.is-full { background: #2f7d6b; }
.sg-qty-badge.is-part { background: #fff4d6; }
.sg-pick-menu-col { width: 40px; text-align: right; }
/* A row's ⋯ menu (pick rows): opens to the left, its entries are buttons. */
.sg-row-menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--sg-bg-soft); color: var(--sg-muted); font-size: 15px; cursor: pointer; }
.sg-row-menu-btn:hover, .sg-row-menu[open] .sg-row-menu-btn { background: var(--sg-rule); color: var(--sg-ink); }
.sg-row-menu .sg-menu-panel { left: auto; right: 0; min-width: 160px; text-align: left; }
.sg-menu-panel button { display: block; width: 100%; padding: 6px 12px; border: 0; background: none; color: var(--sg-ink); font: 13px var(--sg-font); text-align: left; cursor: pointer; }
.sg-menu-panel button:hover { background: var(--sg-bg-soft); }
/* The Partial pick pop-up: the item, then − [n] / of + */
.sg-pick-partial-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-radius: 8px; background: var(--sg-bg-soft); }
.sg-qstep-fixed .sg-qstep-btn { opacity: 1; width: 26px; height: 26px; line-height: 26px; }
.sg-modal .sg-qstep-fixed .sg-in { width: 4rem; text-align: center; }
.sg-qstep-fixed .sg-unit { margin: 0 4px; }
.sg-pick-foot { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13px; }
.sg-pick-total strong { margin-left: 16px; font-size: 15px; }
.sg-pick-next { display: flex; gap: 8px; justify-content: flex-end; }

/* Payment history modal (sales/partials/_payment_history.html), like inFlow's. */
.sg-modal:has(.sg-payments-form) { width: min(760px, 100%); }
.sg-card-actions { display: flex; gap: 14px; }
.sg-row-link { cursor: pointer; }
.sg-row-link:hover td { background: var(--sg-bg-soft); }
.sg-pay-grid { display: flex; flex-direction: column; }
.sg-pay-head, .sg-pay-row {
    display: grid;
    grid-template-columns: 9.5rem minmax(0, 1fr) minmax(0, 1fr) 7.5rem 1.5rem;
    gap: 4px 8px;
    align-items: start;
}
.sg-pay-head { padding: 0 0 6px; border-bottom: 1px solid var(--sg-rule); color: var(--sg-muted); font-size: 12px; }
.sg-pay-row { padding: 8px 0; border-bottom: 1px solid var(--sg-rule-soft); }
.sg-pay-row.is-locked { align-items: baseline; color: var(--sg-ink); }
.sg-pay-remarks { grid-column: 1 / 5; }
.sg-pay-kind { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 8px; }
.sg-pay-tag { padding: 1px 8px; border-radius: 4px; background: #e3f4ee; color: #1d6b55; font-size: 12px; font-weight: 600; }
.is-refund .sg-pay-tag, .sg-pay-tag.is-refund { background: #e4edf9; color: #2b4f86; }
/* A refund's amount is typed positive and shown in brackets, like inFlow. */
.is-refund .sg-pay-amount { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 2px; }
.is-refund .sg-pay-amount::before { content: "("; }
.is-refund .sg-pay-amount::after { content: ")"; }
.is-refund .sg-pay-amount .sg-in-error { grid-column: 1 / -1; grid-row: 2; }
.sg-pay-remarks textarea.sg-in { min-height: 30px; resize: vertical; }
.sg-pay-remove { cursor: pointer; color: var(--sg-muted); font-size: 18px; line-height: 30px; text-align: center; }
.sg-pay-remove input { position: absolute; opacity: 0; pointer-events: none; }
.sg-pay-row.is-removed > :not(.sg-pay-remove) { opacity: 0.4; }
.sg-pay-row.is-removed .sg-pay-remove { color: var(--sg-out); }
.sg-pay-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-top: 4px; }
.sg-pay-totals { min-width: 220px; margin: 0; }
.sg-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 640px) {
    .sg-pay-head { display: none; }
    .sg-pay-row { grid-template-columns: 1fr 1fr 1.5rem; }
    .sg-pay-kind { grid-column: 1 / -1; }
    .sg-pay-remarks { grid-column: 1 / 3; }
}

/* Cost details modal (sales/partials/_order_cost_details.html). */
.sg-cost-rows > div { align-items: center; }
.sg-cost-rows .sg-in { width: 9rem; }
.sg-cost-input-row dt { display: flex; align-items: center; gap: 8px; }
.sg-cost-unit { display: inline-flex; border: 1px solid var(--sg-field); border-radius: 6px; overflow: hidden; }
.sg-cost-unit label { cursor: pointer; }
.sg-cost-unit input { position: absolute; opacity: 0; pointer-events: none; }
.sg-cost-unit span { display: block; padding: 1px 9px; font-size: 12px; }
.sg-cost-unit label + label span { border-left: 1px solid var(--sg-field); }
.sg-cost-unit input:checked + span { background: var(--sg-accent); color: #fff; font-weight: 600; }
.sg-cost-unit input:focus-visible + span { outline: 2px solid var(--sg-accent); outline-offset: -2px; }
.sg-cost-link { display: block; margin: 8px 0 0 auto; }

/* --- Category tree (catalog/partials/_category_tree.html) ---------------- */

.sg-cat-tree { position: relative; }
.sg-cat-name { display: inline-flex; align-items: center; gap: 4px; padding-left: calc(var(--level, 0) * 22px); }
.sg-cat-grip { color: var(--sg-faint); letter-spacing: -3px; padding-right: 6px; cursor: grab; opacity: 0; }
.sg-cat-table tbody tr:hover .sg-cat-grip { opacity: 1; }
.sg-cat-table tbody tr[draggable] { cursor: grab; }
.sg-cat-toggle { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border: 0; padding: 0; background: none; color: var(--sg-muted); cursor: pointer; }
.sg-cat-toggle .sg-icon { width: 14px; height: 14px; transition: transform 0.12s; }
.sg-cat-toggle[aria-expanded="false"] .sg-icon { transform: rotate(-90deg); }
.sg-cat-table td:last-child .sg-card-actions { justify-content: flex-end; opacity: 0; }
.sg-cat-table tbody tr:hover td:last-child .sg-card-actions,
.sg-cat-table td:last-child .sg-card-actions:focus-within { opacity: 1; }
.sg-link-danger { color: var(--sg-out); }
.sg-cat-empty { padding: 24px 16px; }

/* Dragging: the row being moved fades, a valid target is outlined, and the top-level bar covers the
   column headings (laid over them, so the rows don't shift under the pointer). */
.sg-cat-root-drop { display: none; position: sticky; top: 0; z-index: 2; height: 0; overflow: visible; }
.sg-cat-root-drop span { display: flex; align-items: center; justify-content: center; height: 32px; border: 1px dashed var(--sg-accent); background: #fff; color: var(--sg-accent-ink); font-size: 12px; }
.sg-cat-tree.is-dragging .sg-cat-root-drop { display: block; }
.sg-cat-tree.is-dragging .sg-card-actions { visibility: hidden; }
.sg-cat-table tr.is-dragged td { opacity: 0.4; }
.sg-cat-table tr.is-drop-target td { background: var(--sg-accent-soft); box-shadow: inset 0 1px 0 var(--sg-accent), inset 0 -1px 0 var(--sg-accent); }
.sg-cat-table tr.is-drop-target td:first-child { box-shadow: inset 2px 0 0 var(--sg-accent), inset 0 1px 0 var(--sg-accent), inset 0 -1px 0 var(--sg-accent); }
.sg-cat-root-drop.is-drop-target span { background: var(--sg-accent-soft); border-style: solid; }
.sg-cat-drop-hint { position: fixed; z-index: 60; pointer-events: none; padding: 3px 8px; border-radius: 4px; background: var(--sg-ink); color: #fff; font-size: 12px; white-space: nowrap; }

/* --- Radio cards (manufacturing/partials/_bom_procedure_fields.html) ----- */

.sg-choice-group { margin: 0 0 18px; padding: 0; border: 0; min-width: 0; }
.sg-choice-group legend { padding: 0; font-weight: 600; font-size: 14px; }
.sg-choice-group .sg-hint { margin: 2px 0 8px; }
.sg-choice-card { display: flex; gap: 10px; align-items: flex-start; margin-top: 8px; padding: 10px 12px; border: 1px solid var(--sg-rule); border-radius: 6px; background: var(--sg-bg-soft); cursor: pointer; }
.sg-choice-card:hover { border-color: var(--sg-field); }
.sg-choice-card:has(input:checked) { border-color: var(--sg-accent); background: var(--sg-bg); box-shadow: 0 0 0 1px var(--sg-accent); }
.sg-choice-card:has(input:focus-visible) { outline: 2px solid var(--sg-accent); outline-offset: 2px; }
.sg-choice-card input { margin-top: 3px; accent-color: var(--sg-accent); }
.sg-choice-card strong { font-weight: 600; }
.sg-choice-card small { display: block; margin-top: 2px; color: var(--sg-muted); font-size: 12px; line-height: 1.4; }
.sg-choice-tag { margin-left: 6px; padding: 1px 6px; border-radius: 3px; background: var(--sg-rule-soft); color: var(--sg-muted); font-size: 10px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap; }
.sg-badge-btn { border: 0; font-family: var(--sg-font); cursor: pointer; }
.sg-badge-btn:hover { text-decoration: underline; }
.sg-limiting { font-weight: 600; }

/* The item page's Manufacturing tab (catalog/partials/_part_manufacturing.html) */
.sg-tab-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.sg-tab-toolbar form { margin: 0; }

/* Settings › Shopify (templates/shopify/) */
.sg-shop { display: flex; flex-direction: column; gap: 12px; max-width: 900px; }
.sg-shop-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.sg-shop-store { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.sg-shop-avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #f4c86a; color: #5a3d00; font-weight: 600; }
.sg-shop-actions, .sg-shop-buttons { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sg-shop-status { margin-top: -4px; }
.sg-shop-tab { display: flex; flex-direction: column; gap: 12px; }
.sg-shop-card { display: flex; flex-direction: column; gap: 10px; }
.sg-shop-card > p { margin: 0; }
.sg-shop-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.sg-shop-form .sg-shop-field { flex: 1 1 22rem; }
.sg-shop-field { display: flex; flex-direction: column; gap: 4px; max-width: 420px; font-weight: 600; font-size: 12px; color: var(--sg-muted); }
.sg-shop-field .sg-input { font-weight: 400; color: inherit; font-size: 13px; }
.sg-shop-check { display: block; margin: 5px 0; }
.sg-shop-check input { margin: 0 4px 0 0; vertical-align: -1px; }
.sg-shop-check input, .sg-shop-location input { accent-color: var(--sg-accent); }
.sg-shop-master { font-size: 14px; }
.sg-shop-short { width: 12rem; margin-left: 22px; }
.sg-shop-categories { width: calc(100% - 22px); max-width: 420px; margin: 4px 0 0 22px; }
.sg-shop-select { margin-top: 6px; max-width: 280px; }
.sg-shop-location { margin: 0; padding: 10px 0 4px; border: 0; border-top: 1px solid var(--sg-rule); min-width: 0; }
.sg-shop-location:first-of-type { border-top: 0; }
.sg-shop-location legend { display: flex; gap: 10px; align-items: baseline; padding: 0; }
.sg-shop-steps { margin: 0; padding-left: 20px; line-height: 1.6; list-style: decimal; }
.sg-shop-steps code, .sg-shop-card code { font-size: 12px; word-break: break-all; }
.sg-shop-warn { margin: 0; padding: 8px 10px; border-radius: 6px; background: #fdf1dc; color: #8a5300; }
.sg-shop-unmatched summary { cursor: pointer; color: var(--sg-accent); }
.sg-shop-log-error td:last-child { color: var(--sg-out); }
.sg-shop-log-warning td:last-child { color: #8a5300; }
.sg-scroll-x { overflow-x: auto; }
.sg-shop-wide { max-width: 1200px; }
.sg-shop-item { display: flex; flex-direction: column; gap: 12px; max-width: 900px; }
.sg-shop-item .sg-shop-sku { display: flex; flex-direction: column; gap: 10px; }
.sg-shop-item p { margin: 0; }
.sg-shop-sku-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sg-shop-sku-head > div:first-child { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sg-shop-compare td:first-child { white-space: nowrap; }
.sg-shop-draft { max-width: 420px; }
.sg-count-alert { opacity: 1; padding: 1px 6px; border-radius: 999px; background: var(--sg-accent-soft); color: var(--sg-accent); font-weight: 600; }
.sg-shop-diff { font-weight: 600; color: var(--sg-accent); }
.sg-shop-link summary { cursor: pointer; color: var(--sg-accent); font-size: 12px; }
.sg-shop-link .sg-shop-buttons { margin-top: 6px; }
.sg-shop-link select { flex: 1 1 14rem; min-width: 0; max-width: 100%; }
.sg-shop-done { color: #18794e; }
.sg-shop-wide td.sg-mono { white-space: nowrap; }
.sg-tabs a[aria-current="page"] .sg-count-alert { background: #ffffff; color: var(--sg-accent); }
.sg-import-log { margin: 0; max-height: 28rem; overflow: auto; padding: 10px 12px; border-radius: 6px; background: var(--sg-bg-soft, #f6f7f9); font-size: 12px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.sg-shopify-attention { display: grid; gap: 6px; margin-bottom: 10px; }
.sg-shopify-attention p { margin: 0; }
.sg-shopify-attention form { margin: 0; }
.sg-receipt-actions { display: flex; gap: 12px; align-items: center; }

/* Sign out in the rail's user menu: a button styled like the menu's links. */
.sg-rail-signout { margin: 0; }
.sg-rail-signout button {
    display: block; width: 100%; padding: 7px 14px; border: 0; background: none; text-align: left;
    font: inherit; font-size: 13px; color: var(--sg-ink); cursor: pointer;
}
.sg-rail-signout button:hover,
.sg-rail-signout button:focus-visible { background: var(--sg-accent-soft); color: var(--sg-accent-ink); outline: none; }

/* Staff sign-in page (accounts/login.html). */
.sg-signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--sg-bg-soft); }
.sg-signin-card { width: 100%; max-width: 360px; background: var(--sg-bg); border: 1px solid var(--sg-rule); border-radius: 10px; padding: 28px 24px; }
.sg-signin-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.sg-signin-logo { width: 32px; height: 32px; border-radius: 8px; background: var(--sg-rail); color: #fff; display: grid; place-items: center; font-weight: 700; }
.sg-signin h1 { margin: 0; font-size: 18px; }
.sg-signin form { display: grid; gap: 14px; }
.sg-signin label { display: grid; gap: 5px; font-size: 13px; font-weight: 500; color: var(--sg-ink); }
.sg-signin input {
    padding: 8px 10px; border: 1px solid var(--sg-field); border-radius: 6px; font: inherit; font-size: 14px;
}
.sg-signin input:focus { outline: 2px solid var(--sg-accent-soft); border-color: var(--sg-accent); }
.sg-signin .sg-btn { justify-content: center; padding-block: 9px; }

/* Set up Storagile (onboarding/setup.html) and Reset. */
.sg-setup { max-width: 760px; }
.sg-setup-step.is-done { border-color: #cfe9da; }
.sg-setup-num {
    display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 6px; border-radius: 50%;
    background: var(--sg-accent-soft); color: var(--sg-accent-ink); font-size: 12px; font-weight: 700; vertical-align: 1px;
}
.sg-setup-step.is-done .sg-setup-num { background: #e6f4ec; color: #18794e; }
.sg-setup-grid, .sg-setup-address { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 14px; }
.sg-setup-grid .sg-shop-field, .sg-setup-address .sg-shop-field { max-width: none; }
.sg-setup-wide { grid-column: 1 / -1; }
.sg-setup-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.sg-setup-choices .sg-choice-card { margin: 0; color: inherit; text-decoration: none; }
.sg-setup-choices .sg-choice-card small { display: block; margin-top: 3px; color: var(--sg-muted); font-size: 12px; }
form.sg-setup-demo { padding: 0; }
form.sg-setup-demo button { all: unset; display: block; box-sizing: border-box; width: 100%; padding: 10px 12px; cursor: pointer; }
button.sg-choice-card { width: 100%; font: inherit; color: inherit; text-align: left; }
.sg-setup-connections { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
