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

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

:root {
  --font-sans: 'Onest', system-ui, sans-serif;
  --font-mono: 'DM Mono', 'Fira Code', monospace;

  --gray-0:   #FFFFFF;
  --gray-50:  #FAFAF9;
  --gray-100: #F3F2F0;
  --gray-200: #E5E4E1;
  --gray-300: #C4C1BA;
  --gray-400: #8A8780;
  --gray-500: #6B6865;
  --gray-600: #4A4844;
  --gray-700: #2A2926;
  --gray-800: #1A1918;
  --gray-900: #0E0D0C;

  --indigo-50:  #EEF1FD;
  --indigo-100: #D5DAFB;
  --indigo-200: #A4B5F3;
  --indigo-300: #7E96EE;
  --indigo-400: #5B74ED;
  --indigo-500: #4560E0;
  --indigo-600: #3452D4;
  --indigo-700: #2440B8;
  --indigo-800: #1C35A8;
  --indigo-900: #0E1E72;

  --amber-50:  #FEF5E7;
  --amber-100: #FDE3AC;
  --amber-200: #FBD07A;
  --amber-400: #F5A623;
  --amber-600: #C47E0A;

  --color-success:     #16A34A;
  --color-success-bg:  #F0FDF4;
  --color-success-text:#15803D;
  --color-error:       #DC2626;
  --color-error-bg:    #FEF2F2;
  --color-error-text:  #B91C1C;
  --color-warning:     #D97706;
  --color-warning-bg:  #FFFBEB;
  --color-info:        #2563EB;
  --color-info-bg:     #EFF6FF;

  --bg-page:    #FFFFFF;
  --bg-surface: #FFFFFF;
  --bg-subtle:  #FAFAF9;
  --bg-muted:   #F3F2F0;
  --bg-hover:   rgba(0, 0, 0, 0.025);
  --bg-active:  rgba(0, 0, 0, 0.04);

  --text-primary:   #1A1918;
  --text-secondary: #4A4844;
  --text-tertiary:  #6B6865;
  --text-hint:      #8A8780;
  --text-inverse:   #FFFFFF;
  --text-link:      #3452D4;

  --border-default:  #E5E4E1;
  --border-emphasis: #C4C1BA;
  --border-focus:    #5B74ED;

  --brand-primary: #5B74ED;
  --brand-accent:  #F5A623;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-1: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px -1px rgba(0,0,0,0.05);
  --shadow-2: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-3: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --shadow-4: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --shadow-focus: 0 0 0 3px rgba(91, 116, 237, 0.2);

  --space-0: 0; --space-1: 4px; --space-2: 8px; --space-3: 12px;
  --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --space-10: 40px; --space-12: 48px; --space-16: 64px; --space-20: 80px;

  --radius-xs: 4px; --radius-sm: 6px; --radius-md: 8px;
  --radius-lg: 12px; --radius-xl: 16px; --radius-2xl: 24px;
  --radius-full: 9999px;

  --transition-fast: 100ms ease;
  --transition-base: 150ms ease;
  --transition-slow: 250ms ease;

  --text-xs: 11px; --text-sm: 13px; --text-base: 14px;
  --text-md: 15px; --text-lg: 17px; --text-xl: 20px;
  --text-2xl: 26px; --text-3xl: 34px;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  font-size: var(--text-base);
}

h1 { font-size: var(--text-2xl); font-weight: 600; letter-spacing: -0.03em; line-height: 1.2; }
h2 { font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.02em; line-height: 1.3; }
h3 { font-size: var(--text-lg); font-weight: 600; }
p { color: var(--text-secondary); line-height: 1.6; }

a { color: var(--text-link); text-decoration: none; }
a:hover { color: var(--indigo-700); }

/* ── Buttons ────────────────────────────────────────── */
button, .btn {
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  border-radius: var(--radius-md);
  padding: 0 16px;
  height: 36px;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-base);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--indigo-600);
  color: var(--text-inverse);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-primary:hover:not(:disabled) { background: var(--indigo-700); color: var(--text-inverse); }
.btn-primary:focus-visible { box-shadow: var(--shadow-focus); }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-subtle); color: var(--text-primary); }

.btn-danger { background: transparent; color: var(--color-error); border: 1px solid var(--border-default); }
.btn-danger:hover:not(:disabled) { background: var(--color-error-bg); border-color: var(--color-error); }

.btn-ghost { background: transparent; color: var(--text-tertiary); padding: 0 10px; border: none; box-shadow: none; }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }

.btn-sm { height: 32px; padding: 0 12px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-lg { height: 44px; padding: 0 24px; font-size: var(--text-md); }
.btn-icon { background: none; padding: 0; width: 32px; height: 32px; color: var(--text-hint); border-radius: var(--radius-sm); border: none; box-shadow: none; }
.btn-icon:hover { color: var(--text-primary); background: var(--bg-active); }

/* ── Inputs ─────────────────────────────────────────── */
input, textarea, select {
  font-family: var(--font-sans);
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 36px;
  font-size: var(--text-base);
  width: 100%;
  transition: all var(--transition-fast);
  outline: none;
  box-shadow: var(--shadow-xs);
}
input:hover, textarea:hover, select:hover { border-color: var(--border-emphasis); }
input:focus, textarea:focus, select:focus { border-color: var(--border-focus); box-shadow: var(--shadow-focus); }
input::placeholder, textarea::placeholder { color: var(--text-hint); }
textarea { resize: vertical; min-height: 80px; padding: 8px 12px; height: auto; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238A8780' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--transition-base);
}
.card:hover { border-color: var(--border-emphasis); box-shadow: var(--shadow-2); }

/* ── Badges ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.badge-live { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-live::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--color-success); }
.badge-draft { background: var(--bg-muted); color: var(--text-hint); }
.badge-brand { background: var(--indigo-50); color: var(--indigo-800); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-error { background: var(--color-error-bg); color: var(--color-error-text); }

/* ── Toast ──────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--gray-800); color: var(--text-inverse);
  padding: 10px 20px; border-radius: var(--radius-lg);
  font-size: var(--text-sm); z-index: 600;
  box-shadow: var(--shadow-4);
  animation: toastIn 0.2s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.status-dot-active { background: var(--color-success); }
.status-dot-disabled { background: var(--color-error); }

.hidden { display: none !important; }
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; align-items: center; }
.items-center { align-items: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-center { text-align: center; }
.text-mono { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.gap-md { gap: var(--space-4); }
.gap-sm { gap: var(--space-2); }
.mt-sm { margin-top: var(--space-2); }
.mt-md { margin-top: var(--space-4); }
.mt-lg { margin-top: var(--space-6); }
.text-dim { color: var(--text-tertiary); }
.caption { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em; color: var(--text-hint); text-transform: uppercase; }
