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

/* ── Design Tokens ── */
:root {
  --primary:          #4f46e5;
  --primary-hover:    #4338ca;
  --primary-light:    #eef2ff;
  --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --bg:               #f8fafc;
  --surface:          #ffffff;
  --surface-2:        #f1f5f9;
  --text:             #1e293b;
  --text-muted:       #64748b;
  --text-light:       #94a3b8;
  --border:           #e2e8f0;
  --border-focus:     #6366f1;
  --success:          #059669;
  --success-bg:       #d1fae5;
  --success-border:   #a7f3d0;
  --danger:           #dc2626;
  --danger-bg:        #fee2e2;
  --danger-border:    #fca5a5;
  --warning:          #d97706;
  --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 24px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
  --radius-sm:        6px;
  --radius:           10px;
  --radius-lg:        14px;
  --radius-xl:        20px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Typography ── */
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1rem;    font-weight: 600; line-height: 1.4; }
p  { color: var(--text-muted); }
small { font-size: 0.8125rem; color: var(--text-muted); }

/* ── Auth Layout (login / register / confirm) ── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
}
.auth-brand {
  width: 420px;
  flex-shrink: 0;
  background: var(--primary-gradient);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px 48px;
  color: #fff;
}
.auth-brand .brand-logo {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}
.auth-brand .brand-tagline {
  font-size: 1rem;
  opacity: 0.85;
  margin-bottom: 48px;
  line-height: 1.5;
}
.auth-brand .brand-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-brand .brand-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9375rem;
  opacity: 0.9;
}
.auth-brand .brand-features li::before {
  content: '';
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='white'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-size: 12px;
  background-repeat: no-repeat;
  background-position: center;
}
.auth-form-side {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
}
.auth-card .auth-title {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.auth-card .auth-subtitle {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin-bottom: 32px;
}
@media (max-width: 768px) {
  .auth-brand { display: none; }
  .auth-form-side { padding: 32px 20px; }
}

/* ── App Layout (dashboard) ── */
.app-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.app-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--primary-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
}
.app-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 32px;
}
@media (max-width: 768px) {
  .app-header { padding: 0 16px; }
  .app-main   { padding: 20px 16px; }
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { color: var(--text); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,0.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
  box-shadow: 0 4px 12px rgba(79,70,229,0.45);
  text-decoration: none;
  color: #fff;
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--border);
  text-decoration: none;
  color: var(--text);
}
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  text-decoration: none;
}
.btn-success {
  background: linear-gradient(135deg, #059669 0%, #0d9488 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5,150,105,0.35);
}
.btn-success:hover {
  background: linear-gradient(135deg, #047857 0%, #0f766e 100%);
  text-decoration: none;
  color: #fff;
}
.btn-sm { padding: 6px 14px; font-size: 0.875rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Forms ── */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.form-control::placeholder { color: var(--text-light); }
textarea.form-control {
  min-height: 110px;
  resize: vertical;
  line-height: 1.5;
}
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.form-hint { margin-top: 5px; font-size: 0.8125rem; color: var(--text-muted); }
input[type="file"].form-control { padding: 8px 14px; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}
.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}
.alert-info {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #c7d2fe;
}

/* ── Nav Tabs ── */
.nav-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab {
  padding: 12px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Dashboard Grid ── */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 6px;
}
.stat-desc { font-size: 0.875rem; color: var(--text-muted); }

/* ── Usage Bar ── */
.usage-bar {
  background: var(--border);
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 6px;
}
.usage-fill {
  height: 100%;
  background: linear-gradient(90deg, #059669, #0d9488);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.usage-fill.warn { background: linear-gradient(90deg, #d97706, #f59e0b); }
.usage-fill.danger { background: linear-gradient(90deg, #dc2626, #ef4444); }
.usage-text { font-size: 0.8125rem; color: var(--text-muted); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--surface-2); }
th {
  padding: 11px 16px;
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
td {
  padding: 13px 16px;
  font-size: 0.9375rem;
  color: var(--text);
  border-top: 1px solid var(--border);
}
tbody tr:hover { background: var(--bg); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}
.badge-green  { background: var(--success-bg);  color: var(--success); }
.badge-red    { background: var(--danger-bg);    color: var(--danger); }
.badge-purple { background: var(--primary-light); color: var(--primary); }
.badge-gray   { background: var(--surface-2);   color: var(--text-muted); border: 1px solid var(--border); }

/* ── Call Items ── */
.call-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.call-item:last-child { border-bottom: none; }
.call-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.call-meta strong { color: var(--text); font-size: 0.9375rem; }
.call-meta span   { color: var(--text-muted); font-size: 0.875rem; }
.call-summary { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 8px; }
details > summary {
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--primary);
  user-select: none;
  list-style: none;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '▶  '; font-size: 0.7em; }
details[open] > summary::before { content: '▼  '; }
details pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 10px;
  font-size: 0.8125rem;
  white-space: pre-wrap;
  overflow-x: auto;
  color: var(--text);
  line-height: 1.55;
}

/* ── Wizard Steps ── */
.wizard-steps {
  display: flex;
  align-items: center;
  margin-bottom: 36px;
}
.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}
.wizard-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  left: calc(50% + 20px);
  right: calc(-50% + 20px);
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.wizard-step.completed:not(:last-child)::after { background: var(--primary); }
.wizard-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  z-index: 1;
  transition: all 0.2s;
  background: var(--border);
  color: var(--text-muted);
  border: 2px solid var(--border);
}
.wizard-step.active .wizard-step-num {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(99,102,241,0.15);
}
.wizard-step.completed .wizard-step-num {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.wizard-step.completed .wizard-step-num::before { content: '✓'; }
.wizard-step-label {
  margin-top: 7px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
}
.wizard-step.active .wizard-step-label { color: var(--primary); }
.wizard-step.completed .wizard-step-label { color: var(--text); }

/* ── Param Row (Tool Wizard) ── */
.param-row {
  display: grid;
  grid-template-columns: 1fr 130px 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.param-row .check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
}
.param-row input[type="checkbox"] { accent-color: var(--primary); }
@media (max-width: 640px) {
  .param-row { grid-template-columns: 1fr 1fr; }
}

/* ── Preview Box ── */
.preview-box {
  background: #1e1e2e;
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
}
.preview-box pre {
  color: #cdd6f4;
  font-size: 0.8125rem;
  line-height: 1.6;
  white-space: pre-wrap;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ── Upgrade Card ── */
.upgrade-card {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  border-radius: var(--radius-lg);
  padding: 28px;
  color: #fff;
  margin-top: 24px;
}
.upgrade-card h3 { color: #fff; margin-bottom: 8px; font-size: 1.125rem; }
.upgrade-card p  { color: rgba(255,255,255,0.85); margin-bottom: 16px; }
.upgrade-card ul {
  list-style: none;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upgrade-card ul li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9375rem;
  color: rgba(255,255,255,0.9);
}
.upgrade-card ul li::before {
  content: '✓';
  width: 20px;
  height: 20px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.btn-white {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  border: none;
  padding: 10px 22px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9375rem;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
}
.btn-white:hover { background: #f0f0ff; text-decoration: none; color: var(--primary-hover); }

/* ── Misc ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}
.text-muted { color: var(--text-muted); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 16px; }
.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 12px; opacity: 0.35; }
.add-form-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 20px;
}
.add-form-panel h3 { margin-bottom: 16px; color: var(--text); }
