/* Crant AI Studio - Design System
 * Based on ui-design-spec.md - Linear/Raycast inspired design
 * Dark-first, glass morphism, multi-layer shadows, large border radii
 */

/* ============================================
   Light Mode
   ============================================ */
:root {
  --background: #ffffff;
  --foreground: #222222;
  --card: #ffffff;
  --card-foreground: #222222;
  --popover: #ffffff;
  --popover-foreground: #222222;
  --primary: #181e25;
  --primary-foreground: #ffffff;
  --secondary: #f5f5f5;
  --secondary-foreground: #333333;
  --muted: #f5f5f5;
  --muted-foreground: #45515e;
  --accent: #f5f5f5;
  --accent-foreground: #18181b;
  --destructive: #ef4444;
  --border: #e5e5e5;
  --input: #e5e5e5;
  --ring: #3b82f6;
  --radius: 0.8125rem;

  /* Brand colors */
  --brand-blue: #1456f0;
  --brand-blue-bg: #edf4ff;

  /* Shadows */
  --shadow-card: 0 8px 24px rgba(24,40,72,0.07);
  --shadow-button: 0 4px 10px rgba(24,30,37,0.12);
  --shadow-button-outline: 0 4px 6px rgba(0,0,0,0.04);
  --shadow-input: 0 2px 4px rgba(0,0,0,0.03);
  --shadow-dialog: 0 32px 110px -38px rgba(15,23,42,0.45);
  --shadow-nav: 0 0 22.576px rgba(44,74,116,0.09);
  --shadow-dropdown: 0 20px 60px -30px rgba(15,23,42,0.35);
  --shadow-login: 0 28px 80px rgba(15,23,42,0.12), 0 10px 28px rgba(44,30,116,0.08);

  /* Background patterns */
  --bg-base: #fff9fb;
  --bg-gradient-start: #fff8fa;
  --bg-gradient-end: #f4f8ff;
  --dot-color: rgba(20,86,240,0.12);
}

/* ============================================
   Dark Mode
   ============================================ */
.dark {
  --background: #111111;
  --foreground: #e5e5e5;
  --card: #1a1a1a;
  --card-foreground: #e5e5e5;
  --popover: #1a1a1a;
  --popover-foreground: #e5e5e5;
  --primary: #e5e5e5;
  --primary-foreground: #111111;
  --secondary: #262626;
  --secondary-foreground: #e5e5e5;
  --muted: #262626;
  --muted-foreground: #a3a3a3;
  --accent: #262626;
  --accent-foreground: #e5e5e5;
  --destructive: #ef4444;
  --border: rgba(255,255,255,0.08);
  --input: rgba(255,255,255,0.1);
  --ring: #6b7280;

  /* Shadows - reduced in dark mode */
  --shadow-card: 0 8px 24px rgba(0,0,0,0.3);
  --shadow-button: 0 4px 10px rgba(0,0,0,0.4);
  --shadow-button-outline: 0 4px 6px rgba(0,0,0,0.2);
  --shadow-input: 0 2px 4px rgba(0,0,0,0.2);
  --shadow-dialog: 0 32px 110px -38px rgba(0,0,0,0.6);
  --shadow-nav: 0 0 22.576px rgba(0,0,0,0.3);
  --shadow-dropdown: 0 20px 60px -30px rgba(0,0,0,0.5);
  --shadow-login: 0 30px 90px rgba(2,6,23,0.58), 0 12px 32px rgba(2,6,23,0.32);

  /* Background patterns - dark */
  --bg-base: #111111;
  --bg-gradient-start: #0f0f0f;
  --bg-gradient-end: #141414;
  --dot-color: rgba(255,255,255,0.05);
}

/* ============================================
   Global Reset & Base
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--foreground);
  background-color: var(--bg-base);
  background-image:
    radial-gradient(var(--dot-color) 1px, transparent 1px),
    linear-gradient(145deg, var(--bg-gradient-start) 0%, var(--background) 48%, var(--bg-gradient-end) 100%);
  background-position: 0 0, center;
  background-size: 12px 12px, cover;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--muted-foreground);
  border-radius: 9999px;
  opacity: 0.3;
}

::-webkit-scrollbar-thumb:hover {
  opacity: 0.5;
}

/* ============================================
   Selection
   ============================================ */
