:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f0f4ff;
    --text: #142033;
    --text-muted: #596579;
    --line: #e2e8f4;
    --primary: #006d77;
    --primary-strong: #005660;
    --success: #1b9c65;
    --warning: #d08100;
    --shadow: 0 12px 30px rgba(20, 32, 51, 0.08);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: 'Sora', sans-serif;
    background: radial-gradient(circle at top right, #d8f3f4 0%, var(--bg) 45%);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    display: grid;
    grid-template-columns: 270px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, #0b1f3f, #132d58);
    color: #dbe8ff;
    padding: 28px 20px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #00a8b5, #00d4b8);
    color: #07353f;
    font-weight: 700;
}

.brand strong {
    display: block;
    letter-spacing: 0.8px;
}

.brand small {
    color: #a8bcdf;
}

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

.menu-item {
    padding: 12px 14px;
    border-radius: 12px;
    color: #b8cae6;
    transition: 0.2s ease;
}

.menu-item:hover,
.menu-item.active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.main-content {
    padding: 24px;
}

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

.topbar h1 {
    margin: 0;
    font-size: 1.5rem;
}

.topbar p {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 0.92rem;
}

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

.user-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    font-size: 0.78rem;
    font-weight: 600;
}

.user-chip small {
    color: var(--text-muted);
    font-size: 0.68rem;
}

.menu-toggle {
    display: none;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 10px;
    width: 42px;
    height: 42px;
}

.primary-btn {
    border: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #00a8b5);
    color: #fff;
    padding: 12px 18px;
    font-weight: 600;
    cursor: pointer;
}

