:root {
    --admin-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-soft: #f9fafb;
    --surface-strong: #f1f3f5;
    --text: #141821;
    --muted: #667085;
    --muted-strong: #475467;
    --line: #e5e7eb;
    --line-strong: #d0d5dd;
    --brand: #bf2f6b;
    --brand-soft: #fff1f7;
    --brand-dark: #6f1d42;
    --dark: #151923;
    --success: #15803d;
    --danger: #b42318;
    --warning: #b45309;
    --info: #0369a1;
    --radius: 10px;
    --shadow: 0 16px 42px rgba(16, 24, 40, .08);
    --shadow-soft: 0 8px 22px rgba(16, 24, 40, .05);
    --sidebar-width: 286px;
}

* { box-sizing: border-box; }
html { text-size-adjust: 100%; }

body.admin-body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--admin-font);
    font-size: 14px;
    letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

.admin-shell { min-height: 100vh; }

.admin-sidebar,
.admin-nav,
.table-wrap,
.customer-picker-results {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, .75) transparent;
}

.admin-sidebar::-webkit-scrollbar,
.admin-nav::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
.customer-picker-results::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

.admin-sidebar::-webkit-scrollbar-track,
.admin-nav::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track,
.customer-picker-results::-webkit-scrollbar-track { background: transparent; }

.admin-sidebar::-webkit-scrollbar-thumb,
.admin-nav::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
.customer-picker-results::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: rgba(148, 163, 184, .72);
    background-clip: content-box;
}

.admin-sidebar::-webkit-scrollbar-thumb:hover,
.admin-nav::-webkit-scrollbar-thumb:hover,
.table-wrap::-webkit-scrollbar-thumb:hover,
.customer-picker-results::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, .9);
    background-clip: content-box;
}

.admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, .96);
    color: var(--text);
    overflow-y: auto;
    padding: 18px;
    box-shadow: 8px 0 28px rgba(16, 24, 40, .04);
}

.admin-brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 16px;
}

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

.brand-mark {
    display: grid;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 9px;
    background: var(--brand);
    color: #fff;
    font-weight: 900;
}

.admin-brand b {
    display: block;
    font-size: 18px;
    line-height: 1.1;
}

.admin-brand small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.admin-nav {
    display: grid;
    gap: 16px;
    padding: 18px 0;
}

.nav-group {
    display: grid;
    gap: 4px;
}

.nav-title {
    margin: 0 10px 5px;
    color: #98a2b3;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.admin-nav a,
.sidebar-exit {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 40px;
    border-radius: 8px;
    padding: 10px 11px;
    color: var(--muted-strong);
    font-weight: 800;
}

.admin-nav a i,
.sidebar-exit i {
    width: 18px;
    color: #9aa4b2;
    text-align: center;
}

.admin-nav a:hover,
.admin-nav a:focus-visible,
.admin-nav a.active {
    background: var(--brand-soft);
    color: var(--brand-dark);
    outline: none;
}

.admin-nav a:hover i,
.admin-nav a:focus-visible i,
.admin-nav a.active i { color: var(--brand); }

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.sidebar-exit:hover { background: var(--surface-strong); }

.admin-main {
    margin-left: var(--sidebar-width);
    padding: 24px;
}

.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .94);
    padding: 16px 18px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
}

.topbar-title {
    min-width: 0;
    margin-right: auto;
}

.admin-topbar h1 {
    margin: 3px 0 0;
    font-size: 25px;
    line-height: 1.2;
}

.eyebrow,
.section-kicker,
.badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--brand);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

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

