/* Alaya Mazhar Hospital — offline-first LAN system. No external fonts/CDNs. */

:root {
  --teal-900: #0b3d3a;
  --teal-700: #10635d;
  --teal-600: #217b68;
  --teal-500: #1a9c94;
  --teal-100: #e3f3f1;
  --clay: #c96f4a;
  --ink: #1c2a2a;
  --ink-soft: #4d5e5e;
  --paper: #f7f9f8;
  --card: #ffffff;
  --line: #e1e8e6;
  --amber: #b8860b;
  --amber-bg: #fdf3dd;
  --green: #2f7d55;
  --green-bg: #e6f4ec;
  --red: #b0413e;
  --red-bg: #fbe9e8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(11, 61, 58, 0.08), 0 1px 2px rgba(11, 61, 58, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
}

h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 700; color: var(--teal-900); }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; color: var(--ink-soft); }
a { color: var(--teal-600); text-decoration: none; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--teal-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 18px 0;
}
.sidebar .brand {
  padding: 0 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 10px;
}
.sidebar .brand .name { font-weight: 700; font-size: 15px; line-height: 1.3; }
.sidebar .brand .tag { font-size: 11px; opacity: 0.7; margin-top: 2px; }
.sidebar nav { flex: 1; }
.sidebar a.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.78);
  font-size: 13.5px;
  border-left: 3px solid transparent;
}
.sidebar a.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar a.nav-link.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-left-color: var(--clay);
  font-weight: 600;
}
.sidebar .sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 58px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.topbar .title { font-weight: 700; font-size: 16px; color: var(--teal-900); }
.topbar .user-box { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.topbar .user-name { font-weight: 600; }
.topbar .role-badge {
  background: var(--teal-100); color: var(--teal-700);
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em;
}
.topbar .server-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 5px; }
.topbar .server-dot.offline { background: var(--red); }

.content { padding: 24px; flex: 1; }

