/* iM4 Health Management System (Smart Hub) - v4 styles
   Type: sans-serif; page heading 16 bold; subheading 14 semibold; all else 12 regular.
   Colors: primary #0099FF, secondary #FF3366, accent #FFCC66, text/lines #003366. */

:root {
  --primary: #0099FF;
  --primary-dark: #0077CC;
  --secondary: #FF3366;
  --accent: #FFCC66;
  --ink: #003366;
  --ink-soft: #4a6a8a;
  --line: #d7e3f0;
  --bg: #f4f8fc;
  --card: #ffffff;
  --danger: #FF3366;
  --ok: #0a9b58;
}

* { box-sizing: border-box; }

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

h1 { font-size: 16px; font-weight: 700; color: var(--ink); margin: 0 0 12px; }
h2 { font-size: 16px; font-weight: 700; color: var(--ink); margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; color: var(--ink); margin: 18px 0 8px; }
h3.stage-group { margin-top: 22px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--ink-soft); }

/* ---------- header: dark banner, hamburger, logo, profile ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ink);
  color: #fff;
  padding: 8px 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.hamb-wrap { position: relative; }

.hamb {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  font-size: 16px;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}

.hamb-menu {
  display: none;
  position: absolute;
  top: 110%;
  left: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,51,102,0.18);
  min-width: 190px;
  padding: 6px;
  z-index: 100;
}

.hamb-menu.open { display: block; }

.menu-item {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 12px;
}

.menu-item:hover { background: var(--bg); text-decoration: none; }
.menu-item.active { background: var(--primary); color: #fff; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}

.brand:hover { text-decoration: none; }

.brand-logo { display: block; height: auto; }

.brand-text {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.2px;
}

.userbox { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.userbox .user-email { color: #fff; }
.userbox .user-email em { font-style: normal; opacity: 0.75; }

/* ---------- layout ---------- */
.main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 48px; }

