/* MediPal admin website — one small stylesheet, no build step, no external files.
   Palette for medical professionals: deep navy and calm teal (the same family as the mobile app's theme),
   clean white surfaces with a cool tint, green / amber / coral only where a status needs to be read at a glance. */

:root {
  --primary: #0c7f89;          /* teal: buttons, bars, highlights */
  --primary-dark: #0a6470;     /* teal for text and links on white (readable) */
  --primary-hover: #0a6f78;
  --primary-light: #e3f4f6;    /* soft teal wash: active menu item, hover */
  --accent: #5cc8d7;           /* light teal: the name on the dark bar */
  --ink: #0b1c2c;              /* navy: top bar, dark badges */
  --surface: #f2f7f9;          /* page background */
  --white: #ffffff;
  --text: #0b1c2c;
  --text-2: #4a6272;
  --muted: #7f97a6;
  --border: #dbe6eb;
  --good: #23855c;
  --good-light: #ddf3e9;
  --bad: #c4493a;
  --bad-light: #fbe4e0;
  --warning: #a86d0c;
  --warning-light: #fbf0d6;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --topbar: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary-dark); }
h1 { font-size: 28px; line-height: 34px; font-weight: 800; margin: 0 0 4px; }
h2 { font-size: 20px; line-height: 26px; font-weight: 700; margin: 0; }
h3 { font-size: 16px; line-height: 21px; font-weight: 700; margin: 0; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- top bar: the logo lives here */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--ink); color: var(--white);
  border-bottom: 3px solid var(--primary);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--white); text-decoration: none; }
