/* ==========================================================
   FleetFixer CRM — bespoke dark ops theme
   Deliberately different from the public auth + platform
   design system so it reads as an internal tool.
   ========================================================== */

:root {
  /* Dark slate with warm accent — finance-console aesthetic */
  --bg:            #0b1220;
  --bg-subtle:     #111a2e;
  --panel:         #182136;
  --panel-hover:   #1f2a44;
  --stroke:        #243150;
  --stroke-strong: #334466;
  --text:          #e8eef7;
  --text-muted:    #8a9ab5;
  --text-dim:      #627296;
  --accent:        #ffb547;        /* amber */
  --accent-dim:    #c9892f;
  --ok:            #3ecf8e;
  --warn:          #f5b642;
  --err:           #ef5f67;
  --info:          #5aa9ff;

  --shadow-sm:     0 1px 2px rgba(0,0,0,.25);
  --shadow-md:     0 6px 18px rgba(0,0,0,.35);
  --radius:        8px;
  --radius-lg:     12px;

  --font-sans:  ui-sans-serif, "Inter", -apple-system, "Segoe UI", sans-serif;
  --font-mono:  ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dim); }
::selection { background: var(--accent); color: var(--bg); }

/* ── Shell ─────────────────────────────────────────────── */

.crm-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.crm-sidebar {
  background: var(--bg-subtle);
  border-right: 1px solid var(--stroke);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.crm-sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-size: 12px;
}
.crm-sidebar .brand i { font-size: 14px; }
.crm-sidebar .nav-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 14px 12px 6px;
}
.crm-sidebar a.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}
.crm-sidebar a.nav:hover  { background: var(--panel); color: var(--text); }
.crm-sidebar a.nav.active { background: var(--panel); color: var(--accent); }
.crm-sidebar a.nav i { width: 16px; text-align: center; font-size: 13px; }

.crm-sidebar .sidebar-spacer { flex: 1; }
.crm-sidebar .whoami {
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--stroke);
  margin-top: 12px;
  padding-top: 12px;
}
.crm-sidebar .whoami strong { color: var(--text); display: block; font-size: 12px; }
.crm-sidebar .whoami code   { color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; word-break: break-all; }
.crm-sidebar button.signout {
  background: none;
  border: 1px solid var(--stroke);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  margin-top: 8px;
  width: 100%;
}
.crm-sidebar button.signout:hover { background: var(--panel); color: var(--text); border-color: var(--stroke-strong); }

.crm-main {
  padding: 28px 32px;
  min-width: 0;
}
.crm-main h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.crm-main .lede {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 13px;
}

/* ── KPIs ──────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi .label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.kpi .value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.kpi .sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.kpi .sub.up { color: var(--ok); }
.kpi .sub.down { color: var(--err); }

/* ── Panel / section ──────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel h2 .h2-actions { display: flex; gap: 8px; text-transform: none; letter-spacing: 0; }

/* ── Table ─────────────────────────────────────────────── */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data thead th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--stroke);
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.6px;
}
table.data tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--stroke);
  color: var(--text);
  vertical-align: top;
}
table.data tbody tr:hover { background: var(--panel-hover); }
table.data td.num, table.data th.num {
  text-align: right;
  font-family: var(--font-mono);
}
table.data td a { color: var(--accent); font-weight: 500; }
table.data .pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-subtle);
  border: 1px solid var(--stroke);
  color: var(--text-muted);
}
table.data .pill.ok    { background: rgba(62, 207, 142, 0.12); color: var(--ok);   border-color: rgba(62, 207, 142, 0.4); }
table.data .pill.warn  { background: rgba(245, 182, 66, 0.12); color: var(--warn); border-color: rgba(245, 182, 66, 0.4); }
table.data .pill.err   { background: rgba(239, 95, 103, 0.12); color: var(--err);  border-color: rgba(239, 95, 103, 0.4); }
table.data .pill.info  { background: rgba(90, 169, 255, 0.12); color: var(--info); border-color: rgba(90, 169, 255, 0.4); }

/* ── Forms ─────────────────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
label.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}
label.field input, label.field select, label.field textarea {
  background: var(--bg);
  border: 1px solid var(--stroke);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}
label.field input:focus,
label.field select:focus,
label.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 181, 71, 0.15);
}
label.field textarea { min-height: 64px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--stroke-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--panel-hover); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dim); border-color: var(--accent-dim); }
.btn-danger {
  background: transparent;
  color: var(--err);
  border-color: rgba(239, 95, 103, 0.4);
}
.btn-danger:hover:not(:disabled) { background: rgba(239, 95, 103, 0.1); }

.btn-group { display: flex; gap: 8px; }

/* ── Messages ─────────────────────────────────────────── */
.msg {
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid;
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg.err  { background: rgba(239, 95, 103, 0.08); color: var(--err);  border-color: rgba(239, 95, 103, 0.3); }
.msg.ok   { background: rgba(62, 207, 142, 0.08); color: var(--ok);   border-color: rgba(62, 207, 142, 0.3); }
.msg.info { background: rgba(90, 169, 255, 0.08); color: var(--info); border-color: rgba(90, 169, 255, 0.3); }
.msg.hidden { display: none; }

/* ── Loading ──────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--panel) 0%, var(--panel-hover) 50%, var(--panel) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 4px;
  color: transparent;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Login page (standalone — no sidebar) ─────────────── */
.crm-login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 181, 71, 0.08) 0, transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(90, 169, 255, 0.06) 0, transparent 40%),
    var(--bg);
}
.crm-login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
}
.crm-login-card .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  font-size: 13px;
}
.crm-login-card h1 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
}
.crm-login-card .lede {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 22px;
}

/* ── Misc ──────────────────────────────────────────────── */
.mono    { font-family: var(--font-mono); }
.muted   { color: var(--text-muted); }
.dim     { color: var(--text-dim); }
.small   { font-size: 11px; }
.right   { text-align: right; }
.center  { text-align: center; }
.row     { display: flex; align-items: center; gap: 12px; }
.grow    { flex: 1; }
.hidden  { display: none !important; }
pre.out  {
  background: #020617;
  color: #a5b4fc;
  padding: 12px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  overflow: auto;
  max-height: 320px;
  border: 1px solid var(--stroke);
  margin: 10px 0 0;
}
