/* Modern Minimal Design for Sandbox Gateway */
/* No functional changes - CSS only */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.06), 0 4px 6px -2px rgba(0,0,0,0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Topbar */
.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.brand {
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.link-button {
  background: transparent;
  color: var(--primary);
  font-weight: 500;
  min-height: auto;
  padding: 6px 10px;
}
.link-button:hover {
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  text-decoration: none;
}

/* Container */
.container {
  margin: 0 auto;
  max-width: 1200px;
  padding: 20px 24px;
}

/* Login */
.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  padding: 32px;
  width: 100%;
}

.login-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.login-card > p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 20px;
}

.login-card .alert {
  background: var(--danger-light);
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* Page Header */
.page-head {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 20px;
}

h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 2px;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 14px;
  color: var(--text);
}

p {
  margin-top: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

/* Buttons */
.button,
button,
input[type="submit"] {
  align-items: center;
  background: var(--primary);
  border: 0;
  border-radius: var(--radius-sm);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  justify-content: center;
  min-height: 36px;
  padding: 7px 14px;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.button:active,
button:active {
  transform: translateY(0);
  box-shadow: none;
}

.button.secondary {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}

.button.secondary:hover {
  background: var(--surface-hover);
  border-color: #cbd5e1;
  box-shadow: none;
  transform: translateY(-1px);
}

button.wide,
.button.wide {
  width: 100%;
}

/* Alerts */
.alert {
  background: var(--danger-light);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: #991b1b;
  margin-bottom: 14px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 500;
}

.success {
  background: var(--success-light);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  color: #166534;
  margin-bottom: 14px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Metrics */
.metrics {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 18px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}

.metric:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.metric span {
  color: var(--text-muted);
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.metric strong {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 4px;
  color: var(--text);
}

.muted {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 12px;
}

/* Grid */
.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Panel */
.panel,
.metric,
.mini-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  margin-bottom: 16px;
  padding: 18px;
  transition: box-shadow 0.2s;
}

.panel:hover {
  box-shadow: var(--shadow-md);
}

/* Forms */
form {
  width: 100%;
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.check {
  align-items: flex-start;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.check:hover {
  background: var(--surface-hover);
  border-color: #cbd5e1;
}

.check input {
  min-height: auto;
  margin-top: 1px;
  accent-color: var(--primary);
  cursor: pointer;
}

.check span {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.85rem;
  line-height: 1.4;
}

input,
select {
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.85rem;
  min-height: 38px;
  padding: 8px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  outline: none;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23667085' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* Checks group */
.checks {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.checks label.check {
  border: 1px solid transparent;
}

.checks label.check:hover {
  border-color: var(--border);
  background: var(--surface-hover);
}

.btnlogout {
  display: contents;
}

/* Tables */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  border-collapse: collapse;
  min-width: 640px;
  width: 100%;
  font-size: 0.85rem;
}

thead {
  background: #f8fafc;
}

th,
td {
  border-bottom: 1px solid var(--border-light);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

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

tbody tr:hover {
  background: #f8fafc;
}

td span {
  color: var(--text-muted);
  display: block;
  font-size: 0.75rem;
  margin-top: 2px;
}

td a {
  color: var(--primary);
  font-weight: 500;
}

td a:hover {
  text-decoration: underline;
}

/* Pills */
.pill {
  border-radius: 999px;
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  text-transform: uppercase;
}

.pill.ok {
  background: var(--success-light);
  color: var(--success);
}

.pill.bad {
  background: var(--danger-light);
  color: var(--danger);
}

/* Token / API Key */
.token {
  background: #0f172a;
  border-radius: var(--radius-sm);
  color: #ffffff;
  display: block;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  padding: 12px 14px;
}

/* Endpoint Access and Charges */
.endpoint-list,
.usage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.endpoint-row {
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 0;
}

.endpoint-row:last-child {
  border-bottom: none;
}

.endpoint-row strong {
  color: var(--text);
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

.endpoint-row small {
  color: var(--text-muted);
  display: block;
  font-size: 0.8rem;
  margin-top: 2px;
}

.endpoint-price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}

.endpoint-price .price {
  color: var(--primary);
  font-size: 1rem;
  font-weight: 700;
}

.endpoint-price small {
  color: var(--text-muted);
  display: block;
  font-size: 0.75rem;
}

/* Usage By API */
.usage-row {
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(130px, 1fr) 2fr auto auto;
  padding: 12px 0;
}

.usage-row:last-child {
  border-bottom: none;
}

.usage-name {
  color: var(--text-secondary);
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
}

.usage-bar {
  background: #e2e8f0;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.usage-fill {
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  border-radius: 999px;
  height: 100%;
}

.usage-count {
  color: var(--text-secondary);
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 54px;
  text-align: right;
}

.usage-total {
  color: var(--primary);
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 72px;
  text-align: right;
}

/* Responsive */
@media (max-width: 1024px) {
  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .metrics,
  .grid.two,
  .form-grid,
  .checks,
  .mini-grid {
    grid-template-columns: 1fr;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
    width: 100%;
  }

  .actions .button {
    flex: 1;
    justify-content: center;
  }

  .login-card {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 12px;
  }

  .panel {
    padding: 14px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  th,
  td {
    font-size: 0.75rem;
    padding: 8px 10px;
  }
}

/* animations */
@media (prefers-reduced-motion: no-preference) {
  .panel {
    transition: box-shadow 0.2s;
  }
  .metric {
    transition: box-shadow 0.2s, transform 0.2s;
  }
  .button,
  button {
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  }
}
