:root {
    --ink: #222a2f;
    --muted: #697177;
    --charcoal: #3f4448;
    --charcoal-2: #585f64;
    --line: #d9dddf;
    --paper: #ffffff;
    --canvas: #f4f6f5;
    --teal: #52b7ae;
    --teal-dark: #287a73;
    --teal-soft: #e0f2ef;
    --green-soft: #e5f3e4;
    --yellow: #fff3c8;
    --yellow-border: #e0c76a;
    --danger: #a63636;
    --danger-soft: #fae4e4;
    --shadow: 0 12px 32px rgba(34, 42, 47, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--canvas);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}

button,
input,
select {
    font: inherit;
}

button,
select {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(82, 183, 174, 0.42);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.print-only {
    display: none;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid rgba(63, 68, 72, 0.12);
    backdrop-filter: blur(14px);
}

.app-header-inner {
    max-width: 1380px;
    min-height: 76px;
    margin: 0 auto;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    width: 168px;
    height: auto;
    display: block;
}

.header-title {
    display: grid;
    gap: 1px;
    padding-left: 16px;
    border-left: 1px solid var(--line);
}

.header-title strong {
    font-size: 1.03rem;
}

.header-title span {
    color: var(--muted);
    font-size: 0.78rem;
}

.logout-link {
    margin-left: auto;
    color: var(--charcoal);
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    padding: 9px 13px;
    border-radius: 10px;
}

.logout-link:hover {
    background: #edf0f1;
}

.app-shell {
    max-width: 1380px;
    margin: 0 auto;
    padding: 32px 24px 56px;
}

.welcome-strip {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 32px;
    margin-bottom: 22px;
    padding: 6px 4px;
}

.welcome-strip h1 {
    margin: 2px 0 5px;
    font-size: clamp(1.8rem, 3vw, 2.75rem);
    line-height: 1.08;
    letter-spacing: -0.035em;
}

.welcome-strip p {
    max-width: 760px;
    margin: 0;
    color: var(--muted);
}

.eyebrow {
    color: var(--teal-dark);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.catalog-count {
    min-width: 122px;
    display: grid;
    justify-items: end;
}

.catalog-count strong {
    font-size: 2.2rem;
    line-height: 1;
}

.catalog-count span {
    color: var(--muted);
    font-size: 0.8rem;
}

.card {
    background: var(--paper);
    border: 1px solid rgba(63, 68, 72, 0.1);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.setup-card,
.items-card {
    padding: 24px;
}

.line-controls-help {
    margin: -8px 0 16px;
    color: var(--muted);
    font-size: 0.78rem;
}

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

.section-heading h2,
.quick-note h2 {
    margin: 2px 0 0;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.source-badge,
.private-pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--teal-soft);
    color: var(--teal-dark);
    font-size: 0.75rem;
    font-weight: 800;
}

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

label {
    display: grid;
    gap: 7px;
    color: var(--charcoal);
    font-size: 0.78rem;
    font-weight: 800;
}

input,
select {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--yellow-border);
    border-radius: 11px;
    background: var(--yellow);
    color: var(--ink);
    padding: 10px 12px;
    font-size: 0.96rem;
    font-weight: 600;
}

input::placeholder {
    color: #8c897d;
    font-weight: 500;
}

.wide-field {
    grid-column: span 2;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1.08fr 0.92fr;
    gap: 18px;
    margin: 18px 0;
}

.summary-card,
.quick-note {
    min-height: 218px;
    padding: 22px;
}

.summary-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 13px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.summary-title span {
    font-size: 0.75rem;
    font-weight: 850;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.summary-title small {
    color: var(--muted);
    font-size: 0.72rem;
}

.summary-card dl {
    margin: 0;
}

.summary-card dl > div {
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.summary-card dt {
    color: var(--muted);
    font-size: 0.88rem;
}

.summary-card dd {
    margin: 0;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.summary-card .summary-total {
    margin-top: 6px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.summary-card .summary-total dt {
    color: var(--ink);
    font-weight: 800;
}

.summary-card .summary-total dd {
    font-size: 1.25rem;
}

.customer-summary-card {
    border-color: rgba(82, 183, 174, 0.45);
    background: linear-gradient(145deg, #ffffff 0%, #f2faf8 100%);
}

.customer-total-row dd {
    color: var(--teal-dark);
}

.quick-note {
    background: var(--charcoal);
    color: white;
}

.quick-note .eyebrow {
    color: #93ddd7;
}

.quick-note h2 {
    margin-top: 7px;
    color: white;
}

.quick-note p {
    margin: 10px 0 18px;
    color: #e1e5e6;
    font-size: 0.9rem;
}

.quick-note .secondary-button {
    border-color: white;
    background: white;
    color: var(--charcoal);
}

.items-card {
    padding-bottom: 8px;
    overflow: hidden;
}

.button-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.primary-button,
.secondary-button,
.quiet-button,
.remove-button {
    min-height: 44px;
    border-radius: 11px;
    border: 1px solid transparent;
    padding: 10px 16px;
    font-weight: 800;
}

.primary-button {
    background: var(--charcoal);
    color: white;
}

.primary-button:hover {
    background: #262c30;
}

.secondary-button {
    border-color: #bfc5c8;
    background: white;
    color: var(--charcoal);
}

.secondary-button:hover,
.quiet-button:hover {
    background: #edf0f1;
}

.quiet-button {
    border-color: transparent;
    background: transparent;
    color: var(--charcoal);
}

.compact-button {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 0.86rem;
}

.table-wrap {
    overflow-x: auto;
    margin: 0 -24px;
}

.items-table {
    width: 100%;
    min-width: 1260px;
    border-collapse: collapse;
    table-layout: fixed;
}

.items-table th {
    background: var(--charcoal-2);
    color: white;
    padding: 11px 9px;
    font-size: 0.73rem;
    letter-spacing: 0.035em;
    text-align: left;
    text-transform: uppercase;
}

.items-table td {
    padding: 10px 9px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.items-table tbody tr:last-child td {
    border-bottom: 0;
}

.items-table tbody tr.has-error {
    background: #fffafa;
}

.items-table input,
.items-table select {
    min-height: 40px;
    border-radius: 9px;
    padding: 8px 9px;
    font-size: 0.9rem;
}

.line-style-select,
.custom-picker-row select {
    margin-bottom: 8px;
}

.line-style-select {
    border-color: #9fd1cc;
    background: var(--teal-soft);
    color: var(--teal-dark);
}

.custom-picker-row select {
    border-color: #b9c1c4;
    background: #f1f3f4;
}

.item-fields {
    display: grid;
    grid-template-columns: minmax(150px, 0.8fr) minmax(180px, 1.4fr);
    gap: 8px;
}

.custom-item-fields {
    grid-template-columns: minmax(130px, 0.65fr) minmax(220px, 1.6fr);
}

.custom-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 8px;
}

.mini-button {
    min-height: 30px;
    border: 1px solid #bfc5c8;
    border-radius: 8px;
    background: white;
    color: var(--charcoal);
    padding: 5px 9px;
    font-size: 0.72rem;
    font-weight: 800;
}

.mini-button:hover {
    background: #edf0f1;
}

.mini-button:disabled {
    cursor: wait;
    opacity: 0.55;
}

.danger-button {
    border-color: #e2b4b4;
    color: var(--danger);
}

.item-code-input {
    text-transform: uppercase;
}

.line-column {
    width: 48px;
    text-align: center !important;
}

.qty-column {
    width: 82px;
}

.money-column {
    width: 126px;
    text-align: right !important;
}

.markup-column {
    width: 104px;
    text-align: center !important;
}

.tax-column {
    width: 78px;
    text-align: center !important;
}

.markup-input {
    text-align: right;
}

.tax-cell {
    text-align: center;
}

.tax-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--charcoal);
    font-size: 0.76rem;
    font-weight: 800;
}

.tax-toggle input {
    width: 19px;
    min-height: 19px;
    height: 19px;
    margin: 0;
    padding: 0;
    accent-color: var(--teal-dark);
}

.status-column {
    width: 118px;
    text-align: center !important;
}

.remove-column {
    width: 54px;
}

.line-number {
    color: var(--muted);
    text-align: center;
    font-weight: 700;
}

.money-cell {
    text-align: right;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.customer-money {
    color: var(--teal-dark);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    min-height: 28px;
    border-radius: 999px;
    padding: 4px 8px;
    background: #edf0f1;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
}

.status-pill.ok {
    background: var(--green-soft);
    color: #2e7132;
}

.status-pill.error {
    background: var(--danger-soft);
    color: var(--danger);
}

.status-pill.manual {
    background: var(--teal-soft);
    color: var(--teal-dark);
}

.remove-button {
    width: 38px;
    min-height: 38px;
    padding: 0;
    border-color: transparent;
    background: transparent;
    color: #7e868b;
    font-size: 1.3rem;
}

.remove-button:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.empty-items {
    padding: 42px 18px;
    color: var(--muted);
    text-align: center;
}

.action-bar {
    position: sticky;
    bottom: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 18px;
    padding: 12px;
    border: 1px solid rgba(63, 68, 72, 0.12);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 16px 36px rgba(34, 42, 47, 0.14);
    backdrop-filter: blur(14px);
}

.privacy-note {
    max-width: 840px;
    margin: 18px auto 0;
    color: var(--muted);
    font-size: 0.76rem;
    text-align: center;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 90px;
    z-index: 40;
    max-width: min(360px, calc(100vw - 40px));
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--ink);
    color: white;
    box-shadow: var(--shadow);
    font-size: 0.88rem;
    font-weight: 700;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 10%, rgba(82, 183, 174, 0.16), transparent 36%),
        linear-gradient(145deg, #eef2f1, #f8f9f8 55%, #edf3f1);
}

.auth-shell {
    width: min(100%, 460px);
}

.auth-card {
    padding: 36px;
    border: 1px solid rgba(63, 68, 72, 0.12);
    border-radius: 24px;
    background: white;
    box-shadow: 0 24px 70px rgba(34, 42, 47, 0.14);
}

.auth-logo {
    width: min(100%, 270px);
    height: auto;
    display: block;
    margin: 0 auto 24px;
}

.auth-card .private-pill {
    width: fit-content;
    margin: 0 auto 18px;
}

.auth-card h1 {
    margin: 0 0 7px;
    font-size: 1.65rem;
    line-height: 1.15;
    text-align: center;
}

.auth-card > p {
    margin: 0 0 22px;
    color: var(--muted);
    text-align: center;
}

.auth-form {
    display: grid;
    gap: 16px;
}

.auth-form .primary-button {
    width: 100%;
    min-height: 48px;
}

.form-hint {
    margin: -5px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.form-error {
    margin: 0 0 18px;
    padding: 11px 13px;
    border: 1px solid #eab5b5;
    border-radius: 10px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 0.86rem;
    font-weight: 700;
}

@media (max-width: 980px) {
    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .quick-note {
        grid-column: 1 / -1;
        min-height: 0;
    }
}

@media (max-width: 680px) {
    .app-header-inner {
        min-height: 66px;
        padding: 9px 14px;
    }

    .header-logo {
        width: 128px;
    }

    .header-title {
        display: none;
    }

    .logout-link {
        font-size: 0.8rem;
    }

    .app-shell {
        padding: 22px 12px 42px;
    }

    .welcome-strip {
        align-items: start;
        margin-bottom: 15px;
    }

    .welcome-strip h1 {
        font-size: 1.75rem;
    }

    .welcome-strip p {
        font-size: 0.86rem;
    }

    .catalog-count {
        display: none;
    }

    .setup-card,
    .items-card {
        padding: 18px;
        border-radius: 15px;
    }

    .section-heading {
        align-items: start;
        flex-direction: column;
        gap: 12px;
    }

    .source-badge {
        align-self: stretch;
        justify-content: center;
    }

    .form-grid,
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .wide-field,
    .quick-note {
        grid-column: auto;
    }

    .summary-card,
    .quick-note {
        min-height: 0;
        padding: 18px;
    }

    .items-card .button-row {
        width: 100%;
        justify-content: stretch;
    }

    .items-card .button-row button {
        flex: 1;
    }

    .table-wrap {
        overflow: visible;
        margin: 0 -18px;
    }

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

    .items-table thead {
        display: none;
    }

    .items-table tbody tr {
        position: relative;
        padding: 16px 52px 14px 18px;
        border-top: 1px solid var(--line);
    }

    .items-table td {
        padding: 5px 0;
        border: 0;
        text-align: left !important;
    }

    .items-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 3px;
        color: var(--muted);
        font-size: 0.68rem;
        font-weight: 850;
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }

    .line-number {
        position: absolute;
        top: 16px;
        right: 18px;
        color: var(--muted);
    }

    .line-number::before {
        display: none !important;
    }

    .item-fields {
        grid-template-columns: 1fr;
    }

    .custom-item-fields {
        grid-template-columns: 1fr;
    }

    .tax-cell {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
    }

    .tax-cell::before {
        margin-bottom: 0 !important;
    }

    .money-cell {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
    }

    .status-cell {
        padding-top: 8px !important;
    }

    .remove-cell {
        position: absolute;
        right: 10px;
        bottom: 8px;
        width: auto !important;
    }

    .remove-cell::before {
        display: none !important;
    }

    .action-bar {
        align-items: stretch;
        flex-direction: column-reverse;
        bottom: 8px;
    }

    .action-bar > button,
    .action-bar .button-row,
    .action-bar .button-row button {
        width: 100%;
    }

    .auth-card {
        padding: 28px 22px;
    }
}

@media print {
    @page {
        size: letter;
        margin: 0.55in;
    }

    body {
        background: white;
        color: #111;
        font-size: 10pt;
    }

    .no-print,
    .internal-only,
    .screen-items,
    .summary-grid,
    .setup-card,
    .welcome-strip,
    .items-card {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }

    .app-shell {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .print-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 30px;
        padding-bottom: 18px;
        border-bottom: 3px solid var(--charcoal);
    }

    .print-header img {
        width: 210px;
        height: auto;
    }

    .print-header h1 {
        margin: 0;
        font-size: 22pt;
        text-align: right;
    }

    .print-meta {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        margin: 18px 0;
    }

    .print-meta div {
        padding: 9px 10px;
        border: 1px solid #ccc;
    }

    .print-meta span {
        display: block;
        color: #666;
        font-size: 7.5pt;
        font-weight: 800;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

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

    .print-table th {
        padding: 8px;
        background: var(--charcoal);
        color: white;
        font-size: 8pt;
        text-align: left;
    }

    .print-table td {
        padding: 8px;
        border-bottom: 1px solid #d5d5d5;
    }

    .print-table .print-money {
        text-align: right;
        white-space: nowrap;
    }

    .print-totals {
        width: 300px;
        margin: 18px 0 0 auto;
    }

    .print-totals div {
        display: flex;
        justify-content: space-between;
        gap: 20px;
        padding: 5px 0;
    }

    .print-totals .final {
        margin-top: 5px;
        padding-top: 10px;
        border-top: 2px solid #333;
        font-size: 13pt;
        font-weight: 850;
    }

    .print-note {
        margin-top: 28px;
        color: #555;
        font-size: 8pt;
    }
}
