/* Modern Minimalist Linear/Vercel-inspired Theme */
:root {
  --bg-color: #000000;
  --surface: #0a0a0a;
  --surface-hover: #141414;
  --surface-raised: #111111;
  --border: #222222;
  --border-hover: #333333;
  
  --text-primary: #ededed;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  
  --accent: #ffffff;
  --accent-fg: #000000;
  --accent-hover: #e5e5e5;
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --info: #3b82f6;
  
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 13px;
  line-height: 1.5;
}

/* Layout */
.app-root {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}
.main-content {
  flex: 1;
  min-width: 0;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Sidebar Components */
.sidebar-brand {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.brand-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: transparent;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.nav-item svg { flex-shrink: 0; opacity: 0.85; }
.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.logout-nav { color: var(--text-tertiary); }
.logout-nav:hover { color: var(--danger); }

.section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.section-header .section-title { margin: 0; }

/* Setup cards */
.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 16px;
  scroll-margin-top: 24px;
}
.card-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 20px;
}
.card-panel .panel-header {
  margin-bottom: 14px;
  align-items: flex-start;
}
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.endpoint-card { display: flex; flex-direction: column; gap: 14px; }
.endpoint-box {
  display: flex;
  align-items: center;
  background: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.endpoint-box code {
  flex: 1;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.endpoint-box .btn-icon {
  margin-right: 4px;
  flex-shrink: 0;
}
.endpoint-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}
.meta-k { color: var(--text-tertiary); font-weight: 500; }
.meta-v { color: var(--text-secondary); }
.import-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.import-actions .btn { align-self: flex-start; }

/* Activity rail (right sticky) */
.activity-rail {
  width: 320px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
  transition: width 0.2s ease;
}
.activity-rail.collapsed {
  width: 44px;
}
.activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 12px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 48px;
}
.activity-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 0;
}
.activity-toggle:hover { background: var(--surface-hover); }
.activity-toggle .chevron {
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: transform 0.2s ease;
}
.activity-rail.collapsed .activity-toggle .chevron {
  transform: rotate(180deg);
}
.activity-title {
  white-space: nowrap;
  overflow: hidden;
}
.activity-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.activity-rail.collapsed .activity-title,
.activity-rail.collapsed .activity-actions,
.activity-rail.collapsed .log-container {
  display: none;
}
.activity-rail.collapsed .activity-header {
  justify-content: center;
  padding: 12px 0;
  border-bottom: none;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  height: 100%;
  min-height: 100vh;
}
.activity-rail.collapsed .activity-toggle {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: none;
  gap: 10px;
  padding: 12px 6px;
  letter-spacing: 0.08em;
}
.activity-rail.collapsed .activity-toggle .chevron {
  transform: rotate(90deg);
}
.activity-rail.collapsed .activity-title {
  display: inline;
  margin-top: 4px;
}




/* Inputs & Buttons */
input, select, textarea {
  width: 100%;
  background: var(--bg-color);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--text-secondary);
}
textarea {
  resize: vertical;
  min-height: 80px;
  margin-bottom: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  outline: none;
  white-space: nowrap;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.btn-icon {
  padding: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s;
}
.btn-icon.danger {
  color: var(--danger);
}
.btn-icon.danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}
.btn-icon:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-secondary {
  background: var(--surface-raised);
  border-color: var(--border);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: var(--border);
}
.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--surface-raised);
}
.btn-danger {
  background: var(--danger-bg);
  border-color: transparent;
  color: var(--danger);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--danger);
}
.w-full { width: 100%; }

