:root {
    --bg: #eef2f7;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef2f7;
    --line: #d8dee8;
    --line-strong: #c5cfdd;
    --text: #172033;
    --muted: #64748b;
    --primary: #0f766e;
    --primary-strong: #115e59;
    --accent: #2563eb;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --shadow: 0 18px 45px rgba(15, 23, 42, .12);
    --radius: 8px;
    --sidebar: 252px;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, .12), transparent 34%),
        linear-gradient(225deg, rgba(37, 99, 235, .11), transparent 38%),
        var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    letter-spacing: 0;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.desktop-only-warning {
    display: none;
}

.desktop-app {
    height: 100vh;
    overflow: hidden;
}

@media (max-width: 900px) {
    body {
        background: var(--surface);
    }

    .desktop-app {
        display: none !important;
    }

    .desktop-only-warning {
        min-height: 100vh;
        display: grid;
        place-items: center;
        padding: 28px;
        color: var(--text);
    }

    .desktop-only-warning .warning-card {
        width: min(100%, 460px);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        padding: 26px;
        background: var(--surface);
        box-shadow: var(--shadow);
    }

    .desktop-only-warning h1 {
        margin: 0 0 10px;
        font-size: 22px;
    }

    .desktop-only-warning p {
        margin: 0;
        color: var(--muted);
        line-height: 1.55;
    }
}

.app-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    overflow: hidden;
}

.side-nav {
    background: #101827;
    color: #dbe5f3;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: 0;
    overflow: hidden;
}

.brand {
    padding: 2px 6px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.brand-kicker {
    color: #8fb3ff;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.brand-title {
    margin-top: 7px;
    color: #ffffff;
    font-size: 22px;
    font-weight: 800;
}

.branch-pill {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .1);
    color: #cbd5e1;
    font-size: 13px;
    line-height: 1.35;
}

.branch-pill strong {
    display: block;
    color: #ffffff;
    font-size: 14px;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: #dbe5f3;
    text-decoration: none;
    border: 1px solid transparent;
    background: transparent;
}

.nav-link:hover,
.nav-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, .09);
    border-color: rgba(255, 255, 255, .1);
}

.nav-link.disabled {
    color: #7d899b;
    cursor: default;
}

.nav-link.disabled:hover {
    background: transparent;
    border-color: transparent;
}

.main-area {
    min-width: 0;
    min-height: 0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
    flex-shrink: 0;
}

.page-title {
    margin: 0;
    font-size: 28px;
    line-height: 1.15;
}

.page-subtitle {
    margin: 6px 0 0;
    color: var(--muted);
}

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

.panel {
    background: rgba(255, 255, 255, .92);
    border: 1px solid rgba(216, 222, 232, .95);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0;
}

.panel-pad {
    padding: 18px;
}

.page-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
    min-height: 0;
    overflow: hidden;
}

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) 360px;
    gap: 16px;
    align-items: start;
    min-height: 0;
    overflow: hidden;
}

.toolbar {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
    background: rgba(248, 250, 252, .86);
    border-radius: var(--radius) var(--radius) 0 0;
    flex-shrink: 0;
}

.field {
    display: grid;
    gap: 6px;
}

.field label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.input,
.select {
    height: 40px;
    min-width: 190px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--text);
    padding: 0 12px;
    outline: none;
}

.input:focus,
.select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .16);
}

.input.wide {
    min-width: 320px;
}

.btn {
    min-height: 40px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--text);
    padding: 0 14px;
    font-weight: 700;
}

.btn:hover {
    border-color: var(--primary);
}

.btn.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.btn.primary:hover {
    background: var(--primary-strong);
}

.btn.dark {
    border-color: #172033;
    background: #172033;
    color: #ffffff;
}

.btn.danger {
    border-color: rgba(220, 38, 38, .25);
    background: #fef2f2;
    color: var(--danger);
}

.btn:disabled {
    cursor: default;
    color: #94a3b8;
    background: #f1f5f9;
    border-color: var(--line);
}

.segmented {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: var(--radius);
    background: var(--surface-3);
    border: 1px solid var(--line);
}

.segmented .segment {
    min-height: 32px;
    border: 0;
    border-radius: 6px;
    padding: 0 12px;
    background: transparent;
    color: var(--muted);
    font-weight: 700;
}

.segmented .segment.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 5px rgba(15, 23, 42, .1);
}

.status {
    min-height: 20px;
    color: var(--muted);
    font-size: 14px;
}

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

.status.success {
    color: var(--success);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    flex-shrink: 0;
}

