/* ============================================================
   x365 Audit Tool — Design System
   Matches theadminstack.com v4.0 tokens exactly
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ============================================================
   Tokens — light palette
   ============================================================ */
:root {
  /* Backgrounds */
  --bg:        #f9fafb;
  --bg-1:      #ffffff;
  --bg-2:      #f3f4f6;
  --bg-3:      #e5e7eb;

  /* Surfaces */
  --surface:   #ffffff;
  --surface-2: rgba(0,0,0,0.025);
  --surface-3: rgba(0,0,0,0.05);

  /* Borders — solid hairlines (design.md v4.0) */
  --border:    #e5e7eb;
  --border-2:  #d1d5db;
  --border-3:  #9ca3af;

  /* Accent — monochrome (hue is reserved for severity only) */
  --accent:        #111827;
  --accent-inv:    #ffffff;
  --accent-2:      #374151;
  --accent-subtle: #f3f4f6;
  --accent-dim:    #f3f4f6;
  --accent-glow:   rgba(17,24,39,0.08);

  /* Severity — the only hues allowed */
  --sev-critical: #dc2626;
  --sev-high:     #ea580c;
  --sev-medium:   #d97706;
  --sev-low:      #16a34a;
  --sev-none:     #6b7280;
  --sev-critical-bg: rgba(220,38,38,0.12);
  --sev-high-bg:     rgba(234,88,12,0.12);
  --sev-medium-bg:   rgba(217,119,6,0.12);
  --sev-low-bg:      rgba(22,163,74,0.12);
  --sev-none-bg:     rgba(107,114,128,0.12);

  /* Status — legacy aliases mapped onto severity */
  --green:     var(--sev-low);
  --red:       var(--sev-critical);
  --orange:    var(--sev-medium);
  --blue:      var(--sev-none);   /* monochrome: "info" reads neutral, not blue */

  /* Text */
  --text:   #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --text-4: #d1d5db;

  /* Fonts */
  --font-display: 'IBM Plex Sans', system-ui, sans-serif;
  --font-body:    'IBM Plex Sans', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  /* Spacing */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;
  --space-3xl: 4.5rem;
  --space-4xl: 7rem;

  /* Layout */
  --container: 1240px;
  --nav-h:     64px;
  --sidebar-w: 240px;

  /* Radii — design.md v4.0 scale */
  --r-xs:  2px;
  --r-sm:  6px;    /* buttons / inputs / badges */
  --r-md:  8px;
  --r:     10px;   /* card */
  --r-lg:  10px;   /* card */
  --r-xl:  14px;   /* large card */
  --r-pill: 999px;

  /* Transitions */
  --t-fast: 120ms ease;
  --t-mid:  220ms ease;
  --t-slow: 380ms ease;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);

  /* ── Aliases: radius / text ─────────────────────────────── */
  --radius:      var(--r-sm);
  --radius-sm:   var(--r-xs);
  --radius-lg:   var(--r-lg);
  --radius-xl:   var(--r-xl);
  --radius-full: var(--r-pill);
  --text-muted:  var(--text-2);
  --text-dim:    var(--text-3);

  /* ── Aliases: numeric spacing scale ─────────────────────── */
  --space-2:  var(--space-sm);   /* 0.5rem  */
  --space-3:  0.75rem;
  --space-4:  var(--space-md);   /* 1rem    */
  --space-5:  1.25rem;
  --space-6:  var(--space-lg);   /* 1.5rem  */
  --space-8:  var(--space-xl);   /* 2rem    */
  --space-10: 2.5rem;
  --space-12: var(--space-2xl);  /* 3rem    */
  --space-14: 3.5rem;

}

/* ============================================================
   Dark mode
   ============================================================ */
html.dark {
  /* GitHub-dark palette (design.md v4.0) — never pure black */
  --bg:        #0f1117;
  --bg-1:      #161b22;
  --bg-2:      #21262d;
  --bg-3:      #30363d;
  --surface:   #161b22;
  --surface-2: rgba(255,255,255,0.03);
  --surface-3: rgba(255,255,255,0.06);
  --border:    #30363d;
  --border-2:  #3d444d;
  --border-3:  #484f58;
  --accent:        #f0f6fc;
  --accent-inv:    #0f1117;
  --accent-2:      #8b949e;
  --accent-subtle: #21262d;
  --accent-dim:    #21262d;
  --accent-glow:   rgba(240,246,252,0.08);
  --text:   #f0f6fc;
  --text-2: #8b949e;
  --text-3: #484f58;
  --text-4: #30363d;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5), 0 2px 4px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.6), 0 4px 8px rgba(0,0,0,0.3);
}

