:root{
  --bg:#F2F6F5; --surface:#FFFFFF; --surface-2:#E9F1EF; --border:#D7E3E0;
  --text:#142B29; --text-muted:#5C7370;
  --primary:#0E7C74; --primary-dark:#0A5C56; --primary-tint:#E3F3F1;
  --accent:#C9860A; --accent-tint:#FBF0DA;
  --st-scheduled:#3B7DD8; --st-scheduled-tint:#E7F0FC;
  --st-confirmed:#1F9D6B; --st-confirmed-tint:#E4F6EE;
  --st-completed:#6B7A85; --st-completed-tint:#EDEFF1;
  --st-cancelled:#D6555F; --st-cancelled-tint:#FBE9EA;
  --st-noshow:#C9860A; --st-noshow-tint:#FBF0DA;
  --shadow:0 1px 2px rgba(20,43,41,.06), 0 4px 16px rgba(20,43,41,.06);
  --radius:12px; --radius-sm:8px;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#0E1716; --surface:#152322; --surface-2:#1B2C2A; --border:#22403C;
    --text:#E7F1EF; --text-muted:#93A8A5;
    --primary:#2FBBAC; --primary-dark:#59D0C3; --primary-tint:#17332F;
    --accent:#E9B75B; --accent-tint:#2E2415;
    --st-scheduled:#6FA3EE; --st-scheduled-tint:#182A3E;
    --st-confirmed:#4FCB93; --st-confirmed-tint:#12281F;
    --st-completed:#9AA8B0; --st-completed-tint:#20282C;
    --st-cancelled:#EF7D85; --st-cancelled-tint:#331A1C;
    --st-noshow:#E9B75B; --st-noshow-tint:#2E2415;
    --shadow:0 1px 2px rgba(0,0,0,.3), 0 4px 20px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"]{
  --bg:#0E1716; --surface:#152322; --surface-2:#1B2C2A; --border:#22403C;
  --text:#E7F1EF; --text-muted:#93A8A5;
  --primary:#2FBBAC; --primary-dark:#59D0C3; --primary-tint:#17332F;
  --accent:#E9B75B; --accent-tint:#2E2415;
  --st-scheduled:#6FA3EE; --st-scheduled-tint:#182A3E;
  --st-confirmed:#4FCB93; --st-confirmed-tint:#12281F;
  --st-completed:#9AA8B0; --st-completed-tint:#20282C;
  --st-cancelled:#EF7D85; --st-cancelled-tint:#331A1C;
  --st-noshow:#E9B75B; --st-noshow-tint:#2E2415;
  --shadow:0 1px 2px rgba(0,0,0,.3), 0 4px 20px rgba(0,0,0,.35);
}
*{box-sizing:border-box;}
html{direction:rtl; overflow-x:hidden;}
body{
  margin:0; background:var(--bg); color:var(--text);
  font-family:'Heebo',system-ui,-apple-system,sans-serif;
  font-size:15px; line-height:1.5; direction:rtl;
  font-variant-numeric:tabular-nums;
  overflow-x:hidden; width:100%;
}
.dropdown{max-width:calc(100vw - 20px);}
h1,h2,h3,h4{font-family:'Rubik',system-ui,sans-serif; margin:0; text-wrap:balance;}
button{font-family:inherit; font-size:inherit;}
input,select,textarea{font-family:inherit; font-size:inherit;}
a{color:inherit;}
::selection{background:var(--primary-tint);}
.hidden{display:none!important;}

/* ---------- layout shells ---------- */
#app-root{min-height:100vh; display:flex; flex-direction:column;}
.center-screen{min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px;}

