/* ============================================================
   ELECTROMED CORPORATION — SaaS Platform
   Design tokens & global styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800&display=swap');

:root {
  /* Surfaces — cool neutral */
  --bg:        #e9ebee;        /* app background */
  --shell:     #f4f5f6;        /* big rounded app container */
  --surface:   #ffffff;        /* cards */
  --surface-2: #f6f7f8;        /* inset / secondary cards */
  --surface-3: #eef0f1;        /* hover / track */

  /* Ink */
  --ink:       #0d1411;        /* primary text (near-black, faint green) */
  --ink-2:     #5b6470;        /* secondary text */
  --ink-3:     #8a929c;        /* tertiary / placeholder */
  --line:      #e6e8ea;        /* hairline borders */
  --line-2:    #dfe2e5;

  /* Brand — lime green + deep forest */
  --lime:      #a9ec6e;        /* primary accent */
  --lime-600:  #8fd84e;
  --lime-700:  #6fb834;
  --lime-soft: #eafad9;        /* tint backgrounds */
  --forest:    #0f3324;        /* deep green */
  --forest-2:  #0a2419;
  --grad-green: linear-gradient(150deg, #1c5a3a 0%, #103626 55%, #0a2117 100%);
  --grad-lime:  linear-gradient(160deg, #c0f48a 0%, #a3e766 60%, #8ed64f 100%);
  --grad-dark:  linear-gradient(150deg, #1d3a2c 0%, #0e1f17 100%);

  /* Status */
  --ok:    #1f9d57;   --ok-bg:   #e3f6ea;
  --warn:  #d98a13;   --warn-bg: #fdf0d9;
  --info:  #2f6fd6;   --info-bg: #e3edfb;
  --bad:   #d63b3b;   --bad-bg:  #fbe5e5;
  --idle:  #8a929c;   --idle-bg: #eef0f1;

  /* Radius */
  --r-xl: 26px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;

  /* Shadow */
  --sh-sm: 0 1px 2px rgba(13,20,17,.04), 0 1px 1px rgba(13,20,17,.03);
  --sh:    0 6px 18px -8px rgba(13,20,17,.12), 0 2px 6px -3px rgba(13,20,17,.06);
  --sh-lg: 0 24px 60px -20px rgba(13,20,17,.28);

  --rail: 252px;   /* sidebar width */
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#root { height: 100%; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
::selection { background: var(--lime); color: var(--forest-2); }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #cdd2d6; border-radius: 20px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #b6bcc2; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- App layout ---------- */
.app {
  height: 100%;
  padding: 16px;
  display: flex;
  gap: 0;
}
.app-shell {
  flex: 1;
  display: flex;
  min-width: 0;
  background: var(--shell);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--sh);
}

/* Sidebar */
.sidebar {
  width: var(--rail);
  flex-shrink: 0;
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid var(--line);
  background: var(--shell);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--grad-green);
  display: grid; place-items: center; flex-shrink: 0;
  box-shadow: 0 4px 10px -3px rgba(15,51,36,.5);
}
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -.02em; line-height: 1; }
.brand-sub { font-size: 10.5px; color: var(--ink-3); font-weight: 600; letter-spacing: .02em; margin-top: 3px; }

.nav-label { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  font-size: 14px; font-weight: 600; color: var(--ink-2);
  width: 100%; text-align: left; transition: background .14s, color .14s;
  position: relative;
}
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item.active { background: var(--ink); color: #fff; box-shadow: var(--sh-sm); }
.nav-item.active .nav-ic { color: var(--lime); }
.nav-ic { width: 19px; height: 19px; flex-shrink: 0; color: var(--ink-3); }
.nav-item.active .nav-ic { color: var(--lime); }
.nav-item:hover .nav-ic { color: var(--ink); }
.nav-badge { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--lime); color: var(--forest-2); border-radius: 20px; padding: 1px 8px; }
.nav-item.active .nav-badge { background: var(--lime); color: var(--forest-2); }

/* Main column */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px; border-bottom: 1px solid var(--line);
  background: var(--shell);
}
.content { flex: 1; overflow-y: auto; padding: 26px 28px 40px; }
.content-inner { max-width: 1320px; margin: 0 auto; }

/* Generic helpers */
.row { display: flex; align-items: center; }
.muted { color: var(--ink-2); }
.tiny { font-size: 12px; }
.grow { flex: 1; }
.mono { font-variant-numeric: tabular-nums; }

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  box-shadow: var(--sh-sm);
}
.card-pad { padding: 22px; }

