:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --bg-app: #f8fafc;
  --bg-sidebar: #0f172a;
  --bg-surface: #ffffff;
  --text-main: #334155;
  --text-muted: #64748b;
  --text-inverse: #f8fafc;
  --border: #e2e8f0;
  --radius: 8px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  background: var(--bg-app);
  color: var(--text-main);
  font-size: 14px;
}

.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-logo {
  width: 24px;
  height: 24px;
  color: var(--primary);
}

.nav-links {
  padding: 15px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: #94a3b8;
  text-decoration: none;
  transition: 0.2s;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border-right: 3px solid var(--primary);
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

/* Main Area */
.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.main-header {
  padding: 30px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.page-title {
  font-size: 1.5rem;
  color: #0f172a;
  margin-bottom: 4px;
}

.page-subtitle {
  color: var(--text-muted);
}

.content-wrapper {
  padding: 40px;
  flex: 1;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: 0.2s;
  text-decoration: none;
  font-size: 14px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-main);
}

.btn-outline:hover {
  background: #f1f5f9;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.btn-icon:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

/* Table */
.table-container {
  background: var(--bg-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th,
.data-table td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: #f8fafc;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

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

.data-table tbody tr:hover {
  background: #f8fafc;
}

/* Badges */
.badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-neutral {
  background: #f1f5f9;
  color: #475569;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 40;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 5vh;
  overflow-y: auto;
}

.modal {
  position: relative;
  background: var(--bg-surface);
  width: 100%;
  max-width: 600px;
  border-radius: var(--radius);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  z-index: 50;
  display: flex;
  flex-direction: column;
  margin-bottom: 5vh;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 24px;
  flex: 1;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #f8fafc;
  border-radius: 0 0 var(--radius) var(--radius);
}

.hidden {
  display: none !important;
}

/* Forms */
.form-section {
  margin-bottom: 24px;
}

.form-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-weight: 500;
  color: #0f172a;
  font-size: 13px;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="password"],
.form-group select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.help-text {
  font-size: 12px;
  color: var(--text-muted);
}

.input-prefix-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.input-prefix-group .prefix {
  padding: 8px 12px;
  background: #f1f5f9;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  font-size: 14px;
}

.input-prefix-group input {
  border: none !important;
  border-radius: 0 !important;
  flex: 1;
}

.input-prefix-group input:focus {
  box-shadow: none !important;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

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

.flex-between label {
  margin-bottom: 0;
}

/* Utilities */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

.py-4 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.btn-danger {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}

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

/* API Key Reveal Banner */
.apikey-reveal {
  margin-bottom: 20px;
}

.apikey-reveal-inner {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 16px 20px;
}

.apikey-reveal-inner strong {
  display: block;
  margin-bottom: 10px;
  color: #166534;
}

.apikey-reveal-value {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid #d1fae5;
}

.apikey-reveal-value code {
  flex: 1;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 14px;
  word-break: break-all;
  color: #0f172a;
}

/* API Key Usage Hint */
.apikey-usage-hint {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.apikey-usage-hint p {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.apikey-usage-hint code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.apikey-usage-hint pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  overflow-x: auto;
  font-family: 'SF Mono', 'Fira Code', monospace;
}