/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:       #1a3a5c;
  --blue-mid:   #2e6da4;
  --blue-light: #d9e6f2;
  --blue-pale:  #f0f6fb;
  --green:      #2e7d32;
  --green-bg:   #e8f5e9;
  --red:        #c62828;
  --red-bg:     #ffebee;
  --orange:     #e65100;
  --orange-bg:  #fff3e0;
  --gray:       #6b7280;
  --gray-light: #f3f4f6;
  --border:     #e0e7ef;
  --text:       #1a1a2e;
  --white:      #ffffff;
  --radius:     8px;
  --shadow:     0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.05);
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--gray-light);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ── Navbar ─────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--blue);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 32px; height: 32px;
  background: var(--blue-mid);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub  { font-size: 12px; color: rgba(255,255,255,.6); }

.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  color: rgba(255,255,255,.8);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  transition: background .15s;
}
.nav-links a:hover, .nav-links a.active {
  background: rgba(255,255,255,.15);
  color: var(--white);
  text-decoration: none;
}

.nav-user { display: flex; align-items: center; gap: 8px !important; }
.avatar {
  width: 28px; height: 28px;
  background: var(--blue-mid);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}

.btn-logout {
  background: rgba(255,255,255,.12) !important;
  border: 1px solid rgba(255,255,255,.2);
}
.btn-logout:hover { background: rgba(255,255,255,.22) !important; }

/* ── Main content ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: var(--green-bg); color: var(--green); border-left: 4px solid var(--green); }
.alert-error   { background: var(--red-bg);   color: var(--red);   border-left: 4px solid var(--red);   }
.alert-info    { background: var(--blue-pale); color: var(--blue);  border-left: 4px solid var(--blue-mid); }

/* ── Page header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; font-weight: 700; color: var(--blue); }
.page-header p  { color: var(--gray); font-size: 13px; margin-top: 2px; }
.header-actions { display: flex; gap: 8px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none !important;
}
.btn-primary  { background: var(--blue-mid); color: var(--white); }
.btn-primary:hover  { background: var(--blue); color: var(--white); }
.btn-outline  { background: var(--white); color: var(--blue); border: 1.5px solid var(--border); }
.btn-outline:hover  { background: var(--blue-pale); }
.btn-connect  { background: #00875a; color: var(--white); }
.btn-connect:hover  { background: #006644; color: var(--white); }
.btn-danger   { background: var(--red-bg); color: var(--red); border: 1.5px solid var(--red); }
.btn-danger:hover   { background: var(--red); color: var(--white); }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-lg  { padding: 12px 28px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── Cards grid (dashboard) ─────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.client-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
  border: 1.5px solid var(--border);
  transition: box-shadow .15s, border-color .15s;
}
.client-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.1); border-color: var(--blue-mid); }

.card-top { display: flex; align-items: flex-start; gap: 12px; }
.client-avatar {
  width: 42px; height: 42px; min-width: 42px;
  background: var(--blue);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font-weight: 700; font-size: 18px;
}
.client-info h3 { font-size: 15px; font-weight: 700; color: var(--blue); margin-bottom: 3px; }
.client-info .nipt { font-size: 12px; color: var(--gray); font-family: monospace; }
.card-top .badge { margin-left: auto; }

.card-status { font-size: 12px; color: var(--gray); display: flex; align-items: center; gap: 6px; }
.card-actions { display: flex; gap: 8px; margin-top: 4px; }

/* ── Status dots ────────────────────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
}
.status-dot.connected    { background: var(--green); box-shadow: 0 0 0 2px var(--green-bg); }
.status-dot.disconnected { background: #9ca3af; box-shadow: 0 0 0 2px #f3f4f6; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-small  { background: #e3f2fd; color: #1565c0; }
.badge-medium { background: #f3e5f5; color: #6a1b9a; }
.badge-ojf    { background: #e8f5e9; color: #2e7d32; }
.badge-admin  { background: #fff3e0; color: #e65100; }
.badge-client { background: var(--blue-pale); color: var(--blue); }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table thead tr { background: var(--blue); }
.table thead th { padding: 11px 16px; color: var(--white); font-size: 12px; font-weight: 600; text-align: left; }
.table tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: var(--blue-pale); }
.table td { padding: 11px 16px; font-size: 13px; }
.table .actions { display: flex; gap: 6px; }
.empty { text-align: center; color: var(--gray); padding: 24px !important; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  border: 1.5px solid var(--border);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--blue); }
.form-group small { font-size: 11px; color: var(--gray); margin-top: 2px; }
.form-group input, .form-group select, .form-group textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color .15s;
  outline: none;
  width: 100%;
}
.form-group input:focus, .form-group select:focus { border-color: var(--blue-mid); }
.form-group input[readonly] { background: var(--gray-light); color: var(--gray); }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ── Radio cards ────────────────────────────────────────────────────────── */
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.radio-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all .15s;
  display: flex; gap: 10px; align-items: flex-start;
}
.radio-card input[type=radio] { margin-top: 3px; accent-color: var(--blue-mid); }
.radio-card:hover  { border-color: var(--blue-mid); background: var(--blue-pale); }
.radio-card.selected { border-color: var(--blue-mid); background: var(--blue-pale); }
.rc-body strong { display: block; font-size: 13px; color: var(--blue); margin-bottom: 4px; }
.rc-body small  { font-size: 11px; color: var(--gray); line-height: 1.4; }