/* ---------- Cards / KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.kpi-card .kpi-label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.kpi-card .kpi-value { font-size: 26px; font-weight: 700; color: var(--teal-900); }
.kpi-card .kpi-value.accent { color: var(--clay); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 13.5px; background: #fff; color: var(--ink); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal-500); box-shadow: 0 0 0 3px var(--teal-100); }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
textarea { resize: vertical; min-height: 60px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 7px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-primary { background: var(--teal-600); color: #fff; }
.btn-primary:hover { background: var(--teal-700); }
.btn-accent { background: var(--clay); color: #fff; }
.btn-accent:hover { background: #b25f3d; }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--teal-500); color: var(--teal-700); }
.btn-danger { background: var(--red); color: #fff; }
.btn-lg { padding: 14px 22px; font-size: 15px; }
.btn-block { width: 100%; }
button:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--ink-soft); border-bottom: 1px solid var(--line); padding: 8px 10px; }
td { padding: 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafcfb; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: capitalize; }
.badge-waiting { background: var(--amber-bg); color: var(--amber); }
.badge-called { background: var(--amber-bg); color: var(--amber); }
.badge-in_consultation { background: var(--teal-100); color: var(--teal-700); }
.badge-completed { background: var(--green-bg); color: var(--green); }
.badge-cancelled { background: var(--red-bg); color: var(--red); }
.badge-no_show { background: var(--red-bg); color: var(--red); }
.badge-paid { background: var(--green-bg); color: var(--green); }
.badge-pending { background: var(--amber-bg); color: var(--amber); }
.badge-partially_paid { background: var(--amber-bg); color: var(--amber); }
.badge-refunded { background: var(--red-bg); color: var(--red); }
.badge-scheduled { background: var(--amber-bg); color: var(--amber); }
.badge-confirmed { background: var(--green-bg); color: var(--green); }
.badge-rejected { background: var(--red-bg); color: var(--red); }
.badge-checked_in { background: var(--teal-100); color: var(--teal-700); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty-state .big { font-size: 32px; margin-bottom: 8px; }

.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--teal-900); color: #fff;
  padding: 12px 18px; border-radius: 8px; font-size: 13.5px; box-shadow: var(--shadow);
  z-index: 999; max-width: 340px;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

.hint { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.search-box { position: relative; }
.search-box input { padding-left: 34px; }
.muted { color: var(--ink-soft); font-size: 12.5px; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}

/* Shared workspace presentation */
:root {
  --paper: #f3f6f8;
  --ink: #23353d;
  --ink-soft: #586b75;
  --line: #dfe7eb;
  --radius: 12px;
  --shadow: none;
}
body { line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #32a99d; outline-offset: 3px;
}
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 1100; padding: 12px 20px; background: #fff; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.sidebar { width: 250px; height: 100vh; position: sticky; top: 0; overflow-y: auto; padding: 26px 14px 14px; background: #fff; color: var(--ink); border-right: 1px solid var(--line); }
.sidebar .brand { padding: 0 12px 20px; margin-bottom: 18px; border-color: var(--line); }
.brand-symbol { float: left; width: 38px; height: 38px; display: grid; place-items: center; margin-right: 11px; background: #e5f5ef; color: #12675c; border-radius: 11px; font-size: 32px; font-weight: 500; line-height: 1; }
.sidebar .brand .name { font-size: 15px; letter-spacing: -.2px; }
.sidebar .brand .tag { margin: 12px 0 0; font-size: 11px; letter-spacing: .06em; }
.nav-caption { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: #6b7b84; padding: 0 12px 10px; font-weight: 700; }
.sidebar a.nav-link { padding: 10px 12px; min-height: 42px; margin-bottom: 3px; border: 0; border-radius: 7px; font-size: 13px; color: #52646f; }
.sidebar a.nav-link:hover { background: #f2f6f5; color: #15574d; }
.sidebar a.nav-link.active { background: #e2f3ed; color: #15574d; }
.nav-icon { width: 19px; height: 19px; flex: 0 0 19px; opacity: .85; }
.nav-link.active .nav-icon, .nav-link:hover .nav-icon { opacity: 1; }
.sidebar .sidebar-footer { padding: 18px 10px 4px; margin-top: 20px; font-size: 11px; color: #62757d; border-color: var(--line); }
.server-dot { width: 7px; height: 7px; border-radius: 50%; background: #69d5ac; display: inline-block; margin-right: 5px; }
.server-dot.offline { background: #ef9890; }
.topbar { min-height: 82px; height: auto; padding: 16px 32px; gap: 16px; }
.topbar-heading { display: flex; align-items: center; gap: 12px; }
.topbar-eyebrow { display: none; }
.topbar .title { font-size: 19px; letter-spacing: -.4px; }
.topbar .role-badge { padding: 5px 10px; text-transform: none; letter-spacing: 0; }
.menu-toggle { display: none; }
.content { padding: 30px 32px; width: 100%; max-width: 1800px; margin: 0 auto; }
.card { padding: 22px; margin-bottom: 20px; overflow-x: auto; }
.card-header { gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.card-header select { width: auto; max-width: 100%; }
.card h3 { font-size: 15px; margin-bottom: 16px; }
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 26px; }
.kpi-card { padding: 20px; border: 1px solid var(--line); min-width: 0; }
.kpi-card .kpi-label { font-size: 13px; letter-spacing: 0; text-transform: none; min-height: 0; margin-bottom: 10px; }
.kpi-card .kpi-value { font-size: clamp(23px, 2vw, 27px); letter-spacing: -.8px; line-height: 1.3; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kpi-card .kpi-value.accent { color: #167867; }
.grid-2, .grid-3 { min-width: 0; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
th { background: #f7f9fa; padding: 12px; font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0; white-space: nowrap; }
td { padding: 13px 12px; font-variant-numeric: tabular-nums; }
.badge { padding: 4px 8px; border-radius: 5px; font-weight: 600; }
input, select, textarea { min-height: 40px; border-color: #ccd9df; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: auto; accent-color: var(--teal-700); }
button, .btn { min-height: 39px; }
label { margin-bottom: 6px; }
.empty-state { border: 0; border-radius: 8px; background: #f7f9fa; }
.workspace-intro { display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 25px; }
.workspace-intro h1 { font-size: 26px; letter-spacing: -.7px; }
.workspace-intro p { margin: 0; }
.workspace-actions { display: flex; gap: 9px; flex-wrap: wrap; }
@media (max-width: 1100px) {
  .sidebar { width: 222px; }
  .content { padding: 24px; }
  .topbar { padding: 16px 24px; }
  .topbar .user-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; width: min(280px, 85vw); top: 82px; bottom: 0; height: calc(100dvh - 82px); left: 0; z-index: 100; display: none; box-shadow: 12px 0 32px #183e4326; }
  .sidebar.is-open { display: flex; }
  .menu-toggle { display: inline-flex; padding: 6px 11px; }
  .topbar { padding: 13px 16px; min-height: 82px; }
  .topbar .title { font-size: 15px; }
  .topbar .user-box { gap: 8px; }
  .topbar .user-name, .topbar .role-badge { display: none; }
  .content { padding: 20px 16px; }
  .card { padding: 18px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-card { padding: 15px; }
  .kpi-card .kpi-value { font-size: 23px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .toast { left: 16px; right: 16px; max-width: none; }
  .workspace-intro h1 { font-size: 23px; }
}
@media print {
  .sidebar, .topbar, .skip-link { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; }
  .card, .kpi-card { box-shadow: none; overflow: visible; }
}

/* New visit review and validation */
.visit-summary { background: var(--teal-100); border: 1px solid #c7e3db; border-radius: 8px; padding: 14px 16px; margin: 16px 0; color: var(--teal-900); overflow-wrap: anywhere; }
.visit-error { color: var(--red); margin: 12px 0; }
[hidden] { display: none !important; }

/* Shared spacing and responsive controls across all workspaces. */
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -.25px; }
.card-header h3 { margin-bottom: 0; }
.card > :last-child { margin-bottom: 0; }
.field-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field, .field-row > *, .consult-grid > * { min-width: 0; }
input, select, textarea { max-width: 100%; }
input:disabled, select:disabled, textarea:disabled { background: #f2f5f6; color: #64747c; }
input[readonly] { background: #f7f9fa; }
.btn-accent { background: var(--teal-600); }
.btn-accent:hover { background: var(--teal-700); }
.btn-danger:hover { background: #943734; }
.flex, .flex-between { gap: 10px; flex-wrap: wrap; }
.search-box input { padding-left: 12px; }
.nav-group + .nav-group { margin-top: 20px; }
.nav-group .nav-caption { padding-top: 2px; padding-bottom: 7px; }
.sidebar { scrollbar-width: thin; scrollbar-color: #d6e0df transparent; }
@media (max-width: 760px) {
  .field-row { grid-template-columns: 1fr; }
  .card-header > .flex { width: 100%; }
  .card-header input, .card-header select { flex: 1 1 140px; min-width: 0; }
  input, select, textarea { font-size: 16px; }
  button, .btn { min-height: 44px; }
}