html.dark .btn-primary { background: var(--accent); color: var(--accent-inv); }
html.dark .badge-green  { background: rgba(22,163,74,0.15);  color: #4ade80; border-color: rgba(22,163,74,0.25); }
html.dark .badge-orange { background: rgba(217,119,6,0.15);  color: #fbbf24; border-color: rgba(217,119,6,0.25); }
html.dark .badge-red    { background: rgba(220,38,38,0.15);  color: #f87171; border-color: rgba(220,38,38,0.25); }
/* monochrome: former blue/purple/cyan badges read neutral */
html.dark .badge-blue,
html.dark .badge-purple,
html.dark .badge-cyan   { background: var(--sev-none-bg); color: var(--text-2); border-color: var(--border-2); }
html.dark .alert-success { color: #4ade80; }
html.dark .alert-danger  { color: #f87171; }
html.dark .alert-warning { color: #fbbf24; }
html.dark .alert-info    { color: var(--text-2); }
html.dark .form-group input,
html.dark .form-group select,
html.dark .form-group textarea { background: var(--bg-2); }
html.dark .code-block { background: #0d1117; }
html.dark code { color: #c9d1d9; }

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   Typography
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
}

h1 { font-size: clamp(2.25rem, 4.5vw, 3.75rem); }
h2 { font-size: clamp(1.5rem, 2.5vw, 2.1rem); }
h3 { font-size: clamp(1rem, 1.5vw, 1.2rem); font-weight: 600; }
h4 { font-size: 0.95rem; font-weight: 600; }

p { color: var(--text-2); line-height: 1.7; }

a { color: var(--text); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-2); }

code, pre { font-family: var(--font-mono); }

/* .serif removed — no serif font in this design */

.lead { font-size: 1.05rem; line-height: 1.75; color: var(--text-2); }

.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: var(--space-md);
}

/* ============================================================
   Layout
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

.section    { padding: var(--space-4xl) 0; }
.section-sm { padding: var(--space-3xl) 0; }

.grid-2    { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-xl); }
.grid-3    { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-xl); }
.grid-4    { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-lg); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-xl); }

/* ============================================================
   Top Nav — for landing pages (index.html, setup)
   ============================================================ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 900;
  display: flex;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: box-shadow var(--t-mid);
}

html.dark .nav { background: var(--surface); }

.nav.scrolled { box-shadow: var(--shadow-sm); }
html.dark .nav.scrolled { box-shadow: var(--shadow-sm); }

.nav-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}

.nav-brand-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.nav-brand-badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  padding: 0.18rem 0.5rem;
  border-radius: var(--r-xs);
  background: var(--accent);
  color: white;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

html.dark .nav-brand-badge { background: #374151; color: #e5e7eb; }

.nav-actions { display: flex; align-items: center; gap: var(--space-md); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--t-fast);
  white-space: nowrap;
  line-height: 1;
}

.btn-primary { background: var(--accent); color: var(--accent-inv); }
.btn-primary:hover { opacity: 0.85; color: var(--accent-inv); }

.btn-outline {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-2);
}
.btn-outline:hover { color: var(--text); border-color: var(--border-3); background: var(--bg-2); }

.btn-ghost {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }

.btn-sm  { padding: 0.375rem 0.875rem; font-size: 0.8rem; }
.btn-lg  { padding: 0.75rem 1.75rem; font-size: 0.95rem; }

.btn-danger {
  background: rgba(220,38,38,0.08);
  color: #dc2626;
  border: 1px solid rgba(220,38,38,0.18);
}
.btn-danger:hover { background: rgba(220,38,38,0.14); }

.btn-success {
  background: rgba(22,163,74,0.08);
  color: #15803d;
  border: 1px solid rgba(22,163,74,0.18);
}
.btn-success:hover { background: rgba(22,163,74,0.14); }
html.dark .btn-success { color: #4ade80; }

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: none;
  border: 1px solid var(--border);
  color: var(--text-3);
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--text-2); background: var(--bg-2); border-color: var(--border-2); }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: border-color var(--t-mid), box-shadow var(--t-mid);
}
.card:hover { border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.card-body { padding: var(--space-xl); }
.card-sm   { padding: var(--space-lg); }
.card-lg   { padding: 2.5rem; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: var(--r-xs);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid;
  white-space: nowrap;
}

.badge-green  { background: rgba(22,163,74,0.07);  color: #15803d; border-color: rgba(22,163,74,0.18); }
.badge-orange { background: rgba(217,119,6,0.08);  color: #b45309; border-color: rgba(217,119,6,0.18); }
.badge-red    { background: rgba(220,38,38,0.07);  color: #b91c1c; border-color: rgba(220,38,38,0.18); }
/* monochrome: former blue/purple/cyan badges read neutral */
.badge-blue,
.badge-purple,
.badge-cyan,
.badge-gray   { background: var(--bg-2); color: var(--text-3); border-color: var(--border-2); }

.tag {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: var(--r-pill);
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--bg-2);
  color: var(--text-3);
  border: 1px solid var(--border);
  transition: all var(--t-fast);
}
.tag:hover { color: var(--text-2); border-color: var(--border-2); }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: var(--space-lg); }

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.01em;
  margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17,24,39,0.06);
}
html.dark .form-group input:focus,
html.dark .form-group select:focus,
html.dark .form-group textarea:focus {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-4); }

