/* ===== Dreamer Healthcare — Service Documentation ===== */
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #1a2434;
  --ink-soft: #44546a;
  --muted: #6b7a90;
  --line: #e3e9f1;
  --brand: #1f7a8c;
  --brand-dark: #155e6b;
  --brand-soft: #e3f1f4;
  --accent: #2a9d8f;
  --danger: #d64545;
  --danger-soft: #fbe7e7;
  --warn: #e8a33d;
  --warn-soft: #fbf1de;
  --ok: #2f9e6f;
  --ok-soft: #e3f4ec;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20,40,70,.08), 0 6px 24px rgba(20,40,70,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; }

/* ===== Buttons ===== */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: 10px;
  padding: 11px 18px; background: var(--brand); color: #fff;
  transition: filter .15s, background .15s, border .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { filter: brightness(.96); }
.btn-ghost { background: transparent; color: var(--brand); border-color: var(--line); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-danger { background: var(--danger); }
.btn-soft { background: var(--brand-soft); color: var(--brand-dark); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; display: block; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Login ===== */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1f7a8c 0%, #155e6b 60%, #0e4651 100%);
  padding: 24px;
}
.login-card {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow);
  padding: 36px; width: 100%; max-width: 460px;
}
.login-card h2 { margin-top: 18px; }
.staff-login-list { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.staff-pick {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); cursor: pointer; font: inherit; transition: .15s;
}
.staff-pick:hover { border-color: var(--brand); background: var(--brand-soft); }
.login-foot { margin-top: 18px; text-align: center; font-size: 12px; }

/* ===== Brand ===== */
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 20px; margin: 0; }
.brand .tagline { margin: 0; font-size: 13px; color: var(--muted); }
.brand-mark {
  width: 46px; height: 46px; flex: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff; font-weight: 800; letter-spacing: .5px;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.brand-logo {
  width: 46px; height: 46px; flex: none; border-radius: 12px;
  object-fit: cover;
}
.avatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}

/* ===== App shell ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex: none; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 14px; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { padding: 0 6px; }
.sidebar-brand strong { display: block; font-size: 15px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn {
  text-align: left; font: inherit; font-weight: 600; font-size: 14.5px;
  padding: 11px 14px; border-radius: 10px; border: none; background: transparent;
  color: var(--ink-soft, #44546a); cursor: pointer; transition: .12s;
}
.nav-btn:hover { background: var(--surface-2); }
.nav-btn.active { background: var(--brand-soft); color: var(--brand-dark); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.sidebar-foot .who { font-weight: 600; margin-bottom: 8px; font-size: 14px; }

.content { flex: 1; padding: 30px 38px; max-width: 1100px; }

/* ===== Page header ===== */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 24px; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ===== Cards / grid ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.stat { padding: 18px 20px; }
.stat .num { font-size: 30px; font-weight: 800; color: var(--brand-dark); }
.stat .lbl { color: var(--muted); font-size: 13.5px; font-weight: 600; }

/* ===== Forms ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: 13.5px; }
.field .req { color: var(--danger); }
.field .hint { font-size: 12px; color: var(--muted); }
input, select, textarea {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 90px; }
.invalid { border-color: var(--danger) !important; background: var(--danger-soft); }
.field-err { color: var(--danger); font-size: 12px; font-weight: 600; }

/* fieldset look */
.section { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; background: var(--surface); }
.section.incident-on { border-color: var(--danger); box-shadow: inset 4px 0 0 var(--danger); }
.notify-row:first-of-type { border-top: none !important; }
.section > h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.section .step-num {
  width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff;
  font-size: 12px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}
.auto-badge { font-size: 11px; font-weight: 700; color: var(--ok); background: var(--ok-soft); padding: 2px 8px; border-radius: 20px; }

/* goals checklist */
.goal-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 8px; cursor: pointer; }
.goal-item:hover { background: var(--surface-2); }
.goal-item input { width: auto; margin-top: 3px; }
.goal-item .g-area { font-size: 11px; color: var(--brand-dark); background: var(--brand-soft); padding: 1px 7px; border-radius: 12px; font-weight: 600; }

/* signature */
.sig-box { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sig-pad { border: 2px dashed var(--line); border-radius: 10px; background: var(--surface-2); touch-action: none; cursor: crosshair; }
.sig-typed { font-family: "Segoe Script", "Snell Roundhand", cursive; font-size: 26px; color: var(--brand-dark); }

/* unit calc */
.calc-row { display: flex; gap: 16px; flex-wrap: wrap; }
.calc-pill { background: var(--brand-soft); color: var(--brand-dark); padding: 8px 14px; border-radius: 20px; font-weight: 700; }

/* ===== Tables / lists ===== */
.list { display: flex; flex-direction: column; gap: 10px; }
.row-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.row-card .grow { flex: 1; min-width: 0; }
.row-card .title { font-weight: 700; }
.row-card .sub { color: var(--muted); font-size: 13px; }
.tag { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 20px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: #a9701f; }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.brand { background: var(--brand-soft); color: var(--brand-dark); }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; flex: 1; min-width: 160px; }

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

/* ===== Modal ===== */
.modal-host { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20,30,50,.45); }
.modal { position: relative; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; padding: 26px; }
.modal h3 { font-size: 19px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ===== Toast ===== */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 30px; font-weight: 600; box-shadow: var(--shadow); z-index: 80; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

/* ===== Note detail / print ===== */
.note-doc { background: var(--surface); }
.note-doc .doc-head { display: flex; justify-content: space-between; border-bottom: 2px solid var(--brand); padding-bottom: 14px; margin-bottom: 18px; }
.doc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; margin-bottom: 18px; }
.doc-field .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; }
.doc-field .v { font-weight: 600; }
.doc-narr { background: var(--surface-2); border-radius: 10px; padding: 16px; white-space: pre-wrap; line-height: 1.6; }
.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; margin: 10px 0 0; }
.checklist .ci { font-size: 13px; display: flex; gap: 6px; align-items: center; }
.checklist .ci .x { color: var(--ok); font-weight: 800; }

