/* ==========================================================================
   ERP Console — design tokens
   Signature idea: each of the four departments (Sales / Operations /
   Finance / HR) carries its own accent color everywhere its data appears —
   nav link, page header rule, cards, chips — so a person always feels which
   "room" of the system they're in without reading the label twice.
   ========================================================================== */

:root {
  /* Ink & surfaces */
  --ink:            #142433;
  --ink-soft:       #4A5A68;
  --bg:             #F3F4F1;
  --surface:        #FFFFFF;
  --border:         #DADAD3;
  --border-soft:    #E7E7E1;

  /* Module accents */
  --c-sales:        #B5652D;
  --c-sales-soft:   #F4E3D3;
  --c-operations:   #2F6F5E;
  --c-operations-soft: #DCEAE5;
  --c-finance:      #1F4E79;
  --c-finance-soft: #DCE6EF;
  --c-hr:           #6B4A8A;
  --c-hr-soft:      #E7DEEF;

  --success:        #2F6F5E;
  --danger:         #A6362C;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --shadow-card: 0 1px 2px rgba(20, 36, 51, 0.06), 0 1px 12px rgba(20, 36, 51, 0.04);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* Active module tints a few global accents — see .topbar::after below for
   the actual accent line (a 1px border can't be tinted independently of
   its own thickness the way a pseudo-element can). */

/* ==========================================================================
   App shell
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #16273A 0%, var(--ink) 100%);
  color: #E9EDF1;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  transition: width 0.18s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 22px;
}

.brand-mark {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  background: #223347;
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 5px 7px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-collapse-btn {
  background: rgba(255,255,255,0.06);
  border: none;
  border-radius: var(--radius-sm);
  color: #C4CDD6;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,0.14); color: #fff; }
.sidebar-collapse-btn svg { width: 15px; height: 15px; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: #C4CDD6;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-label { white-space: nowrap; overflow: hidden; }

.nav-link:hover { background: rgba(255,255,255,0.07); color: #fff; }

.nav-link.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  box-shadow: inset 3px 0 0 0 rgba(255,255,255,0.35);
}

.nav-link.module-sales.active      { box-shadow: inset 3px 0 0 0 var(--c-sales); }
.nav-link.module-operations.active { box-shadow: inset 3px 0 0 0 var(--c-operations); }
.nav-link.module-finance.active    { box-shadow: inset 3px 0 0 0 var(--c-finance); }
.nav-link.module-hr.active         { box-shadow: inset 3px 0 0 0 var(--c-hr); }

.nav-link-settings {
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 6px 4px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-finance), var(--c-hr));
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #E9EDF1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer-label {
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: #8593A0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.employee-code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: #E9EDF1;
}

/* Collapsed state — icons only, toggled by app.js, persisted in localStorage */
body.sidebar-collapsed .sidebar { width: 74px; }
body.sidebar-collapsed .brand-name,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .sidebar-user-info { display: none; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; flex-wrap: wrap; padding-bottom: 14px; }
body.sidebar-collapsed .nav-link { justify-content: center; padding: 10px; }
body.sidebar-collapsed .sidebar-user-chip { justify-content: center; }
body.sidebar-collapsed .sidebar-collapse-btn { transform: rotate(180deg); }

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 1px 0 var(--border), 0 4px 14px rgba(20,36,51,0.03);
  position: relative;
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--border);
  transition: background-color 0.2s ease;
}
body.module-sales      .topbar::after { background: var(--c-sales); }
body.module-operations .topbar::after { background: var(--c-operations); }
body.module-finance    .topbar::after { background: var(--c-finance); }
body.module-hr         .topbar::after { background: var(--c-hr); }

.topbar-title {
  font-size: 18px;
  font-weight: 600;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

.topbar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-finance), var(--c-hr));
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.role-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--border-soft);
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--ink);
}

.logout-link {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  border: 1px solid var(--border);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
}
.logout-link svg { width: 16px; height: 16px; }
.logout-link:hover { background: var(--border-soft); color: var(--ink); }

.content {
  padding: 28px 32px 48px;
  max-width: 1180px;
}

/* ==========================================================================
   Page head, cards, module tinting
   ========================================================================== */