/* ---------- buttons ---------- */
.btn{
  display:inline-flex; align-items:center; gap:6px; justify-content:center;
  padding:10px 16px; border-radius:var(--radius-sm); border:1px solid transparent;
  cursor:pointer; font-weight:600; transition:filter .15s, transform .05s; white-space:nowrap;
}
.btn:active{transform:translateY(1px);}
.btn-primary{background:var(--primary); color:#fff;}
.btn-primary:hover{filter:brightness(1.06);}
.btn-secondary{background:var(--surface-2); color:var(--text); border-color:var(--border);}
.btn-secondary:hover{filter:brightness(1.03);}
.btn-ghost{background:transparent; color:var(--text-muted); border-color:transparent; padding:8px 10px;}
.btn-ghost:hover{background:var(--surface-2); color:var(--text);}
.btn-danger{background:var(--st-cancelled); color:#fff;}
.btn-danger:hover{filter:brightness(1.06);}
.btn-icon{padding:8px; border-radius:var(--radius-sm); background:transparent; border:1px solid transparent; color:var(--text-muted); cursor:pointer; display:inline-flex;}
.btn-icon:hover{background:var(--surface-2); color:var(--text);}
.btn-sm{padding:6px 10px; font-size:13px;}
.btn-block{width:100%;}
.btn[disabled]{opacity:.5; cursor:not-allowed;}

/* ---------- form controls ---------- */
.field{display:flex; flex-direction:column; gap:6px; margin-bottom:14px;}
.field label{font-size:13px; font-weight:600; color:var(--text-muted);}
.field input[type=text],.field input[type=tel],.field input[type=date],
.field input[type=time],.field input[type=number],.field input[type=password],
.field select,.field textarea{
  padding:10px 12px; border-radius:var(--radius-sm); border:1px solid var(--border);
  background:var(--surface); color:var(--text); width:100%;
}
.field input:focus,.field select:focus,.field textarea:focus{outline:2px solid var(--primary); outline-offset:1px;}
.field textarea{resize:vertical; min-height:70px;}
.field-row{display:flex; gap:12px; flex-wrap:wrap;}
.field-row > .field{flex:1; min-width:140px;}
.hint{font-size:12px; color:var(--text-muted);}

/* ---------- cards / surfaces ---------- */
.card{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow);}
.card-pad{padding:20px;}
.panel-title{display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:14px;}
.panel-title h2,.panel-title h3{font-size:17px;}

/* ---------- pills / badges ---------- */
.pill{display:inline-flex; align-items:center; gap:5px; padding:4px 10px; border-radius:999px; font-size:12.5px; font-weight:700;}
.role-badge{padding:2px 8px; border-radius:999px; font-size:11px; font-weight:700;}
.role-admin{background:var(--accent-tint); color:var(--accent);}
.role-rep{background:var(--primary-tint); color:var(--primary-dark);}
.avatar{width:36px; height:36px; border-radius:50%; display:flex; align-items:center; justify-content:center; color:#fff; font-weight:700; font-size:14px; flex-shrink:0;}
.avatar-sm{width:26px; height:26px; font-size:11px;}
.avatar-lg{width:64px; height:64px; font-size:22px;}

/* ---------- login ---------- */
.login-wrap{width:100%; max-width:420px;}
.login-logo{display:flex; flex-direction:column; align-items:center; gap:10px; margin-bottom:28px; text-align:center;}
.login-logo img{width:64px; height:64px; border-radius:16px; object-fit:cover;}
.login-logo .mark{width:64px; height:64px; border-radius:16px; background:var(--primary); color:#fff; display:flex; align-items:center; justify-content:center;}
.user-tile{
  display:flex; align-items:center; gap:12px; width:100%; padding:14px; border-radius:var(--radius);
  border:1px solid var(--border); background:var(--surface); cursor:pointer; margin-bottom:10px; text-align:right;
}
.user-tile:hover{border-color:var(--primary);}
.user-tile .info{flex:1;}
.user-tile .name{font-weight:700;}
.pinpad{display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin:18px 0;}
.pinpad button{padding:16px; border-radius:var(--radius-sm); border:1px solid var(--border); background:var(--surface); font-size:18px; font-weight:700; cursor:pointer;}
.pinpad button:hover{background:var(--surface-2);}
.pin-dots{display:flex; gap:10px; justify-content:center; margin:14px 0;}
.pin-dot{width:14px; height:14px; border-radius:50%; border:2px solid var(--border);}
.pin-dot.filled{background:var(--primary); border-color:var(--primary);}
.login-error{color:var(--st-cancelled); font-size:13px; text-align:center; min-height:18px;}

/* ---------- header / nav ---------- */
header.topbar{
  position:sticky; top:0; z-index:20; background:var(--surface); border-bottom:1px solid var(--border);
  display:flex; align-items:center; gap:16px; padding:10px 20px;
}
.brand{display:flex; align-items:center; gap:10px; font-weight:700; font-family:'Rubik',sans-serif; font-size:16px;}
.brand img{width:34px; height:34px; border-radius:9px; object-fit:cover;}
.brand .mark{width:34px; height:34px; border-radius:9px; background:var(--primary); color:#fff; display:flex; align-items:center; justify-content:center;}
nav.mainnav{display:flex; gap:4px; flex:1;}
nav.mainnav button{
  background:transparent; border:none; padding:9px 14px; border-radius:var(--radius-sm); cursor:pointer;
  color:var(--text-muted); font-weight:600; display:flex; align-items:center; gap:6px;
}
nav.mainnav button:hover{background:var(--surface-2); color:var(--text);}
nav.mainnav button.active{background:var(--primary-tint); color:var(--primary-dark);}
.topbar-actions{display:flex; align-items:center; gap:8px;}
.bell-wrap{position:relative;}
.bell-badge{position:absolute; top:2px; left:2px; background:var(--st-cancelled); color:#fff; font-size:10px; font-weight:700; border-radius:999px; min-width:16px; height:16px; display:flex; align-items:center; justify-content:center; padding:0 3px;}
.user-menu-btn{display:flex; align-items:center; gap:8px; background:transparent; border:1px solid var(--border); border-radius:999px; padding:4px 10px 4px 4px; cursor:pointer; color:var(--text);}
.hamburger{display:none;}
.dropdown{position:absolute; top:calc(100% + 8px); left:0; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); min-width:220px; z-index:40; overflow:hidden;}
.dropdown.right{left:auto; right:0;}
.dropdown-item{display:flex; align-items:center; gap:8px; padding:11px 14px; cursor:pointer; width:100%; text-align:right; background:none; border:none; color:var(--text);}
.dropdown-item:hover{background:var(--surface-2);}
.dropdown-sep{height:1px; background:var(--border); margin:4px 0;}
.notif-panel{width:320px; max-width:80vw;}
.notif-item{padding:12px 14px; border-bottom:1px solid var(--border); display:flex; gap:10px; align-items:flex-start;}
.notif-item:last-child{border-bottom:none;}
.notif-empty{padding:24px 16px; text-align:center; color:var(--text-muted); font-size:13px;}

main#page-root{flex:1; max-width:1180px; width:100%; margin:0 auto; padding:22px 20px 80px;}

/* ---------- dashboard ---------- */
.stats-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:20px;}
.stat-tile{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:16px 18px; box-shadow:var(--shadow);}
.stat-tile .num{font-family:'Rubik',sans-serif; font-size:28px; font-weight:700; line-height:1;}
.stat-tile .lbl{color:var(--text-muted); font-size:13px; margin-top:6px;}
.dash-grid{display:grid; grid-template-columns:1.6fr 1fr; gap:16px; align-items:start;}
.info-banner{display:flex; align-items:flex-start; gap:10px; background:var(--accent-tint); color:var(--text); border:1px solid var(--accent); border-radius:var(--radius); padding:12px 14px; margin-bottom:16px; font-size:13.5px;}
.info-banner button{margin-right:auto;}

/* ---------- appointment row/card ---------- */
.appt-row{display:flex; align-items:center; gap:12px; padding:12px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--surface); margin-bottom:8px;}
.appt-row .time-block{width:58px; text-align:center; flex-shrink:0;}
.appt-row .time-block .t{font-weight:700; font-family:'Rubik',sans-serif;}
.appt-row .time-block .d{font-size:11px; color:var(--text-muted);}
.appt-row .main{flex:1; min-width:0;}
.appt-row .client{font-weight:700; display:flex; align-items:center; gap:4px; min-width:0;}
.appt-row .client .name-text{white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0;}
.wa-btn{color:#25D366; padding:3px; flex-shrink:0;}
.wa-btn:hover{background:#25D36622;}
.appt-row .meta{font-size:12.5px; color:var(--text-muted); display:flex; gap:8px; flex-wrap:wrap; margin-top:2px;}
.appt-row .actions{display:flex; gap:4px; flex-shrink:0;}
.rep-dot{width:9px; height:9px; border-radius:50%; display:inline-block; flex-shrink:0;}
.remind-row{border-inline-start:3px solid var(--accent);}

/* ---------- calendar ---------- */
.cal-toolbar{display:flex; align-items:center; gap:10px; margin-bottom:14px;}
.cal-toolbar h2{font-size:19px; min-width:150px; text-align:center;}
.cal-grid{display:grid; grid-template-columns:repeat(7,1fr); gap:8px;}
.cal-dow{text-align:center; font-size:12px; font-weight:700; color:var(--text-muted); padding-bottom:4px;}
.cal-cell{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-sm);
  min-height:96px; padding:6px; cursor:pointer; display:flex; flex-direction:column; gap:3px; overflow:hidden;
}
.cal-cell:hover{border-color:var(--primary);}
.cal-cell.other-month{opacity:.4;}
.cal-cell.today{border-color:var(--primary); box-shadow:0 0 0 1px var(--primary) inset;}
.cal-cell.closed-day{background:var(--surface-2);}
.cal-cell .daynum{font-weight:700; font-size:13px; font-family:'Rubik',sans-serif;}
.cal-chip{font-size:10.5px; padding:2px 5px 2px 5px; border-radius:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; background:var(--surface-2); border-inline-start:3px solid var(--primary);}
.cal-more{font-size:10.5px; color:var(--text-muted);}
.holiday-badge{font-size:10px; font-weight:600; color:var(--accent); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.holiday-badge.is-empty{visibility:hidden;}
.avail-band{position:absolute; left:0; right:0; pointer-events:none; border-radius:4px; overflow:hidden; z-index:0;}
.avail-band-label{font-size:10px; font-weight:700; padding:2px 6px; display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}

/* ---------- legend ---------- */
.legend-row{display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:14px;}
.legend-chip{display:inline-flex; align-items:center; gap:6px; padding:5px 10px; border-radius:999px; border:1px solid var(--border); background:var(--surface); cursor:pointer; font-size:12.5px; font-weight:600; color:var(--text);}
.legend-chip.off{opacity:.4;}
.legend-chip:hover{border-color:var(--primary);}

/* ---------- week/day time grid ---------- */
.week-grid{display:flex; gap:0; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); overflow:hidden;}
.time-gutter{width:52px; flex-shrink:0; border-inline-end:1px solid var(--border);}
.hour-row{position:relative; border-top:1px solid var(--border); box-sizing:border-box;}
.hour-row:first-child{border-top:none;}
.hour-label{position:absolute; top:-8px; right:6px; font-size:11px; color:var(--text-muted); background:var(--surface); padding-inline-end:2px;}
.week-days{display:flex; flex:1; overflow-x:auto;}
.week-day-col{flex:1; min-width:110px; border-inline-start:1px solid var(--border);}
.week-day-col:first-child{border-inline-start:none;}
.week-day-col.closed-day{background:var(--surface-2);}
.week-day-head{text-align:center; padding:8px 4px; border-bottom:1px solid var(--border); position:sticky; top:0; background:var(--surface); z-index:2;}
.week-day-head .wd-name{font-size:11.5px; color:var(--text-muted); font-weight:700;}
.week-day-head .wd-num{font-size:16px; font-weight:700; font-family:'Rubik',sans-serif;}
.week-day-head.today .wd-num{color:var(--primary);}
.week-day-body{position:relative; background-image:repeating-linear-gradient(to bottom, var(--border) 0, var(--border) 1px, transparent 1px, transparent 52px); cursor:pointer;}
.grid-event{
  position:absolute; border-radius:6px; padding:3px 6px; overflow:hidden; cursor:pointer;
  box-shadow:var(--shadow); z-index:1;
}
.grid-event:hover{filter:brightness(0.97); z-index:3;}
.grid-event-time{font-size:10px; font-weight:700; color:var(--text-muted);}
.grid-event-title{font-size:12px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.grid-event-sub{font-size:11px; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}

/* ---------- day slots ---------- */
.slot-row{display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:var(--radius-sm); border:1px dashed var(--border); margin-bottom:6px;}
.slot-row.filled{border-style:solid; border-color:var(--border); background:var(--surface-2);}
.slot-time{width:56px; font-weight:700; font-family:'Rubik',sans-serif; flex-shrink:0;}
.slot-empty-label{color:var(--text-muted); flex:1;}
.slot-fill{flex:1; min-width:0;}

/* ---------- table / list filters ---------- */
.filter-bar{display:flex; gap:10px; flex-wrap:wrap; margin-bottom:16px; align-items:flex-end;}
.filter-bar .field{margin-bottom:0; min-width:140px;}
.chip-toggle{display:inline-flex; align-items:center; gap:5px; padding:6px 11px; border-radius:999px; border:1px solid var(--border); background:var(--surface); cursor:pointer; font-size:12.5px; font-weight:600; color:var(--text-muted);}
.chip-toggle.active{background:var(--primary-tint); border-color:var(--primary); color:var(--primary-dark);}
.tabs{display:flex; gap:4px; border-bottom:1px solid var(--border); margin-bottom:16px;}
.tab-btn{padding:10px 16px; background:none; border:none; border-bottom:2px solid transparent; cursor:pointer; font-weight:600; color:var(--text-muted);}
.tab-btn.active{color:var(--primary); border-color:var(--primary);}
.empty-state{text-align:center; padding:50px 20px; color:var(--text-muted);}
.empty-state svg{opacity:.5; margin-bottom:10px;}

/* ---------- reps / settings ---------- */
.rep-row{display:flex; align-items:center; gap:12px; padding:13px; border:1px solid var(--border); border-radius:var(--radius-sm); margin-bottom:8px; background:var(--surface);}
.rep-row .info{flex:1;}
.rep-row .name{font-weight:700; display:flex; align-items:center; gap:8px;}
.swatch-row{display:flex; gap:8px; flex-wrap:wrap;}
.swatch{width:28px; height:28px; border-radius:50%; cursor:pointer; border:2px solid transparent;}
.swatch.selected{border-color:var(--text);}
input[type=color]{width:52px; height:38px; padding:2px; border-radius:var(--radius-sm); border:1px solid var(--border); background:var(--surface); cursor:pointer;}
.hours-table{width:100%; border-collapse:collapse;}
.hours-table td,.hours-table th{padding:8px 6px; text-align:right; border-bottom:1px solid var(--border);}
.hours-table input[type=time]{padding:6px 8px;}
.switch{position:relative; display:inline-block; width:40px; height:22px; flex-shrink:0;}
.switch input{opacity:0; width:0; height:0;}
.switch .slider{position:absolute; inset:0; background:var(--border); border-radius:999px; cursor:pointer; transition:.15s;}
.switch .slider:before{content:""; position:absolute; width:16px; height:16px; right:3px; top:3px; background:#fff; border-radius:50%; transition:.15s;}
.switch input:checked + .slider{background:var(--primary);}
.switch input:checked + .slider:before{transform:translateX(-18px);}
.logo-preview{width:76px; height:76px; border-radius:16px; object-fit:cover; border:1px solid var(--border); background:var(--surface-2);}
.settings-section{margin-bottom:26px;}
.settings-section h3{margin-bottom:12px; font-size:15px;}

/* ---------- modal ---------- */
.modal-backdrop{position:fixed; inset:0; background:rgba(10,20,19,.45); display:flex; align-items:center; justify-content:center; z-index:100; padding:16px;}
.modal{background:var(--surface); border-radius:var(--radius); width:100%; max-width:520px; max-height:90vh; overflow-y:auto; box-shadow:var(--shadow);}
.modal-sm{max-width:380px;}
.modal-header{display:flex; align-items:center; justify-content:space-between; padding:18px 20px; border-bottom:1px solid var(--border); position:sticky; top:0; background:var(--surface);}
.modal-header h3{font-size:16px;}
.modal-body{padding:20px;}
.modal-footer{display:flex; justify-content:flex-end; gap:10px; padding:16px 20px; border-top:1px solid var(--border); position:sticky; bottom:0; background:var(--surface);}
.modal-footer .spacer{flex:1;}

/* toast */
#toast-wrap{position:fixed; bottom:20px; left:50%; transform:translateX(-50%); z-index:200; display:flex; flex-direction:column; gap:8px; align-items:center;}
.toast{background:var(--text); color:var(--bg); padding:10px 18px; border-radius:999px; font-size:13.5px; font-weight:600; box-shadow:var(--shadow); animation:toast-in .2s ease;}
@keyframes toast-in{from{opacity:0; transform:translateY(8px);} to{opacity:1; transform:translateY(0);}}

.fab{position:fixed; bottom:26px; left:26px; z-index:30; box-shadow:var(--shadow); border-radius:999px; padding:14px 22px;}

/* ---------- responsive ---------- */
@media (max-width:880px){
  .stats-grid{grid-template-columns:repeat(2,1fr);}
  .dash-grid{grid-template-columns:1fr;}
}
@media (max-width:720px){
  nav.mainnav{display:none; position:absolute; top:100%; right:0; left:0; background:var(--surface); border-bottom:1px solid var(--border); flex-direction:column; padding:8px; box-shadow:var(--shadow);}
  nav.mainnav.open{display:flex;}
  header.topbar{position:sticky;}
  .hamburger{display:flex;}
  .brand span{display:none;}
}
@media (max-width:520px){
  .stats-grid{grid-template-columns:1fr 1fr;}
  .cal-grid{gap:4px;}
  .cal-cell{min-height:64px; padding:4px;}
  .cal-chip{display:none;}
  .cal-more{display:block;}
  main#page-root{padding:16px 12px 90px;}
  .appt-row{flex-wrap:wrap;}
  .fab span{display:none;}
}
