:root {
    --bg: #f8fafc;
    --panel: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --accent: #4f46e5;
    --accent-dark: #4338ca;
    --accent-soft: #eef2ff;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --success-soft: #ecfdf5;
    --success-text: #047857;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}

a {
    color: inherit;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h2 {
    color: #0f172a;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0;
    margin-bottom: 16px;
}

p {
    line-height: 1.55;
}

.page {
    min-height: 100vh;
}

.container-xl {
    width: min(100% - 32px, 1440px);
    margin: 0 auto;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
    backdrop-filter: blur(16px);
}

.topbar > .container-xl {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 64px;
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #111827;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.app-logo {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    padding: 0;
    overflow-x: auto;
}

.tabs button.nav-link {
    min-height: 34px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #475569;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.tabs button.nav-link:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.tabs button.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.navbar-user {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    white-space: nowrap;
}

.user-menu-toggle {
    min-height: 34px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: #fff;
    color: #0f172a;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 700;
}

.user-menu-toggle:hover {
    border-color: var(--line);
    background: #f8fafc;
}

.user-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 1000;
    min-width: 190px;
    display: grid;
    gap: 4px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s ease;
}

.navbar-user:hover .user-menu,
.navbar-user.menu-open .user-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu button,
.user-menu a {
    display: flex;
    align-items: center;
    min-height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
}

.user-menu button:hover,
.user-menu a:hover {
    background: #f1f5f9;
    color: var(--accent-dark);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    background: var(--accent-soft);
    color: #3730a3;
    padding: 0 9px;
    font-size: 12px;
    font-weight: 700;
}

.bg-green-lt {
    border-color: #bbf7d0;
    background: var(--success-soft);
    color: var(--success-text);
}

.bg-blue-lt {
    border-color: #c7d2fe;
    background: var(--accent-soft);
    color: #3730a3;
}

.page-info-bar {
    border-bottom: 1px solid rgba(226, 232, 240, 0.72);
    background: rgba(248, 250, 252, 0.78);
}

.page-info {
    display: grid;
    gap: 4px;
    min-height: 58px;
    padding: 12px 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.page-info strong {
    color: #0f172a;
    font-size: 15px;
    font-weight: 800;
}

.page-info span {
    max-width: 920px;
}

.page-body {
    padding: 20px 0 40px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(300px, 25%) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 18px;
}

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

.panel-heading h2 {
    margin-bottom: 0;
}

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

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(260px, 1fr));
    gap: 16px;
    align-items: start;
}

.admin-stack {
    display: grid;
    gap: 16px;
}

.admin-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.admin-sidebar {
    position: sticky;
    top: 84px;
    display: grid;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow);
}

.admin-sidebar button {
    justify-content: flex-start;
    border: 0;
    background: transparent;
    color: #475569;
    text-align: left;
}

.admin-sidebar button.active {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

.form-grid,
.entity-form {
    display: grid;
    gap: 12px;
}

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

#create-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

#create-form label {
    gap: 4px;
    min-width: 0;
    font-size: 11px;
}

#create-form input,
#create-form select {
    height: 32px;
    min-height: 32px;
    padding: 5px 7px;
    font-size: 12px;
}

.form-grid h2 {
    grid-column: 1 / -1;
}

#create-form .tool-row,
#create-form .muted,
.span-all {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 6px;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    padding: 8px 10px;
    font: inherit;
    transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

input,
select {
    height: 38px;
}

textarea {
    resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--line-strong);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: 16px;
    accent-color: var(--accent);
}

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: #334155;
    padding: 0 22px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.row-actions button,
.row-actions .button-link {
    min-width: 88px;
    padding-inline: 16px;
}

button:hover,
.button-link:hover {
    border-color: #c7d2fe;
    background: #f8fafc;
    color: var(--accent-dark);
}

button:disabled,
.button-link.disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.button-link.disabled {
    pointer-events: none;
}

button.active,
button.primary,
.button-link.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.18);
}

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

button.danger {
    border-color: #fecaca;
    background: #fff1f2;
    color: var(--danger);
}

button.danger:hover {
    background: #ffe4e6;
    border-color: #fca5a5;
}

button.action-edit,
.button-link.action-edit {
    border-color: #c7d2fe;
    background: #eef2ff;
    color: #3730a3;
}

button.action-edit:hover,
.button-link.action-edit:hover {
    border-color: #a5b4fc;
    background: #e0e7ff;
    color: #312e81;
}

