@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=DM+Mono:ital,wght@0,400;0,500;1,400&family=DM+Sans:wght@400;500;600&display=swap');

/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --bg:         #0f1117;
  --surface:    #161b27;
  --surface2:   #1e2535;
  --border:     #2a3348;
  --accent:     #c9a84c;
  --accent2:    #e8c97a;
  --green:      #4caf82;
  --red:        #e05555;
  --blue:       #5b9cf6;
  --purple:     #9b7fe8;
  --text:       #e8eaf0;
  --text-muted: #7b8499;
  --text-dim:   #4a5568;

  --radius:     10px;
  --radius-lg:  16px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 48px rgba(0,0,0,0.6);
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Typography ───────────────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: 'Playfair Display', serif;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

.mono { font-family: 'DM Mono', monospace; }
.muted { color: var(--text-muted); }
.dim   { color: var(--text-dim); }
.accent-text { color: var(--accent); }

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

.page-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header / Navbar ──────────────────────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.navbar-brand {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.navbar-brand span { color: var(--text-muted); font-size: 0.85rem; font-family: 'DM Mono', monospace; }

.navbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar-user {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-family: 'DM Mono', monospace;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}
.back-link:hover { color: var(--accent); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #0f1117;
}
.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-success {
  background: transparent;
  color: var(--green);
  border: 1px solid var(--green);
}
.btn-success:hover { background: var(--green); color: #fff; }

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 7px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.form-group label {
  font-size: 0.8rem;
  font-family: 'DM Mono', monospace;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 17px;
  padding: 11px 14px;
  transition: border-color 0.15s;
  width: 100%;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}

.form-group input::placeholder { color: var(--text-dim); }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card-hover {
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.card-hover:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(201,168,76,0.12);
}

/* ── Tool grid ────────────────────────────────────────────────────────────── */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(201,168,76,0.1);
}

.tool-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.tool-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.tool-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  flex: 1;
  line-height: 1.5;
}

.tool-card .btn {
  margin-top: 6px;
  align-self: flex-start;
}

/* ── Stat cards ───────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.stat-value {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.78rem;
  font-family: 'DM Mono', monospace;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 24px;
  width: fit-content;
}

.tab-btn {
  padding: 8px 20px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.tab-btn:hover:not(.active) { color: var(--text); }

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

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: var(--surface2);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 400;
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-family: 'DM Mono', monospace;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-green  { background: rgba(76,175,130,0.15); color: var(--green); border: 1px solid rgba(76,175,130,0.3); }
.badge-red    { background: rgba(224,85,85,0.15);  color: var(--red);   border: 1px solid rgba(224,85,85,0.3); }
.badge-blue   { background: rgba(91,156,246,0.15); color: var(--blue);  border: 1px solid rgba(91,156,246,0.3); }
.badge-gold   { background: rgba(201,168,76,0.15); color: var(--accent); border: 1px solid rgba(201,168,76,0.3); }
.badge-muted  { background: rgba(123,132,153,0.1); color: var(--text-muted); border: 1px solid rgba(123,132,153,0.2); }
.badge-purple { background: rgba(155,127,232,0.15); color: var(--purple); border: 1px solid rgba(155,127,232,0.3); }

/* ── Pill list (tool tags) ────────────────────────────────────────────────── */
.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pill-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-size: 0.9rem;
  transition: color 0.1s;
}
.pill-remove:hover { color: var(--red); }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

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

.modal-body { padding: 20px 24px; }

.modal-footer {
  padding: 16px 24px 24px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 4px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

/* Tool access list in modal */
.tool-access-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.tool-access-item:last-child { border-bottom: none; }

.tool-access-info { display: flex; align-items: center; gap: 10px; }
.tool-access-icon { font-size: 1.3rem; }
.tool-access-name { font-size: 0.9rem; font-weight: 500; }

/* ── Alerts / error messages ──────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-error   { background: rgba(224,85,85,0.1);  border: 1px solid rgba(224,85,85,0.3);  color: #f08080; }
.alert-success { background: rgba(76,175,130,0.1); border: 1px solid rgba(76,175,130,0.3); color: var(--green); }
.alert-info    { background: rgba(91,156,246,0.1); border: 1px solid rgba(91,156,246,0.3); color: var(--blue); }

.alert.hidden { display: none; }

/* ── Toast notifications ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 0.875rem;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.25s ease;
  pointer-events: auto;
  max-width: 320px;
  word-break: break-word;
}

.toast.show { opacity: 1; transform: translateX(0); }
.toast.toast-error   { border-color: rgba(224,85,85,0.5);  color: #f08080; }
.toast.toast-success { border-color: rgba(76,175,130,0.5); color: var(--green); }
.toast.toast-info    { border-color: rgba(91,156,246,0.5); color: var(--blue); }

/* ── Section headings ─────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  font-weight: 600;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { font-size: 0.9rem; }

/* ── Dividers / spacing ───────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.mt-sm  { margin-top: 8px; }
.mt-md  { margin-top: 16px; }
.mt-lg  { margin-top: 24px; }
.mb-sm  { margin-bottom: 8px; }
.mb-md  { margin-bottom: 16px; }
.mb-lg  { margin-bottom: 24px; }

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(201,168,76,0.08) 0%, transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 440px;
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-brand h1 {
  font-size: 1.8rem;
  color: var(--accent);
  margin-bottom: 6px;
}

.login-brand p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .navbar { padding: 12px 16px; }
  .container { padding: 0 16px; }
  .tools-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .tab-bar { width: 100%; }
  .tab-btn { flex: 1; text-align: center; }
  table { font-size: 0.8rem; }
  th, td { padding: 10px 12px; }
}
