:root {
    --bg: #f5ede5;
    --bg-strong: #f0e2d3;
    --panel: rgba(255, 250, 246, 0.92);
    --panel-strong: #fffdf9;
    --line: rgba(99, 63, 39, 0.12);
    --text: #2f1f18;
    --muted: #7a6154;
    --primary: #9d355d;
    --primary-strong: #7d2448;
    --success: #1f7a57;
    --warning: #b36a16;
    --danger: #b13f35;
    --shadow: 0 20px 50px rgba(63, 35, 20, 0.12);
    --radius-lg: 28px;
    --radius-md: 20px;
    --radius-sm: 14px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--text);
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #f9f3eb 0%, #f5ede5 100%);
}

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

button,
input,
select,
textarea {
    font: inherit;
}

.site-backdrop {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at top right, rgba(157, 53, 93, 0.14), transparent 24%),
        radial-gradient(circle at left 10% bottom 15%, rgba(31, 122, 87, 0.12), transparent 20%),
        radial-gradient(circle at center, rgba(255, 255, 255, 0.45), transparent 55%);
    pointer-events: none;
    z-index: 0;
}

.topbar,
.page-shell {
    position: relative;
    z-index: 1;
}

.topbar {
    padding: 18px 20px 0;
}

.topbar-inner {
    max-width: 1220px;
    margin: 0 auto;
    padding: 16px 20px;
    border: 1px solid var(--line);
    border-radius: 26px;
    background: rgba(255, 248, 242, 0.88);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 18px;
    justify-content: space-between;
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand strong,
h1,
h2,
h3 {
    font-family: Georgia, "Times New Roman", serif;
}

.brand strong {
    display: block;
    font-size: 1.15rem;
}

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

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #9d355d, #d06b70);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.08em;
}

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

.main-nav {
    display: flex;
    gap: 8px;
}

.main-nav a {
    padding: 10px 14px;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 700;
}

.main-nav a.active,
.main-nav a:hover {
    background: rgba(157, 53, 93, 0.1);
    color: var(--primary-strong);
}

.user-pill {
    display: grid;
    gap: 2px;
    padding: 10px 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
}

.user-pill span {
    color: var(--muted);
    font-size: 0.88rem;
}

.menu-toggle {
    display: none;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 16px;
    background: #fff;
    box-shadow: inset 0 0 0 1px var(--line);
    padding: 11px;
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    height: 2px;
    background: var(--text);
    border-radius: 999px;
}

.menu-toggle span + span {
    margin-top: 6px;
}

.page-shell {
    max-width: 1220px;
    margin: 0 auto;
    padding: 26px 20px 42px;
}

.guest-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.flash {
    margin-bottom: 18px;
    padding: 15px 18px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid transparent;
    box-shadow: var(--shadow);
}

.flash-success {
    background: rgba(31, 122, 87, 0.12);
    border-color: rgba(31, 122, 87, 0.18);
}

.flash-error {
    background: rgba(177, 63, 53, 0.12);
    border-color: rgba(177, 63, 53, 0.18);
}

.flash-close {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 1.4rem;
    cursor: pointer;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 16px;
    padding: 12px 18px;
    font-weight: 700;
    border: 0;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    background: linear-gradient(135deg, var(--primary), #cb5c73);
    color: #fff;
    box-shadow: 0 14px 30px rgba(157, 53, 93, 0.24);
}

.button-light {
    background: rgba(255, 255, 255, 0.78);
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--line);
}