.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; font-weight: 600; }
.page-sub { margin: 0; color: var(--ink-soft); font-size: 14.5px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px 24px;
  margin-bottom: 20px;
}

.card h2 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }

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

.module-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  border-top: 4px solid var(--border);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.module-card:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(20,36,51,0.09); }

.module-card.module-sales      { border-top-color: var(--c-sales); }
.module-card.module-operations { border-top-color: var(--c-operations); }
.module-card.module-finance    { border-top-color: var(--c-finance); }
.module-card.module-hr         { border-top-color: var(--c-hr); }

.module-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.module-card h2 { font-size: 17px; margin: 6px 0 6px; }
.module-card p { margin: 0; font-size: 13.5px; color: var(--ink-soft); }

/* ==========================================================================
   Dashboard — stat cards, charts, activity feed
   ========================================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
a.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(20,36,51,0.09); }

.stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { margin-top: 4px; font-size: 12.5px; color: var(--ink-soft); }
.stat-sub { margin-top: 6px; font-size: 11.5px; font-weight: 600; color: var(--danger); }
.stat-card.is-danger .stat-value { color: var(--danger); }

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.dash-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 880px) {
  .dash-grid-2 { grid-template-columns: 1fr; }
}

.chart-card h2 { margin-bottom: 6px; }
.chart-body { display: flex; justify-content: center; }

.chart-svg { width: 100%; height: auto; max-height: 220px; }
.chart-value-label { font-size: 11px; font-weight: 600; fill: var(--ink); font-family: var(--font-body); }
.chart-axis-label { font-size: 10.5px; fill: var(--ink-soft); font-family: var(--font-body); }

.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: center; }
.donut-svg { width: 160px; height: 160px; flex-shrink: 0; }

.chart-legend { display: flex; flex-direction: column; gap: 8px; }
.chart-legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.chart-legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.chart-legend-value { color: var(--ink-soft); }

.activity-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
}
.activity-item:last-child { border-bottom: none; }
.activity-item .lead-status-pill { flex-shrink: 0; margin-top: 1px; }
.activity-item-body { font-size: 13.5px; min-width: 0; }
.activity-item-body strong { font-weight: 600; }

/* ==========================================================================
   Forms
   ========================================================================== */

form label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 14px 0 5px;
}
form label:first-of-type { margin-top: 0; }

input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  background: #FCFCFB;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--c-finance);
  outline-offset: 1px;
  border-color: var(--c-finance);
}

button[type="submit"], button.primary {
  margin-top: 18px;
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
}
button[type="submit"]:hover, button.primary:hover { background: #0D1826; }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.form-note { margin-top: 10px; font-size: 13px; }
.form-note.is-error { color: var(--danger); }
.form-note.is-success { color: var(--success); }

/* ==========================================================================
   HR: team table, drawer
   ========================================================================== */

.hr-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 880px) {
  .hr-layout { grid-template-columns: 1fr; }
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.cell-primary { font-weight: 600; }
.cell-secondary { color: var(--ink-soft); font-size: 12.5px; }

.employee-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--border-soft);
  padding: 3px 8px;
  border-radius: 999px;
}

.status-pill {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
}
.status-active   { background: var(--c-operations-soft); color: var(--c-operations); }
.status-inactive { background: #EFE1DD; color: var(--danger); }

.link-btn {
  background: none;
  border: none;
  color: var(--c-finance);
  font-weight: 600;
  font-size: 13px;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

.drawer {
  position: fixed;
  inset: 0;
  background: rgba(20, 36, 51, 0.35);
  display: flex;
  justify-content: flex-end;
  z-index: 50;
}
.drawer[hidden] { display: none; }

.drawer-panel {
  width: 420px;
  max-width: 92vw;
  background: var(--surface);
  height: 100%;
  padding: 24px;
  overflow-y: auto;
  box-shadow: -8px 0 24px rgba(20,36,51,0.15);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.drawer-head h2 { margin: 0; font-size: 17px; }
.drawer-sub { color: var(--ink-soft); font-size: 13px; margin: 6px 0 20px; }

.icon-btn {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--ink-soft);
}

.perm-group { margin-bottom: 20px; }
.perm-group h3 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 0 0 8px;
}

.perm-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
}