/* ---------- buttons / forms ---------- */
.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--secondary); border-color: var(--secondary); color: #fff; font-weight: 600; }
.btn-danger:hover { filter: brightness(0.9); }
.btn-small { padding: 3px 8px; }
.btn-link { background: none; border: none; color: #fff; cursor: pointer; padding: 4px 6px; }
.btn-link:hover { text-decoration: underline; }

label { display: block; margin: 8px 0 4px; font-weight: 600; }

input[type="email"], input[type="password"], input[type="text"], select, textarea {
  width: 100%;
  max-width: 420px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  color: var(--ink);
  margin-top: 4px;
}

textarea { resize: vertical; }

.form-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.form-inline input, .form-inline select { width: auto; }

.csvbox { font-family: monospace; max-width: 100%; }

/* ---------- cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  display: block;
}

a.card:hover { text-decoration: none; border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,153,255,0.15); }

.card-code {
  display: inline-block;
  font-weight: 700;
  color: var(--primary-dark);
  background: #e8f4ff;
  border-radius: 4px;
  padding: 1px 7px;
  margin-bottom: 4px;
}

.card-title { font-weight: 600; font-size: 12px; margin: 2px 0 6px; }

.card-numbers { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0; }
.card-numbers b { color: var(--ink); }

.card-meta { margin-top: 6px; }

.card-summary { margin-top: 6px; color: var(--ink-soft); }

.code-chip {
  display: inline-block;
  font-weight: 700;
  color: var(--primary-dark);
  background: #e8f4ff;
  border-radius: 4px;
  padding: 1px 8px;
  margin-right: 6px;
}

.rollup {
  background: #e8f4ff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 8px 0 4px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1px 8px;
  color: var(--ink-soft);
  background: #fff;
}

.badge-rush { background: var(--secondary); border-color: var(--secondary); color: #fff; }
.badge-warn { background: var(--accent); border-color: var(--accent); color: #003366; }
.badge-overdue { background: var(--secondary); border-color: var(--secondary); color: #fff; }
.card.arrears-yellow { border-left-color: var(--accent); }
.card.arrears-red { border-left-color: var(--secondary); }

.rag {
  display: inline-block;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 10px;
  margin-bottom: 6px;
  color: #fff;
}

.rag-green { background: var(--ok); }
.rag-yellow { background: #d99a00; }
.rag-red { background: var(--secondary); }

/* ---------- mini pipeline (card level) ---------- */
.mini-pipe { display: flex; gap: 4px; margin: 8px 0; }
.mp-step { height: 8px; flex: 1; border-radius: 4px; background: #dfe9f3; }
.mp-step.done { background: var(--primary); }
.mp-step.current { background: var(--accent); }

/* ---------- lifecycle visual (project page) ---------- */
.lifecycle {
  display: flex;
  align-items: flex-start;
  margin: 14px 0 6px;
  padding: 14px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
}

.lc-step { display: flex; flex-direction: column; align-items: center; min-width: 96px; text-align: center; }

.lc-node {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  background: #e6eef6;
  color: var(--ink-soft);
  border: 2px solid var(--line);
}

.lc-step.done .lc-node { background: var(--primary); border-color: var(--primary); color: #fff; }
.lc-step.current .lc-node {
  background: #8B5CF6;
  border-color: #8B5CF6;
  color: #fff;
  box-shadow: 0 0 0 5px rgba(139,92,246,0.30);
}

/* Thick status ring on the current stage node: red / yellow / green. */
.lc-node.rag-ring-red { border: 5px solid var(--secondary); }
.lc-node.rag-ring-yellow { border: 5px solid #d99a00; }
.lc-node.rag-ring-green { border: 5px solid var(--ok); }

.lc-label { margin-top: 6px; font-weight: 600; }
.lc-step.current .lc-label { color: var(--ink); }
.lc-days { color: var(--ink-soft); margin-top: 2px; }

.lc-link { flex: 1; height: 2px; background: var(--line); margin-top: 20px; min-width: 12px; }
.lc-link.done { background: var(--primary); }

/* ---------- project two-column ---------- */
.proj-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
@media (max-width: 860px) { .proj-grid { grid-template-columns: 1fr; } }

/* ---------- messages ---------- */
.msg {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 8px 0;
}

.msg-out { border-left: 4px solid var(--primary); }

.msg-head { margin-bottom: 4px; }
.msg-body { white-space: pre-wrap; }

.summary {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
}

.summary-old { opacity: 0.92; }
.summary-body { white-space: pre-wrap; margin-top: 4px; }

/* ---------- tables ---------- */
.data-table { border-collapse: collapse; width: 100%; background: #fff; margin: 10px 0; }
.data-table th, .data-table td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; font-size: 12px; }
.data-table th { background: var(--ink); color: #fff; font-weight: 600; }
.data-table tr:nth-child(even) td { background: #f7fbff; }
.row-actions { white-space: nowrap; }
.table-scroll { overflow-x: auto; }

/* ---------- filters ---------- */
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0 0 14px; }
.filterbar input[type="search"] { max-width: 300px; margin-top: 0; }
.filterbar select { width: auto; min-width: 170px; margin-top: 0; }

/* ---------- auth ---------- */
.auth-wrap { display: flex; justify-content: center; padding-top: 60px; }
.auth-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  width: 360px;
  max-width: 92vw;
  text-align: center;
}
.auth-card form { text-align: left; }
.auth-card label { margin-top: 10px; }
.auth-card .btn-primary { width: 100%; margin-top: 14px; }

/* ---------- alerts ---------- */
.alert { border-radius: 6px; padding: 8px 12px; margin: 10px 0; }
.alert-error { background: #ffe9ef; border: 1px solid var(--secondary); color: #a31236; }
.alert-ok { background: #e6f7ef; border: 1px solid var(--ok); color: #06663a; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .userbox { margin-left: 0; }
  .brand-text { font-size: 14px; }
}

/* ---------- v5 additions: dashboard stats, billing tabs, role switcher ---------- */
.stat-big { font-size: 28px; font-weight: 700; color: var(--ink); margin: 6px 0; }
.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.stat-row:last-child { border-bottom: none; }
.tabs { display: flex; gap: 8px; margin: 12px 0; }
.tab { background: var(--card); border: 1px solid var(--line); color: var(--ink); border-radius: 6px; padding: 6px 14px; cursor: pointer; font-size: 12px; }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.role-switch { color: #fff; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.role-switch select { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 12px; }
.userbox .btn-link { color: #fff; }
/* ---------- v5.1: billing two-panel layout ---------- */
.billing-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .billing-panels { grid-template-columns: 1fr; } }
.billing-panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.billing-panel h3 { margin: 0 0 8px 0; font-size: 14px; }
.billing-scroll { max-height: 560px; overflow-y: auto; }

/* 12-week implementation plan */
.timeline { display: grid; gap: 10px; margin-top: 10px; }
.tl-block { border: 1px solid #003366; border-radius: 8px; padding: 10px 12px; }
.tl-block.tl-done { border-left: 6px solid var(--primary); opacity: 0.65; }
.tl-block.tl-current { border-left: 6px solid #8B5CF6; background: #f5f0ff; }
.tl-title { font-weight: 700; margin-bottom: 6px; }
.tl-dates { margin-top: 8px; font-size: 12px; }

/* implementation card: one fact per line */
.card-line { margin: 3px 0; }
.tl-duties { margin: 0; padding-left: 20px; font-size: 12px; }

/* Onboarding workflow (v5.6) */
.ob-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin: 10px 0 20px; }
.ob-card { border: 1px solid #003366; border-radius: 10px; padding: 14px; background: #fff; }
.ob-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 15px; }
.ob-doc { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #e6ecf3; font-size: 13px; }
.ob-doc:last-child { border-bottom: none; }
.ob-issue { padding: 8px 10px; border: 1px solid #e6ecf3; border-left: 4px solid #FFCC66; border-radius: 6px; margin: 8px 0; font-size: 13px; }