::selection {
  background-color: var(--primary);
  color: var(--primary-foreground);
}

/* ============================================
   Focus
   ============================================ */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--foreground);
}

h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

a {
  color: var(--brand-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code, pre {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
}

code {
  background: var(--muted);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
}

pre {
  background: var(--muted);
  padding: 16px;
  border-radius: 12px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  outline: none;
  text-decoration: none;
  flex-shrink: 0;
}

.btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-button);
  padding: 8px 16px;
  height: 36px;
}

.btn-primary:hover {
  background: #2a323d;
}

.dark .btn-primary:hover {
  background: #2a2a2a;
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  box-shadow: none;
  padding: 8px 16px;
  height: 36px;
}

.btn-secondary:hover {
  background: #e8e8e8;
}

.dark .btn-secondary:hover {
  background: #333333;
}

.btn-outline {
  background: var(--background);
  color: var(--foreground);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-button-outline);
  padding: 8px 16px;
  height: 36px;
}

.btn-outline:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
  padding: 8px 16px;
  height: 36px;
}

.btn-ghost:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.btn-danger {
  background: var(--destructive);
  color: white;
  padding: 8px 16px;
  height: 36px;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-link {
  background: transparent;
  color: var(--primary);
  padding: 8px 16px;
  height: 36px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-icon {
  background: transparent;
  color: var(--muted-foreground);
  padding: 8px;
  width: 36px;
  height: 36px;
  border-radius: 9999px;
}

.btn-icon:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.btn-sm {
  height: 32px;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 11px;
}

.btn-lg {
  height: 40px;
  padding: 10px 24px;
  font-size: 15px;
}

/* ============================================
   Inputs
   ============================================ */
.input {
  display: flex;
  height: 40px;
  width: 100%;
  min-width: 0;
  border-radius: 13px;
  border: 1px solid var(--input);
  background: var(--background);
  padding: 8px 12px;
  font-size: 14px;
  color: var(--foreground);
  box-shadow: var(--shadow-input);
  outline: none;
  transition: color 0.15s, box-shadow 0.15s;
}

.input::placeholder {
  color: var(--muted-foreground);
}

.input::selection {
  background: var(--primary);
  color: var(--primary-foreground);
}

.input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   Textarea
   ============================================ */
.textarea {
  display: flex;
  min-height: 120px;
  width: 100%;
  border-radius: 13px;
  border: 1px solid var(--input);
  background: var(--background);
  padding: 12px;
  font-size: 14px;
  color: var(--foreground);
  box-shadow: var(--shadow-input);
  outline: none;
  resize: vertical;
  font-family: inherit;
  transition: color 0.15s, box-shadow 0.15s;
}

.textarea::placeholder {
  color: var(--muted-foreground);
}

.textarea:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

/* ============================================
   Select
   ============================================ */
.select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 40px;
  width: 100%;
  border-radius: 13px;
  border: 1px solid var(--input);
  background: var(--background);
  padding: 8px 12px;
  font-size: 14px;
  color: var(--foreground);
  box-shadow: var(--shadow-input);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2345515e' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.select:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

/* ============================================
   Checkbox
   ============================================ */
.checkbox {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--input);
  background: var(--background);
  cursor: pointer;
  accent-color: var(--brand-blue);
  transition: all 0.15s ease;
}

.checkbox:focus {
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

.checkbox:checked {
  border-color: var(--brand-blue);
  background: var(--brand-blue);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px;
}

/* ============================================
   Range Input
   ============================================ */
.range-input {
  width: 100%;
  height: 6px;
  border-radius: 9999px;
  background: var(--muted);
  outline: none;
  cursor: pointer;
  accent-color: var(--brand-blue);
}

.range-input::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--background);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.range-input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--background);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* ============================================
   Modifier Classes
   ============================================ */
.input-mono,
.textarea-mono {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 13px;
}

/* ============================================
   Card
   ============================================ */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 24px;
}

.card-title {
  font-weight: 600;
  font-size: 16px;
  line-height: 1;
}

.card-description {
  font-size: 14px;
  color: var(--muted-foreground);
  line-height: 1.5;
}

.card-content {
  padding: 24px;
  padding-top: 0;
}