/* Log Section */
.log-container {
  flex: 1;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  line-height: 1.6;
  padding: 12px 14px 20px;
  min-height: 0;
}
.log-container::-webkit-scrollbar { width: 4px; }
.log-container::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }
.log-line {
  display: flex;
  gap: 6px;
  padding: 3px 0;
  align-items: center;
  white-space: nowrap;
}
.log-msg {
  color: var(--text-secondary);
  word-break: break-all;
  white-space: normal;
}
.log-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, monospace;
  line-height: 1.4;
  flex-shrink: 0;
}
.log-badge.time { color: var(--text-tertiary); background: transparent; font-weight: 400; padding-left: 0; }
.log-badge.green { color: var(--success); }
.log-badge.red { color: var(--danger); }
.log-badge.blue { color: var(--info); }
.log-badge.st-ok { color: var(--success); background: var(--success-bg); }
.log-badge.st-redir { color: var(--warning); background: var(--warning-bg); }
.log-badge.st-err { color: var(--danger); background: var(--danger-bg); }
.log-badge.dur { color: var(--text-tertiary); background: transparent; }
.log-badge.tk { color: var(--info); background: transparent; }
.log-badge.model { color: var(--text-tertiary); background: transparent; font-weight: 400; }
.log-badge.method-get { color: var(--info); background: rgba(59,130,246,0.12); }
.log-badge.method-post { color: var(--success); background: rgba(16,185,129,0.12); }
.log-badge.method-put { color: var(--warning); background: rgba(245,158,11,0.12); }
.log-badge.method-delete { color: var(--danger); background: rgba(239,68,68,0.12); }

/* Main Content Header */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.header-stats {
  display: flex;
  gap: 24px;
}
.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-val {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.header-models {
  display: flex;
  gap: 8px;
}
.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, monospace;
}
.model-chip span {
  font-family: "Inter", sans-serif;
  color: var(--text-tertiary);
  font-size: 11px;
}

/* Panels */
.content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 28px;
  max-width: 100%;
}
.panel {
  display: flex;
  flex-direction: column;
  scroll-margin-top: 24px;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px 0;
  letter-spacing: -0.01em;
}
.panel-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Toolbar & Filters */
.filters {
  display: flex;
  gap: 8px;
  align-items: center;
}
.search-box {
  position: relative;
  width: 200px;
}
.search-box svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
}
.search-box input {
  padding-left: 32px;
  height: 32px;
}
.select-sm {
  height: 32px;
  padding: 4px 28px 4px 12px;
  width: auto;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  transition: border-color 0.2s, background 0.2s;
  cursor: default;
  background: var(--bg-color);
  min-height: 140px;
  display: flex;
  flex-direction: column;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(255,255,255,0.04);
}
.drop-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.drop-zone textarea {
  margin-bottom: 0;
  flex: 1;
  min-height: 96px;
  border-color: transparent;
  background: transparent;
  resize: vertical;
}
.drop-zone textarea:focus {
  border-color: var(--border-hover);
  background: var(--surface);
}

.toolbar-wrapper {
  margin-bottom: 16px;
}
.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.tool-group {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2px;
}

.action-alert {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
  border-left: 2px solid var(--info);
}
.action-alert:empty { display: none; }

.progress-bar-wrap {
  margin-top: 12px;
}
.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--text-secondary);
  gap: 8px;
}
.progress-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-stop {
  color: var(--danger) !important;
  border-color: rgba(239, 68, 68, 0.35) !important;
  padding: 2px 8px !important;
  font-size: 11px !important;
}
.progress-stop:hover {
  background: rgba(239, 68, 68, 0.12) !important;
}
.progress-track {
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

/* Data Tables */
.table-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  background: var(--surface);
}
.accounts-table { max-height: 500px; overflow-y: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.data-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--text-tertiary);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: var(--surface-hover); }

.compact td, .compact th { padding: 8px 12px; }