.metric {
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.metric-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.metric-value {
    margin-top: 7px;
    font-size: 24px;
    font-weight: 800;
}

.table-wrap {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    max-height: calc(100vh - 315px);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    min-width: 0;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8fafc;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.data-table tbody tr {
    background: #ffffff;
}

.data-table tbody tr:hover {
    background: #f6fbff;
}

.data-table tbody tr.selected {
    background: #eefcf8;
}

.num {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    background: #eef2ff;
    color: #3730a3;
    max-width: 100%;
}

.badge.success {
    background: #dcfce7;
    color: #166534;
}

.badge.warning {
    background: #fef3c7;
    color: #92400e;
}

.badge.danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge.neutral {
    background: #e2e8f0;
    color: #334155;
}

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

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.detail-item {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    padding: 12px;
}

.detail-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.detail-value {
    margin-top: 6px;
    font-weight: 800;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, .44);
    z-index: 20;
}

.modal-backdrop.active {
    display: flex;
}

.modal {
    width: min(560px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    background: #ffffff;
    border-radius: var(--radius);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
    border: 1px solid var(--line);
}

.modal-header,
.modal-body,
.modal-footer {
    padding: 18px;
}

.modal-header {
    border-bottom: 1px solid var(--line);
}

.modal-title {
    margin: 0;
    font-size: 20px;
}

.modal-subtitle {
    margin: 6px 0 0;
    color: var(--muted);
}

.modal-subtitle.success {
    color: var(--success);
}

.modal-subtitle.error {
    color: var(--danger);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--line);
}

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

.form-grid .field.full {
    grid-column: 1 / -1;
}

.branch-list {
    display: grid;
    gap: 10px;
}

.branch-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.branch-row-title {
    font-weight: 800;
}

.branch-row-url {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.branch-actions {
    display: flex;
    gap: 8px;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 14px;
}

.menu-card {
    min-height: 142px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    color: var(--text);
    text-decoration: none;
    background: #ffffff;
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.menu-card:hover {
    transform: translateY(-2px);
    border-color: rgba(15, 118, 110, .45);
    box-shadow: 0 14px 30px rgba(15, 23, 42, .12);
}

.menu-card.disabled {
    color: #94a3b8;
    background: #f8fafc;
    cursor: default;
}

.menu-card.disabled:hover {
    transform: none;
    border-color: var(--line);
    box-shadow: none;
}

.menu-card-title {
    font-size: 17px;
    font-weight: 850;
}

.menu-card-sub {
    margin-top: 8px;
    color: var(--muted);
    line-height: 1.45;
}

.menu-card-meta {
    margin-top: 16px;
    color: var(--primary);
    font-weight: 800;
    font-size: 13px;
}

.search-hero {
    display: grid;
    grid-template-columns: minmax(280px, 520px) auto;
    align-items: end;
    gap: 12px;
}

.record-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.record-title-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.record-title {
    font-size: 24px;
    font-weight: 850;
}

.record-subtitle {
    margin-top: 5px;
    color: var(--muted);
}

.side-panel {
    position: sticky;
    top: 24px;
}

.side-note {
    color: var(--muted);
    line-height: 1.55;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 30px;
}

.login-panel {
    width: min(1120px, 100%);
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
    overflow: hidden;
}

.login-aside {
    background: #101827;
    color: #ffffff;
    padding: 34px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.login-aside h1 {
    margin: 10px 0 0;
    font-size: 34px;
    line-height: 1.08;
}

.login-aside p {
    color: #cbd5e1;
    line-height: 1.6;
}

.login-content {
    padding: 28px;
    background: rgba(255, 255, 255, .95);
}

.setup-panel {
    width: min(520px, 100%);
    overflow: hidden;
}

.setup-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.share-panel {
    width: min(1120px, 100%);
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    overflow: hidden;
}

.share-toolbar {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.share-list {
    margin-top: 12px;
    display: grid;
    gap: 10px;
}

.share-row {
    display: grid;
    grid-template-columns: 38px minmax(0, .85fr) minmax(0, 1.15fr) auto;
    gap: 10px;
    align-items: end;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.share-check {
    height: 40px;
    display: grid;
    place-items: center;
}

.share-check input {
    width: 18px;
    height: 18px;
}

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

.setup-output {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.textarea {
    width: 100%;
    min-height: 92px;
    resize: vertical;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--text);
    padding: 10px 12px;
    outline: none;
    font: inherit;
    line-height: 1.45;
}

.textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .16);
}

.branch-select-list {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.branch-select {
    width: 100%;
    min-height: 66px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    text-align: left;
}

.branch-select:hover {
    border-color: var(--primary);
    background: #f6fffc;
}

.branch-select-name {
    font-weight: 850;
}

.branch-select-url {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kbd {
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 6px;
    padding: 2px 7px;
    background: #ffffff;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

@media (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 218px minmax(0, 1fr);
    }

    .menu-grid {
        grid-template-columns: repeat(3, minmax(180px, 1fr));
    }

    .two-col {
        grid-template-columns: minmax(0, 1fr);
    }

    .side-panel {
        position: static;
    }
}

.content-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.content-panel .table-wrap {
    flex: 1;
}

.product-table col:nth-child(1) { width: 25%; }
.product-table col:nth-child(2) { width: 14%; }
.product-table col:nth-child(3) { width: 14%; }
.product-table col:nth-child(4) { width: 9%; }
.product-table col:nth-child(5) { width: 9%; }
.product-table col:nth-child(6) { width: 9%; }
.product-table col:nth-child(7) { width: 10%; }
.product-table col:nth-child(8) { width: 10%; }

.customer-table col:nth-child(1) { width: 32%; }
.customer-table col:nth-child(2) { width: 34%; }
.customer-table col:nth-child(3) { width: 18%; }
.customer-table col:nth-child(4) { width: 16%; }

.customer-table td {
    white-space: normal;
}

.customer-main {
    font-weight: 850;
    margin-bottom: 5px;
}

.customer-sub {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.report-table col:first-child { width: 28%; }

.section-title {
    margin: 0 0 12px;
    font-size: 18px;
}

.section-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    min-height: 0;
}

.section-grid .panel {
    min-height: 260px;
}

.panel-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
    background: rgba(248, 250, 252, .86);
    border-radius: var(--radius) var(--radius) 0 0;
}

.panel-titlebar h2 {
    margin: 0;
    font-size: 16px;
}

.small-table-wrap {
    max-height: 300px;
}