.perm-label { display: flex; flex-direction: column; }
.perm-code { font-size: 13.5px; font-weight: 500; }
.perm-hint { font-size: 11.5px; color: var(--ink-soft); }

.perm-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}
.perm-toggle button {
  border: none;
  background: var(--surface);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 10px;
  color: var(--ink-soft);
}
.perm-toggle button[data-state="allow"].is-active { background: var(--c-operations); color: #fff; }
.perm-toggle button[data-state="deny"].is-active { background: var(--danger); color: #fff; }
.perm-toggle button[data-state="default"].is-active { background: var(--border-soft); color: var(--ink); }

.muted { color: var(--ink-soft); font-size: 13px; }

/* ==========================================================================
   Sales: tabs, lead status/assignment chips, wide drawer, modal
   ========================================================================== */

.sales-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 9px 4px;
  margin-right: 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}
.tab-btn.active { color: var(--c-sales); border-bottom-color: var(--c-sales); }

.tab-panel[hidden] { display: none; }

.lead-status-pill {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  display: inline-block;
}
.lead-status-New        { background: var(--border-soft); color: var(--ink-soft); }
.lead-status-Contacted  { background: var(--c-finance-soft); color: var(--c-finance); }
.lead-status-Qualified  { background: var(--c-hr-soft); color: var(--c-hr); }
.lead-status-Won        { background: var(--c-operations-soft); color: var(--c-operations); }
.lead-status-Lost       { background: #EFE1DD; color: var(--danger); }

.lead-id-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.source-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
}

.drawer-panel-wide { width: 520px; }

.lead-section { margin-bottom: 22px; }
.lead-section h3 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

.lead-field-row {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft);
}
.lead-field-row .k { color: var(--ink-soft); }
.lead-field-row .v { font-weight: 500; text-align: right; max-width: 62%; }

.assignment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--border-soft);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  font-size: 12.5px;
  margin: 0 6px 6px 0;
}
.assignment-chip .mod-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 2px 6px;
}
.assignment-chip.mod-sales .mod-tag      { background: var(--c-sales); }
.assignment-chip.mod-operations .mod-tag { background: var(--c-operations); }
.assignment-chip.mod-finance .mod-tag    { background: var(--c-finance); }

.assign-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.assign-row select { flex: 1; min-width: 160px; }
.assign-row button {
  margin-top: 0;
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}

.note-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
}
.note-item .note-meta { color: var(--ink-soft); font-size: 11.5px; margin-top: 3px; }

.history-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  padding: 6px 0;
  color: var(--ink-soft);
}
.history-item .lead-status-pill { flex-shrink: 0; }

.add-note-row { display: flex; gap: 8px; margin-top: 10px; }
.add-note-row textarea { flex: 1; min-height: 44px; resize: vertical; }
.add-note-row button {
  margin-top: 0;
  align-self: flex-end;
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}

.status-select-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.status-select-row select { flex: 1; }
.status-select-row button {
  margin-top: 0;
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}

.handoff-banner {
  background: var(--c-operations-soft);
  border: 1px solid var(--c-operations);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 18px;
}
.handoff-banner p { margin: 0 0 8px; font-size: 13px; color: var(--ink); }

.app-status-pill { background: var(--c-finance-soft); color: var(--c-finance); }

.pay-status-received { background: var(--c-operations-soft); color: var(--c-operations); }
.pay-status-pending  { background: var(--border-soft); color: var(--ink-soft); }
.pay-status-failed   { background: #EFE1DD; color: var(--danger); }

.upload-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.upload-row select { flex: 0 0 160px; }
.upload-row input[type="file"] { flex: 1; min-width: 160px; font-size: 13px; }
.upload-row button {
  margin-top: 0;
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}

/* Modal (centered) — distinct from the side drawer, used for creation flows */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 36, 51, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.modal-overlay[hidden] { display: none; }

.modal {
  width: 420px;
  max-width: 92vw;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(20,36,51,0.25);
  padding: 22px 24px;
}

/* ==========================================================================
   Auth page
   ========================================================================== */

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(31,78,121,0.08), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(107,74,138,0.08), transparent 40%),
    var(--bg);
}

.auth-card {
  width: 360px;
  max-width: 92vw;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px 28px;
}