/* Pills / buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 999px;
  font-weight: 700; font-size: 14px; white-space: nowrap;
  transition: transform .08s, background .14s, box-shadow .14s, opacity .14s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--lime); color: var(--forest-2); box-shadow: 0 6px 16px -8px rgba(111,184,52,.9); }
.btn-primary:hover { background: var(--lime-600); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #1d2a22; }
.btn-ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fca5a5; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-icon { padding: 10px; border-radius: 12px; }

/* Status badge */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* Chips / tabs */
.tabs { display: inline-flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); padding: 4px; border-radius: 999px; }
.tab { padding: 8px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 700; color: var(--ink-2); transition: .14s; }
.tab:hover { color: var(--ink); }
.tab.active { background: var(--ink); color: #fff; box-shadow: var(--sh-sm); }

/* Inputs */
.field {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 16px; color: var(--ink);
}
.field:focus-within { border-color: var(--lime-700); box-shadow: 0 0 0 3px var(--lime-soft); }
.field input { border: none; background: none; outline: none; font-size: 14px; width: 100%; color: var(--ink); }
.field input::placeholder { color: var(--ink-3); }
.input-block {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 14px; font-size: 14px; color: var(--ink); outline: none;
}
.input-block:focus { border-color: var(--lime-700); box-shadow: 0 0 0 3px var(--lime-soft); }
label.fld { display: block; }
label.fld > span { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }

/* Table */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 12px; font-weight: 700; color: var(--ink-3);
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  text-transform: none; letter-spacing: .01em;
}
.tbl td { padding: 14px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: none; }

/* Page header */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 30px; font-weight: 800; letter-spacing: -.025em; line-height: 1.05; }
.page-sub { color: var(--ink-2); font-size: 14.5px; margin-top: 7px; }
.eyebrow { font-size: 12px; font-weight: 700; color: var(--lime-700); letter-spacing: .06em; text-transform: uppercase; }

/* Grids */
.grid { display: grid; gap: 18px; }

/* Stat card */
.stat { padding: 18px 20px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink); }
.stat-label { font-size: 13.5px; color: var(--ink-2); font-weight: 600; }
.stat-val { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.delta.up { color: var(--ok); background: var(--ok-bg); }
.delta.down { color: var(--bad); background: var(--bad-bg); }

/* Modal */
.scrim { position: fixed; inset: 0; background: rgba(10,20,15,.42); backdrop-filter: blur(3px); z-index: 60; display: flex; justify-content: center; overflow-y: auto; padding: 28px; animation: fade .16s ease; }
.modal { background: var(--surface); border-radius: var(--r-lg); width: 100%; max-width: 560px; max-height: calc(100vh - 56px); margin: auto; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--sh-lg); animation: pop .18s cubic-bezier(.2,.8,.3,1); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 22px 24px 16px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; background: var(--surface-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty / placeholder */
.ph-img {
  background-color: var(--surface-2);
  background-image: repeating-linear-gradient(45deg, transparent, transparent 9px, rgba(13,20,17,.045) 9px, rgba(13,20,17,.045) 10px);
  border: 1px dashed var(--line-2); border-radius: var(--r-md);
  display: grid; place-items: center; color: var(--ink-3); font-family: ui-monospace, monospace; font-size: 11px;
}

/* Fade-in for views — opacity-free (some preview iframes freeze the anim timeline) */
.view-enter { opacity: 1; animation: viewIn .3s ease both; }
@keyframes viewIn { from { transform: translateY(9px); } to { transform: none; } }

/* avatar */
.avatar { border-radius: 50%; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; font-weight: 700; color: var(--ink-2); flex-shrink: 0; }

/* progress */
.track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.track > i { display: block; height: 100%; border-radius: 999px; background: var(--grad-lime); }
.track.dark > i { background: var(--grad-green); }

/* ============================================================
   LOGIN / SIGN-IN
   ============================================================ */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.login-brand { background: linear-gradient(160deg, #0d1411 0%, #143026 55%, #1c5a3a 130%); position: relative; overflow: hidden; }
.login-brand::after { content: ''; position: absolute; right: -120px; top: -120px; width: 380px; height: 380px; border-radius: 50%; background: radial-gradient(circle, rgba(169,236,110,.16), transparent 68%); }
.login-brand-inner { position: relative; z-index: 1; height: 100%; padding: 52px 56px; display: flex; flex-direction: column; gap: 18px; }
.login-form-panel { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px; }
.login-card { width: 100%; max-width: 384px; }
.login-eye { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--lime-700); font-weight: 700; font-size: 12.5px; cursor: pointer; padding: 4px; }
.login-demo { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 18px; padding: 11px; background: var(--surface-2); border-radius: 11px; }
@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}

/* ============================================================
   PRINT / PDF ENGINE
   printDocument(node) clones the document into #print-mount, adds
   body.printing, then window.print(). Browser "Save as PDF" handles
   download. Only the cloned sheet prints — app chrome is hidden.
   ============================================================ */
#print-mount { display: none; }
.print-only { display: none; }
@media print {
  @page { size: A4; margin: 13mm; }
  html, body { background: #fff !important; }
  body:not(.printing) #print-mount { display: none !important; }
  body.printing #root { display: none !important; }
  body.printing #print-mount { display: block !important; }
  body.printing #print-mount * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .print-sheet { box-shadow: none !important; border: none !important; border-radius: 0 !important; max-width: none !important; width: 100% !important; }
  .print-sheet .no-print, .no-print { display: none !important; }
  .print-only { display: block !important; }
  /* keep document rows from splitting awkwardly across pages */
  .print-sheet table tr, .print-sheet .pb-avoid { break-inside: avoid; }
}
