:root {
    --ink: #152033;
    --muted: #6f6f6f;
    --line: #dedede;
    --bg: #f7f7f6;
    --panel: #ffffff;
    --primary: #f36d2b;
    --primary-dark: #c94f17;
    --accent: #f4a261;
    --neutral: #9e9e9e;
    --danger: #bd2c2c;
    --warning: #9a6a00;
    --success: #147a4d;
    --shadow: 0 16px 40px rgba(38, 38, 38, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
}

a {
    color: var(--primary);
    text-decoration: none;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(243, 109, 43, 0.18);
    border-color: var(--primary);
}

textarea {
    min-height: 92px;
    resize: vertical;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.app-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 22px;
    color: #f8f8f8;
    background: #2f2f2f;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
}

.brand.inline {
    color: var(--ink);
}

.brand-logo {
    width: 54px;
    height: 54px;
    border: 1px solid rgba(158, 158, 158, 0.26);
    border-radius: 50%;
    object-fit: contain;
    padding: 3px;
    background: #fff;
}

.brand.inline .brand-logo {
    width: 62px;
    height: 62px;
}

.brand-mark {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    background: var(--primary);
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: 2px;
    color: #d7d7d7;
    font-size: 12px;
}

.brand.inline small {
    color: var(--muted);
}

.nav {
    display: grid;
    gap: 5px;
}

.nav a {
    display: block;
    border-radius: 8px;
    padding: 11px 12px;
    color: #eeeeee;
    font-weight: 700;
}

.nav a:hover,
.nav a.active {
    color: #fff;
    background: rgba(243, 109, 43, 0.22);
}

.session-box {
    margin-top: auto;
    display: grid;
    gap: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    padding-top: 18px;
}

.session-box span {
    color: #d7d7d7;
    font-size: 13px;
}

.session-box a {
    margin-top: 8px;
    color: #f4a261;
    font-weight: 700;
}

.main {
    padding: 28px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel,
.stat-card,
.login-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.panel {
    padding: 18px;
}

.panel + .panel {
    margin-top: 16px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.panel-header h2,
.panel h2 {
    margin: 0;
    font-size: 18px;
}

.stat-card {
    padding: 18px;
}

.stat-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.actions form {
    display: inline-flex;
}

.button,
button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--ink);
    background: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
}

.button.primary,
button.primary {
    border-color: var(--primary);
    color: #fff;
    background: var(--primary);
}

.button.primary:hover,
button.primary:hover {
    background: var(--primary-dark);
}

.button.danger,
button.danger {
    border-color: var(--danger);
    color: #fff;
    background: var(--danger);
}

.button.full {
    width: 100%;
}

.muted {
    color: var(--muted);
}

.status {
    display: inline-flex;
    min-width: 88px;
    justify-content: center;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 800;
}

.status.ok {
    color: #0f5132;
    background: #d9f4e8;
}

.status.low {
    color: #8a4a0d;
    background: #fff0df;
}

.status.zero {
    color: var(--danger);
    background: #ffe0e0;
}

.alert {
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 12px 14px;
    font-weight: 700;
}

.alert.success {
    color: var(--success);
    background: #dff7ec;
}

.alert.danger {
    color: var(--danger);
    background: #ffe0e0;
}

.alert.info {
    color: var(--primary-dark);
    background: #fff0e8;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.form-grid .span-2 {
    grid-column: span 2;
}

.form-grid .span-3 {
    grid-column: 1 / -1;
}

.table-wrap {
    overflow-x: auto;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #f3f3f2;
}

.login-card {
    width: min(420px, 100%);
    padding: 26px;
}

.login-card .brand.inline {
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    text-align: center;
}

.login-card .brand-logo {
    width: 96px !important;
    height: 96px !important;
    display: block;
    margin: 0 auto;
}

.login-card .brand strong {
    font-size: 18px;
}

.login-card .brand small {
    color: var(--muted);
}

.login-card button.primary {
    border-color: #f4a261;
    background: #f4a261;
}

.login-card button.primary:hover {
    border-color: #f36d2b;
    background: #f36d2b;
}

.setup-card {
    width: min(560px, 100%);
}

.login-card form {
    display: grid;
    gap: 14px;
    margin-top: 22px;
}

.search-results {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.search-results.compact {
    margin-top: 6px;
}

.search-toolbar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    background: #fff;
    font-size: 13px;
    font-weight: 800;
}

.close-results {
    min-height: 38px;
    padding: 8px 12px;
}

.product-hit {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}

.client-hit {
    width: 100%;
    display: grid;
    gap: 3px;
    justify-items: start;
    border-color: var(--line);
    text-align: left;
    background: #fff;
}

.client-hit span,
.selection-note {
    font-size: 13px;
}

.selection-note {
    display: block;
    margin-top: 8px;
}

.success-text {
    color: var(--success);
    font-weight: 800;
}

.line-input {
    min-width: 96px;
}

.compact-number {
    max-width: 118px;
}

.money-input {
    min-width: 132px;
}

.icon-button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
}