/* Cell Styles */
.acc-email {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.acc-meta {
  font-size: 11px;
  color: var(--text-tertiary);
}
.text-center { text-align: center; }
.text-right { text-align: right; }
.mono-text {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px;
  color: var(--text-secondary);
}
.err-text {
  color: var(--danger);
  font-size: 11.5px;
  max-width: 200px;
  word-break: break-word;
}
tr.disabled-row td { opacity: 0.4; }

/* Status Badges */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  text-transform: capitalize;
  color: var(--text-primary);
}
.status-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.status-dot.active::before { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.exhausted::before { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.status-dot.dead::before { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.status-dot.error::before { background: #f43f5e; box-shadow: 0 0 6px #f43f5e; }

.on-off-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.on-off-tag.on { background: var(--surface-raised); color: var(--text-primary); border: 1px solid var(--border); }
.on-off-tag.off { background: transparent; color: var(--text-tertiary); border: 1px dashed var(--border); }

.cell-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* Key Creator */
.key-creator {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}
.key-creator input { flex: 1; }
.msg-text {
  font-size: 12px;
  color: var(--text-tertiary);
  min-height: 18px;
}
.mt-4 { margin-top: 16px; }
.muted { color: var(--text-tertiary); }

/* Page views */
.page-view { display: none; flex-direction: column; min-height: 0; width: 100%; }
.page-view.active { display: flex; flex: 1; width: 100%; }

/* Usage page */
#pageUsage {
  width: 100%;
  min-width: 0;
  flex: 1;
}
#pageUsage .card-panel {
  width: 100%;
}
#usageDetails .table-container {
  width: 100%;
}
.usage-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: none;
  margin: 0;
  flex: 1;
  min-height: 0;
}
.usage-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.segmented {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}
.segment {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.segment:hover { color: var(--text-primary); }
.segment.active {
  background: var(--surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.usage-tab { display: none; flex-direction: column; gap: 16px; width: 100%; flex: 1; min-height: 0; }
.usage-tab.active { display: flex; }

.usage-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
  flex-shrink: 0;
}
.usage-stat-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.usage-stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.usage-stat-val {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Chart left + recent right, equal height */
.usage-main-row {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(300px, 0.95fr);
  gap: 16px;
  align-items: stretch;
  width: 100%;
  flex: 1;
  min-height: 380px;
}
.usage-chart-card,
.usage-recent-card {
  display: flex;
  flex-direction: column;
  min-height: 380px;
  min-width: 0;
  height: 100%;
  margin: 0;
}
.usage-chart-card .panel-header,
.usage-recent-card .panel-header {
  flex-shrink: 0;
  margin-bottom: 12px;
}
.usage-chart-wrap {
  width: 100%;
  flex: 1 1 auto;
  min-height: 280px;
  position: relative;
}
.usage-chart-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.usage-chart-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}
.chart-grid-line { stroke: var(--border); stroke-width: 1; }
.chart-axis-label {
  fill: var(--text-tertiary);
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.chart-area {
  fill: rgba(255, 255, 255, 0.06);
}
.chart-line {
  fill: none;
  stroke: var(--text-primary);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart-dot {
  fill: var(--bg-color);
  stroke: var(--text-primary);
  stroke-width: 1.5;
}
.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-tertiary);
  font-size: 13px;
}

.usage-recent-card .recent-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-color);
  overflow-y: auto;
}
.recent-list::-webkit-scrollbar { width: 4px; }
.recent-list::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }
.recent-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.recent-row:last-child { border-bottom: 0; }
.recent-row:hover { background: var(--surface-hover); }
.recent-model {
  font-weight: 500;
  color: var(--text-primary);
  min-width: 0;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px;
  flex-shrink: 0;
}
.recent-io {
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
}
.recent-when {
  color: var(--text-tertiary);
  font-size: 11px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.empty-state {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  margin: auto;
}

@media (max-width: 1100px) {
  .usage-main-row {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .usage-chart-card,
  .usage-recent-card {
    min-height: 300px;
  }
  .usage-recent-card .recent-list {
    max-height: 320px;
  }
}
@media (max-width: 900px) {
  .usage-stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .usage-stat-grid { grid-template-columns: 1fr; }
}

/* Image Generation page */
#pageImages {
  width: 100%;
  min-width: 0;
  flex: 1;
}
.images-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  flex: 1;
  min-height: 0;
}
.images-endpoint-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
}
.images-endpoint-pill code {
  color: var(--text-secondary);
  font-size: 11.5px;
}
.images-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(0, 1.35fr);
  gap: 16px;
  align-items: stretch;
  width: 100%;
  flex: 1;
  min-height: 420px;
}
.images-form-card,
.images-gallery-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 420px;
  height: 100%;
}
.images-form-card .panel-header,
.images-gallery-card .panel-header {
  flex-shrink: 0;
  margin-bottom: 12px;
}
.img-prompt {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  margin-bottom: 14px;
  font-family: inherit;
  line-height: 1.45;
}
.img-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.img-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.img-field .field-label { margin-bottom: 0; }
.img-select {
  width: 100%;
  height: 36px;
}
.images-form-card > .field-label { margin-top: 2px; }
.images-form-card > .input { margin-bottom: 14px; }
.img-form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.img-payload-box {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.img-payload-pre {
  margin: 8px 0 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-color);
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  overflow: auto;
  max-height: 160px;
  white-space: pre-wrap;
  word-break: break-word;
}
.img-gallery {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  align-content: start;
  overflow-y: auto;
  padding: 2px;
}
.img-gallery::-webkit-scrollbar { width: 4px; }
.img-gallery::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }
.img-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-color);
  color: var(--text-tertiary);
}
.img-empty-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}
.img-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.img-card-thumb {
  aspect-ratio: 1;
  background:
    linear-gradient(45deg, var(--surface) 25%, transparent 25%),
    linear-gradient(-45deg, var(--surface) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--surface) 75%),
    linear-gradient(-45deg, transparent 75%, var(--surface) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.img-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.img-card-placeholder {
  color: var(--text-tertiary);
  font-size: 11px;
  text-align: center;
  padding: 12px;
}
.img-card-meta {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.img-card-prompt {
  font-size: 11px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}
.img-card-sub {
  font-size: 10px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}
.img-card-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.img-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  width: fit-content;
}
.img-status-badge.pending {
  color: var(--warning);
  background: var(--warning-bg);
}
.img-status-badge.ok {
  color: var(--success);
  background: var(--success-bg);
}
.img-status-badge.err {
  color: var(--danger);
  background: var(--danger-bg);
}
@media (max-width: 1100px) {
  .images-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .images-form-card,
  .images-gallery-card {
    min-height: 0;
    height: auto;
  }
}
@media (max-width: 560px) {
  .img-options-grid { grid-template-columns: 1fr; }
}

/* Login splash */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(255,255,255,0.06), transparent),
    var(--bg-color);
  padding: 24px;
}
.login-screen.hidden { display: none; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 32px 28px;
  box-shadow: var(--shadow-md);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand .logo {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
}
.login-brand h1 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.login-sub {
  margin: 0;
  color: var(--text-tertiary);
  font-size: 13px;
}
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.login-input { width: 100%; }
.login-submit { margin-top: 8px; height: 40px; font-weight: 500; }
.login-error {
  min-height: 18px;
  font-size: 12px;
  color: var(--danger);
}
.login-hint {
  margin: 20px 0 0;
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  line-height: 1.45;
}
.sidebar-brand { position: relative; }

/* Responsive */
@media (max-width: 1200px) {
  .setup-grid { grid-template-columns: 1fr; }
  .activity-rail { width: 280px; }
}

@media (max-width: 1024px) {
  .app-root { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 4px;
  }
  .nav-item { width: auto; }
  .sidebar-footer { border-top: none; padding: 0 10px 10px; }
  .activity-rail {
    width: 100%;
    height: auto;
    max-height: 280px;
    position: static;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .activity-rail.collapsed {
    width: 100%;
    max-height: 48px;
  }
  .activity-rail.collapsed .activity-header {
    writing-mode: horizontal-tb;
    transform: none;
    height: auto;
    min-height: 48px;
    justify-content: flex-start;
    padding: 12px;
    border-bottom: none;
  }
  .activity-rail.collapsed .activity-toggle {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
  }
  .activity-rail.collapsed .activity-toggle .chevron {
    transform: rotate(-90deg);
  }
  .activity-rail.collapsed .activity-title { display: inline; }
  .main-content { padding: 20px; }
  .header-stats { flex-wrap: wrap; }
  .key-creator { flex-direction: column; }
  .filters { flex-wrap: wrap; }
  .search-box { width: 100%; max-width: 240px; }
}