:root {
    --ink: #221c16;
    --muted: #85796a;
    --bg: #f7f2e9;
    --card: #fffdfa;
    --border: #e8dfd0;
    --gold: #b4893f;
    --gold-light: #d9b876;
    --gold-dark: #8a6526;
    --charcoal: #1d1712;
    --charcoal-2: #2a2119;
    --error: #a83f37;
    --error-bg: #fbeae7;
    --success: #3f7a4d;
    --success-bg: #e9f5ea;
    --accent: var(--gold);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
    animation: fade-in 0.35s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

h1, h2, h3 { font-family: "Fraunces", Georgia, serif; font-weight: 600; letter-spacing: -0.01em; }
h1 { margin-top: 0; font-size: 1.9rem; }
h2 { font-size: 1.3rem; margin: 32px 0 12px; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 14px 28px;
    background: linear-gradient(180deg, var(--charcoal-2), var(--charcoal));
    border-bottom: 1px solid #000;
    box-shadow: 0 4px 20px -8px rgba(0, 0, 0, 0.4);
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600;
    font-size: 1.2rem;
    color: #f5ecd9;
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--gold-light), var(--gold-dark));
    font-size: 1rem;
}

.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topbar nav a {
    color: #cfc2ac; text-decoration: none; font-size: 0.88rem; font-weight: 500;
    padding: 8px 12px; border-radius: 6px; transition: color 0.15s, background 0.15s;
    position: relative;
}
.topbar nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.topbar nav a.active { color: var(--gold-light); }
.topbar nav a.active::after {
    content: ""; position: absolute; left: 12px; right: 12px; bottom: 1px; height: 2px;
    background: var(--gold-light); border-radius: 2px;
}

.logout-form { display: flex; align-items: center; gap: 12px; margin: 0; }
.user-name { font-size: 0.85rem; color: #cfc2ac; }

.btn-ghost {
    background: transparent; color: #cfc2ac; border: 1px solid #4a4038;
    padding: 6px 14px; border-radius: 6px; font-size: 0.82rem; cursor: pointer;
    font-family: inherit; transition: color 0.15s, border-color 0.15s;
}
.btn-ghost:hover { color: var(--gold-light); border-color: var(--gold-dark); }

/* ---------- Layout ---------- */
.container { max-width: 1160px; margin: 0 auto; padding: 32px 24px; }

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

/* ---------- Cards ---------- */
.cards { display: flex; gap: 18px; margin: 16px 0 32px; flex-wrap: wrap; }
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-top: 3px solid var(--gold);
    border-radius: 12px;
    padding: 18px 22px;
    min-width: 170px;
    box-shadow: 0 6px 18px -12px rgba(34, 28, 22, 0.25);
    transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -12px rgba(34, 28, 22, 0.3); }
