:root {
  --bg: #0b1020;
  --bg-elev: #121932;
  --bg-card: #161f3d;
  --bg-hover: #1d284d;
  --border: rgba(148, 163, 184, 0.16);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #06b6d4;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at top right, #18234a 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: #7dd3fc; text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: rgba(15, 23, 42, 0.7);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.88em;
  color: #bae6fd;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.mt-12 { margin-top: 12px; }
.mt-24 { margin-top: 24px; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
}
.brand-badge {
  display: inline-block;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: #a5b4fc;
  background: rgba(99,102,241,0.16);
  border: 1px solid rgba(99,102,241,0.35);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.login-card h1 { margin: 0 0 8px; font-size: 1.5rem; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 12px 0 6px; }
input, select, textarea {
  width: 100%;
  background: #0d1428;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.92rem;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { min-height: 76px; resize: vertical; }
.error-text { color: #fca5a5; margin-top: 10px; font-size: 0.88rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  transition: 0.15s ease;
}
.btn-sm { padding: 6px 11px; font-size: 0.82rem; }
.btn-full { width: 100%; margin-top: 16px; padding: 11px; }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-accent { background: #0891b2; }
.btn-accent:hover { background: #0e7490; }
.btn-green { background: #059669; }
.btn-green:hover { background: #047857; }
.btn-danger { background: #dc2626; }
.btn-ghost { background: rgba(148,163,184,0.1); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: rgba(148,163,184,0.2); }

/* Header & Tabs */
.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  box-shadow: 0 0 14px rgba(56,189,248,0.8);
}
.topbar-title { font-weight: 700; font-size: 1.08rem; }
.topbar-sub { font-size: 0.82rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sep { opacity: 0.4; }

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 25, 50, 0.65);
}
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--text); background: rgba(148,163,184,0.08); }
.tab.active {
  color: #fff;
  background: rgba(99,102,241,0.22);
  border-color: rgba(99,102,241,0.45);
}
.tab-count {
  background: var(--red);
  color: #fff;
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 999px;
}

.container { max-width: 1400px; margin: 0 auto; padding: 20px 24px 60px; }

/* KPI Strip */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
}
.kpi-label { font-size: 0.8rem; color: var(--muted); }
.kpi-value { font-size: 1.55rem; font-weight: 700; margin-top: 4px; }
.kpi-sub { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.text-green { color: #34d399; }
.text-amber { color: #fbbf24; }
.text-red { color: #f87171; }
.text-cyan { color: #38bdf8; }

.panel-view { display: none; }
.panel-view.active { display: block; }

.section-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}
.section-header h2 { margin: 0 0 4px; font-size: 1.15rem; }

/* Cards & Grids */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 14px; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card.highlight-gemini {
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.12);
}

/* Pills & Chips */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.pill-green { background: rgba(16,185,129,0.18); color: #34d399; }
.pill-amber { background: rgba(245,158,11,0.18); color: #fbbf24; }
.pill-red { background: rgba(239,68,68,0.18); color: #f87171; }
.pill-cyan { background: rgba(6,182,212,0.18); color: #38bdf8; }
.pill-indigo { background: rgba(99,102,241,0.22); color: #a5b4fc; }
.pill-muted { background: rgba(148,163,184,0.15); color: #cbd5e1; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.83rem;
  cursor: pointer;
}
.chip.active, .chip:hover {
  background: rgba(99,102,241,0.22);
  border-color: rgba(99,102,241,0.5);
  color: #fff;
}

/* Tables */
.table-wrap { overflow-x: auto; padding: 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.data-table th, .data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.data-table th { color: var(--muted); font-weight: 600; background: rgba(11,16,32,0.45); white-space: nowrap; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* Suppliers */
.suppliers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}
.sup-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.sup-name { font-size: 1.05rem; font-weight: 700; }
.sup-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.sup-meta { font-size: 0.84rem; color: #cbd5e1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: rgba(11,16,32,0.45); padding: 10px; border-radius: 8px; }
.sup-gemini { font-size: 0.83rem; color: #7dd3fc; background: rgba(6,182,212,0.1); border-left: 3px solid #38bdf8; padding: 6px 10px; border-radius: 6px; }
.sup-keys { display: flex; flex-direction: column; gap: 5px; }
.key-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; background: rgba(15,23,42,0.65); padding: 6px 9px; border-radius: 6px; }
.sup-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }

/* Approvals */
.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.approval-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.approval-card.priority-high { border-color: rgba(245,158,11,0.55); }
.approval-amount { font-size: 1.35rem; font-weight: 800; color: #fbbf24; }

/* Pelican Gallery */
.pelican-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.pelican-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.pelican-canvas {
  background: #f8fafc;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.pelican-canvas iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.pelican-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.pelican-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 0.8rem; background: rgba(11,16,32,0.5); padding: 8px; border-radius: 8px; text-align: center; }
.pelican-metrics b { display: block; font-size: 0.95rem; color: #fff; }

/* Logs */
.logs-list { display: flex; flex-direction: column; gap: 8px; }
.log-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(11,16,32,0.45);
  border-radius: 8px;
  border-left: 3px solid var(--primary);
  font-size: 0.85rem;
}
.log-item.warn { border-left-color: var(--amber); }
.log-item.error { border-left-color: var(--red); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(2, 6, 23, 0.78);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 100;
}
.modal-card {
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-header h3 { margin: 0; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1e293b; border: 1px solid rgba(99,102,241,0.5);
  color: #fff; padding: 12px 18px; border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45); z-index: 200;
  font-size: 0.9rem;
}

@media (max-width: 720px) {
  .topbar { padding: 12px 14px; }
  .tabs { padding: 8px 12px; }
  .container { padding: 14px 12px 48px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .suppliers-grid, .card-list, .pelican-grid { grid-template-columns: 1fr; }
}