.primary-btn:hover {
    background: linear-gradient(135deg, var(--primary-strong), #008f9a);
}

.secondary-btn {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    padding: 12px 16px;
    font-weight: 600;
    cursor: pointer;
}

.auth-body {
    min-height: 100vh;
}

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

.auth-card {
    width: 100%;
    max-width: 430px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 24px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.auth-brand p {
    margin: 2px 0 0;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.auth-card h1 {
    margin: 0 0 16px;
    font-size: 1.4rem;
}

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

.auth-form label {
    font-size: 0.86rem;
    font-weight: 600;
}

.auth-form input[type='email'],
.auth-form input[type='password'] {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    font-size: 0.95rem;
}

.checkbox-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 8px;
    font-weight: 500;
}

.error-text {
    color: #bf1f1f;
    font-size: 0.8rem;
}

.auth-tip {
    margin: 14px 0 0;
    color: var(--text-muted);
    font-size: 0.78rem;
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.kpi-card {
    padding: 16px;
}

.kpi-label {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.kpi-card h3 {
    margin: 10px 0 8px;
    font-size: 1.45rem;
}

.kpi-delta {
    color: var(--success);
    font-size: 0.85rem;
    font-weight: 600;
}

.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 14px;
}

.panel {
    padding: 16px;
}

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

.panel-head h2 {
    margin: 0;
    font-size: 1.05rem;
}

.panel-head a {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
}

.table-wrap {
    overflow: auto;
}

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

th,
td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
    font-size: 0.88rem;
}

th {
    color: var(--text-muted);
    font-weight: 600;
}

.status {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status.ok {
    background: #e6f8ef;
    color: #177f53;
}

.status.pending {
    background: #fff4df;
    color: var(--warning);
}

.shortcut-list {
    display: grid;
    gap: 12px;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 12px;
    background: var(--surface-soft);
    border: 1px solid #d9e4ff;
}

.shortcut-item h4 {
    margin: 0 0 6px;
    font-size: 0.95rem;
}

.shortcut-item p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.84rem;
}

kbd {
    background: #ffffff;
    border: 1px solid #ccd7ef;
    border-bottom-width: 2px;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 0.78rem;
    font-weight: 700;
}

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

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

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

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 260px;
        transform: translateX(-105%);
        transition: 0.2s ease;
        z-index: 1000;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .menu-toggle {
        display: inline-grid;
        place-items: center;
    }

    .topbar {
        flex-wrap: wrap;
    }

    .topbar-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .topbar-actions .primary-btn,
    .topbar-actions .secondary-btn {
        width: 100%;
    }

    .user-chip {
        width: 100%;
        align-items: flex-start;
    }
}

@media (max-width: 580px) {
    .main-content {
        padding: 14px;
    }

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

.page-head-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.page-head-row h2 {
    margin: 0;
}

.alert {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
    font-size: 0.9rem;
    font-weight: 600;
}

.alert.success {
    background: #e7f8ef;
    color: #177f53;
    border: 1px solid #cdeedc;
}

.alert.error {
    background: #fdecec;
    color: #af2323;
    border: 1px solid #f6cdcd;
}

.form-panel {
    padding: 18px;
}

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

.grid-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.grid-form input[type='text'],
.grid-form input[type='number'],
.grid-form select,
.grid-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 12px;
    font: inherit;
}

.grid-form textarea {
    resize: vertical;
}

.full-width {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.actions-col {
    display: flex;
    gap: 8px;
    align-items: center;
}

.table-link {
    border: 0;
    background: none;
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
    padding: 0;
}

.table-link.danger {
    color: #bf1f1f;
}

.empty-row {
    text-align: center;
    color: var(--text-muted);
    padding: 24px 8px;
}

.pagination-wrap {
    margin-top: 14px;
}

.pagination-wrap nav {
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 860px) {
    .page-head-row {
        flex-wrap: wrap;
    }

    .page-head-row .primary-btn,
    .page-head-row .secondary-btn {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 580px) {
    .grid-form {
        grid-template-columns: 1fr;
    }
}

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

.muted-line {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 0.84rem;
}

@media (max-width: 860px) {
    .page-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .page-actions .primary-btn,
    .page-actions .secondary-btn {
        width: 100%;
        text-align: center;
    }
}

.disabled-btn {
    opacity: 0.7;
    cursor: not-allowed;
}

.divider {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 18px 0;
}

.search-wrap {
    position: relative;
    margin-bottom: 12px;
}

.search-wrap input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    font: inherit;
}

.search-results {
    margin-top: 8px;
    display: grid;
    gap: 6px;
    max-height: 260px;
    overflow: auto;
}

.result-item {
    text-align: left;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 10px;
    cursor: pointer;
}

.result-item strong {
    display: block;
    font-size: 0.9rem;
}

.result-item small {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.inline-form input {
    width: 78px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px;
}

.total-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border: 1px dashed #a4bad7;
    border-radius: 10px;
    background: #f7fbff;
}

.hidden-form {
    display: none;
}

.payment-lines {
    display: grid;
    gap: 8px;
}

.payment-line {
    display: grid;
    grid-template-columns: 1.2fr 1fr auto;
    gap: 8px;
    align-items: center;
}

.payment-line select,
.payment-line input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    font: inherit;
}

@media (max-width: 860px) {
    .payment-line {
        grid-template-columns: 1fr;
    }
}

.context-pre {
    margin: 0;
    max-width: 360px;
    max-height: 140px;
    overflow: auto;
    background: #f6f9ff;
    border: 1px solid #dce6f8;
    border-radius: 8px;
    padding: 8px;
    font-size: 0.75rem;
    line-height: 1.35;
}

.pdv-body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at top right, #d8f3f4 0%, var(--bg) 45%);
}

.pdv-shell {
    min-height: 100vh;
    padding: 14px;
}

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

.pdv-topbar h1 {
    margin: 0;
    font-size: 1.35rem;
}

.pdv-topbar p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.84rem;
}

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

.pdv-shortcuts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px 12px;
}

.pdv-shortcuts span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    background: var(--surface-soft);
    border: 1px solid #d9e4ff;
    font-size: 0.8rem;
}

.pdv-launcher {
    max-width: 780px;
}

@media (max-width: 860px) {
    .pdv-topbar {
        flex-wrap: wrap;
    }

    .pdv-main .kpi-grid {
        grid-template-columns: 1fr;
    }
}
