/* Nimbus CRM — design tokens + primitives (Lightning-style, light theme only) */
:root {
  --brand: #0176d3;
  --brand-dark: #014486;
  --brand-darker: #032d60;
  --brand-light: #d8edff;
  --brand-lighter: #eef4ff;
  --bg: #f3f3f3;
  --surface: #ffffff;
  --surface-alt: #f8f8f8;
  --border: #c9c9c9;
  --border-weak: #e5e5e5;
  --text: #181818;
  --text-weak: #5c5c5c;
  --text-inverse: #ffffff;
  --link: #0b5cab;
  --success: #2e844a;
  --success-bg: #cdefc4;
  --warning: #a86403;
  --warning-bg: #fef1e0;
  --error: #ea001e;
  --error-bg: #fedbdb;
  --offline: #444;
  --radius: 0.25rem;
  --radius-lg: 0.5rem;
  --shadow-1: 0 2px 2px 0 rgba(0,0,0,.1);
  --shadow-2: 0 2px 3px 0 rgba(0,0,0,.16);
  --shadow-3: 0 8px 16px 0 rgba(0,0,0,.2);
  --header-h: 3rem;
  --nav-h: 2.75rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans",
          Arial, sans-serif;
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem;
  --space-5: 1.5rem; --space-6: 2rem;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 13px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: var(--text); }
h1,h2,h3,h4 { margin: 0; font-weight: 600; }
ul, ol { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- boot splash ---------------- */
.boot-splash {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1.5rem;
  background: linear-gradient(180deg,#0b5cab,#032d60); z-index: 9999;
}
.boot-logo svg { fill: #fff; }
.boot-spinner, .spinner {
  width: 2rem; height: 2rem; border: 3px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%; animation: spin .9s linear infinite;
}
.spinner.dark { border-color: rgba(0,0,0,.15); border-top-color: var(--brand); }
.spinner.sm { width: 1rem; height: 1rem; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .boot-spinner, .spinner { animation-duration: 2s; }
  * { scroll-behavior: auto !important; }
}

/* ---------------- icons ---------------- */
.icon { width: 1rem; height: 1rem; fill: currentColor; flex: none; display: block; }
.icon.xs { width: .75rem; height: .75rem; }
.icon.sm { width: .875rem; height: .875rem; }
.icon.md { width: 1.25rem; height: 1.25rem; }
.icon.lg { width: 1.5rem; height: 1.5rem; }
.obj-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: var(--radius); flex: none;
  background: var(--brand); color: #fff;
}
.obj-icon .icon { width: 1.25rem; height: 1.25rem; }
.obj-icon.sm { width: 1.5rem; height: 1.5rem; border-radius: 3px; }
.obj-icon.sm .icon { width: .95rem; height: .95rem; }
.obj-icon.lg { width: 2.5rem; height: 2.5rem; }
.obj-icon.lg .icon { width: 1.6rem; height: 1.6rem; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 2rem; padding: 0 .85rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--link);
  font-weight: 400; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }
.btn:active { background: #eef1f6; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn.brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.brand:hover { background: #014486; border-color: #014486; }
.btn.destructive { background: var(--error); border-color: var(--error); color: #fff; }
.btn.destructive:hover { background: #ba0517; }
.btn.text { border-color: transparent; background: transparent; padding: 0 .5rem; }
.btn.text:hover { background: rgba(0,0,0,.05); }
.btn.icon-only { width: 2rem; padding: 0; }
.btn.sm { min-height: 1.75rem; font-size: 12px; padding: 0 .6rem; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

/* ---------------- form controls ---------------- */
.field { margin-bottom: .85rem; }
.field-label {
  display: block; font-size: 12px; color: var(--text-weak); margin-bottom: .15rem;
}
.field-label .req { color: var(--error); margin-right: .15rem; }
.input, .select, .textarea {
  width: 100%; min-height: 2rem; padding: .3rem .6rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand);
}
.textarea { min-height: 5rem; resize: vertical; line-height: 1.5; }
.select { appearance: none; background-image:
  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='%235c5c5c' d='M8 11L3 6h10z'/></svg>");
  background-repeat: no-repeat; background-position: right .45rem center;
  background-size: 14px; padding-right: 1.6rem; }
.input.error, .select.error, .textarea.error { border-color: var(--error); box-shadow: 0 0 0 1px var(--error); }
.field-error { color: var(--error); font-size: 12px; margin-top: .15rem; }
.checkbox { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }
.checkbox input { width: 1rem; height: 1rem; accent-color: var(--brand); margin: 0; }
.help-icon { color: var(--brand); cursor: help; }

/* ---------------- misc primitives ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: .25rem; padding: .05rem .45rem;
  border-radius: 999px; background: #ecebea; color: var(--text-weak); font-size: 11px;
  font-weight: 600; white-space: nowrap;
}
.badge.success { background: var(--success-bg); color: #1c5c33; }
.badge.warning { background: var(--warning-bg); color: var(--warning); }
.badge.error { background: var(--error-bg); color: #8e0000; }
.badge.brand { background: var(--brand-light); color: var(--brand-darker); }
.pill { border-radius: 999px; border: 1px solid var(--border); padding: .1rem .55rem; font-size: 12px; }
.divider { height: 1px; background: var(--border-weak); margin: .5rem 0; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-weak); }
.empty-state .icon { width: 2.5rem; height: 2.5rem; opacity: .35; margin: 0 auto .5rem; }
.avatar {
  width: 2rem; height: 2rem; border-radius: 50%; background: var(--brand);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex: none; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 1.5rem; height: 1.5rem; font-size: 9px; }
.avatar.lg { width: 3rem; height: 3rem; font-size: 15px; }
