:root {
  --bg: #f5f3f7;
  --card: #ffffff;
  --ink: #241f2b;
  --muted: #7c7488;
  --line: #e7e2ee;
  --brand: #8b5cf6;
  --brand-ink: #5b21b6;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(36, 31, 43, .08), 0 8px 24px rgba(36, 31, 43, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
code { background: #f0ecf6; padding: .1em .35em; border-radius: 5px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.r { text-align: right; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }
.big { font-size: 1.6rem; font-weight: 700; }

/* layout */
.appbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; color: var(--brand-ink); font-size: 1.05rem; }
.topnav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.topnav a { padding: .35rem .6rem; border-radius: 8px; color: var(--ink); }
.topnav a.active { background: var(--brand); color: #fff; }
.topnav a:hover { text-decoration: none; background: #efeaf9; }
.topnav a.active:hover { background: var(--brand); }
.logout { color: var(--muted); }
.wrap { max-width: 1000px; margin: 0 auto; padding: 1rem; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 780px) { .grid-2 { grid-template-columns: 1fr; } }

.head-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; }

/* forms */
.stack { display: flex; flex-direction: column; gap: .7rem; }
.stack > label, label.chk { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
label.chk { flex-direction: row; align-items: center; gap: .4rem; color: var(--ink); }
.row { display: flex; gap: .7rem; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 8rem; }
input, select, textarea {
  font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink); width: 100%;
}
input[type=checkbox] { width: auto; }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 9px; padding: .5rem .75rem; }
legend { color: var(--muted); font-size: .85rem; padding: 0 .3rem; }
button {
  font: inherit; font-weight: 600; cursor: pointer; padding: .55rem .9rem;
  border: 0; border-radius: 9px; background: var(--brand); color: #fff;
}
button:hover { filter: brightness(1.05); }
button.ghost { background: #efeaf9; color: var(--brand-ink); }
button.ok { background: var(--ok); }
button.danger { background: var(--danger); }
button.sm { padding: .35rem .6rem; font-size: .85rem; }
button.x, button.x:hover { background: transparent; color: var(--danger); padding: 0 .3rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn-link { color: var(--brand-ink); font-weight: 600; cursor: pointer; }
.inline { display: inline-flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
form.inline { display: inline-flex; }

.searchbar { margin-bottom: 1rem; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem; text-align: center; box-shadow: var(--shadow);
}
.kpi.warn { border-color: var(--warn); }
.kpi-num { display: block; font-size: 1.4rem; font-weight: 700; }
.kpi-label { font-size: .8rem; color: var(--muted); }

/* tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.tbl.compact th, .tbl.compact td { padding: .35rem .5rem; font-size: .9rem; }
.tbl tr.total td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.clickable { cursor: pointer; }
.clickable:hover { background: #faf8fe; }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* pills / statuses */
.pill {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem;
  background: #efeaf9; color: var(--brand-ink); white-space: nowrap;
}
.pill.premium { background: #fde68a; color: #92400e; }
.pill.ok { background: #dcfce7; color: #166534; }
.st-pending .pill, .pill.st-pending { background: #fef3c7; color: #92400e; }
.st-approved .pill, .pill.st-approved { background: #dcfce7; color: #166534; }
.st-done .pill, .pill.st-done { background: #e0e7ff; color: #3730a3; }
.st-cancelled .pill, .pill.st-cancelled, .st-declined .pill { background: #fee2e2; color: #991b1b; }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.feed li { display: flex; gap: .6rem; padding: .4rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.feed time { color: var(--muted); flex-shrink: 0; }

/* daylist */
.daylist { list-style: none; margin: 0; padding: 0; }
.daylist li { border-bottom: 1px solid var(--line); }
.daylist a { display: flex; gap: .5rem; align-items: center; padding: .55rem .2rem; color: var(--ink); }
.daylist a:hover { text-decoration: none; background: #faf8fe; }
.amount { font-weight: 700; margin-left: auto; }

/* sparkline */
.spark { width: 100%; height: 100px; }
.spark.tall { height: 120px; }
.spark rect { fill: var(--brand); }
.spark-axis { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-top: .25rem; }

/* calendar */
.cal-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-start; margin-bottom: 1rem; }
.popform { position: relative; }
.popform > .card { margin-top: .5rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: .4rem; overflow-x: auto; }
@media (max-width: 780px) { .cal-grid { grid-template-columns: repeat(7, minmax(120px, 1fr)); } }
.cal-col { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .35rem; min-height: 120px; }
.cal-day { font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: .35rem; }
.cal-appt { display: block; padding: .3rem .4rem; margin-bottom: .3rem; border-radius: 7px; background: #efeaf9; color: var(--ink); font-size: .82rem; }
.cal-appt small { display: block; color: var(--muted); }
.cal-appt.st-approved { background: #dcfce7; }
.cal-appt.st-pending { background: #fef3c7; }
.cal-appt.st-done { background: #e0e7ff; }
.cal-appt.st-cancelled { background: #fee2e2; text-decoration: line-through; }
.cal-block { font-size: .78rem; color: #991b1b; background: #fee2e2; border-radius: 6px; padding: .2rem .35rem; margin-bottom: .3rem; }
.cal-empty { text-align: center; padding: .5rem 0; }
.legend { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.week-nav { display: flex; gap: .6rem; align-items: center; font-size: .9rem; }

/* detail / kv */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem .8rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.pref { background: #fffbeb; padding: .3rem .5rem; border-radius: 7px; }
.pos-box, .bonus-box, .pay-box { margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.paid-badge { color: var(--ok); font-weight: 700; }
.mt { margin-top: .8rem; }

/* lists of expandable cards */
.list { display: flex; flex-direction: column; gap: .5rem; }
.row-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; color: inherit; }
.row-card:hover { text-decoration: none; }
.row-card[open] { box-shadow: var(--shadow); }
.row-card.inactive { opacity: .65; }
.row-card summary { cursor: pointer; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row-card summary b { margin-right: .2rem; }
.row-card form { margin-top: .7rem; }
.hours-row { align-items: center; }
.hours-row label.chk { min-width: 4rem; }

/* flash / alerts */
.flash {
  position: sticky; top: 0; z-index: 30; background: var(--brand-ink); color: #fff;
  text-align: center; padding: .5rem; font-size: .9rem;
}
.alert { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; padding: .6rem .8rem; border-radius: 10px; margin-bottom: 1rem; }
.alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* Hide the native file input (its "Choose file" caption renders in the
   browser's own UI language, which we can't control) and trigger it via a
   same-styled label instead — works with zero JS. */
.file-input-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.file-label {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
  padding: .45rem .8rem; border-radius: 9px; background: #efeaf9; color: var(--brand-ink);
  font-weight: 600; font-size: .9rem;
}
.file-label:hover { filter: brightness(0.97); }
.file-label .count { color: var(--muted); font-weight: 400; }

/* photo galleries (service/product detail + owner upload forms) */
.detail-hero { width: 100%; max-height: 320px; object-fit: cover; border-radius: 12px; margin-bottom: .6rem; }
.gallery-strip { display: flex; gap: .4rem; margin-bottom: 1rem; overflow-x: auto; }
.gallery-strip img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; }
.photo-manager { display: flex; flex-wrap: wrap; gap: .6rem; margin: .5rem 0; }
.photo-manager .thumb { position: relative; width: 72px; height: 72px; }
.photo-manager .thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; display: block; }
.photo-manager .thumb form {
  position: absolute; top: -6px; right: -6px; margin: 0;
}
.photo-manager .thumb button {
  width: 22px; height: 22px; padding: 0; border-radius: 50%; font-size: .75rem;
  line-height: 1; background: var(--danger); color: #fff;
}

/* home: public catalog */
.home-header { row-gap: .5rem; }
.searchbar-form { flex: 1 1 240px; min-width: 180px; }
.searchbar-form input {
  width: 100%; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 8px;
}
.promo-banner {
  background: linear-gradient(120deg, var(--brand), var(--brand-ink)); color: #fff;
  border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem;
}
.promo-slide { display: flex; flex-direction: column; gap: .3rem; }
.promo-slide .muted { color: rgba(255, 255, 255, .85); }
.filterbar { display: flex; gap: .7rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filterbar label { display: flex; flex-direction: column; gap: .2rem; font-size: .82rem; color: var(--muted); }
.filterbar select { padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.feed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.feed-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.feed-card-media { display: block; aspect-ratio: 4 / 3; background: #f0ecf6; overflow: hidden; }
.feed-card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.feed-card-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 2.2rem; }
.feed-card-body { padding: .8rem; display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.feed-card-title { font-weight: 700; color: var(--ink); }
.feed-card-price { font-weight: 700; color: var(--brand-ink); }
.feed-card-bonus { line-height: 1.4; }
.btn-link-block {
  display: block; text-align: center; margin-top: auto; padding: .5rem; border-radius: 9px;
  background: var(--brand); color: #fff; font-weight: 600;
}
.btn-link-block:hover { filter: brightness(1.05); text-decoration: none; }

/* auth + booking single-column */
body.auth .wrap, body.booking .wrap { max-width: 460px; }
.auth-card h1, .booking-card h1 { font-size: 1.3rem; }
.auth-card .demo { background: #f0ecf6; padding: .4rem .6rem; border-radius: 8px; }
.booking-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow); margin-top: 1.5rem;
}
.booking-card .brand { display: block; margin-bottom: 1rem; }
.results { list-style: none; margin: 0; padding: 0; }
.result { display: flex; justify-content: space-between; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.result-meta { font-size: .82rem; color: var(--muted); }
.result-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: none; }
.result-cta { text-align: right; display: flex; flex-direction: column; gap: .4rem; align-items: flex-end; }
.date-list { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0 1.2rem; }
.date-list form { margin: 0; }
.date-btn {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  padding: .5rem .8rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.date-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-ink); }
.date-btn:disabled { opacity: .4; cursor: not-allowed; }
.time-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.time-opt {
  display: block; padding: .45rem .8rem; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; font-size: .9rem; width: auto;
}
.time-opt input { width: auto; margin-right: .35rem; }
.time-opt:has(input:checked) { border-color: var(--brand); background: #f0ecf6; color: var(--brand-ink); }
.success { font-size: 2.5rem; color: var(--ok); text-align: center; }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; }
.tabs a { padding: .3rem .6rem; border-radius: 8px; background: #efeaf9; font-size: .85rem; }
.tabs a.active { background: var(--brand); color: #fff; }
