:root {
    --color-main: #c4a574;
    --color-secondary: #8d6e4e;
    --color-text: #2a241c;
    --color-button: #c4a574;
    --color-sidebar: #161310;
    --color-topbar: #ffffff;
    --color-background: #f4efe8;
    --color-footer: #161310;
    --color-card: #ffffff;
    --color-border: #e6ddd2;
    --color-muted: #7a7168;
    --color-danger: #b42318;
    --color-success: #067647;
    --color-warning: #b54708;
    --shadow: 0 18px 50px rgba(22, 19, 16, 0.08);
    --shadow-sm: 0 8px 24px rgba(22, 19, 16, 0.06);
    --radius: 22px;
    --radius-sm: 14px;
    --sidebar-w: 272px;
    --font: "Outfit", system-ui, sans-serif;
    --serif: "Cormorant Garamond", Georgia, serif;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-background);
    line-height: 1.5;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--color-main); outline-offset: 2px; }

.app-body[style*="background-image"] .app-main {
    background: color-mix(in srgb, var(--color-background) 90%, transparent);
}
.app-shell {
    display: flex;
    min-height: 100vh;
}
.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-w);
}
.page-content {
    flex: 1;
    padding: 28px 28px 48px;
    animation: fadeUp 0.45s var(--ease);
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--color-sidebar);
    color: #f6efe6;
    display: flex;
    flex-direction: column;
    z-index: 40;
    box-shadow: 16px 0 40px rgba(0,0,0,.12);
    transition: transform 0.35s var(--ease);
}
.brand {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 28px 22px 18px;
}
.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, var(--color-main), var(--color-secondary));
    color: #1a1612;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.brand-text strong {
    display: block;
    font-family: var(--serif);
    font-size: 1.25rem;
    letter-spacing: 0.04em;
}
.brand-text span {
    color: rgba(246,239,230,.62);
    font-size: 0.78rem;
}
.nav { padding: 10px 14px; display: grid; gap: 6px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    color: rgba(246,239,230,.78);
    transition: background 0.25s var(--ease), color 0.25s, transform 0.25s;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; transform: translateX(3px); }
.nav-link.active {
    background: linear-gradient(135deg, var(--color-main), var(--color-secondary));
    color: #1a1612;
    font-weight: 600;
}
.nav-icon { width: 22px; height: 22px; display: grid; place-items: center; }
.nav-icon svg { width: 20px; height: 20px; }
.sidebar-foot {
    margin-top: auto;
    padding: 18px 22px 24px;
    color: rgba(246,239,230,.5);
    font-size: 0.8rem;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16,12,8,.45);
    z-index: 30;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 28px;
    background: color-mix(in srgb, var(--color-topbar) 92%, transparent);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--color-border);
}
.topbar-title h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: 1.7rem;
    font-weight: 600;
}
.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.68rem;
    color: var(--color-muted);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    padding: 6px 12px 6px 6px;
    border-radius: 999px;
}
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--color-main); color: #1a1612; font-weight: 700;
}
.icon-btn {
    width: 42px; height: 42px; border: 0; border-radius: 14px;
    background: var(--color-card); color: var(--color-text);
    border: 1px solid var(--color-border);
    display: grid; place-items: center; cursor: pointer;
    transition: transform 0.2s var(--ease), background 0.2s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { transform: translateY(-1px); background: #fff; }
.sidebar-toggle { display: none; }

.app-footer {
    background: var(--color-footer);
    color: #f3ebe1;
    padding: 22px 28px;
    display: grid;
    gap: 6px;
}
.footer-brand { font-family: var(--serif); font-size: 1.3rem; }
.footer-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; color: rgba(243,235,225,.72); font-size: 0.88rem; }
.footer-message { margin: 4px 0 0; color: rgba(243,235,225,.62); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    animation: fadeUp 0.5s var(--ease);
}
.card h2, .card h3 { margin: 0 0 12px; font-family: var(--serif); }
.card-head {
    display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px;
}
.section-title {
    font-family: var(--serif);
    font-size: 1.45rem;
    margin: 0;
}

.stat-card {
    position: relative;
    overflow: hidden;
    padding: 20px;
    min-height: 124px;
    transition: transform 0.25s var(--ease), box-shadow 0.25s;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.stat-card .label { color: var(--color-muted); font-size: 0.86rem; }
.stat-card .value {
    font-family: var(--serif);
    font-size: 2.4rem;
    line-height: 1.1;
    margin-top: 8px;
}
.stat-card::after {
    content: "";
    position: absolute;
    right: -20px; bottom: -20px;
    width: 90px; height: 90px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--color-main) 18%, transparent);
}

