/* FiberLink CRM — design system v2 ("fiber": navy structure, optic-teal accent)
   Tokens first; every component reads from them. One file, no build step. */
:root {
  /* palette */
  --bg: #f2f5f9;            /* cool page background */
  --surface: #ffffff;
  --border: #e3e9f0;
  --border-strong: #cbd6e2;
  --ink: #0f1b2d;            /* primary text — deep navy-ink */
  --ink-2: #33465e;          /* secondary text */
  --muted: #64748b;
  --navy: #0c2340;           /* brand structure (topbar) */
  --navy-2: #123057;
  --accent: #0d9488;         /* fiber teal */
  --accent-strong: #0f766e;
  --accent-soft: #ccfbf1;
  --accent-ink: #ffffff;
  --gold: #f5b301;           /* the ⚡ */
  --good: #15803d;  --good-soft: #dcfce7;
  --warn: #b45309;  --warn-soft: #fef3c7;
  --bad:  #b91c1c;  --bad-soft:  #fee2e2;
  --info: #1d4ed8;  --info-soft: #dbeafe;
  --neutral-soft: #eef2f7;
  /* type + shape */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 4px 14px rgba(15, 27, 45, .05);
  --focus-ring: 0 0 0 3px rgba(13, 148, 136, .3);
}

* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.55 var(--font); background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; display: flex; min-height: 100vh; }
.content { flex: 1; min-width: 0; }
main { max-width: 1560px; margin: 0; padding: 26px 34px 40px; }

/* ---------- sidebar (Zoho-style) ---------- */
.sidebar { width: 226px; flex: 0 0 226px; background: var(--navy); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  border-right: 3px solid var(--accent); }
.brand { font-weight: 800; letter-spacing: .01em; font-size: 16px; white-space: nowrap;
  padding: 18px 18px 14px; }
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px;
  padding: 4px 10px; overflow-y: auto; }
.sidebar nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: var(--radius-sm); text-decoration: none; color: #b9cbdd;
  font-weight: 500; font-size: 14px; white-space: nowrap; }
.sidebar nav a svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar nav a.active { background: rgba(13, 148, 136, .28); color: #fff; font-weight: 650;
  box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot { padding: 12px 14px 14px; border-top: 1px solid rgba(255, 255, 255, .12);
  display: flex; flex-direction: column; gap: 10px; }
.entity-switch { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .28);
  text-decoration: none; color: #b9cbdd; font-size: 12.5px; white-space: nowrap; }
a.chip:hover { border-color: rgba(255, 255, 255, .6); color: #fff; }
.chip.active { background: var(--accent); color: var(--accent-ink);
  border-color: var(--accent); font-weight: 700; }
.userline { display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: #b9cbdd; }
.userline .who { font-weight: 650; color: #fff; }
.userline a { color: #b9cbdd; }
.userline a:hover { color: #fff; }

/* ---------- headings / layout ---------- */
h1 { font-size: 23px; letter-spacing: -.01em; margin: 0 0 18px; font-weight: 750; }
h1 .muted { font-weight: 450; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-2); margin: 26px 0 10px; }
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar h1 { margin: 0; flex: 1; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }

/* stat cards */
.stat { border-top: 3px solid var(--accent); }
.stat .label { color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .07em; font-weight: 600; }
.stat .value { font-size: 23px; font-weight: 750; margin-top: 6px;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .value .muted { font-size: 14px; font-weight: 500; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--neutral-soft); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 650; background: #f8fafc; }
tbody tr:hover td, table tr:hover td { background: #f7fafc; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .02em;
  background: var(--neutral-soft); color: var(--ink-2); }
.badge.lead    { background: var(--warn-soft); color: var(--warn); }
.badge.quoted, .badge.sent, .badge.active { background: var(--info-soft); color: var(--info); }
.badge.won, .badge.paid, .badge.income { background: var(--good-soft); color: var(--good); }
.badge.lost, .badge.void, .badge.expense { background: var(--bad-soft); color: var(--bad); }

/* ---------- forms ---------- */
input, select, textarea { font: inherit; padding: 9px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: var(--focus-ring); }
textarea { min-height: 72px; }
label { font-size: 12px; color: var(--ink-2); display: block; margin-bottom: 4px; font-weight: 600; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 140px; }

/* ---------- buttons ---------- */
button, .btn { font: inherit; font-weight: 600; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer;
  text-decoration: none; color: var(--ink); display: inline-block; }
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent-strong); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink);
  border-color: var(--accent); }
button.primary:hover, .btn.primary:hover { background: var(--accent-strong);
  border-color: var(--accent-strong); color: #fff; }
button.small { padding: 4px 11px; font-size: 12.5px; }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
form.inline { display: inline; }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.note { background: var(--warn-soft); border: 1px solid #f2dfa9; border-radius: var(--radius-sm);
  padding: 11px 14px; font-size: 13px; color: #7a5b0b; margin-bottom: 16px; }
details.editor { margin-top: 12px; }
details.editor summary { cursor: pointer; color: var(--accent-strong); font-weight: 650;
  padding: 6px 2px; }
details.editor summary:hover { color: var(--accent); }
pre { white-space: pre-wrap; background: var(--bg); padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-size: 13px; }

/* ---------- login / password screens ---------- */
.login-wrap { max-width: 370px; margin: 12vh auto 0; padding: 0 20px; }
.login-wrap .brand { font-size: 21px; font-weight: 800; text-align: center;
  margin-bottom: 20px; color: var(--ink); }
.login-wrap .card { padding: 22px; }
.error { color: var(--bad); font-size: 13px; margin: 8px 0; }

/* ---------- mobile (the guys' view): sidebar becomes a top bar ---------- */
@media (max-width: 800px) {
  body { display: block; }
  .sidebar { width: 100%; flex: none; height: auto; position: static;
    border-right: none; border-bottom: 3px solid var(--accent); padding-bottom: 8px; }
  .brand { padding: 12px 14px 8px; }
  .sidebar nav { flex-direction: row; overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; padding: 0 10px; gap: 4px; }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav a { flex: 0 0 auto; padding: 8px 12px; }
  .sidebar nav a.active { box-shadow: inset 0 -3px 0 var(--accent); }
  .sidebar-foot { border-top: none; padding: 8px 14px 2px; flex-direction: row;
    align-items: center; justify-content: space-between; gap: 10px; }
  .entity-switch { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .entity-switch::-webkit-scrollbar { display: none; }
  main { margin: 0; padding: 16px 14px 30px; }
  h1 { font-size: 19px; }
  .grid { gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .card { padding: 13px; }
  .stat .value { font-size: 19px; }
  /* tables scroll inside their own container instead of squeezing */
  table { display: block; overflow-x: auto; white-space: nowrap; }
  td, th { padding: 10px 12px; }
  td span.muted { white-space: normal; }
  /* touch targets */
  button, .btn { min-height: 40px; }
  button.small { min-height: 34px; }
}