button.action-copy,
.button-link.action-copy {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

button.action-copy:hover,
.button-link.action-copy:hover {
    border-color: #86efac;
    background: #dcfce7;
    color: #14532d;
}

button.action-delete,
.button-link.action-delete {
    min-width: 96px;
}

.tool-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tool-row button,
.tool-row .button-link,
.panel-heading button,
.price-matrix-tabs button {
    padding-inline: 24px;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

.notice {
    border: 1px solid #c7d2fe;
    border-radius: 12px;
    background: var(--accent-soft);
    color: #3730a3;
    padding: 12px;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 600;
}

.notice.error {
    border-color: #fecaca;
    background: var(--danger-soft);
    color: #991b1b;
}

.list,
#product-list {
    margin-top: 16px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.table {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    color: #334155;
    text-align: left;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: 0;
}

th {
    background: #f8fafc;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
}

tbody tr {
    transition: background-color 180ms ease;
}

tbody tr:hover td {
    background: #fbfdff;
}

tbody tr.row-highlight td,
tbody tr.row-highlight th {
    background: #fef3c7;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.empty,
.empty-table-cell {
    color: var(--muted);
    padding: 14px;
    text-align: center;
}

.product-entry-row td {
    background: #f8fafc;
}

.product-entry-row input,
.product-entry-row select {
    width: 100%;
}

.icon-button {
    width: 36px;
    padding: 0;
    font-size: 15px;
}

.excel-tools {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.file-status {
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: 13px;
}

.file-status strong {
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
}

.preview-wrap,
.matrix-wrap {
    overflow: auto;
}

.preview-wrap {
    max-height: 520px;
}

.preview-wrap table {
    min-width: 2200px;
}

.preview-wrap th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.price-matrix-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0;
}

.price-matrix-tab-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #dbe3ef;
    border-radius: 12px;
    background: #f8fafc;
    padding: 4px;
}

.price-matrix-tabs button {
    gap: 8px;
    border-color: #dbe3ef;
    background: #f8fafc;
    color: #475569;
}

.price-matrix-tabs button.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.price-matrix-tabs .price-matrix-icon {
    min-width: 32px;
    min-height: 30px;
    padding: 0;
    border-radius: 9px;
    font-size: 16px;
    font-weight: 900;
}

.price-matrix-icon.current {
    border-color: #86efac;
    background: #dcfce7;
    color: #166534;
}

.price-matrix-icon.muted-icon {
    opacity: 0.38;
}

.matrix-wrap {
    margin-bottom: 14px;
}

.matrix-wrap input {
    min-width: 75px;
    min-height: 30px;
    padding: 4px 8px;
}

.price-plan-header {
    cursor: context-menu;
    user-select: none;
}

.price-context-menu {
    position: fixed;
    z-index: 1100;
    width: 240px;
    display: grid;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.14);
}

.price-context-menu[hidden] {
    display: none;
}

.price-context-menu button {
    width: 100%;
    justify-content: flex-start;
}

.price-menu-form {
    display: grid;
    gap: 10px;
}

.price-color-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.price-color-choice {
    min-height: 34px;
    border-color: #cbd5e1;
}

.price-color-grid button:not(.price-color-choice) {
    grid-column: span 2;
}

.import-box,
.import-help {
    display: grid;
    gap: 10px;
}

.import-help p {
    margin: 0;
}

.import-help pre,
.help-doc {
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fafc;
    color: #334155;
    padding: 12px;
    white-space: pre-wrap;
    overflow-x: auto;
    font: inherit;
    line-height: 1.55;
}

.app-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(6px);
}

.app-modal-backdrop[hidden] {
    display: none;
}

.app-modal-dialog {
    width: min(540px, 100%);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.2);
    padding: 18px;
}

.prose {
    max-width: 800px;
}

.prose p + p {
    margin-top: 10px;
}

#toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1200;
    max-width: min(420px, calc(100vw - 36px));
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    background: #0f172a;
    color: #fff;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: 160ms ease;
}

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

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: var(--bg);
}

.auth-card {
    width: min(420px, 100%);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow);
    padding: 26px;
}

.auth-card h1 {
    margin-bottom: 16px;
    font-size: 24px;
    font-weight: 800;
}

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

.payment-summary {
    display: grid;
    gap: 10px;
    margin: 18px 0;
}

.payment-summary > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fafc;
    padding: 12px 14px;
}

.payment-summary strong {
    text-align: right;
}

.payment-form {
    margin-top: 16px;
}

.pos-box {
    margin-top: 18px;
    border: 1px solid #c7d2fe;
    border-radius: 14px;
    background: linear-gradient(180deg, #fff, #f8fafc);
    padding: 18px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.payment-method-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.payment-method-heading h2,
.eft-box summary strong {
    display: block;
    color: #0f172a;
    font-size: 18px;
    font-weight: 800;
}

.payment-method-label {
    display: block;
    margin-bottom: 4px;
    color: var(--accent-dark);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.eft-box {
    margin-top: 22px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    overflow: hidden;
}

.eft-box summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    list-style: none;
    padding: 16px 18px;
}

.eft-box summary::-webkit-details-marker {
    display: none;
}

.eft-box[open] .eft-chevron {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.eft-chevron {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f8fafc;
    color: #475569;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 800;
}

.eft-content {
    border-top: 1px solid var(--line);
    padding: 18px;
}

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

.payment-debug {
    margin-top: 18px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.payment-debug summary {
    cursor: pointer;
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 800;
}

.payment-debug strong {
    display: block;
    margin-top: 12px;
    font-size: 12px;
    color: #334155;
}

.payment-debug pre {
    max-height: 220px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #0f172a;
    color: #e2e8f0;
    padding: 12px;
    font-size: 11px;
    line-height: 1.5;
}

.auth-links {
    display: flex;
    gap: 14px;
    margin: 14px 0;
}

.auth-secondary-form {
    margin-top: 10px;
}

.auth-links a {
    color: var(--accent-dark);
    font-weight: 700;
}

.button-link.google {
    width: 100%;
    margin-top: 8px;
}

@media (max-width: 1100px) {
    .topbar > .container-xl {
        flex-wrap: wrap;
        padding: 10px 0;
    }

    .tabs {
        order: 3;
        width: 100%;
    }

    .workspace,
    .settings-grid,
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .container-xl {
        width: min(100% - 20px, 1440px);
    }

    .topbar > .container-xl {
        align-items: flex-start;
        gap: 10px;
    }

    .navbar-user {
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
    }

    .user-menu {
        left: 0;
        right: auto;
    }

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

    .panel {
        padding: 14px;
    }

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

    .row-actions {
        justify-content: flex-start;
    }
}
