/* RCPL ERP v2 — Shared light theme
 * Import on every v2 page: <link rel="stylesheet" href="css/rcpl-light.css">
 * Pages are free to add page-specific styles after this.
 */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Surfaces */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Text */
  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --text-on-accent: #ffffff;

  /* Brand + semantic */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #dbeafe;
  --success: #059669;
  --success-soft: #d1fae5;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-lg: 0 4px 12px rgba(15,23,42,.1), 0 2px 4px rgba(15,23,42,.06);

  /* Radius */
  --r-sm: 4px;
  --r: 6px;
  --r-md: 8px;
  --r-lg: 12px;
}

html, body {
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* ── Topbar ────────────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}
.topbar h1 .v {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}
.topbar .sub {
  color: var(--text-dim);
  font-size: 12px;
}
.topbar .spacer { flex: 1; }
.topbar .kpi {
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.topbar .kpi b { color: var(--accent); }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 7px 14px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--text-dim);
}
.btn.primary {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}
.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn.success {
  background: var(--success);
  color: var(--text-on-accent);
  border-color: var(--success);
}
.btn.danger {
  background: var(--danger);
  color: var(--text-on-accent);
  border-color: var(--danger);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn.sm { padding: 4px 10px; font-size: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Cards ─────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
}
.card-head .count {
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.card-body { padding: 14px 16px; }
.card-body.flush { padding: 0; }

/* ── Form fields ───────────────────────────────────────────────────── */
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.field input,
.field select,
.field textarea,
input.inp, select.inp, textarea.inp {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--r);
  font-family: inherit;
  font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
input.inp:focus, select.inp:focus, textarea.inp:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { min-height: 56px; resize: vertical; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

/* ── Tables ────────────────────────────────────────────────────────── */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl th {
  text-align: left;
  padding: 9px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tbl td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.tbl tbody tr:hover td {
  background: var(--surface-2);
  cursor: pointer;
}
.tbl .mono { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: 12px; }
.tbl .code { color: var(--accent); font-family: monospace; font-weight: 600; }
.tbl .amt { text-align: right; font-family: monospace; color: var(--success); font-weight: 600; }
.tbl .muted { color: var(--text-dim); font-size: 11px; }

/* ── Badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.accent   { background: var(--accent-soft);  color: var(--accent); }
.badge.success  { background: var(--success-soft); color: var(--success); }
.badge.warn     { background: var(--warn-soft);    color: var(--warn); }
.badge.danger   { background: var(--danger-soft);  color: var(--danger); }
.badge.purple   { background: var(--purple-soft);  color: var(--purple); }
.badge.muted    { background: var(--surface-2);    color: var(--text-muted); }

/* status aliases (used by commercial-docs) */
.badge.status-draft,
.badge.status-expired,
.badge.status-cancelled    { background: var(--surface-2);    color: var(--text-muted); }
.badge.status-sent,
.badge.status-partial      { background: var(--warn-soft);    color: var(--warn); }
.badge.status-accepted,
.badge.status-paid,
.badge.status-delivered    { background: var(--success-soft); color: var(--success); }
.badge.status-rejected,
.badge.status-overdue      { background: var(--danger-soft);  color: var(--danger); }
.badge.status-dispatched,
.badge.status-issued       { background: var(--accent-soft);  color: var(--accent); }
.badge.status-returned     { background: var(--purple-soft);  color: var(--purple); }

/* ── KV grid ───────────────────────────────────────────────────────── */
.kv-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 14px;
  font-size: 13px;
}
.kv-grid .k {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
}
.kv-grid .v {
  color: var(--text);
  font-weight: 500;
}
.kv-grid .v.code {
  font-family: monospace;
  color: var(--accent);
  font-size: 12px;
}
.kv-grid .v.big {
  font-size: 16px;
  font-weight: 700;
  color: var(--success);
}

/* ── Modal ─────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.4);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal.show { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

/* ── Toast ─────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 10px 18px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 200;
}
#toast.show { display: block; }

/* ── Utilities ──────────────────────────────────────────────────────── */
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.mono { font-family: 'SFMono-Regular', Consolas, monospace; }
.text-success { color: var(--success); }
.text-warn { color: var(--warn); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent); }

.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.spacer { flex: 1; }

.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-dim);
}
.empty-state .ic {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: .4;
}
.empty-state .title {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.empty-state .desc {
  font-size: 12px;
  color: var(--text-dim);
}

/* Scrollbars (webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
