/*
 * TelemeTank Distribution product identity
 * ------------------------------------
 * app.css owns reusable layout and component behaviour. This file is loaded
 * afterwards and provides only the Distribution product's visual personality.
 * Keeping this layer separate prevents supplier branding changes from
 * affecting TelemeTank Customer or obscuring operational CSS rules.
 */

:root {
    --ink: #17283a;
    --muted: #667686;
    --line: #d8dfe6;
    --paper: #ffffff;
    --wash: #f3f5f7;
    --brand: #a66312;
    --brand-dark: #71430a;
    --accent: #dda039;
    --supplier-navy: #0d2033;
    --supplier-navy-soft: #18364f;
    --supplier-teal: #65c5b0;
    --shadow: 0 12px 30px rgba(13, 32, 51, .08);
}

body {
    background:
        linear-gradient(180deg, #eaf0f4 0, var(--wash) 260px),
        var(--wash);
    color: var(--ink);
}

/* Distribution screens favour a compact control-room type treatment. */
h1,
h2,
h3,
.metric strong {
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-weight: 750;
    letter-spacing: -.025em;
}

.app-header {
    background: linear-gradient(105deg, var(--supplier-navy), #102b43 62%, #173d55);
    border-bottom: 3px solid var(--accent);
    box-shadow: 0 5px 20px rgba(8, 25, 40, .22);
}

.brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    min-width: max-content;
}

.brand-mark {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 9px;
    background: linear-gradient(145deg, #efb44d, #b66b11);
    box-shadow: 0 5px 14px rgba(0, 0, 0, .2);
}

.brand-mark svg {
    width: 27px;
    height: 27px;
    fill: none;
    stroke: #fff;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2.3;
}

.brand-mark circle {
    fill: #fff;
    stroke: none;
}

.brand-wordmark {
    display: grid;
    line-height: 1;
}

.brand-wordmark > span {
    color: #fff;
    font-size: 1.18rem;
    letter-spacing: -.02em;
}

.brand-wordmark strong {
    color: var(--supplier-teal);
}

.brand-wordmark small {
    margin-top: .3rem;
    color: #f1bb60;
    font-size: .62rem;
    font-weight: 850;
    letter-spacing: .2em;
    text-transform: uppercase;
}

.primary-nav a {
    border-bottom: 2px solid transparent;
    color: #d8e4ec;
}

.primary-nav a:hover {
    border-bottom-color: var(--accent);
    background: rgba(255, 255, 255, .07);
}

.account-summary span {
    color: #b8cad7;
}

.eyebrow {
    color: var(--brand);
}

.panel,
.metric,
.table-wrap {
    border-color: var(--line);
    box-shadow: var(--shadow);
}

.metric {
    position: relative;
    overflow: hidden;
}

.metric::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(var(--accent), var(--brand));
    content: "";
}

.button {
    border-color: var(--brand);
    background: var(--brand);
}

.button:hover {
    border-color: var(--brand-dark);
    background: var(--brand-dark);
}

.button-secondary {
    border-color: #ccd6de;
    background: #fff;
    color: var(--supplier-navy);
}

input:focus,
select:focus {
    border-color: var(--accent);
    outline-color: rgba(221, 160, 57, .28);
}

.section-nav {
    background: rgba(243, 245, 247, .95);
}

.section-nav a {
    color: var(--supplier-navy);
}

.run-header {
    background: linear-gradient(135deg, #fff, #edf2f6);
}

.run-stop > span {
    background: var(--supplier-navy-soft);
    box-shadow: 0 0 0 3px #dce5eb;
}

.custody-key {
    background: #e5ebf0;
    border-left: 4px solid var(--accent);
}

.delivery-action {
    border-left-color: var(--accent);
}

.local-preview-badge {
    border-color: #e0ad52;
    background: #f6dfae;
    color: #593704;
}

.app-footer {
    border-top: 1px solid #cfd8df;
    background: #e4e9ed;
    color: #536474;
}

.app-footer strong span {
    color: #117661;
}

@media (max-width: 620px) {
    .brand-mark {
        width: 32px;
        height: 32px;
    }
}

/* Stock custody screens retain the operational palette while letting each
 * product grade remain the strongest local colour cue. */
.stock-metrics {
    grid-template-columns: repeat(4, 1fr);
}

.stock-balance-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.stock-balance-card {
    border-top: 5px solid var(--grade);
}

.stock-quantity-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
    margin: 1rem 0;
}

.stock-quantity-pair > div {
    padding: .75rem;
    border-radius: 8px;
    background: var(--wash);
}

.stock-quantity-pair span,
.carry-banner span {
    display: block;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.stock-quantity-pair strong {
    font-size: 1.15rem;
}

.carry-banner {
    margin: .8rem 0;
    padding: .7rem;
    border-left: 4px solid var(--accent);
    border-radius: 6px;
    background: #f7ead1;
}

.correction-control {
    min-width: 230px;
}

/* Delivery-date controls are intentionally compact so a planner can scan the
 * upcoming cutoff calendar without leaving the distribution workspace. */
.delivery-date-close-form {
    grid-template-columns: minmax(190px, .45fr) 1fr;
}

.delivery-date-calendar .status-closed {
    background: #f9dfdc;
    color: #8c332d;
}

.delivery-date-calendar .status-open {
    background: #dbf3e7;
    color: #175f47;
}

.delivery-date-calendar td:last-child {
    min-width: 290px;
}

.delivery-date-calendar .muted {
    color: var(--muted);
}

@media (max-width: 1050px) {
    .stock-balance-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .stock-metrics,
    .stock-balance-grid,
    .delivery-date-close-form {
        grid-template-columns: 1fr;
    }
}


/* Native details provides keyboard/touch access without a hover-only submenu. */
.nav-submenu{position:relative}
.nav-submenu summary{cursor:pointer;color:inherit;font-weight:600;padding:8px}
.nav-submenu-links{position:absolute;top:100%;left:0;z-index:30;min-width:220px;background:#0d2033;border:1px solid #506174;border-radius:8px;padding:8px;box-shadow:0 8px 20px #0003}
.primary-nav .nav-submenu-links a{display:block;color:#fff;padding:10px;white-space:nowrap}
.nav-submenu summary:focus-visible,.nav-submenu-links a:focus-visible{outline:2px solid #e8b45c;outline-offset:2px}

/*
 * Distribution order desk
 * -----------------------
 * Dense, scan-first controls deliberately echo established dispatch systems:
 * the data grid carries the visual hierarchy, while colour is reserved for
 * state and action rather than decoration.
 */
body {
    background: #edf1f5;
    font-size: 14px;
}

.page-shell {
    width: min(1800px, calc(100% - 2rem));
    padding-top: 1.35rem;
}

.page-heading h1 {
    font-size: clamp(1.8rem, 3vw, 2.45rem);
    letter-spacing: -.035em;
}

.page-heading p {
    max-width: 68rem;
}

.panel,
.metric,
.table-wrap {
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(13, 32, 51, .07);
}

.panel {
    padding: 1rem;
}

.metric {
    min-height: 100px;
    padding: .85rem 1rem;
}

.metric strong {
    margin-top: .2rem;
    font-size: 1.7rem;
    font-variant-numeric: tabular-nums;
}

.status-pill,
.status {
    border-radius: 3px;
    font-size: .63rem;
}

.dispatch-heading {
    align-items: end;
    margin-bottom: .8rem;
}

.dispatch-toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: .75rem 1rem;
    border: 1px solid #b9c7d2;
    border-top: 4px solid var(--supplier-navy-soft);
    border-radius: 4px;
    background: #fff;
}

.dispatch-toolbar .inline-form {
    flex-wrap: nowrap;
}

.dispatch-toolbar label {
    min-width: 210px;
}

.dispatch-toolbar input,
.dispatch-toolbar .button {
    min-height: 38px;
}

.dispatch-toolbar-note {
    display: grid;
    grid-template-columns: auto auto auto auto;
    align-items: baseline;
    gap: .3rem .7rem;
    color: var(--muted);
    white-space: nowrap;
}

.dispatch-toolbar-note strong {
    color: var(--supplier-navy);
    font-size: 1.2rem;
    font-variant-numeric: tabular-nums;
}

.dispatch-toolbar-note span {
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.dispatch-metrics {
    margin: 1rem 0;
}

.dispatch-sheet {
    margin-top: 1rem;
}

.table-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    padding: .1rem .15rem .75rem;
}

.table-heading p {
    max-width: 34rem;
    margin: 0;
    color: var(--muted);
    font-size: .78rem;
}

/* Tables are the primary planning surface, so headings stay visible and rows
 * remain compact enough for an operator to scan a full dispatch date. */
.dispatch-grid {
    max-height: min(64vh, 760px);
    border-color: #aebdca;
    border-radius: 3px;
}

.dispatch-grid table {
    min-width: 1220px;
    font-size: .8rem;
}

.dispatch-grid th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: .62rem .7rem;
    border-bottom: 2px solid #55718a;
    background: linear-gradient(180deg, #264c6b, #173a58);
    color: #f7fafc;
    font-size: .64rem;
    letter-spacing: .07em;
}

.dispatch-grid td {
    padding: .55rem .7rem;
    border-bottom-color: #d7e0e7;
    line-height: 1.35;
}

.dispatch-grid tbody tr:nth-child(even) {
    background: #f6f8fa;
}

.dispatch-grid tbody tr:hover {
    background: #e8f1f7;
    box-shadow: inset 4px 0 0 var(--accent);
}

.dispatch-grid td:first-child,
.dispatch-grid td:nth-child(4),
.dispatch-grid td:nth-child(6) {
    font-variant-numeric: tabular-nums;
    font-weight: 750;
}

.dispatch-grid small {
    display: block;
    margin-top: .18rem;
    color: var(--muted);
    font-size: .69rem;
}

.dispatch-grid .inline-form {
    margin-top: .45rem;
    gap: .35rem;
}

.dispatch-grid .inline-form label {
    min-width: 105px;
    font-size: .66rem;
}

.dispatch-grid input,
.dispatch-grid .button {
    min-height: 32px;
    padding: .35rem .5rem;
    font-size: .72rem;
}

.dispatch-grid .button {
    white-space: nowrap;
}

/* The site directory uses a dense, filterable register so dispatch staff can
 * scan customer locations without opening a configuration card per record. */
.site-directory-section .table-heading {
    margin-bottom: .7rem;
}

.site-directory-section .create-panel > summary {
    list-style: none;
}

.site-directory-section .create-panel > summary::-webkit-details-marker {
    display: none;
}

.site-directory-section .create-panel[open] > summary {
    margin-bottom: .55rem;
}

.site-directory-grid table {
    min-width: 1340px;
}

.site-directory-grid .table-filters th {
    position: sticky;
    top: 38px;
    z-index: 1;
    padding: .35rem .45rem;
    background: #e7edf2;
}

.site-directory-grid .table-filters input {
    width: 100%;
    min-height: 28px;
    padding: .25rem .4rem;
    border: 1px solid #98aab9;
    background: #fff;
    color: var(--supplier-navy);
    font-size: .7rem;
}

.site-directory-grid .table-filters span {
    color: var(--supplier-navy);
    font-size: .7rem;
}

.site-directory-grid td:nth-child(4),
.site-directory-grid td:nth-child(7) {
    font-weight: 500;
}

.site-directory-grid details > summary {
    cursor: pointer;
    color: var(--supplier-navy);
    font-weight: 800;
}

.site-directory-grid .site-edit-details {
    position: relative;
}

.site-directory-grid .site-edit-details > summary {
    display: inline-block;
    padding: .3rem .55rem;
    border: 1px solid #8fa4b5;
    border-radius: 3px;
    background: #edf3f7;
    font-size: .72rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.site-directory-grid .site-edit-details[open] > summary {
    border-color: var(--supplier-navy-soft);
    background: var(--supplier-navy-soft);
    color: #fff;
}

.site-directory-grid .site-edit-form {
    position: absolute;
    right: 0;
    z-index: 5;
    display: grid;
    width: min(780px, calc(100vw - 4rem));
    min-width: 430px;
    margin-top: .6rem;
    padding: .85rem;
    border: 1px solid #8fa4b5;
    border-top: 4px solid var(--supplier-navy-soft);
    border-radius: 3px;
    background: #fff;
    box-shadow: 0 10px 26px rgba(13, 32, 51, .2);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .55rem .7rem;
    text-align: left;
}

/* High-volume order queues favour scan density over card spacing. */
.accepted-orders-grid table,
.demand-grid .record-card {
    font-size: .78rem;
}

.accepted-orders-grid td,
.accepted-orders-grid th {
    padding: .38rem .55rem;
}

.accepted-orders-grid td {
    line-height: 1.2;
}

.demand-grid .record-card {
    padding: .65rem .75rem;
}

.demand-grid .record-card dl {
    margin: .35rem 0;
}

.site-details-page {
    max-width: 980px;
    border-top: 4px solid var(--supplier-navy-soft);
}

.site-details-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.2rem;
}

.site-details-form .form-span,
.site-details-form .form-actions {
    grid-column: 1 / -1;
}

.site-details-form .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
    padding-top: .5rem;
    border-top: 1px solid #d4dfe7;
}

.site-directory-grid .site-edit-form label {
    color: var(--supplier-navy);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.site-directory-grid .site-edit-form input,
.site-directory-grid .site-edit-form textarea {
    min-height: 32px;
    margin-top: .2rem;
    padding: .35rem .45rem;
    border: 1px solid #9eb0be;
    border-radius: 2px;
    font-size: .78rem;
}

.site-directory-grid .site-edit-form textarea {
    min-height: 64px;
}

.site-directory-grid .site-edit-form .form-span,
.site-directory-grid .site-edit-form button {
    grid-column: 1 / -1;
}

.site-directory-grid .site-edit-form textarea {
    width: 100%;
}

.site-directory-grid .site-edit-form small {
    display: block;
    margin-top: .15rem;
    color: var(--muted);
    font-size: .65rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
}

@media (max-width: 850px) {
    .site-directory-grid .site-edit-form {
        position: static;
        width: min(560px, calc(100vw - 3rem));
        min-width: 0;
        grid-template-columns: 1fr;
    }
}

.form-grid,
.stack-form {
    gap: .75rem;
}

input,
select {
    min-height: 38px;
    border-radius: 3px;
}

.button {
    min-height: 38px;
    border-radius: 3px;
    letter-spacing: .01em;
}

@media (max-width: 850px) {
    .dispatch-heading,
    .dispatch-toolbar,
    .table-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .dispatch-toolbar .inline-form {
        flex-wrap: wrap;
    }

    .dispatch-toolbar-note {
        align-self: flex-start;
    }
}
