:root {
  --teal: #0e8f88;
  --teal-dark: #0b6f6a;
  --tint: #e7f3f2;
  --border: #e2e9e8;
  --ink: #12201f;
  --muted: #5f6f6c;
  --muted-2: #8a9997;
  --bg: #eef2f1;
  --dark: #12201f;
  --dark-border: #24332f;
  --dark-card: #1c2c2a;
  --pending-bg: #fdf6e7; --pending-c: #a97e1c;
  --confirmed-bg: #e7f3f2; --confirmed-c: #0b6f6a;
  --completed-bg: #e8f5ec; --completed-c: #2f7d46;
  --cancelled-bg: #fdecea; --cancelled-c: #c0503f;
  --noshow-bg: #f2f5f4; --noshow-c: #5f6f6c;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: 'Tajawal', system-ui, sans-serif;
  direction: rtl;
  background: var(--bg);
  color: var(--ink);
}
::selection { background: #cdeae7; }
input, textarea, button, select { font-family: inherit; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--teal) !important; box-shadow: 0 0 0 3px rgba(14,143,136,0.12);
}
::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-thumb { background: #cfdad8; border-radius: 99px; }
.hidden { display: none !important; }
.headline { font-family: 'Cairo', system-ui, sans-serif; font-weight: 800; letter-spacing: -0.01em; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.section-content { animation: fadeUp .25s ease both; }

/* Login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
}
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 38px 34px; box-shadow: 0 30px 60px -30px rgba(0,0,0,.4); }
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; justify-content: center; }
.brand-mark { width: 42px; height: 42px; border-radius: 11px; background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center; font-family: 'Cairo'; font-weight: 800; font-size: 23px; flex-shrink: 0; }
.login-brand .name { font-family: 'Cairo'; font-weight: 800; font-size: 19px; }
.login-brand .sub { font-size: 13px; color: var(--muted-2); }
.login-card h1 { font-family: 'Cairo'; font-weight: 700; font-size: 22px; margin: 0 0 6px; text-align: center; }
.login-card .lead { color: var(--muted); font-size: 14px; text-align: center; margin: 0 0 24px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 15px; background: #f9fbfb;
}
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; border-radius: 10px; padding: 12px 22px; font-weight: 700; font-size: 15px; cursor: pointer; font-family: inherit; transition: background .15s ease, color .15s ease, border-color .15s ease; }
.btn-primary { background: var(--teal); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--ink); }
.btn-outline:hover { border-color: var(--teal); }
.btn-danger { background: var(--cancelled-bg); color: var(--cancelled-c); }
.btn-danger:hover { background: #f9dcd8; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }
.login-msg { margin-top: 10px; padding: 10px 12px; border-radius: 8px; font-size: 13px; background: var(--cancelled-bg); color: var(--cancelled-c); display: none; }
.login-msg.show { display: block; }
.login-foot { margin-top: 20px; padding-top: 18px; border-top: 1px solid #eef2f1; font-size: 12px; color: var(--muted-2); text-align: center; line-height: 1.7; }

/* App shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 250px; flex-shrink: 0; background: var(--dark); color: #c8d4d2; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar-top { padding: 22px 22px 18px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--dark-border); }
.sidebar-top .name { font-family: 'Cairo'; font-weight: 700; font-size: 16px; color: #fff; }
.sidebar-top .sub { font-size: 12px; color: #7d8f8c; }
.sidebar-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; border-radius: 10px; cursor: pointer; transition: all .15s; color: #9fb0ad; background: none; border: none; font-family: inherit; text-align: right; width: 100%; }
.nav-item:hover { background: var(--dark-card); color: #fff; }
.nav-item.active { background: var(--teal); color: #fff; }
.nav-item .left { display: flex; align-items: center; gap: 11px; }
.nav-item .ic { font-size: 18px; width: 22px; text-align: center; }
.nav-item .lbl { font-weight: 600; font-size: 14px; }
.nav-badge { background: var(--teal); color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 99px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.nav-item.active .nav-badge { background: rgba(255,255,255,.3); }
.sidebar-bottom { padding: 14px 12px; border-top: 1px solid var(--dark-border); }
.logout-item { display: flex; align-items: center; gap: 11px; padding: 11px 14px; border-radius: 10px; cursor: pointer; color: #9fb0ad; background: none; border: none; font-family: inherit; width: 100%; text-align: right; }
.logout-item:hover { background: var(--dark-card); color: #fff; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border); padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-family: 'Cairo'; font-weight: 800; font-size: 22px; margin: 0; }
.topbar .subtitle { font-size: 13px; color: var(--muted-2); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-user { display: flex; align-items: center; gap: 10px; padding-inline-start: 12px; border-inline-start: 1px solid #eef2f1; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--tint); color: var(--teal-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.topbar-user .who { line-height: 1.2; }
.topbar-user .who .n { font-weight: 700; font-size: 14px; }
.topbar-user .who .r { font-size: 12px; color: var(--muted-2); }
.refresh-btn { background: #f5f8f7; border: 1px solid var(--border); border-radius: 9px; padding: 9px 15px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--teal-dark); }
.refresh-btn:hover { border-color: var(--teal); }

.main-content { flex: 1; padding: 26px 28px; min-width: 0; overflow-x: auto; }

/* Dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin-bottom: 22px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 22px; }
.stat-card .lbl { font-size: 13px; color: var(--muted-2); margin-bottom: 8px; }
.stat-card .val { font-family: 'Cairo'; font-weight: 800; font-size: 32px; }
.dash-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head .t { font-family: 'Cairo'; font-weight: 700; font-size: 17px; }
.panel-head .link { cursor: pointer; color: var(--teal-dark); font-weight: 600; font-size: 13px; background: none; border: none; font-family: inherit; }
.recent-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f2f5f4; }
.recent-row:last-child { border-bottom: none; }
.recent-left { display: flex; align-items: center; gap: 12px; }
.recent-left .n { font-weight: 600; font-size: 15px; }
.recent-left .s { color: var(--muted-2); font-size: 13px; }
.status-pill { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.bar-row { margin-bottom: 12px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.bar-top .l { color: var(--muted); }
.bar-top .c { font-weight: 700; }
.bar-track { height: 8px; background: #f0f4f3; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; }
.empty-note { text-align: center; color: var(--muted-2); padding: 30px 0; font-size: 14px; }

/* Toolbar / filters */
.filter-bar { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.filter-bar .lbl { font-size: 13px; color: var(--muted-2); font-weight: 600; }
.filter-bar select, .filter-bar input { border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; font-size: 14px; background: #f9fbfb; cursor: pointer; }
.filter-count { margin-inline-start: auto; font-size: 13px; color: var(--muted-2); }

/* Appointment cards */
.appt-list { display: flex; flex-direction: column; gap: 12px; }
.appt-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; }
.appt-top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.appt-left { display: flex; gap: 14px; align-items: flex-start; min-width: 220px; }
.appt-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--tint); color: var(--teal-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.appt-name-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.appt-name-row .n { font-family: 'Cairo'; font-weight: 700; font-size: 17px; }
.type-chip { font-size: 12px; color: var(--muted-2); background: #f2f5f4; padding: 2px 9px; border-radius: 99px; }
.appt-meta { color: var(--muted); font-size: 14px; margin-top: 5px; }
.appt-sub { color: var(--muted-2); font-size: 13px; margin-top: 3px; }
.appt-reason { color: var(--muted); font-size: 13px; margin-top: 6px; background: #f9fbfb; border: 1px solid #eef2f1; border-radius: 8px; padding: 7px 10px; }
.appt-note { color: #8a6d1e; font-size: 13px; margin-top: 6px; background: #fdf6e7; border: 1px solid #f2e4bf; border-radius: 8px; padding: 7px 10px; }
.appt-right { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.dentist-select { border: 1px solid var(--border); border-radius: 9px; padding: 7px 11px; font-size: 13px; background: #f9fbfb; cursor: pointer; min-width: 150px; }
.appt-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 380px; }
.chip-btn { border: none; border-radius: 8px; padding: 7px 12px; font-weight: 600; font-size: 13px; cursor: pointer; }
.chip-confirm { background: var(--confirmed-bg); color: var(--confirmed-c); }
.chip-confirm:hover { background: #d3ebe8; }
.chip-complete { background: var(--completed-bg); color: var(--completed-c); }
.chip-complete:hover { background: #d8eede; }
.chip-noshow, .chip-reschedule, .chip-note, .chip-edit { background: #f2f5f4; color: var(--muted); }
.chip-noshow:hover, .chip-reschedule:hover, .chip-note:hover, .chip-edit:hover { background: #e8ecea; }
.chip-cancel { background: var(--cancelled-bg); color: var(--cancelled-c); }
.chip-cancel:hover { background: #f9dcd8; }
.chip-delete { background: var(--dark); color: #fff; }
.chip-delete:hover { background: #000; }
.empty-panel { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 50px; text-align: center; color: var(--muted-2); }

/* Calendar */
.day-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 16px; }
.day-chip { min-width: 74px; text-align: center; padding: 12px 10px; border-radius: 12px; cursor: pointer; flex-shrink: 0; background: #fff; border: 1px solid var(--border); color: var(--ink); }
.day-chip.selected { background: var(--teal); color: #fff; border-color: var(--teal); }
.day-chip .wd { font-size: 12px; }
.day-chip .dnum { font-family: 'Cairo'; font-weight: 800; font-size: 19px; }
.day-chip .cnt { font-size: 11px; opacity: .7; }
.slot-list { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 8px 20px; }
.slot-row { display: flex; gap: 16px; border-bottom: 1px solid #f4f7f6; padding: 12px 0; align-items: flex-start; }
.slot-row:last-child { border-bottom: none; }
.slot-time { width: 70px; flex-shrink: 0; color: var(--muted-2); font-weight: 600; font-size: 13px; padding-top: 4px; }
.slot-appt { background: var(--tint); border-inline-start: 3px solid var(--teal); border-radius: 8px; padding: 8px 12px; color: var(--teal-dark); margin: 3px 0; }
.slot-appt .n { font-weight: 700; font-size: 14px; }
.slot-appt .s { font-size: 13px; opacity: .85; }
.slot-empty { color: #c5d0ce; font-size: 13px; padding: 6px 0; }

/* Patients */
.search-input { width: 100%; max-width: 360px; border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px; font-size: 14px; background: #fff; margin-bottom: 16px; }
.patients-table { background: #fff; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.p-row-head { display: grid; grid-template-columns: 2fr 1.4fr 1fr 1.2fr 0.8fr; gap: 12px; padding: 14px 20px; background: #f7faf9; font-size: 13px; font-weight: 700; color: var(--muted); border-bottom: 1px solid #eef2f1; }
.p-row { display: grid; grid-template-columns: 2fr 1.4fr 1fr 1.2fr 0.8fr; gap: 12px; padding: 14px 20px; border-bottom: 1px solid #f4f7f6; align-items: center; font-size: 14px; cursor: pointer; }
.p-row:hover { background: #f7faf9; }
.p-row:last-child { border-bottom: none; }
.p-name { display: flex; align-items: center; gap: 11px; }
.p-name .who { font-weight: 600; }
.p-visits { font-weight: 700; }

/* Patient profile */
.profile-wrap { max-width: 860px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--teal-dark); font-weight: 600; font-size: 14px; cursor: pointer; margin-bottom: 16px; background: none; border: none; font-family: inherit; }
.profile-head { background: #fff; border: 1px solid var(--border); border-radius: 18px; padding: 26px; margin-bottom: 16px; }
.profile-top { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile-avatar { width: 66px; height: 66px; border-radius: 50%; background: var(--tint); color: var(--teal-dark); display: flex; align-items: center; justify-content: center; font-family: 'Cairo'; font-weight: 800; font-size: 28px; flex-shrink: 0; }
.profile-name-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.profile-name-row h2 { font-family: 'Cairo'; font-weight: 800; font-size: 24px; margin: 0; }
.profile-contact { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: 14px; }
.profile-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-top: 22px; }
.profile-stat { background: #f7faf9; border: 1px solid #eef2f1; border-radius: 12px; padding: 14px; text-align: center; }
.profile-stat .v { font-family: 'Cairo'; font-weight: 800; font-size: 24px; }
.profile-stat .l { font-size: 12px; color: var(--muted-2); margin-top: 2px; }
.timeline-item { display: flex; gap: 16px; padding: 16px 0; border-bottom: 1px solid #f4f7f6; }
.timeline-item:last-child { border-bottom: none; }
.timeline-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--tint); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }

/* Services */
.service-row { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 16px 20px; display: flex; align-items: center; gap: 16px; }
.service-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--tint); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.service-name { font-family: 'Cairo'; font-weight: 700; font-size: 17px; }
.service-status { font-size: 13px; color: var(--muted-2); }
.toggle-btn { border: none; border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 13px; cursor: pointer; }
.toggle-on { background: var(--tint); color: var(--teal-dark); }
.toggle-off { background: #f2f5f4; color: var(--muted); }

/* Schedule */
.slot-manage-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #f9fbfb; border: 1px solid #eef2f1; border-radius: 11px; padding: 11px 16px; margin-bottom: 8px; }
.slot-manage-row:last-child { margin-bottom: 0; }
.slot-manage-label { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 16px; }
.slot-manage-right { display: flex; align-items: center; gap: 14px; }
.slot-manage-count { font-size: 12px; color: var(--muted-2); }

/* Reviews / Messages */
.review-card, .message-card { background: #fff; border-radius: 14px; padding: 18px 20px; border: 1px solid var(--border); margin-bottom: 12px; }
.review-card:last-child, .message-card:last-child { margin-bottom: 0; }
.message-card.unread { border-color: #bfe6e2; box-shadow: 0 2px 0 var(--tint); }
.rc-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.rc-left { display: flex; gap: 12px; }
.rc-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); display: inline-block; }
.rc-meta { font-size: 13px; color: var(--muted-2); }
.rc-stars { font-size: 13px; color: #f0b429; }
.rc-text { font-size: 15px; line-height: 1.7; color: #3d4b49; margin: 12px 0 0; }
.review-stat-row { display: flex; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.review-stat { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 18px 24px; }
.review-stat .l { font-size: 13px; color: var(--muted-2); }
.review-stat .v { font-family: 'Cairo'; font-weight: 800; font-size: 30px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(18,32,31,.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 18px; padding: 26px; width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto; }
.modal h3 { font-family: 'Cairo'; font-weight: 700; font-size: 19px; margin: 0 0 4px; }
.modal .modal-sub { color: var(--muted-2); font-size: 14px; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini-date-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 16px; }
.mini-date-chip { min-width: 56px; text-align: center; padding: 9px 6px; border-radius: 10px; cursor: pointer; flex-shrink: 0; background: #f9fbfb; border: 1px solid var(--border); }
.mini-date-chip.selected { background: var(--teal); color: #fff; }
.mini-date-chip .wd { font-size: 11px; }
.mini-date-chip .dnum { font-family: 'Cairo'; font-weight: 800; font-size: 17px; }
.mini-time-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.mini-time-chip { text-align: center; padding: 9px 4px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13px; background: #f9fbfb; border: 1px solid var(--border); }
.mini-time-chip.selected { background: var(--tint); border: 1.5px solid var(--teal); color: var(--teal-dark); }
.mini-field-label { font-weight: 700; font-size: 13px; color: var(--muted); margin-bottom: 8px; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .stat-grid, .dash-grid { grid-template-columns: 1fr 1fr; }
}