.icon-btn {
    display: inline-grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

.menu-toggle,
.sidebar-close { display: none; }

.panel,
.stat {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.panel {
    margin-bottom: 18px;
    padding: 20px;
    overflow: visible;
}

.panel h3 {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 850;
}

.lead,
.panel p {
    color: var(--muted);
    line-height: 1.55;
}

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

.compact-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 16px;
}

.stat {
    min-width: 0;
    padding: 17px;
}

.stat small {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.stat b {
    display: block;
    margin-top: 7px;
    font-size: 25px;
    font-weight: 900;
}

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

.two,
.three {
    display: grid;
    gap: 16px;
}

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

.form,
.filters {
    display: grid;
    gap: 14px;
}

.filters {
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    align-items: end;
}

.compact-filters { grid-template-columns: minmax(240px, 1fr) auto auto; }

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

.field,
.form-label {
    display: grid;
    gap: 7px;
    min-width: 0;
}

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

.field span,
.field label,
.form-label {
    color: #344054;
    font-size: 13px;
    font-weight: 850;
}

input:not([type="hidden"]):not([type="radio"]):not([type="checkbox"]),
select,
textarea {
    display: block;
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    outline: none;
    box-shadow: none;
}

input:not([type="hidden"]):not([type="radio"]):not([type="checkbox"]),
select {
    min-height: 44px;
    padding: 0 12px;
}

textarea {
    min-height: 112px;
    padding: 12px;
    resize: vertical;
    line-height: 1.5;
}

select { padding-right: 36px; }

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(191, 47, 107, .12);
}

input[type="file"] { padding: 7px; }

input[type="file"]::file-selector-button {
    min-height: 32px;
    margin-right: 10px;
    border: 0;
    border-radius: 7px;
    background: var(--dark);
    color: #fff;
    font-weight: 850;
}

.btn,
button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    max-width: 100%;
    border: 1px solid var(--brand);
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    padding: 9px 13px;
    font-weight: 850;
    line-height: 1.2;
    text-align: center;
}

.btn:hover,
.btn:focus-visible {
    filter: brightness(.97);
    outline: none;
}

.btn.small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 12px;
}

.btn.light,
.btn-light {
    border-color: var(--line);
    background: #fff;
    color: var(--text);
}

.btn.dark,
.btn-dark {
    border-color: var(--dark);
    background: var(--dark);
    color: #fff;
}

.btn.success { border-color: var(--success); background: var(--success); }
.btn.danger,
.delete-link {
    border-color: #fee4e2;
    background: #fff5f5;
    color: var(--danger);
}

.inline-action,
.inline-delete,
.appointment-complete-form {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}

.appointment-complete-form select {
    width: auto;
    min-width: 138px;
    min-height: 34px;
    font-size: 12px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
}

table {
    width: 100%;
    min-width: 780px;
    border-collapse: separate;
    border-spacing: 0;
}

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

th {
    background: var(--surface-soft);
    color: #475467;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

td { color: #344054; }
tbody tr:hover td { background: #fcfcfd; }

.status {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    background: #f2f4f7;
    color: #344054;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 850;
}

.status.active,
.status.approved,
.status.completed,
.status.paid,
.status.answered,
.status.read {
    background: #ecfdf3;
    color: var(--success);
}

.status.pending,
.status.open,
.status.new,
.status.unpaid {
    background: #fff7ed;
    color: var(--warning);
}

.status.cancelled,
.status.inactive,
.status.refunded,
.status.closed {
    background: #fff1f3;
    color: var(--danger);
}

.calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.day {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 10px;
}

.day.free { background: #f0fdf4; }
.day.busy { background: #fff7ed; }
.day.full { background: #fff1f3; }

.package-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.package-progress-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    padding: 16px;
}

.package-progress-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.package-progress-head b {
    display: block;
    font-weight: 900;
}

.package-progress-head span,
.package-progress-card small {
    color: var(--muted);
    font-size: 12px;
}

.progress-track {
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #eef2f6;
    margin: 12px 0;
}

.progress-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--brand);
}

.mini-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    margin-bottom: 10px;
}

.mini-metrics span {
    display: grid;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-align: center;
}

.mini-metrics b {
    display: block;
    color: var(--text);
    font-size: 16px;
}

.info-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.info-list div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 12px 14px;
}

.info-list span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
}

.info-list b {
    text-align: right;
    overflow-wrap: anywhere;
}

.inline-search {
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 8px 10px;
}

.inline-search i { color: var(--brand); }

.table-search {
    border: 0 !important;
    min-height: 36px !important;
    padding: 0 !important;
    box-shadow: none !important;
}

.customer-picker {
    position: relative;
    z-index: 4;
}