.card-footer {
  display: flex;
  align-items: center;
  padding: 24px;
  padding-top: 0;
}

/* ============================================
   Badge
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  transition: background-color, color, border-color;
  border: 1px solid transparent;
}

.badge-default {
  background: var(--brand-blue-bg);
  color: var(--brand-blue);
}

.dark .badge-default {
  background: rgba(20,86,240,0.2);
  color: #60a5fa;
}

.badge-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.badge-outline {
  background: transparent;
  color: var(--foreground);
  border: 1px solid var(--border);
}

.badge-success {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.dark .badge-success {
  background: rgba(16,185,129,0.15);
  color: #6ee7b7;
  border-color: rgba(16,185,129,0.3);
}

.badge-warning {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.dark .badge-warning {
  background: rgba(245,158,11,0.15);
  color: #fcd34d;
  border-color: rgba(245,158,11,0.3);
}

.badge-danger {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
}

.dark .badge-danger {
  background: rgba(244,63,94,0.15);
  color: #fda4af;
  border-color: rgba(244,63,94,0.3);
}

.badge-info {
  background: #f0f9ff;
  color: var(--brand-blue);
  border: 1px solid #bae6fd;
}

.dark .badge-info {
  background: rgba(14,165,233,0.15);
  color: #7dd3fc;
  border-color: rgba(14,165,233,0.3);
}

.badge-violet {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.dark .badge-violet {
  background: rgba(139,92,246,0.15);
  color: #c4b5fd;
  border-color: rgba(139,92,246,0.3);
}

/* ============================================
   Dialog / Modal
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(2px);
}

.modal.active {
  display: flex;
}

.modal-content {
  position: relative;
  width: min(92vw, 560px);
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--background);
  padding: 24px;
  box-shadow: var(--shadow-dialog);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 600;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: transparent;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  opacity: 0.7;
  font-size: 18px;
}

.modal-close:hover {
  opacity: 1;
  background: var(--accent);
}

/* ============================================
   Field System
   ============================================ */
.field {
  display: grid;
  gap: 8px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground);
}

.field-description {
  font-size: 12px;
  line-height: 20px;
  color: var(--muted-foreground);
}

.modal-body {
  margin-bottom: 0;
}

.modal-footer {
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

@media (min-width: 640px) {
  .modal-footer {
    flex-direction: row;
    justify-content: flex-end;
  }
}

/* Wide modal */
.modal-wide {
  max-width: 800px;
}

/* ============================================
   Table
   ============================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.5;
}

.table th {
  height: 40px;
  padding: 0 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  background: rgba(245,245,245,0.55);
  border-bottom: 1px solid var(--border);
}

.dark .table th {
  background: rgba(38,38,38,0.55);
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: rgba(245,245,245,0.5);
}

.dark .table tr:hover td {
  background: rgba(38,38,38,0.5);
}

/* ============================================
   Navigation (TopNav)
   ============================================ */
.topnav {
  position: sticky;
  top: 12px;
  z-index: 40;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.9);
  box-shadow: var(--shadow-nav);
  backdrop-filter: blur(12px);
}

.dark .topnav {
  background: rgba(26,26,26,0.9);
}

.topnav-inner {
  display: flex;
  min-height: 56px;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px;
}

@media (min-width: 1024px) {
  .topnav-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 16px;
  }
}

.topnav-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
  text-decoration: none;
}

.topnav-brand img {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.topnav-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 4px;
  scrollbar-width: none;
}

.topnav-nav::-webkit-scrollbar {
  display: none;
}

.topnav-link {
  position: relative;
  flex-shrink: 0;
  white-space: nowrap;
  border-radius: 9999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: all 0.15s;
}

.topnav-link:hover {
  background: var(--accent);
  color: var(--accent-foreground);
  text-decoration: none;
}

.topnav-link.active {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.topnav-tag {
  border-radius: 9999px;
  background: var(--muted);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted-foreground);
}