.brand img { width: 38px; height: 38px; flex-shrink: 0; }
.brand-name { font-weight: 800; letter-spacing: 0.6px; font-size: 20px; line-height: 22px; color: var(--ink); }
.brand-name span { color: var(--primary-dark); }
.brand-name--light { color: var(--white); }
.brand-name--light span { color: var(--accent); }
.brand small { display: block; font-size: 11px; line-height: 13px; letter-spacing: 1.4px; text-transform: uppercase; font-weight: 700; color: #8fb3c4; }
.topbar-spacer { flex: 1; }
.topbar .who { font-size: 14px; color: #b9cfda; text-align: right; line-height: 1.2; }
.topbar .who strong { display: block; color: var(--white); }
.topbar a.who { text-decoration: none; }
.topbar a.who:hover strong, .topbar a.who:focus-visible strong { text-decoration: underline; }
.topbar .who__hint { display: block; font-size: 12px; color: #7fc7d1; }
.menu-btn { display: none; background: transparent; border: 0; color: var(--white); padding: 6px; border-radius: var(--radius-sm); cursor: pointer; }
.icon { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- shell: sidebar + content */
.shell { display: flex; min-height: calc(100vh - var(--topbar)); }
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--white); border-right: 1px solid var(--border);
  padding: 12px; position: sticky; top: var(--topbar); align-self: flex-start;
  height: calc(100vh - var(--topbar)); overflow-y: auto;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--radius-md);
  color: var(--text-2); font-weight: 600; text-decoration: none;
}
.nav a:hover { background: var(--surface); }
.nav a.active { background: var(--primary-light); color: var(--primary-dark); }
.nav .group { margin: 18px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.nav form { margin: 0; }
.nav button { width: 100%; background: transparent; border: 0; font: inherit; cursor: pointer; text-align: left; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-md); color: var(--text-2); font-weight: 600; }
.nav button:hover { background: var(--surface); }
.content { flex: 1; min-width: 0; padding: 24px; max-width: 1320px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { color: var(--text-2); margin: 0; }
.stack > * + * { margin-top: 16px; }

/* ---------------------------------------------------------------- cards and grids */
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card > header p { margin: 2px 0 0; color: var(--text-2); font-size: 14px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.stat { padding: 14px 16px; border-top: 3px solid var(--primary-light); }
.stat__label { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--primary-dark); }
.stat__value { font-size: 28px; line-height: 34px; font-weight: 800; }
.stat__sub { font-size: 13px; color: var(--text-2); }
.stat--warn { border-top-color: var(--warning); }
.stat--warn .stat__value { color: var(--warning); }
.stat--bad { border-top-color: var(--bad); }
.stat--bad .stat__value { color: var(--bad); }
.stat--good { border-top-color: var(--good); }
.stat--good .stat__value { color: var(--good); }
.kv { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; padding-top: 2px; }
.kv dd { margin: 0; word-break: break-word; }
.section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.section-title::before { content: ""; width: 4px; height: 20px; border-radius: 2px; background: var(--primary); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:hover td { background: #f6fafb; }
td .sub { display: block; font-size: 13px; color: var(--text-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 32px 16px; text-align: center; color: var(--text-2); }
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* ---------------------------------------------------------------- badges, buttons */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 18px; white-space: nowrap; }
.badge--success { background: var(--good-light); color: var(--good); }
.badge--danger { background: var(--bad-light); color: var(--bad); }
.badge--warning { background: var(--warning-light); color: var(--warning); }
.badge--primary { background: var(--primary-light); color: var(--primary-dark); }
.badge--muted { background: var(--surface); color: var(--text-2); }
.badge--dark { background: var(--ink); color: var(--white); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-md); border: 1px solid transparent;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; line-height: 1.2; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: var(--white); border-color: var(--primary); color: var(--primary-dark); }
.btn-outline:hover { background: var(--primary-light); }
.btn-secondary { background: var(--white); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface); }
.btn-danger { background: var(--bad); color: var(--white); }
.btn-danger:hover { background: #a63a2d; }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > label, .label { font-size: 12px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.input, select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.help { font-size: 12px; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { margin: 0; min-width: 160px; }
.filters .field.grow { flex: 1; min-width: 240px; }

/* ---------------------------------------------------------------- alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-md); border: 1px solid; margin-bottom: 16px; }
.alert strong { display: block; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert--success { background: var(--good-light); border-color: #9bd8bb; color: #14532d; }
.alert--error { background: var(--bad-light); border-color: #f0b0a7; color: #7a2419; }
.alert--warning { background: var(--warning-light); border-color: #ecd08a; color: #6b4300; }
.alert--info { background: var(--primary-light); border-color: #a9dce2; color: #0a4a53; }

/* ---------------------------------------------------------------- pager */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 14px; color: var(--text-2); font-size: 14px; }
.pager nav { display: flex; gap: 6px; flex-wrap: wrap; }
.pager a, .pager .page {
  min-width: 38px; padding: 6px 12px; text-align: center; text-decoration: none;
  color: var(--text); background: var(--white); border: 1px solid var(--border); border-radius: 10px;
}
.pager a:hover { background: var(--primary-light); border-color: var(--primary); }
.pager .current { background: var(--primary); border-color: var(--primary); color: var(--white); font-weight: 700; }
.pager .disabled { opacity: 0.4; }

/* ---------------------------------------------------------------- bar chart (plain CSS, no script) */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 130px; padding-top: 8px; }
.bars .col { position: relative; flex: 1; min-width: 4px; height: 100%; display: flex; align-items: flex-end; }
.bars .bar { width: 100%; background: linear-gradient(180deg, var(--accent), var(--primary)); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------------------------------------------------------------- small controls */
/* A small "open to confirm" control inside a table row (e.g. Make inactive). It opens in place, so the table never clips it. */
details.pop { display: inline-block; vertical-align: top; text-align: left; }
details.pop > summary { list-style: none; cursor: pointer; }
details.pop > summary::-webkit-details-marker { display: none; }
details.pop .pop__body { width: 270px; max-width: 100%; margin-top: 8px; padding: 12px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); white-space: normal; }
details.pop .pop__body p { font-size: 13px; }

/* ---------------------------------------------------------------- sign-in page */
.auth-wrap { min-height: calc(100vh - var(--topbar)); display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(180deg, #e3f4f6 0%, var(--surface) 55%); }
.auth-card { width: 100%; max-width: 440px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 28px 24px; box-shadow: 0 10px 30px rgba(11, 28, 44, 0.08); }
.auth-card h1 { margin-bottom: 6px; }
.auth-card .lead { color: var(--text-2); margin-bottom: 18px; }
.auth-card .btn { width: 100%; }
.auth-foot { text-align: center; margin-top: 14px; font-size: 14px; color: var(--text-2); }

/* ---------------------------------------------------------------- narrower screens */
@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }
  .sidebar { position: fixed; left: -260px; top: var(--topbar); z-index: 40; transition: left 0.2s; box-shadow: 0 8px 24px rgba(11, 28, 44, 0.25); }
  body.nav-open .sidebar { left: 0; }
  .content { padding: 16px; }
  .topbar .who { display: none; }
  .brand small { display: none; }
  .kv { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- in-page section links (Settings) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chips a { padding: 6px 14px; border-radius: 999px; background: var(--white); border: 1px solid var(--border); color: var(--primary-dark); font-weight: 700; font-size: 14px; text-decoration: none; }
.chips a:hover { background: var(--primary-light); border-color: var(--primary); }
html { scroll-behavior: smooth; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; cursor: pointer; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--primary); flex-shrink: 0; }
.check span { font-weight: 600; }
.check small { display: block; font-weight: 400; color: var(--muted); }
textarea { min-height: 96px; resize: vertical; }
