@font-face { font-family: Cairo; font-weight: 400; font-display: swap; src: url(../fonts/cairo-400.woff2) format("woff2"); }
@font-face { font-family: Cairo; font-weight: 600; font-display: swap; src: url(../fonts/cairo-600.woff2) format("woff2"); }
@font-face { font-family: Cairo; font-weight: 700; font-display: swap; src: url(../fonts/cairo-700.woff2) format("woff2"); }

:root {
  --bg: #f3f6f9;
  --card: #ffffff;
  --text: #1c2b36;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0e7c86;
  --primary-dark: #0a5f67;
  --primary-soft: #e0f2f3;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --success: #1e8e3e;
  --success-soft: #e6f4ea;
  --warn: #b7791f;
  --warn-soft: #fef6e4;
  --info-soft: #e8f0fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Cairo, Tahoma, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.7; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.4; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.icon { width: 20px; height: 20px; fill: currentColor; flex: none; }
.hidden { display: none !important; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: #0f2d3a; color: #cfe3e8; flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff; flex: none; }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; background: #fff; }
.brand-name { font-weight: 700; color: #fff; line-height: 1.3; }
.brand-sub { font-size: .75rem; color: #8fb3bd; }
.sidebar nav { padding: .6rem; display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: 9px; color: #cfe3e8; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: .7rem 1.4rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 1.15rem; margin: 0; flex: 1; }
.topbar-user { display: flex; align-items: center; gap: .6rem; }
.topbar-user form { margin: 0; }
.menu-btn { display: none; background: none; border: 0; color: var(--text); cursor: pointer; padding: .2rem; }
.content { padding: 1.4rem; max-width: 1280px; width: 100%; }

/* Cards and grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem; margin-bottom: 1.2rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 1.2rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { display: flex; align-items: center; gap: 1rem; }
.stat .stat-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.stat .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat .stat-label { color: var(--muted); font-size: .9rem; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: .35rem 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-line; }

/* Forms */
form { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field label { font-weight: 600; font-size: .9rem; }
.field .hint { color: var(--muted); font-size: .8rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=time], input[type=number], input[type=search], input[type=file], select, textarea {
  font: inherit; width: 100%; padding: .55rem .75rem; border: 1px solid #cbd5e1; border-radius: 9px; background: #fff; color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.inline-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { min-width: 160px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; padding: .5rem 1.1rem; border-radius: 9px; border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #a93226; }
.btn-light { background: #fff; color: var(--text); border-color: var(--line); }
.btn-light:hover { background: #f8fafc; }
.btn-sm { padding: .25rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .7rem; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
td .actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 1.6rem; }

/* Badges and alerts */
.badge { display: inline-block; padding: .05rem .6rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); font-size: .8rem; font-weight: 600; }
.badge-off { background: #eef2f6; color: var(--muted); }
.status { display: inline-block; padding: .05rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.status-scheduled { background: var(--info-soft); color: #1a56db; }
.status-checked_in { background: var(--warn-soft); color: var(--warn); }
.status-completed { background: var(--success-soft); color: var(--success); }
.status-cancelled { background: #eef2f6; color: var(--muted); }
.status-no_show { background: var(--danger-soft); color: var(--danger); }
.alert { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert ul { margin: 0; padding-inline-start: 1.2rem; }
.alert-success { background: var(--success-soft); color: #14532d; border-color: #b7e1c1; }
.alert-error { background: var(--danger-soft); color: #7f1d1d; border-color: #f5c2bd; }
.alert-info { background: var(--info-soft); color: #1e3a8a; border-color: #c7d7fb; }
.secret { font-family: Consolas, monospace; font-size: 1.1rem; background: #fff; padding: .2rem .6rem; border-radius: 6px; border: 1px dashed #94a3b8; direction: ltr; display: inline-block; }
.pill-list { display: flex; flex-wrap: wrap; gap: .4rem; }

/* Slots */
.slots { display: flex; flex-wrap: wrap; gap: .4rem; }
.slot { border: 1px solid var(--line); border-radius: 8px; padding: .25rem .6rem; background: #fff; cursor: pointer; font: inherit; font-size: .9rem; direction: ltr; }
.slot:hover { border-color: var(--primary); }
.slot.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.slot.taken { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; text-decoration: line-through; }

/* Prescriptions */
.rx-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 2fr auto; gap: .5rem; margin-bottom: .5rem; align-items: center; }

/* Auth / public pages */
body.public { background: linear-gradient(160deg, #0f2d3a 0%, #0e7c86 100%); min-height: 100vh; }
.auth-wrap { max-width: 480px; margin: 0 auto; padding: 3rem 1rem; }
.auth-wrap.wide { max-width: 980px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: .7rem; color: #fff; font-size: 1.3rem; font-weight: 700; margin-bottom: 1.4rem; }
.auth-wrap .card { padding: 1.6rem; }
.hero { color: #fff; text-align: center; margin-bottom: 2rem; }
.hero h2 { font-size: 1.9rem; margin-bottom: .5rem; }
.hero p { color: #d3ecee; font-size: 1.05rem; }
.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.features .card { margin: 0; }
.cta { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }
.cta .btn { padding: .7rem 1.6rem; font-size: 1.05rem; }
.cta .btn-light { border-color: #fff; }

@media (max-width: 960px) {
  .grid-3, .grid-4, .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rx-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; right: 0; top: 0; z-index: 20; transform: translateX(100%); transition: transform .2s ease; box-shadow: -4px 0 20px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .grid-2, .grid-3, .grid-4, .form-grid, .features { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
  .user-name { display: none; }
  .kv { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .topbar, .no-print, .form-actions { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}
.mt { margin-top: 1.25rem; }
.inline-form .field.grow { flex: 1; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0 0 1rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.details dd[dir="ltr"] { text-align: right; }
.history-item { border-top: 1px solid var(--line); padding: .8rem 0; }
.history-item:first-of-type { border-top: 0; }
.history-item p { margin: .35rem 0; }
.rx-summary { margin: .4rem 0 0; padding-inline-start: 1.2rem; }
.day-nav { display: flex; gap: .4rem; align-items: flex-end; flex-wrap: wrap; }
.picker-results { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.chosen { font-weight: 600; color: var(--primary-dark); margin-top: .4rem; }
.vitals-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; }
.print-only { display: none; }
.auth-wrap.wide .auth-brand { justify-content: flex-start; }
.portal-logout { margin-inline-start: auto; }
.portal-nav { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.portal-nav a { color: #fff; text-decoration: none; padding: .45rem 1rem; border-radius: 999px; background: rgba(255, 255, 255, .12); font-weight: 600; }
.portal-nav a:hover { background: rgba(255, 255, 255, .22); }
.portal-nav a.active { background: #fff; color: var(--primary-dark); }
.field .check { display: flex; align-items: center; gap: .5rem; font-weight: 600; margin-top: 1.6rem; }
@media (max-width: 760px) { .vitals-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media print { .print-only { display: block; } .history-item { break-inside: avoid; } }