.button-success {
    background: linear-gradient(135deg, var(--success), #2ea06d);
    color: #fff;
}

.button-warning {
    background: linear-gradient(135deg, var(--warning), #d58a2d);
    color: #fff;
}

.button-danger {
    background: linear-gradient(135deg, var(--danger), #cf5a4d);
    color: #fff;
    box-shadow: 0 14px 30px rgba(177, 63, 53, 0.2);
}

.button-small {
    padding: 9px 14px;
    border-radius: 14px;
    font-size: 0.92rem;
}

.button-block {
    width: 100%;
}

.button-link {
    border: 0;
    background: transparent;
    color: var(--primary-strong);
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}

.danger-link {
    color: var(--danger);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    font-size: 0.84rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.eyebrow::before {
    content: "";
    width: 26px;
    height: 2px;
    border-radius: 999px;
    background: rgba(157, 53, 93, 0.45);
}

.hero-panel,
.section-head,
.detail-hero {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 18px;
    margin-bottom: 24px;
}

h1 {
    margin: 8px 0 10px;
    font-size: clamp(2rem, 5vw, 3.3rem);
    line-height: 1.02;
}

h2 {
    margin: 6px 0 0;
    font-size: 1.55rem;
}

h3 {
    margin: 0;
    font-size: 1.2rem;
}

p {
    margin-top: 0;
    color: var(--muted);
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.hero-actions .inline-form {
    display: flex;
}

.panel-card,
.customer-card,
.stat-card,
.feature-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.panel-card,
.customer-card {
    padding: 24px;
}

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

.text-link {
    color: var(--primary-strong);
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 22px;
    display: grid;
    gap: 8px;
}

.stat-card strong {
    font-size: 1.8rem;
    font-family: Georgia, "Times New Roman", serif;
}

.stat-card span,
.stat-card small {
    color: var(--muted);
}

.stat-card-accent {
    background: linear-gradient(135deg, rgba(157, 53, 93, 0.95), rgba(90, 28, 57, 0.95));
    color: #fff;
}

.stat-card-accent span,
.stat-card-accent small {
    color: rgba(255, 255, 255, 0.84);
}

.content-grid,
.admin-layout {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

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

.data-table th {
    color: var(--muted);
    font-size: 0.84rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.text-right {
    text-align: right !important;
}

.text-danger {
    color: var(--danger);
    font-weight: 700;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
}

.badge-danger {
    background: rgba(177, 63, 53, 0.12);
    color: var(--danger);
}

.badge-success {
    background: rgba(31, 122, 87, 0.12);
    color: var(--success);
}

.badge-warning {
    background: rgba(179, 106, 22, 0.14);
    color: var(--warning);
}

.badge-muted {
    background: rgba(122, 97, 84, 0.12);
    color: var(--muted);
}

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

.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.62);
}

.list-row strong,
.list-meta strong {
    display: block;
}

.list-row span,
.list-meta small {
    color: var(--muted);
}

.list-meta {
    text-align: right;
}

.login-layout {
    width: 100%;
    display: grid;
    grid-template-columns: 1.2fr minmax(320px, 460px);
    gap: 28px;
    align-items: center;
}

.feature-points {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 24px;
}

.feature-card {
    padding: 18px;
    display: grid;
    gap: 8px;
}

.login-card {
    max-width: 460px;
    justify-self: end;
}

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

.field span {
    font-weight: 700;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid rgba(99, 63, 39, 0.14);
    border-radius: 16px;
    background: #fff;
    padding: 13px 15px;
    outline: none;
    color: var(--text);
}

.field textarea {
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: rgba(157, 53, 93, 0.45);
    box-shadow: 0 0 0 4px rgba(157, 53, 93, 0.08);
}

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

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

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

.form-actions,
.filters-actions,
.row-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.inline-alert {
    margin-bottom: 16px;
    padding: 13px 16px;
    border-radius: 16px;
    font-weight: 700;
}

.inline-alert-error {
    background: rgba(177, 63, 53, 0.12);
    color: var(--danger);
}

.filters-row {
    display: flex;
    align-items: end;
    gap: 14px;
    flex-wrap: wrap;
}

.grow-field {
    flex: 1 1 280px;
}

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

.customer-card {
    display: grid;
    gap: 18px;
}

.customer-card-head,
.customer-card-foot {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.customer-card h2 {
    margin: 0 0 6px;
}

.customer-card-body {
    display: grid;
    gap: 11px;
}

.balance-chip {
    padding: 10px 14px;
    border-radius: 999px;
    font-weight: 800;
}

.balance-danger {
    background: rgba(177, 63, 53, 0.12);
    color: var(--danger);
}

.balance-success {
    background: rgba(31, 122, 87, 0.12);
    color: var(--success);
}

.info-line,
.info-box {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
}

.info-line span,
.info-box span,
.info-box a {
    color: var(--muted);
    text-align: right;
}

.info-grid {
    display: grid;
    gap: 14px;
}

.info-box {
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.68);
    border-radius: 18px;
    border: 1px solid var(--line);
}

.quick-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 18px;
}

.quick-scroll a {
    flex: 0 0 auto;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(157, 53, 93, 0.09);
    color: var(--primary-strong);
    font-weight: 700;
}

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

.action-card {
    padding: 18px;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.68);
    display: grid;
    gap: 14px;
}

.action-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.empty-state,
.empty-cell {
    color: var(--muted);
    text-align: center;
}

.empty-state {
    display: grid;
    gap: 6px;
    padding: 18px;
}

.inline-form {
    display: inline;
}

.login-help {
    margin-top: 14px;
    color: var(--muted);
}

@media (max-width: 1080px) {
    .stats-grid,
    .action-forms {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .content-grid,
    .admin-layout,
    .login-layout,
    .customer-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        justify-self: stretch;
        max-width: none;
    }

    .feature-points {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .menu-toggle {
        display: inline-block;
    }

    .topbar-actions {
        position: absolute;
        top: calc(100% + 10px);
        left: 0;
        right: 0;
        display: none;
        flex-direction: column;
        align-items: stretch;
        padding: 14px;
        border-radius: 22px;
        background: rgba(255, 250, 246, 0.98);
        border: 1px solid var(--line);
        box-shadow: var(--shadow);
    }

    .topbar-actions.is-open,
    .topbar-actions[data-open="true"] {
        display: flex;
    }

    .main-nav {
        flex-direction: column;
    }
}

@media (max-width: 720px) {
    .topbar,
    .page-shell {
        padding-left: 14px;
        padding-right: 14px;
    }

    .topbar-inner,
    .panel-card,
    .customer-card {
        padding: 18px;
        border-radius: 22px;
    }

    .hero-panel,
    .section-head,
    .detail-hero,
    .filters-row,
    .customer-card-head,
    .customer-card-foot,
    .card-head {
        align-items: stretch;
        flex-direction: column;
    }

    .stats-grid,
    .two-column-form,
    .action-forms {
        grid-template-columns: 1fr;
    }

    .button,
    .filters-actions,
    .form-actions {
        width: 100%;
    }

    .filters-actions .button,
    .form-actions .button,
    .hero-actions .button,
    .customer-card-foot .button {
        width: 100%;
    }

    .info-line,
    .info-box {
        flex-direction: column;
    }

    .info-line span,
    .info-box span,
    .info-box a {
        text-align: left;
    }

    .data-table {
        min-width: 640px;
    }
}