.clock-hero {
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--color-main) 88%, #1a1612), var(--color-secondary));
    color: #1a1612;
    padding: 28px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    overflow: hidden;
    position: relative;
}
.clock-hero::before {
    content: "";
    position: absolute;
    inset: auto -40px -60px auto;
    width: 220px; height: 220px;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
}
.clock-date { font-family: var(--serif); font-size: clamp(1.6rem, 3vw, 2.4rem); margin: 0; }
.clock-time { font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 600; letter-spacing: 0.04em; margin: 6px 0 0; }
.clock-sub { margin: 0; opacity: 0.75; letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.75rem; }

.btn {
    appearance: none;
    border: 0;
    cursor: pointer;
    border-radius: 14px;
    padding: 11px 16px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--color-button);
    color: #1a1612;
    transition: transform 0.2s var(--ease), filter 0.2s, box-shadow 0.2s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; }
.btn-ghost {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
}
.btn-danger { background: #c9372c; color: #fff; }
.btn-success { background: #14804a; color: #fff; }
.btn-dark { background: #1a1612; color: #f7f1ea; }
.btn-wa { background: #1fa855; color: #fff; }
.btn-block { width: 100%; }

.quick-actions { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 12px; }
.quick-action {
    display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
    padding: 16px; min-height: 108px; text-align: left;
}
.quick-action span { font-size: 0.92rem; font-weight: 600; }
.quick-action .qa-icon {
    width: 36px; height: 36px; border-radius: 12px;
    display: grid; place-items: center;
    background: color-mix(in srgb, var(--color-main) 22%, transparent);
}
.quick-action .qa-icon svg { width: 18px; height: 18px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.field { display: grid; gap: 6px; }
.field.full, .full { grid-column: 1 / -1; }
.field label, .field-label {
    font-size: 0.82rem; font-weight: 600; letter-spacing: 0.03em; color: var(--color-muted);
}
.field input, .field select, .field textarea, .input, .select, .textarea {
    width: 100%;
    border: 1px solid var(--color-border);
    background: #fff;
    border-radius: 12px;
    padding: 11px 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.field textarea, .textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--color-main);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-main) 18%, transparent);
}
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
    border: 1px solid var(--color-border);
    background: #fff;
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 500;
}
.choice input { accent-color: var(--color-main); }
.search-wrap { position: relative; }
.search-wrap input { padding-left: 40px; }
.search-wrap .search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: var(--color-muted); pointer-events: none;
}
.search-wrap .search-icon svg { width: 18px; height: 18px; }
.clock-hero svg { width: 84px; height: 84px; opacity: 0.28; }
.btn .spinner { width: 18px; height: 18px; border-width: 2px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: 16px; }
table.data {
    width: 100%; border-collapse: collapse; min-width: 720px; background: var(--color-card);
}
table.data th, table.data td {
    padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--color-border); vertical-align: top;
}
table.data th { font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-muted); }
table.data tr:hover td { background: color-mix(in srgb, var(--color-main) 7%, white); }
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    border-radius: 999px; padding: 4px 10px; font-size: 0.78rem; font-weight: 600;
}
.badge-scheduled { background: #edf5ff; color: #175cd3; }
.badge-completed { background: #e8f8ef; color: #067647; }
.badge-cancelled { background: #fde8e6; color: #b42318; text-decoration: line-through; }
.line-cancelled { color: #b42318; text-decoration: line-through; }

.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.client-card {
    padding: 18px; cursor: pointer; transition: transform 0.2s var(--ease), box-shadow 0.2s;
}
.client-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.client-card h3 { margin: 0; font-size: 1.25rem; }
.meta { color: var(--color-muted); font-size: 0.88rem; }
.chip { display: inline-block; background: color-mix(in srgb, var(--color-main) 16%, white); padding: 3px 8px; border-radius: 999px; font-size: 0.75rem; }

.calendar {
    display: grid;
    grid-template-columns: 1.4fr 0.9fr;
    gap: 18px;
}
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-nav h3 { margin: 0; font-family: var(--serif); font-size: 1.5rem; }
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}
.cal-dow { text-align: center; font-size: 0.75rem; color: var(--color-muted); padding: 6px 0; }
.cal-day {
    min-height: 74px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: #fff;
    padding: 8px;
    cursor: pointer;
    transition: transform 0.15s var(--ease), border-color 0.15s, background 0.15s;
    display: flex; flex-direction: column; gap: 6px;
}
.cal-day:hover { transform: translateY(-2px); border-color: var(--color-main); }
.cal-day.empty { background: transparent; border-color: transparent; cursor: default; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--color-main); }
.cal-day.selected { background: color-mix(in srgb, var(--color-main) 18%, white); border-color: var(--color-main); }
.cal-day.has-appt { background: color-mix(in srgb, var(--color-main) 10%, white); }
.dots { display: flex; gap: 4px; flex-wrap: wrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; }
.dot-scheduled { background: #175cd3; }
.dot-completed { background: #067647; }
.dot-cancelled { background: #b42318; }

.appt-item {
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    animation: fadeUp 0.3s var(--ease);
}
.appt-item.cancelled { border-color: #f2b8b5; background: #fff6f5; }
.appt-item.cancelled .appt-title { text-decoration: line-through; color: #b42318; }

.toast-stack {
    position: fixed; right: 18px; bottom: 18px; z-index: 80;
    display: grid; gap: 10px; width: min(360px, calc(100vw - 24px));
}
.toast {
    background: #1a1612; color: #fff; border-radius: 16px; padding: 14px 16px;
    box-shadow: var(--shadow); animation: slideIn 0.3s var(--ease);
}
.toast.success { background: #0f5132; }
.toast.error { background: #7a271a; }

.modal-root, .confirm-root {
    position: fixed; inset: 0; background: rgba(16,12,8,.48);
    display: grid; place-items: center; z-index: 70; padding: 18px;
}
.confirm-root[hidden], .modal-root:empty { display: none; }
.modal-card {
    width: min(760px, 100%);
    max-height: calc(100vh - 36px);
    overflow: auto;
    background: var(--color-card);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow);
    animation: pop 0.28s var(--ease);
}
.confirm-card { width: min(440px, 100%); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.empty {
    text-align: center; padding: 36px 16px; color: var(--color-muted);
}
.empty h3 { margin: 0 0 6px; color: var(--color-text); font-family: var(--serif); }

.loading-row { display: flex; justify-content: center; padding: 28px; }
.spinner {
    width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid var(--color-border); border-top-color: var(--color-main);
    animation: spin 0.8s linear infinite;
}

.live-results {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px);
    background: #fff; border: 1px solid var(--color-border); border-radius: 14px;
    box-shadow: var(--shadow); z-index: 8; overflow: hidden;
}
.live-results button {
    width: 100%; text-align: left; border: 0; background: #fff; padding: 10px 12px; cursor: pointer;
    border-bottom: 1px solid var(--color-border);
}
.live-results button:hover { background: color-mix(in srgb, var(--color-main) 12%, white); }

.profile-hero {
    display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
}
.kv { display: grid; gap: 10px; }
.kv-row { display: grid; grid-template-columns: 160px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--color-border); }
.kv-row b { color: var(--color-muted); font-weight: 500; }

.toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--color-border);
}
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
    position: absolute; inset: 0; background: #d6cfc6; border-radius: 999px; cursor: pointer; transition: 0.2s;
}
.switch span::after {
    content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
    background: #fff; top: 3px; left: 3px; transition: 0.2s;
}
.switch input:checked + span { background: var(--color-main); }
.switch input:checked + span::after { transform: translateX(20px); }

.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.color-item { display: grid; gap: 6px; }
.color-item input[type="color"] { width: 100%; height: 42px; border: 0; background: none; padding: 0; cursor: pointer; }

.wa-layout { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 18px; }
.recipient-list { max-height: 360px; overflow: auto; border: 1px solid var(--color-border); border-radius: 14px; }
.recipient-list label {
    display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--color-border);
}
.preview-img { max-height: 160px; border-radius: 12px; margin-top: 8px; }

.pager { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.login-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background:
        radial-gradient(circle at top left, color-mix(in srgb, var(--color-main) 30%, transparent), transparent 40%),
        var(--color-background);
}
.login-card { width: min(440px, 100%); padding: 32px; }
.login-card h1 { font-family: var(--serif); margin: 0 0 8px; font-size: 2.2rem; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1200px) {
    .grid-5, .quick-actions { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .calendar, .wa-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-105%); }
    .sidebar.open { transform: none; }
    .sidebar-overlay.show { display: block; }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: grid; }
    .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .quick-actions, .grid-5 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .page-content, .topbar { padding-left: 16px; padding-right: 16px; }
    .user-name { display: none; }
    .kv-row { grid-template-columns: 1fr; }
    .cal-day { min-height: 56px; }
    .clock-hero { flex-direction: column; align-items: flex-start; }
    .profile-hero { flex-direction: column; }
}
@media (max-width: 640px) {
    .quick-actions { grid-template-columns: 1fr 1fr; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .btn { width: 100%; }
}