.topnav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
  width: 260px;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-title {
  padding: 8px 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 8px 20px;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.nav-item.active {
  background: rgba(20,86,240,0.1);
  color: var(--brand-blue);
}

.nav-item svg,
.nav-item .sf-icon {
  margin-right: 10px;
  opacity: 0.7;
}

.nav-item.active svg,
.nav-item.active .sf-icon {
  opacity: 1;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  background: var(--muted);
}

/* ============================================
   Form Groups
   ============================================ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground);
  margin-bottom: 6px;
}

.form-group .help-text {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 4px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

.toggle-form {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted-foreground);
}

.toggle-form button {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  margin-left: 4px;
}

.toggle-form button:hover {
  text-decoration: underline;
}

/* ============================================
   Layout
   ============================================ */
.app-container {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 24px 32px;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.content-header h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* ============================================
   Stats Grid
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.stat-card .stat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.stat-card .stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-foreground);
}

.stat-card .stat-icon {
  color: var(--muted-foreground);
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

/* ============================================
   Content Sections
   ============================================ */
.content-section {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}

.content-section h2 {
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* ============================================
   Model Cards
   ============================================ */
.models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.model-card {
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  transition: all 0.15s;
}

.model-card:hover {
  border-color: var(--brand-blue);
}

.model-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.model-card p {
  font-size: 14px;
  color: var(--muted-foreground);
  margin-bottom: 12px;
  line-height: 1.5;
}

.model-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.price {
  font-size: 12px;
  color: var(--brand-blue);
  font-weight: 600;
}

.reference-price {
  font-size: 11px;
  color: var(--muted-foreground);
  text-decoration: line-through;
  opacity: 0.7;
  display: block;
  margin-top: 2px;
}

.model-id {
  font-family: "SF Mono", monospace;
  font-size: 12px;
  color: var(--muted-foreground);
}

.model-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.series-badge {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--brand-blue-bg);
  color: var(--brand-blue);
  border-radius: 6px;
  font-weight: 500;
}

/* ============================================
   Model Filters
   ============================================ */
.model-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 0 16px 0 40px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--foreground);
  font-size: 14px;
  transition: all 0.15s;
}

.search-input:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(20, 86, 240, 0.1);
}

.search-input::placeholder {
  color: var(--muted-foreground);
}

.filter-select {
  height: 40px;
  padding: 0 32px 0 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--foreground);
  font-size: 14px;
  cursor: pointer;
  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='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: all 0.15s;
}

.filter-select:focus {
  outline: none;
  border-color: var(--brand-blue);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.model-count-badge {
  font-size: 13px;
  color: var(--muted-foreground);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-state p {
  font-size: 15px;
  font-weight: 500;
  margin-top: 16px;
  color: var(--foreground);
}

.empty-state span {
  font-size: 13px;
  color: var(--muted-foreground);
  margin-top: 4px;
}

/* ============================================
   API Key Cards
   ============================================ */
.api-key-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
  transition: all 0.15s;
}

.api-key-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--brand-blue);
  border-radius: 16px 0 0 16px;
}

.api-key-card:hover {
  border-color: var(--brand-blue);
}

.api-key-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.api-key-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.api-key-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--brand-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.api-key-name {
  font-size: 16px;
  font-weight: 600;
}

.api-key-status {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-weight: 600;
}

.api-key-status.active {
  background: #ecfdf5;
  color: #047857;
}

.api-key-status.expiring {
  background: #fffbeb;
  color: #b45309;
}

.api-key-status.expired {
  background: #fff1f2;
  color: #be123c;
}

.api-key-prefix {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--muted);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.api-key-prefix code {
  font-family: "SF Mono", monospace;
  font-size: 13px;
  color: var(--brand-blue);
  letter-spacing: 0.5px;
  flex: 1;
}

