/* Quote Runner - DLS Dark Theme (layout mirrors zone-map-sales) */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    color: #e5e7eb;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0d0d0d 0%, #1a1a1a 100%);
    min-height: 100vh;
    padding-top: 44px;
}

/* Layout Shell - Sidebar + Main Content */
.layout-shell {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    display: none;
}

@media (min-width: 1024px) {
    .sidebar {
        display: flex;
        flex-direction: column;
        width: 16rem;
        flex-shrink: 0;
        position: sticky;
        top: 60px;
        overflow-y: auto;
        background: #1f1f1f;
        border-right: 1px solid #333333;
    }

    .sidebar-header {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 1.5rem;
        border-bottom: 1px solid #333333;
        flex-shrink: 0;
    }

    .sidebar-icon {
        width: 2.5rem;
        height: 2.5rem;
        background: #2d5016;
        border-radius: 0.75rem;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
    }

    .sidebar-title {
        font-size: 1.25rem;
        font-weight: 700;
        color: #f0f0f0;
        margin: 0;
    }

    .sidebar-subtitle {
        font-size: 0.75rem;
        color: #9ca3af;
        margin: 0;
    }
}

/* Main Content Area */
.layout-main {
    flex: 1;
    overflow-y: auto;
    padding-top: 5px;
    min-height: 0;
}

/* Container */
.container {
    max-width: 1200px;
    /* No top margin: that black band above the card was dead space above the map. */
    margin: 0 auto 2rem;
    padding: 0 1rem;
}

.card {
    background: #1f1f1f;
    border: 1px solid #333333;
    border-left: 4px solid #2d5016;
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    /* Tightened from 2.5rem: keeps a visible frame around the map without
       the wide grey margin that pushed the popup and controls down. */
    padding: 1rem;
}