.auth-mark {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  background: var(--ink);
  color: #fff;
  width: fit-content;
  border-radius: var(--radius-sm);
  padding: 5px 7px;
  margin-bottom: 16px;
}

.auth-card h1 { margin: 0 0 6px; font-size: 21px; }
.auth-sub { margin: 0 0 6px; color: var(--ink-soft); font-size: 13.5px; }
.auth-error { color: var(--danger); font-size: 13px; margin-top: 12px; }

/* ==========================================================================
   Sidebar: settings entry
   ========================================================================== */

.nav-link-settings {
  margin-top: 10px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* ==========================================================================
   Integrations
   ========================================================================== */

.integration-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.integration-status-pill {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  background: var(--border-soft);
  color: var(--ink-soft);
}
.integration-status-pill.is-connected { background: var(--c-operations-soft); color: var(--c-operations); }
.integration-status-pill.is-disconnected { background: #EFE1DD; color: var(--danger); }

.integration-field-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.integration-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
}
.integration-actions button.primary { margin-top: 0; }
.integration-actions button:not(.primary) {
  margin-top: 0;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
}
.integration-actions button:not(.primary):hover { background: var(--border-soft); }

.webhook-url-row { margin-top: 18px; }
.webhook-url-row label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.webhook-url-row input {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--border-soft);
}

.integration-sub-list { margin-top: 16px; }

/* ==========================================================================
   Shared WhatsApp-window banner — used inside the Messages inbox thread
   ========================================================================== */

.wa-window-note {
  background: #EFE1DD;
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12.5px;
  margin: 0 18px 10px;
}

/* ==========================================================================
   Inbox layout — shared by Chat (chat.php) and Messages (messages.php)
   ========================================================================== */

.inbox-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 220px);
  min-height: 480px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.inbox-list-pane {
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.inbox-search { padding: 14px; border-bottom: 1px solid var(--border-soft); }
.inbox-search input { margin: 0; }

.inbox-list { flex: 1; overflow-y: auto; }

.inbox-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
}
.inbox-item:hover { background: var(--bg); }
.inbox-item.is-active { background: var(--c-finance-soft); }

.inbox-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.inbox-item-name { font-weight: 600; font-size: 14px; }
.inbox-item-time { font-size: 11px; color: var(--ink-soft); flex-shrink: 0; }

.inbox-item-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.inbox-item-preview {
  font-size: 12.5px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-unread-badge {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.inbox-thread-pane { display: flex; flex-direction: column; min-width: 0; }
.inbox-empty { flex: 1; display: flex; align-items: center; justify-content: center; }
.inbox-thread { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.inbox-thread-head { padding: 14px 18px; border-bottom: 1px solid var(--border-soft); }
.inbox-thread-title { font-weight: 600; font-size: 15px; }

.inbox-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
}

.inbox-compose {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
}
.inbox-compose textarea { flex: 1; min-height: 40px; max-height: 120px; resize: none; margin: 0; }
.inbox-compose button {
  margin-top: 0;
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
}

.bubble {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.bubble-out { align-self: flex-end; background: var(--c-finance-soft); }
.bubble-in { align-self: flex-start; }
.bubble-meta { font-size: 10.5px; color: var(--ink-soft); margin-top: 4px; text-align: right; }

@media (max-width: 880px) {
  .inbox-layout { grid-template-columns: 1fr; height: auto; }
  .inbox-list-pane { border-right: none; border-bottom: 1px solid var(--border-soft); max-height: 320px; }
}

/* ==========================================================================
   Follow-up reminders — lead drawer section + dashboard widget
   ========================================================================== */

.reminder-item { padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; }
.reminder-item-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.reminder-item-date { font-weight: 600; }
.reminder-item.is-overdue .reminder-item-date { color: var(--danger); }
.reminder-item-note { margin-top: 4px; color: var(--ink); }

.reminder-add-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.reminder-add-row input[type="datetime-local"] { flex: 0 0 200px; }
.reminder-add-row input[type="text"] { flex: 1; min-width: 140px; }
.reminder-add-row button {
  margin-top: 0;
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}

.followup-widget-item { display: block; text-decoration: none; color: inherit; padding: 10px 4px; }
.followup-widget-item:hover { background: var(--bg); }

/* ==========================================================================
   Accessibility baseline
   ========================================================================== */

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--c-finance);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
