:root {
  --gold: #8c7e57;
  --gold-d: #6b603f;
  --gold-l: #c9bd97;
  --gold-xl: #efe9d9;
  --ivory: #f7f4ec;
  --ink: #2a2822;
  --muted: #7a7466;
  --line: #e4ddca;
  --ok: #3f7d58;
  --bad: #a8473b;
  --r: 14px;
  font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ivory); color: var(--ink); }
body { font-size: 15px; line-height: 1.55; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
h1, h2, h3 { margin: 0 0 .6em; font-weight: 700; }
h2 { font-size: 18px; }
b { color: var(--gold); font-weight: 600; }

/* inputs */
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(140,126,87,.15); }
textarea { resize: vertical; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px; padding: 9px 18px;
  border: 1px solid var(--gold); background: #fff; color: var(--gold-d); text-align: center; text-decoration: none;
  transition: background .15s, color .15s;
}
.btn:hover { background: var(--gold-xl); }
.btn.primary { background: var(--gold); color: #fff; }
.btn.primary:hover { background: var(--gold-d); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--gold-xl); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.wide { display: block; width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.error { color: var(--bad); font-size: 13px; min-height: 1em; }
.chip { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--gold-xl); color: var(--gold-d); font-weight: 600; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at 20% 10%, #fff 0, transparent 50%), var(--ivory); }
.login-card { width: min(380px, 100%); background: #fff; border-radius: 20px; padding: 34px 30px;
  box-shadow: 0 20px 50px -20px rgba(80,70,40,.25); display: flex; flex-direction: column; gap: 14px; border-top: 4px solid var(--gold); }
.login-logo { width: 190px; align-self: center; margin-bottom: 6px; }
.login-card h1 { font-size: 20px; text-align: center; margin: 0; }
.login-card .muted { text-align: center; margin: -10px 0 4px; letter-spacing: .08em; font-size: 12px; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 10px 24px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-logo { height: 40px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button { font: inherit; font-weight: 600; background: none; border: 0; padding: 8px 14px; border-radius: 9px; color: var(--muted); cursor: pointer; }
.tabs button.active { background: var(--gold-xl); color: var(--gold-d); }
.who { display: flex; align-items: center; gap: 8px; font-size: 14px; }
body:not(.is-admin) .admin-only { display: none !important; }

main { padding: 22px 24px 60px; max-width: 1400px; margin: 0 auto; }
.panel { background: #fff; border-radius: var(--r); padding: 20px; box-shadow: 0 1px 0 var(--line), 0 10px 30px -22px rgba(80,70,40,.35); }
.grid2 { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
.grid2 > *, .row2 > *, .row2 input { min-width: 0; }
.form { display: flex; flex-direction: column; gap: 13px; }
.form.small { width: min(360px, 92vw); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; gap: 8px; }
.actions .btn.primary { flex: 1; }

fieldset.places { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
fieldset.places legend { font-size: 13px; color: var(--muted); font-weight: 500; padding: 0 6px; }
.radio { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; cursor: pointer; padding: 4px 2px; }
.radio input { accent-color: var(--gold); width: 16px; height: 16px; }

.comps { display: flex; flex-direction: column; gap: 6px; }
.comps-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); font-weight: 500; }
.comp-row { display: flex; gap: 6px; }
.comp-row input { flex: 1; min-width: 0; }
.comp-row button { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 10px; width: 38px; cursor: pointer; font-size: 18px; }
.comp-row button:hover { color: var(--bad); border-color: var(--bad); }
.park { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #d9d4c6; border-radius: 99px; transition: .2s; cursor: pointer; }
.slider::before { content: ''; position: absolute; width: 18px; height: 18px; top: 3px; right: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(-20px); }

/* list */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.list-head h2 { margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select, .filters input { padding: 6px 10px; font-size: 13px; }
.day-head { font-size: 13px; font-weight: 700; color: var(--gold-d); margin: 16px 0 6px; display: flex; align-items: center; gap: 8px; }
.day-head::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.appt { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 8px; transition: border-color .15s, box-shadow .15s; }
.appt:hover { border-color: var(--gold-l); box-shadow: 0 6px 18px -12px rgba(80,70,40,.4); }
.appt .t { font-size: 20px; font-weight: 700; color: var(--gold-d); text-align: center; direction: ltr; }
.appt .t small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.appt .g { font-weight: 700; font-size: 15px; }
.appt .m { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.appt .ops { display: flex; gap: 4px; }
.appt.cancelled { opacity: .55; }
.appt.cancelled .g { text-decoration: line-through; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 99px; font-weight: 600; }
.tag.ok { background: #e3efe6; color: var(--ok); }
.tag.no { background: #f1ede4; color: var(--muted); }
.tag.type { background: var(--gold-xl); color: var(--gold-d); }
.tag.bad { background: #f5e3e0; color: var(--bad); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* stats */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: #fff; border-radius: var(--r); padding: 16px 18px; box-shadow: 0 1px 0 var(--line); border-right: 3px solid var(--gold); }
.kpi .v { font-size: 30px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.kpi .l { font-size: 13px; color: var(--muted); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 20px; }
.hbar { display: grid; grid-template-columns: 170px 1fr 40px; gap: 10px; align-items: center; margin: 7px 0; font-size: 13px; }
.hbar .track { height: 12px; background: var(--gold-xl); border-radius: 99px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--gold); border-radius: 99px; }
.hbar .n { font-weight: 700; text-align: left; }
.vbars { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-top: 10px; border-bottom: 1px solid var(--line); direction: ltr; }
.vbars div { flex: 1; background: var(--gold-l); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.vbars div.today { background: var(--gold-d); }
.vbars div.future { background: repeating-linear-gradient(45deg, var(--gold-l) 0 3px, var(--gold-xl) 3px 6px); }
.vbars-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); direction: ltr; margin-top: 4px; }
.legend { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; gap: 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 4px; vertical-align: -1px; }

table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
table.users th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.users td { padding: 9px 8px; border-bottom: 1px solid var(--line); }
table.users tr.off td { opacity: .5; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(40,36,25,.55); display: grid; place-items: center; z-index: 20; padding: 16px; backdrop-filter: blur(3px); }
.modal-box { position: relative; background: #fff; border-radius: 18px; padding: 24px; max-height: 94vh; overflow: auto; }
.x { position: absolute; top: 8px; left: 12px; background: none; border: 0; font-size: 26px; color: var(--muted); cursor: pointer; }
.card-box { display: flex; gap: 24px; align-items: flex-start; }
.card-wrap canvas { width: min(400px, 60vw); height: auto; border-radius: 12px; box-shadow: 0 16px 40px -16px rgba(60,50,20,.45); display: block; }
.card-side { width: 240px; display: flex; flex-direction: column; gap: 10px; padding-top: 20px; }
.card-side p { font-size: 13px; margin: 0 0 6px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 40px); background: var(--ink); color: #fff; padding: 10px 18px;
  border-radius: 10px; opacity: 0; transition: .25s; pointer-events: none; z-index: 30; font-size: 14px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .tabs { order: 3; flex-basis: 100%; }
  main { padding: 14px; }
  .card-box { flex-direction: column; align-items: center; }
  .card-wrap canvas { width: min(340px, 84vw); }
  .card-side { width: 100%; padding-top: 0; }
  .charts { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 110px 1fr 34px; }
  .who { flex-wrap: wrap; font-size: 13px; }
  .appt { grid-template-columns: 52px 1fr; }
  .appt .ops { grid-column: 1 / -1; justify-content: flex-end; }
}