.card-label { font-size: 0.75rem; color: var(--gold-dark); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
.card-value { font-family: "Fraunces", Georgia, serif; font-size: 1.9rem; font-weight: 600; margin-top: 6px; }
.card-sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.table th {
    background: var(--charcoal); color: #d8cbb4; font-weight: 600;
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em;
}
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: #faf3e5; }
.table tbody tr:last-child td { border-bottom: none; }
.table tr.low-stock { background: var(--error-bg); }
.table tr.low-stock:hover { background: #f8ddd8; }
.table a { color: var(--gold-dark); font-weight: 600; text-decoration: none; }
.table a:hover { color: var(--gold); text-decoration: underline; }

/* ---------- Badges ---------- */
.badge { padding: 3px 10px; border-radius: 12px; font-size: 0.72rem; font-weight: 600; background: #eee; letter-spacing: 0.02em; }
.badge-booked { background: #e6effa; color: #2a5a8f; }
.badge-confirmed { background: #eaf5ea; color: #3a6b3f; }
.badge-completed { background: #fbf1da; color: #8a6526; }
.badge-cancelled { background: #fbeaea; color: #a1352d; }
.badge-no_show { background: #f0eee9; color: #6b6255; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    background: linear-gradient(180deg, var(--gold-light), var(--gold));
    color: #2a2119;
    border: none;
    padding: 9px 18px;
    border-radius: 7px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 3px 10px -4px rgba(138, 101, 38, 0.6);
    transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px -6px rgba(138, 101, 38, 0.7); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-block { width: 100%; text-align: center; padding: 11px 16px; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; max-width: 480px; background: var(--card); padding: 20px; border-radius: 10px; border: 1px solid var(--border); }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.form input, .form select, .form textarea {
    padding: 9px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 0.95rem; font-family: inherit;
    color: var(--ink); background: #fffefc; transition: border-color 0.15s, box-shadow 0.15s;
}
.form input:focus, .form select:focus, .form textarea:focus {
    outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(180, 137, 63, 0.18);
}

.inline-form { display: inline-flex; gap: 8px; align-items: center; margin: 12px 0; }
.inline-form select, .inline-form input {
    padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.inline-form select:focus, .inline-form input:focus {
    outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(180, 137, 63, 0.18);
}
.inline-form button {
    background: var(--card);
    color: var(--gold-dark);
    border: 1px solid var(--gold);
    padding: 7px 14px;
    border-radius: 7px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.inline-form button:hover { background: var(--gold); color: #2a2119; }
.inline-form button.danger { border-color: var(--error); color: var(--error); }
.inline-form button.danger:hover { background: var(--error); color: #fff; }

.add-box { margin: 20px 0; }
.add-box summary { cursor: pointer; font-weight: 600; color: var(--gold-dark); margin-bottom: 10px; }
.add-box summary:hover { color: var(--gold); }

/* ---------- Auth ---------- */
.container:has(.auth-box) { min-height: calc(100vh - 64px); display: flex; align-items: center; justify-content: center; }
.auth-box {
    width: 100%; max-width: 380px; background: var(--card); padding: 36px 32px;
    border-radius: 16px; border: 1px solid var(--border);
    box-shadow: 0 20px 48px -20px rgba(29, 23, 18, 0.35);
    text-align: center;
}
.auth-brand {
    width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--gold-light), var(--gold-dark));
    display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
    box-shadow: 0 8px 20px -8px rgba(138, 101, 38, 0.6);
}
.auth-box h1 { margin-bottom: 4px; font-size: 1.5rem; }
.auth-sub { color: var(--muted); font-size: 0.9rem; margin: 0 0 22px; }
.auth-box .form { max-width: none; padding: 0; border: none; text-align: left; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 0.9rem; font-weight: 500; border: 1px solid transparent; }
.flash-success { background: var(--success-bg); color: var(--success); border-color: #cfe8d2; }
.flash-error { background: var(--error-bg); color: var(--error); border-color: #f2d2cd; }

.muted { color: var(--muted); font-size: 0.9rem; }

/* ---------- Appointments calendar ---------- */
.cal-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin: 8px 0 24px; }
.cal-view-switch { display: flex; gap: 2px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.cal-view-switch a {
    padding: 6px 14px; border-radius: 6px; font-size: 0.85rem; font-weight: 600;
    color: var(--muted); text-decoration: none; transition: background 0.15s, color 0.15s;
}
.cal-view-switch a:hover { color: var(--ink); }
.cal-view-switch a.active { background: var(--gold); color: #2a2119; }

.cal-nav { display: flex; gap: 8px; align-items: center; }
.cal-nav a {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem;
    font-weight: 600; color: var(--gold-dark); text-decoration: none; background: var(--card);
    transition: border-color 0.15s;
}
.cal-nav a:hover { border-color: var(--gold); }
.cal-jump { margin: 0; }
.cal-jump input { padding: 6px 9px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; }

.cal-scroll { overflow-x: auto; }

.cal-week { display: grid; grid-template-columns: repeat(7, minmax(140px, 1fr)); gap: 10px; min-width: 900px; }
.cal-week-day { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px; min-height: 160px; display: flex; flex-direction: column; gap: 6px; }
.cal-week-day.today { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(180, 137, 63, 0.15) inset; }
.cal-week-day-head { font-weight: 700; font-size: 0.78rem; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; letter-spacing: 0.03em; }
.cal-week-day-head .num { font-family: "Fraunces", Georgia, serif; font-size: 1.05rem; color: var(--ink); margin-left: 4px; text-transform: none; }

.cal-month { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap: 8px; min-width: 900px; }
.cal-month-head { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; color: var(--muted); text-align: center; padding-bottom: 4px; letter-spacing: 0.03em; }
.cal-month-day { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px; min-height: 110px; display: flex; flex-direction: column; gap: 4px; }
.cal-month-day.today { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(180, 137, 63, 0.15) inset; }
.cal-month-day.outside { background: #f2ece1; opacity: 0.55; }
.cal-month-day-num { font-weight: 700; font-size: 0.85rem; font-family: "Fraunces", Georgia, serif; }

.cal-event {
    display: block; width: 100%; text-align: left; text-decoration: none; padding: 4px 7px; border-radius: 6px;
    font-size: 0.72rem; line-height: 1.35; background: #f3ede4; color: var(--ink);
    border: none; border-left: 3px solid var(--gold); font-family: inherit; cursor: pointer; margin: 0;
    transition: background 0.12s;
}
.cal-event:hover { background: #ece2d0; }
.cal-event-time, .cal-event-service { font-weight: 600; }
.cal-event-meta { color: var(--muted); }
.cal-event.status-completed { border-left-color: var(--success); }
.cal-event.status-cancelled, .cal-event.status-no_show { border-left-color: var(--error); opacity: 0.65; }
.cal-event.status-confirmed { border-left-color: #2a5a8f; }
.cal-more-link { font-size: 0.72rem; color: var(--gold-dark); text-decoration: none; font-weight: 600; padding-left: 2px; }
.cal-more-link:hover { color: var(--gold); }
.cal-empty { font-size: 0.75rem; color: var(--muted); }

[x-cloak] { display: none !important; }

.cal-modal-backdrop {
    position: fixed; inset: 0; background: rgba(29, 23, 18, 0.55);
    display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.cal-modal {
    background: var(--card); border-radius: 14px; padding: 24px; max-width: 380px; width: 100%;
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.45); border-top: 3px solid var(--gold);
}
.cal-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cal-modal-close {
    background: none; border: none; font-size: 1rem; cursor: pointer; color: var(--muted);
    padding: 4px; line-height: 1;
}
.cal-modal-close:hover { color: var(--ink); }
.cal-modal h3 { margin: 0 0 10px; font-size: 1.25rem; }
.cal-modal-row { margin: 4px 0; font-size: 0.9rem; }
.cal-modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.link-btn {
    display: inline-flex; align-items: center; padding: 9px 16px; border: 1px solid var(--border);
    border-radius: 7px; color: var(--gold-dark); text-decoration: none; font-weight: 600; font-size: 0.9rem;
    transition: border-color 0.15s;
}
.link-btn:hover { border-color: var(--gold); }

/* ---------- POS layout ---------- */
.pos { display: grid; grid-template-columns: 2fr 1fr; gap: 26px; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 12px; margin-bottom: 24px; }
.pos-item {
    background: var(--card); border: 1px solid var(--border); border-radius: 10px;
    padding: 14px; cursor: pointer; text-align: center; font-size: 0.85rem;
    transition: border-color 0.15s, transform 0.12s, box-shadow 0.12s;
}
.pos-item:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: 0 8px 18px -10px rgba(34, 28, 22, 0.3); }
.pos-item:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.pos-cart {
    background: var(--card); border: 1px solid var(--border); border-top: 3px solid var(--gold);
    border-radius: 12px; padding: 18px; height: fit-content;
    box-shadow: 0 6px 18px -12px rgba(34, 28, 22, 0.25);
}
.pos-total { font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 1.2rem; margin: 14px 0; }
.pos-cart table button {
    background: var(--card); border: 1px solid var(--border); border-radius: 5px;
    width: 26px; height: 26px; font-size: 0.85rem; line-height: 1; cursor: pointer;
    color: var(--ink); font-family: inherit; transition: border-color 0.15s, color 0.15s;
}
.pos-cart table button:hover { border-color: var(--gold); color: var(--gold-dark); }

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