.banner { padding: 12px 16px; border-radius: 10px; font-weight: 600; margin-bottom: 16px; display: flex; gap: 10px; align-items: center; }
.banner.warn { background: var(--warn-soft); color: #8a5a14; }
.banner.danger { background: var(--danger-soft); color: var(--danger); }
.banner.info { background: var(--brand-soft); color: var(--brand-dark); }

/* ===== Mobile chrome (hidden on desktop) ===== */
.mobile-header { display: none; }
.mobile-nav    { display: none; }
.menu-overlay  { display: none; position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.45); }
.menu-overlay.open { display: block; }

.hamburger {
  background: none; border: none; cursor: pointer; padding: 8px;
  display: flex; flex-direction: column; gap: 5px; border-radius: 8px;
}
.hamburger span { display: block; width: 22px; height: 2px; background: var(--ink); border-radius: 2px; }

/* ===== Responsive — tablet ===== */
@media (max-width: 860px) {
  .content { padding: 22px 18px; }
  .form-grid, .doc-grid, .grid-3, .grid-2, .checklist { grid-template-columns: 1fr; }
}

/* ===== Responsive — phone ===== */
@media (max-width: 680px) {
  /* Layout */
  .app { flex-direction: column; min-height: 100vh; padding-bottom: 64px; }
  .content { padding: 14px 14px 20px; }

  /* Hide desktop sidebar; show as slide-in drawer */
  .sidebar {
    position: fixed; top: 0; left: -270px; width: 260px; height: 100vh;
    z-index: 40; transition: left .25s cubic-bezier(.4,0,.2,1);
    overflow-y: auto; box-shadow: none;
  }
  .sidebar.open { left: 0; box-shadow: 4px 0 24px rgba(0,0,0,.18); }

  /* Mobile top bar — extra top padding for iPhone notch */
  .mobile-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
    background: var(--surface); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20; flex-shrink: 0;
  }

  /* Mobile bottom nav */
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .mob-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px; padding: 8px 2px;
    background: none; border: none; cursor: pointer; font-family: var(--font);
    color: var(--muted); min-height: 56px; -webkit-tap-highlight-color: transparent;
  }
  .mob-btn.active { color: var(--brand-dark); }
  .mob-icon { font-size: 20px; line-height: 1.2; }
  .mob-lbl { font-size: 10px; font-weight: 600; }

  /* Toast above bottom nav */
  .toast { bottom: 72px; }

  /* Login */
  .login-card { padding: 24px 18px; }
  .brand h1 { font-size: 17px; }

  /* Page header */
  .page-head { margin-bottom: 14px; gap: 10px; }
  .page-head h2 { font-size: 20px; }

  /* Stat cards — 3 across is too tight, go 1 col */
  .grid-3 { grid-template-columns: 1fr; }
  .stat .num { font-size: 26px; }

  /* Row cards — clean single-line layout: truncate long text, hide staff name */
  .row-card { gap: 8px; padding: 12px; flex-wrap: nowrap; align-items: center; }
  .row-card .avatar { display: none; }
  .row-card .grow { min-width: 0; flex: 1; }
  .row-card .grow .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
  .row-card .grow .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
  .row-card .staff-tag { display: none; }
  .row-card > .tag { font-size: 10px; padding: 2px 6px; flex-shrink: 0; white-space: nowrap; }
  .row-card .btn.btn-ghost { flex-shrink: 0; min-height: 36px; padding: 0 10px; font-size: 13px; }

  /* Toolbar — stack vertically so filters don't crunch */
  .toolbar { flex-direction: column; gap: 8px; }
  .toolbar input, .toolbar select { width: 100%; min-width: unset; flex: none; }
  .toolbar .btn { width: 100%; }

  /* Modal slides up from bottom on mobile */
  .modal-host { align-items: flex-end; padding: 0; }
  .modal { border-radius: 20px 20px 0 0; max-width: none; max-height: 88vh; }

  /* Forms — prevent iOS auto-zoom on focus */
  input, select, textarea { font-size: 16px; }

  /* Better tap targets */
  .btn { min-height: 44px; }
  .nav-btn { min-height: 44px; }

  /* Banner */
  .banner { font-size: 13.5px; }
}

/* ===== Print ===== */
@media print {
  .sidebar, .page-head .btn, .toolbar, .modal-actions, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card, .section { box-shadow: none; border: none; }
}