.copy-btn {
  padding: 4px 8px;
  background: none;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.copy-btn:hover {
  background: var(--accent);
  color: var(--brand-blue);
}

.copy-btn.copied {
  color: #10b981;
}

.api-key-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.api-key-stat {
  text-align: center;
  padding: 10px 8px;
  background: var(--muted);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.api-key-stat-value {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.api-key-stat-label {
  font-size: 11px;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.api-key-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.api-key-time {
  font-size: 12px;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  gap: 4px;
}

.api-key-actions {
  display: flex;
  gap: 8px;
}

/* ============================================
   Quick Start
   ============================================ */
.quick-start {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.quick-start-item {
  padding: 20px;
  background: var(--muted);
  border-radius: 16px;
}

.quick-start-item h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.quick-start-item p {
  font-size: 14px;
  color: var(--muted-foreground);
  line-height: 1.5;
}

/* ============================================
   Alert
   ============================================ */
.alert {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-warning {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.3);
  color: #b45309;
}

/* ============================================
   Error Message
   ============================================ */
.error-message {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--destructive);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

.error-message.show {
  display: block;
}

/* ============================================
   Docs Table
   ============================================ */
.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.docs-table th,
.docs-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.docs-table th {
  font-weight: 600;
  color: var(--muted-foreground);
}

/* ============================================
   Theme Toggle
   ============================================ */
.theme-toggle {
  position: relative;
}

.theme-toggle .btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 9999px;
}

/* ============================================
   Usage Overview
   ============================================ */
.usage-overview {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  padding: 20px;
  background: var(--muted);
  border-radius: 16px;
  border: 1px solid var(--border);
}

.usage-overview-item {
  display: flex;
  flex-direction: column;
  flex: 1;
  text-align: center;
}

.usage-overview-label {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-bottom: 4px;
}

.usage-overview-value {
  font-size: 20px;
  font-weight: 600;
}

/* ============================================
   Dropdown
   ============================================ */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-dropdown);
  z-index: 1000;
  overflow: hidden;
  padding: 4px;
}

.dropdown-menu.active {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--foreground);
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
  text-align: left;
  transition: background 0.1s;
}

.dropdown-item:hover {
  background: var(--accent);
}

.dropdown-item svg {
  margin-right: 8px;
  color: var(--muted-foreground);
  flex-shrink: 0;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1068px) {
  .content-header h1 {
    font-size: 20px;
  }
}

@media (max-width: 834px) {
  .sidebar {
    width: 70px;
  }

  .sidebar-header h2,
  .nav-item span,
  .sidebar-footer .user-info span {
    display: none;
  }

  .sidebar-header {
    padding: 12px;
    justify-content: center;
  }

  .nav-item {
    justify-content: center;
    padding: 12px;
  }

  .nav-item svg,
  .nav-item .sf-icon {
    margin-right: 0;
  }

  .sidebar-footer {
    justify-content: center;
  }

  .main-content {
    margin-left: 70px;
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .models-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .content-header h1 {
    font-size: 18px;
  }

  .main-content {
    padding: 12px;
  }

  .content-header {
    margin-bottom: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page.active {
  animation: fadeIn 0.2s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

/* ============================================
   Hide Scrollbar Utility
   ============================================ */
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* ============================================
   Custom Dialog (replaces native alert/confirm)
   ============================================ */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.dialog-overlay.dialog-open {
  opacity: 1;
  pointer-events: auto;
}

.dialog-panel {
  position: relative;
  width: min(92vw, 420px);
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--background);
  padding: 28px 28px 24px;
  box-shadow: var(--shadow-dialog);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transform: scale(0.95) translateY(8px);
  opacity: 0;
  transition: all 0.2s ease;
}

.dialog-panel.dialog-open {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.dialog-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--foreground);
  line-height: 1.4;
}

.dialog-message {
  font-size: 14px;
  color: var(--muted-foreground);
  line-height: 1.6;
  word-break: break-word;
}

.dialog-message strong {
  color: var(--foreground);
  font-weight: 600;
}

.dialog-actions {
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  margin-top: 8px;
}

@media (min-width: 640px) {
  .dialog-actions {
    flex-direction: row;
    justify-content: flex-end;
  }
}

.dialog-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 20px;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none;
  flex: 1;
  min-width: 0;
}

@media (min-width: 640px) {
  .dialog-btn {
    flex: none;
    min-width: 80px;
  }
}

.dialog-btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-button);
}

.dialog-btn-primary:hover {
  background: #2a323d;
}

.dark .dialog-btn-primary:hover {
  background: #2a2a2a;
}

.dialog-btn-danger {
  background: var(--destructive);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(239,68,68,0.25);
}

.dialog-btn-danger:hover {
  background: #dc2626;
}

.dialog-btn-cancel {
  background: var(--secondary);
  color: var(--secondary-foreground);
  box-shadow: none;
}

.dialog-btn-cancel:hover {
  background: #e8e8e8;
}

.dark .dialog-btn-cancel:hover {
  background: #333333;
}