.row-actions {
    text-align: right;
}

.product-hit strong mark,
td mark {
    border-radius: 4px;
    padding: 0 3px;
    color: inherit;
    background: #ffe3d3;
}

.match-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    border-radius: 999px;
    padding: 4px 8px;
    color: #7c3a10;
    background: #fff0e8;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.quote-total {
    margin-left: auto;
    width: min(420px, 100%);
}

.quote-total div {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}

.quote-total strong {
    font-size: 20px;
}

.print-header {
    display: none;
}

.quote-sheet {
    max-width: 820px;
    margin: 0 auto;
    padding: 8px 0 0;
    color: #111;
    background: #fff;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    line-height: 1.32;
}

.quote-letterhead {
    position: relative;
    min-height: 86px;
    text-align: center;
}

.quote-logo {
    position: absolute;
    top: 0;
    left: 58px;
    width: 58px;
    height: 58px;
    object-fit: contain;
}

.quote-company h1 {
    margin: 0 0 4px;
    font-size: 15px;
    letter-spacing: 0;
}

.quote-company p,
.quote-recipient p,
.quote-conditions p,
.quote-signature p {
    margin: 0 0 4px;
}

.quote-date {
    margin: 16px 0 22px;
}

.quote-recipient {
    margin-bottom: 14px;
}

.quote-reference {
    margin: 12px 0;
}

.quote-table-wrap {
    margin-top: 16px;
}

.quote-print-table th,
.quote-print-table td {
    border: 1px solid #202020;
    padding: 6px 7px;
    color: #111;
    font-size: 12px;
}

.quote-print-table th {
    background: #f4f4f4;
    text-transform: none;
}

.quote-total-print {
    margin-top: 16px;
    width: min(340px, 100%);
}

.quote-total-print div {
    padding: 5px 0;
}

.quote-conditions {
    clear: both;
    margin-top: 24px;
    font-size: 12px;
}

.quote-signature {
    margin-top: 42px;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .grid.cols-2,
    .grid.cols-3,
    .grid.cols-4,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .span-2,
    .form-grid .span-3 {
        grid-column: auto;
    }

    .main {
        padding: 16px;
    }

    .topbar {
        margin-bottom: 14px;
    }

    .topbar h1 {
        font-size: 23px;
    }

    .sidebar {
        gap: 14px;
        padding: 16px;
    }

    .nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .nav a {
        min-height: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 9px 8px;
        text-align: center;
    }

    .panel {
        padding: 14px;
    }

    .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .actions,
    .product-hit {
        grid-template-columns: 1fr;
    }

    .actions .button,
    .actions button,
    .product-hit button,
    .client-hit {
        width: 100%;
    }

    .quote-actions {
        position: sticky;
        bottom: 0;
        z-index: 3;
        border-top: 1px solid var(--line);
        margin-right: -14px;
        margin-bottom: -14px;
        margin-left: -14px;
        padding: 12px 14px;
        background: var(--panel);
    }

    .quote-actions button {
        width: 100%;
    }

    .quote-items-table thead {
        display: none;
    }

    .quote-items-table,
    .quote-items-table tbody,
    .quote-items-table tr,
    .quote-items-table td {
        display: block;
        width: 100%;
    }

    .quote-items-table tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 10px;
        background: #fff;
    }

    .quote-items-table td {
        display: grid;
        grid-template-columns: minmax(94px, 34%) minmax(0, 1fr);
        gap: 10px;
        align-items: center;
        border-bottom: 1px solid #eeeeee;
        padding: 9px 0;
    }

    .quote-items-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
    }

    .quote-items-table td.row-actions {
        grid-template-columns: 1fr;
        border-bottom: 0;
    }

    .quote-items-table td.row-actions::before {
        content: '';
        display: none;
    }

    .line-input,
    .compact-number,
    .money-input {
        max-width: none;
        min-width: 0;
        width: 100%;
    }

    .quote-logo {
        left: 0;
        width: 48px;
        height: 48px;
    }

    .quote-company {
        padding-left: 58px;
        text-align: left;
    }
}

@media print {
    body {
        background: #fff;
    }

    .sidebar,
    .topbar,
    .no-print,
    .alert {
        display: none !important;
    }

    .app-shell,
    .main {
        display: block;
        padding: 0;
    }

    .panel,
    .quote-document {
        border: 0;
        box-shadow: none;
        padding: 0;
    }

    .print-header {
        display: block;
        margin-bottom: 24px;
    }

    .quote-sheet {
        max-width: none;
        padding: 0;
        font-size: 11px;
    }

    .quote-logo {
        left: 58px;
    }

    .quote-print-table th,
    .quote-print-table td {
        padding: 4px 5px;
        font-size: 10px;
    }
}