.form-hint { font-size: 0.78rem; color: var(--text-3); margin-top: 0.375rem; }

.form-group input.mono,
.form-group input[data-mono] {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  line-height: 1.55;
  border-left: 3px solid;
}

.alert-success { background: rgba(22,163,74,0.06);  border-color: var(--green);  color: #15803d; }
.alert-danger  { background: rgba(220,38,38,0.06);  border-color: var(--red);    color: #b91c1c; }
.alert-warning { background: rgba(217,119,6,0.06);  border-color: var(--orange); color: #b45309; }
.alert-info    { background: var(--sev-none-bg);    border-color: var(--sev-none); color: #4b5563; }
.alert p { color: inherit; margin: 0; font-size: inherit; }
.alert strong { font-weight: 600; }

/* ============================================================
   Code
   ============================================================ */
.code-block {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow-x: auto;
  margin: var(--space-md) 0;
}
html.dark .code-block { background: #0d1117; }

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
}

.code-lang { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-3); }
pre { padding: 1.25rem; overflow-x: auto; margin: 0; }
code { font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.7; color: var(--text-2); }
html.dark code { color: #c9d1d9; }
pre code { font-size: 0.82rem; }

/* ============================================================
   Dividers & utility
   ============================================================ */
.divider { height: 1px; background: var(--border); }

.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-3) !important; }
.text-mono    { font-family: var(--font-mono); font-size: 0.82em; }
.text-green   { color: var(--green) !important; }
.text-red     { color: var(--red) !important; }
.text-orange  { color: var(--orange) !important; }

.mb-0   { margin-bottom: 0; }
.mb-sm  { margin-bottom: var(--space-sm); }
.mb-md  { margin-bottom: var(--space-md); }
.mb-lg  { margin-bottom: var(--space-lg); }
.mb-xl  { margin-bottom: var(--space-xl); }
.mt-auto { margin-top: auto; }

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.flex-gap { display: flex; align-items: center; gap: var(--space-md); flex-wrap: wrap; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ============================================================
   Empty state
   ============================================================ */
.empty-state { text-align: center; padding: 4rem 2rem; }
.empty-state h3 { color: var(--text-3); font-size: 1.1rem; margin-bottom: 0.5rem; }
.empty-state p  { font-size: 0.875rem; color: var(--text-3); max-width: 320px; margin: 0 auto; }

/* ============================================================
   Footer (landing pages)
   ============================================================ */
.footer {
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-3);
}
.footer-inner a { color: var(--text-3); transition: color var(--t-fast); }
.footer-inner a:hover { color: var(--text-2); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  :root { --nav-h: 58px; }
  .container { padding: 0 1.25rem; }
  .section { padding: var(--space-3xl) 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .grid-4 { grid-template-columns: 1fr; }
}