/* ---------------------------------------------------------------- toolbar */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.toolbar-stats { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.toolbar-actions { display: flex; gap: 0.5rem; }
.stat { color: #9ca3af; font-size: 0.875rem; }
.muted { color: #9ca3af; font-size: 0.875rem; }

.chip {
    background: #262626;
    color: #d1d5db;
    border: 1px solid #3f3f3f;
    border-radius: 999px;
    padding: 0.3rem 0.85rem;
    font-size: 0.8125rem;
    cursor: pointer;
}
.chip:hover { border-color: #4caf50; }
.chip-active { background: #2d5016; color: #f0f0f0; border-color: #4caf50; }
.chip-warn { background: #3a2400; color: #ffb74d; border-color: #ff9800; }

.filter-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* ---------------------------------------------------------------- progress */
.progress-bar {
    position: relative;
    height: 1.75rem;
    background: #1f1f1f;
    border: 1px solid #333;
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 1rem;
}
.progress-fill { height: 100%; background: #2d5016; transition: width 0.2s ease; }
.progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    color: #f0f0f0;
}

.error-display {
    background: #3a1212;
    border-left: 3px solid #ef4444;
    color: #fca5a5;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* ---------------------------------------------------------------- table */
/* The table is the whole point of the page, so it scrolls inside its own box
   rather than pushing the layout sideways on a narrow screen. */
.table-scroll { overflow-x: auto; }

.quote-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    color: #e5e7eb;
    white-space: nowrap;
}
.quote-table th {
    text-align: left;
    font-weight: 600;
    color: #9ca3af;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #333;
}
.quote-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #262626;
}
.quote-table .num, .quote-table th.num { text-align: right; }
.quote-table .col-flag, .quote-table th.col-flag { width: 1.5rem; padding-right: 0; }

.row-flagged td { background: #241a05; }
.row-flagged .col-flag { color: #ff9800; }
.flag-detail td {
    color: #ffb74d;
    font-size: 0.8125rem;
    padding-top: 0;
    border-bottom: 1px solid #262626;
    white-space: normal;
}
.needs-review { color: #ff9800; }

.badge {
    background: #1e3a1e;
    color: #86efac;
    border-radius: 0.25rem;
    padding: 0.05rem 0.35rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

/* Quoted, not marked Sold, and bought since: worth a look before it goes stale. */
.badge-elsewhere {
    background: #3a2a10;
    color: #ffb74d;
    cursor: help;
}


/* ---------------------------------------------------------------- buttons */
/* shared-components.css sizes .btn but leaves colour to the app, and a button
   does not inherit colour from body - without these it renders as the
   browser's black buttontext on the dark card. */
.btn {
    background: #262626;
    color: #e5e7eb;
    border: 1px solid #3f3f3f;
    border-radius: 0.5rem;
}

.btn:hover:not(:disabled) {
    background: #303030;
    border-color: #4caf50;
    color: #ffffff;
}

.btn-primary {
    background: #2d5016;
    color: #f0f0f0;
    border-color: #3d6b1e;
}

.btn-primary:hover:not(:disabled) {
    background: #3a6b1c;
    border-color: #4caf50;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.quote-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.quote-table th.sortable:hover {
    color: #e5e7eb;
}

/* ------------------------------------------------------- fit and legibility */
/* shared.css scales every app down to 90%; this table is dense enough that the
   lost 10% costs more than it saves. */
html {
    font-size: 100%;
}

/* The table is the page, so let it use the window. The 1200px cap inherited
   from the zone map forced a horizontal scrollbar on a full-width table. */
.container {
    max-width: 100%;
    padding: 0 1.5rem;
}

.quote-table {
    font-size: 0.95rem;
    /* Wrapping instead of nowrap is what actually removes the side scroll -
       widening alone just moves the overflow further right. */
    white-space: normal;
}

.quote-table th,
.quote-table td {
    padding: 0.55rem 0.6rem;
}

/* Numbers and dates read worse broken across lines than anything else. */
.quote-table .num,
.quote-table th.num,
.quote-table td:nth-child(2) {
    white-space: nowrap;
}

/* The toolbar sat flush against the table, so the counts read as a table
   header rather than as controls. */
.toolbar {
    margin-bottom: 1.5rem;
}

/* ------------------------------------------------------------- row editing */
/* A submission can be fixed here rather than in the form sheet, so a typo in
   an address or a material does not mean leaving the page to correct it. */
.col-edit { width: 2.5rem; }

.row-edited td { border-left: 3px solid #4caf50; }

/* Lighter than the row, not darker: the page is dark, and 3% black on black is
   nothing at all. */
.edit-detail td { background: rgba(255, 255, 255, 0.04); }

.edit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

.edit-grid label {
    display: block;
    font-size: 0.8rem;
    color: #9ca3af;
    margin-bottom: 0.2rem;
}

/* The same box as .fix-qty, because it is the same kind of box. These were a
   white field told to inherit its colour, which on a dark page is the page's
   own light grey written onto white: a submission being corrected could not be
   read while it was being corrected. */
.edit-grid input,
.edit-grid textarea {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid #3f3f3f;
    border-radius: 4px;
    font: inherit;
    font-size: 0.9rem;
    background: #262626;
    color: #e5e7eb;
}

.edit-grid input:focus,
.edit-grid textarea:focus {
    outline: none;
    border-color: #4caf50;
}

.edit-grid input::placeholder,
.edit-grid textarea::placeholder {
    color: #6b7280;
}

.edit-grid textarea { min-height: 4.5rem; resize: vertical; }

.edit-wide { grid-column: 1 / -1; }

.edit-actions { display: flex; gap: 0.5rem; align-items: center; }

/* Writing a Status back to the form sheet is off unless somebody turns it on. */
.stamp-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
    color: #9ca3af;
    cursor: pointer;
}
.stamp-toggle input { cursor: pointer; }

/* The per-row "Addressed" button sits inside the flag line, so it has to be
   small enough not to push the reason around. */
.btn-tiny {
    padding: 0.1rem 0.45rem;
    font-size: 0.75rem;
    border-radius: 0.35rem;
    margin-left: 0.5rem;
}

/* A flag the page knows the answer to offers it: the candidate products it
   already computed, or a box for the quantity nobody wrote. */
.fix-offer {
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.fix-offer .candidate {
    background: #262626;
    border: 1px solid #3f3f3f;
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 0.8rem;
    color: #d1d5db;
    cursor: pointer;
}
.fix-offer .candidate:hover { border-color: #4caf50; color: #fff; }

.fix-qty {
    width: 6rem;
    padding: 0.2rem 0.45rem;
    background: #262626;
    color: #e5e7eb;
    border: 1px solid #3f3f3f;
    border-radius: 0.35rem;
    font: inherit;
    font-size: 0.85rem;
}

/* Draft order dialog */
.order-modal .modal-content { background: #1f1f1f; border-color: #333333; max-width: 560px; }
.order-modal .modal-header, .order-modal .modal-footer { border-color: #333333; }
.order-items { white-space: pre-wrap; font-size: 0.85em; background: #161616; padding: 0.6rem; border-radius: 0.5rem; }
.order-field { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.6rem 0; }
.order-field > span { font-size: 0.8rem; color: #9ca3af; }

/* The same field as the submission editor, for the same reason: left unstyled,
   the browser draws these black on white in the middle of a dark dialog. */
.order-field input,
.order-field select,
.order-field textarea {
    width: 100%;
    padding: 0.4rem 0.5rem;
    background: #262626;
    color: #e5e7eb;
    border: 1px solid #3f3f3f;
    border-radius: 4px;
    font: inherit;
    font-size: 0.9rem;
}

.order-field input:focus,
.order-field select:focus,
.order-field textarea:focus {
    outline: none;
    border-color: #4caf50;
}

.order-field input::placeholder,
.order-field textarea::placeholder { color: #6b7280; }

/* A select's own list is drawn by the browser, which otherwise keeps it white. */
.order-field select option { background: #262626; color: #e5e7eb; }

/* Tells the browser to draw the date picker's calendar icon and panel dark;
   without it the icon is black on a near-black field and looks missing. */
.order-field input[type="date"] { color-scheme: dark; }
