/* 1CMR Pro Portal — Design System (dark)
   Refined typography + component tokens layered onto the existing 1CMR
   aesthetic: green-matrix brand logo, orange accent, dark surfaces.

   Dark-only by design (no theme toggle). IBM Plex is self-hosted (woff2, latin
   subset) so it loads within the strict CSP (font-src falls back to 'self').
   system-ui remains as a fallback. */

@font-face {
  font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 300; font-display: swap;
  src: url('/_portal/assets/fonts/ibm-plex-sans-300.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/_portal/assets/fonts/ibm-plex-sans-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/_portal/assets/fonts/ibm-plex-sans-500.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/_portal/assets/fonts/ibm-plex-sans-600.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/_portal/assets/fonts/ibm-plex-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/_portal/assets/fonts/ibm-plex-mono-500.woff2') format('woff2');
}

:root {
  --accent: #FF8000;
  --accent-soft: rgba(255, 128, 0, 0.10);
  --accent-strong: #E67100;
  --green: #15A35B;
  --green-soft: rgba(21, 163, 91, 0.12);

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;

  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Dark surfaces (the only theme) */
  --bg: #0C0C0D;
  --bg-2: #111114;
  --surface: #15151A;
  --surface-hover: #1B1B22;
  --border: #22222A;
  --border-strong: #2E2E37;
  --text: #E8E6E3;
  --text-2: #B5B2AC;
  --text-3: #7A7872;
  --text-4: #4A4843;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --row-hover: rgba(255, 255, 255, 0.025);
  color-scheme: dark;
}

/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body.cm {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  letter-spacing: -0.005em;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.cm-mono { font-family: var(--font-mono); font-feature-settings: 'tnum'; }

/* ===== TYPE ===== */
.cm-h1 { font-size: 28px; font-weight: 400; letter-spacing: -0.6px; margin: 0; line-height: 1.2; }
.cm-h2 { font-size: 20px; font-weight: 500; letter-spacing: -0.3px; margin: 0; }
.cm-h3 { font-size: 15px; font-weight: 500; margin: 0; }
.cm-eyebrow {
  font-size: 10px; letter-spacing: 2.5px; font-weight: 500;
  color: var(--text-3); text-transform: uppercase;
}
.cm-eyebrow.accent { color: var(--accent); }
.cm-sub { font-size: 13px; color: var(--text-3); }

/* ===== BUTTONS ===== */
.cm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font: 500 12px var(--font-sans); letter-spacing: 0.1px;
  white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: all .15s;
}
.cm-btn:hover { border-color: var(--text-3); color: var(--text); }
.cm-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cm-btn.primary {
  background: var(--accent); border-color: var(--accent); color: #0C0C0D;
  font-weight: 600;
}
.cm-btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.cm-btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.cm-btn.ghost:hover { background: var(--surface-hover); color: var(--text); }
.cm-btn.sm { padding: 5px 10px; font-size: 11px; }

/* Busy state — set on a button/link while its action is in flight so the user
   sees immediate feedback during the full-page POST + redirect + reload. */
@keyframes cm-spin { to { transform: rotate(360deg); } }
.cm-btn.is-busy { pointer-events: none; opacity: 0.85; }
.cm-btn.is-busy::before {
  content: ''; flex: none; width: 13px; height: 13px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: cm-spin .6s linear infinite;
}

/* ===== INPUTS ===== */
.cm-input {
  width: 100%; padding: 10px 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font: 14px var(--font-sans);
  transition: all .15s;
}
.cm-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.cm-input::placeholder { color: var(--text-4); }
.cm-label {
  display: block; font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 1.2px;
  margin-bottom: 6px; font-weight: 500;
}
.cm-search { position: relative; }
.cm-search input { padding-left: 36px; }
.cm-search > svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-3); pointer-events: none;
}

/* ===== CARDS ===== */
.cm-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* ===== TAGS / PILLS ===== */
.cm-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; padding: 3px 8px; border-radius: 3px;
  background: var(--bg-2); color: var(--text-2);
  border: 1px solid var(--border);
  letter-spacing: 0.4px; line-height: 1.4;
}
.cm-tag.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.cm-tag.green { background: var(--green-soft); color: var(--green); border-color: transparent; }

/* ===== AVATAR ===== */
.cm-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text); font-weight: 500;
  flex-shrink: 0;
}

/* ===== PAGE LAYOUT HELPERS ===== */
.cm-page { max-width: 1100px; margin: 0 auto; padding: 40px 32px 96px; }
.cm-page-h {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 24px; margin-bottom: 28px;
}
.cm-section { margin-bottom: 36px; }
.cm-section-h {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}

/* ===== FORM FEEDBACK (login) ===== */
.error, .login-error {
  background: rgba(250, 128, 128, 0.08); color: #FA8080;
  border: 1px solid rgba(250, 128, 128, 0.3); border-radius: var(--radius);
  padding: 10px 14px; font-size: 13px;
}
.support-panel {
  margin-top: 16px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text-2); font-size: 13px;
}
.support-panel strong { display: block; margin-bottom: 4px; color: var(--text); font-weight: 600; }
.support-panel a { color: var(--accent); text-decoration: none; }
.support-panel a:hover { text-decoration: underline; }
.support-panel-error { border-color: rgba(255, 128, 0, 0.45); background: var(--accent-soft); }