/* ── Toggle group ───────────────────────────────────────────────────────── */
.toggle-group { display: flex; border: 1.5px solid var(--border); border-radius: 6px; overflow: hidden; width: fit-content; }
.toggle-opt {
  padding: 8px 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray);
  transition: all .15s;
  display: flex; align-items: center; gap: 8px;
}
.toggle-opt input { display: none; }
.toggle-opt:hover  { background: var(--blue-pale); color: var(--blue); }
.toggle-opt.active { background: var(--blue-mid); color: var(--white); }

/* ── Detail grid ────────────────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.detail-card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; border: 1.5px solid var(--border);
}
.detail-card h4 { font-size: 13px; font-weight: 700; color: var(--blue); margin-bottom: 14px; text-transform: uppercase; letter-spacing: .5px; }

.info-table { width: 100%; font-size: 13px; }
.info-table td { padding: 6px 0; }
.info-table td:first-child { color: var(--gray); width: 40%; }

.qbo-status { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 13px; }
.qbo-status.connected { color: var(--green); }
.qbo-status.disconnected { color: var(--gray); }
.qbo-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ── Section ────────────────────────────────────────────────────────────── */
.section { margin-top: 28px; }
.section-title { font-size: 14px; font-weight: 700; color: var(--blue); margin-bottom: 12px; }

/* ── Login page ─────────────────────────────────────────────────────────── */
body.login-page {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-mid) 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-box {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  padding: 40px;
  width: 100%; max-width: 400px;
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-logo {
  width: 56px; height: 56px;
  background: var(--blue);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font-size: 26px; font-weight: 700;
  margin: 0 auto 14px;
}
.login-header h1 { font-size: 20px; font-weight: 700; color: var(--blue); }
.login-header p  { font-size: 13px; color: var(--gray); margin-top: 4px; }

/* ── Profile ────────────────────────────────────────────────────────────── */
.profile-info { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.big-avatar {
  width: 56px; height: 56px;
  background: var(--blue); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font-size: 24px; font-weight: 700;
}
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px; color: var(--gray); }
.empty-state p { margin-bottom: 16px; }

/* ── Error pages ────────────────────────────────────────────────────────── */
.error-page { text-align: center; padding: 80px 20px; }
.error-page h1 { font-size: 72px; font-weight: 800; color: var(--blue); margin-bottom: 8px; }
.error-page p  { font-size: 16px; color: var(--gray); margin-bottom: 24px; }

/* ── Utilities ──────────────────────────────────────────────────────────── */
.muted { color: var(--gray); font-size: 12px; }
.mono  { font-family: "Consolas", "Courier New", monospace; font-size: 12px; }
.nipt  { font-family: "Consolas", "Courier New", monospace; font-size: 12px; color: var(--gray); }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer {
  text-align: center; padding: 16px;
  font-size: 11px; color: var(--gray);
  border-top: 1px solid var(--border);
  background: var(--white);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .main-content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .radio-cards { grid-template-columns: 1fr; }
  .nav-links .brand-sub { display: none; }
}