.customer-picker-results {
    position: absolute;
    top: calc(100% - 1px);
    left: 0;
    right: 0;
    z-index: 50;
    display: none;
    max-height: 280px;
    overflow: auto;
    border: 1px solid var(--line-strong);
    border-radius: 0 0 8px 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.customer-picker-results.is-open { display: block; }

.customer-picker-results button {
    display: flex;
    width: 100%;
    min-height: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: #fff;
    padding: 11px 12px;
    color: var(--text);
    text-align: left;
}

.customer-picker-results button:hover { background: var(--brand-soft); }
.customer-picker-results b { font-size: 14px; }

.customer-picker-results small,
.customer-picker-selected,
.field small {
    color: var(--muted);
    font-size: 12px;
}

.toast-stack {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 90;
    display: grid;
    gap: 10px;
}

.app-toast {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: 10px;
    background: #fff;
    padding: 13px 14px;
    box-shadow: var(--shadow);
    font-weight: 850;
    transition: opacity .2s ease, transform .2s ease;
}

.app-toast.success { border-left-color: var(--success); }
.app-toast.error { border-left-color: var(--danger); }
.app-toast button {
    border: 0;
    background: transparent;
    color: var(--muted);
}

.empty-state,
.app-note {
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--muted);
    padding: 13px;
}

.login-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 460px;
    min-height: 100vh;
}

.login-intro {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 40px;
    border-right: 1px solid var(--line);
    background: #fff;
    padding: 42px;
}

.login-intro h1 {
    max-width: 760px;
    margin: 18px 0 0;
    font-size: clamp(34px, 6vw, 72px);
    line-height: .98;
}

.login-intro p {
    max-width: 560px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.7;
}

.login-card {
    align-self: center;
    margin: 24px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    padding: 30px;
    box-shadow: var(--shadow);
}

.login-card-head {
    margin-bottom: 22px;
    text-align: center;
}

.login-card-head b { font-size: 22px; }
.login-card-head h2 {
    margin: 18px 0 0;
    font-size: 30px;
}

.login-card-head p,
.login-help { color: var(--muted); }

.login-help {
    margin: 18px 0 0;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
}

.login-logo {
    max-width: 150px;
    max-height: 42px;
    object-fit: contain;
}

.error-note {
    border-color: #fecdd3;
    background: #fff1f3;
    color: var(--danger);
    margin-bottom: 16px;
    font-weight: 850;
}

.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; }
.block { display: block; }

body.sidebar-open { overflow: hidden; }
.admin-scrim { display: none; }

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

@media (max-width: 980px) {
    .menu-toggle,
    .sidebar-close { display: inline-grid; }

    .admin-sidebar {
        transform: translateX(-104%);
        transition: transform .2s ease;
    }

    body.sidebar-open .admin-sidebar { transform: translateX(0); }
    body.sidebar-open .admin-scrim {
        position: fixed;
        inset: 0;
        z-index: 40;
        display: block;
        background: rgba(15, 23, 42, .28);
    }

    .admin-main {
        margin-left: 0;
        padding: 14px;
    }

    .admin-topbar,
    .page-heading {
        align-items: stretch;
    }

    .topbar-actions { justify-content: flex-start; }
    .three,
    .field-grid { grid-template-columns: 1fr; }
    table { min-width: 760px; }
}

@media (max-width: 640px) {
    .admin-main { padding: 10px; }
    .admin-topbar {
        flex-wrap: wrap;
        padding: 13px;
    }
    .topbar-title { width: calc(100% - 52px); }
    .admin-topbar h1 { font-size: 21px; }
    .topbar-actions,
    .topbar-actions .btn { width: 100%; }
    .panel,
    .stat { padding: 14px; }
    .stats,
    .filters,
    .compact-filters { grid-template-columns: 1fr; }
    .btn,
    .actions .btn,
    .actions form,
    .actions button { width: 100%; }
    .customer-picker-results {
        position: static;
        margin-top: 8px;
        border-radius: 8px;
    }
    .table-wrap {
        margin-left: -10px;
        margin-right: -10px;
        padding-left: 10px;
        padding-right: 10px;
    }
    .calendar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .toast-stack {
        left: 10px;
        right: 10px;
    }
    .app-toast { min-width: 0; }
}
