:root {
  --bg: #fff8f2; --card: #fff; --text: #1e1b3a; --muted: #8a7f7a; --border: #f1e6dd;
  --primary: #ff6b4a; --primary-soft: #ffe9e2; --teal: #14b8a6; --sun: #ffc94a; --danger: #e5484d; --success: #16a34a; --lilac: #8b7cf6;
  --radius: 16px; --shadow: 0 6px 14px rgba(30, 27, 58, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12101c; --card: #1c1a2b; --text: #f7f2ee; --muted: #a8a0b8; --border: #2c2940; --primary-soft: #3a2230; --shadow: none; }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Nunito, system-ui, sans-serif; background: var(--bg); color: var(--text); font-weight: 600; }
a { color: var(--primary); }
h1, h2, h3 { font-weight: 900; margin: 0 0 8px; }
h1 { font-size: 28px; } h2 { font-size: 21px; } h3 { font-size: 17px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px; }
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"] { width: 18px; height: 18px; }
.check { flex-direction: row; align-items: center; text-transform: none; font-size: 15px; color: var(--text); letter-spacing: 0; }
.btn { font: inherit; font-weight: 800; border: 0; border-radius: 12px; padding: 11px 18px; cursor: pointer; background: var(--primary-soft); color: var(--primary); }
.btn.primary { background: linear-gradient(135deg, #ff8a4c, #ff5e62); color: #fff; }
.btn.teal { background: linear-gradient(135deg, #2dd4bf, #0ea5a4); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 14px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 900; background: var(--primary-soft); color: var(--primary); }
.pill.teal { background: #14b8a622; color: var(--teal); } .pill.sun { background: #ffc94a33; color: #b7791f; }
.pill.danger { background: #e5484d22; color: var(--danger); } .pill.success { background: #16a34a22; color: var(--success); } .pill.muted { background: #8a7f7a22; color: var(--muted); }
.error { color: var(--danger); min-height: 1em; margin: 0; }
.boot { position: fixed; inset: 0; display: grid; place-items: center; color: var(--muted); }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, #ff8a4c, #ff5e62); }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 24px; padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand small { display: block; color: var(--muted); font-weight: 700; }
.logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, #ff8a4c, #ff5e62); font-size: 22px; }

/* layout */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--card); border-inline-end: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { text-decoration: none; color: var(--text); padding: 10px 12px; border-radius: 12px; font-weight: 800; display: flex; justify-content: space-between; align-items: center; }
.sidebar nav a.active { background: var(--primary-soft); color: var(--primary); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.main { padding: 28px; max-width: 1200px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat b { display: block; font-size: 30px; font-weight: 900; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
td img.thumb { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; background: var(--primary-soft); }
.table-wrap { overflow-x: auto; }
.list { display: flex; flex-direction: column; gap: 10px; }
.app-item { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.app-item:hover { border-color: var(--primary); }
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photos .ph { position: relative; }
.photos img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; }
.photos button { position: absolute; top: -6px; inset-inline-end: -6px; border: 0; border-radius: 50%; width: 22px; height: 22px; background: var(--danger); color: #fff; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.code { font-size: 26px; font-weight: 900; letter-spacing: 4px; background: var(--primary-soft); padding: 10px 16px; border-radius: 12px; display: inline-block; }

/* modal & toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal-card { background: var(--bg); border-radius: 24px; padding: 24px; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; z-index: 20; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar-foot { flex-direction: row; align-items: center; justify-content: space-between; }
  .main { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ clinic dashboard (clinic.html) */
.main.wide { max-width: 1500px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.banner { margin-bottom: 16px; border-color: var(--sun); background: #ffc94a1a; }
.seg { display: inline-flex; gap: 4px; }
.cal-toolbar { margin-bottom: 12px; }
.cal-toolbar input[type="date"] { padding: 6px 10px; font-size: 14px; }
.cal { padding: 0; overflow: auto; max-height: calc(100vh - 230px); }
.cal-head, .cal-body { display: grid; min-width: min-content; }
.cal-head { position: sticky; top: 0; z-index: 3; background: var(--card); border-bottom: 1px solid var(--border); }
.cal-day { font: inherit; border: 0; background: none; color: var(--text); padding: 10px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; border-inline-start: 1px solid var(--border); text-align: start; }
.cal-day.today b { color: var(--primary); }
.cal-gutter { position: relative; }
.cal-hour { position: absolute; inset-inline-end: 8px; transform: translateY(-50%); font-size: 11px; color: var(--muted); font-weight: 800; }
.cal-hour:first-child { transform: none; }
.cal-col { position: relative; border-inline-start: 1px solid var(--border); cursor: copy;
  background: repeating-linear-gradient(-45deg, transparent 0 6px, color-mix(in srgb, var(--border) 70%, transparent) 6px 7px); }
.cal-col.today { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--primary) 3%, transparent); }
.cal-open { position: absolute; left: 0; right: 0; background: var(--card); }
.cal-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); pointer-events: none; }
.cal-line.half { border-top-style: dashed; opacity: .6; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 2; pointer-events: none; }
.cal-now::before { content: ''; position: absolute; inset-inline-start: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.cal-ev { position: absolute; z-index: 1; font: inherit; font-size: 12px; text-align: start; line-height: 1.25; overflow: hidden; cursor: pointer;
  border-radius: 8px; padding: 3px 6px; border: 1px solid transparent; color: var(--text); display: block; }
.cal-ev .n { display: block; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev .t { font-weight: 800; color: var(--muted); white-space: nowrap; }
.cal-ev .r { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev .tag { font-size: 10px; font-weight: 900; text-transform: uppercase; color: var(--muted); }
.cal-ev.confirmed { background: #14b8a62a; border-color: #14b8a6aa; }
.cal-ev.requested { background: #ffc94a33; border: 1.5px dashed #d69e2e; }
.cal-ev.done { background: #16a34a1f; border-color: #16a34a66; opacity: .8; }
.cal-ev.no_show { background: #e5484d1a; border-color: #e5484d66; opacity: .75; }
.cal-ev.declined, .cal-ev.cancelled { background: transparent; border: 1px dashed var(--border); color: var(--muted); text-decoration: line-through; }
.cal-ev.block { background: repeating-linear-gradient(-45deg, #8a7f7a22 0 6px, #8a7f7a33 6px 12px); border-color: #8a7f7a55; }
.cal-ev:hover { filter: brightness(.97); box-shadow: var(--shadow); }
.legend { margin-inline-start: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 4px 0 10px; vertical-align: -1px; }
.legend i.requested { background: #ffc94a; } .legend i.confirmed { background: #14b8a6; } .legend i.done { background: #16a34a; } .legend i.block { background: #8a7f7a88; }
.req { display: flex; gap: 14px; align-items: center; cursor: pointer; }
.req:hover { border-color: var(--primary); }
.req-when { display: flex; flex-direction: column; align-items: center; min-width: 84px; padding: 8px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.req-when span { font-size: 20px; font-weight: 900; }
table.hours td, table.hours th { padding: 6px; }
table.hours input[type="time"] { padding: 7px 9px; }
.app > * { min-width: 0; }
@media (max-width: 800px) {
  .grid3 { grid-template-columns: 1fr; }
  .req { flex-wrap: wrap; }
  .cal { max-height: none; }
}

/* language picker (i18n.js) */
.lang-select { padding: 7px 10px; font-size: 14px; border-radius: 10px; max-width: 170px; }
.sidebar .lang-select { max-width: none; width: 100%; }
[dir="rtl"] body { font-family: Nunito, Tahoma, 'Segoe UI', system-ui, sans-serif; }

/* services & prices editor (clinic.js, Hours & booking) */
table.services td, table.services th { padding: 6px; }
table.services input { padding: 7px 9px; width: 100%; min-width: 0; }
table.services .svc-name { min-width: 160px; }
table.services .svc-min, table.services .svc-price { width: 7em; }
table.services .svc-cur { width: 5.5em; text-transform: uppercase; }

/* ------------------------------------------------------------------ partner dashboards (org-kit.js) */
.kit-logo { width: 64px; height: 64px; border-radius: 18px; object-fit: cover; background: var(--primary-soft); }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; display: inline-grid; place-items: center; flex: none;
  background: var(--primary-soft); color: var(--primary); font-weight: 900; }
.member, .invite { padding-block: 6px; border-bottom: 1px solid var(--border); }
.member:last-child, .invite:last-child { border-bottom: 0; }
.sidebar #org-select { width: 100%; }
.kit-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.kit-grid > *, .kit-grid label > * { min-width: 0; max-width: 100%; }
@media (max-width: 800px) { .kit-grid { grid-template-columns: minmax(0, 1fr); } }

a.btn { text-decoration: none; display: inline-block; }
