/* ============================================================
   AIM Vault Partner Portal — app.css
   All colors via CSS variables. Iteration 6 adjusts these.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

html, body {
  background-color: #0a0a0a;
}

:root {
  color-scheme: dark;
}
@view-transition {
    navigation: auto;
}

/* ---- Variables ---- */
:root {
  --bg: #0a0a0a;
  --bg-surface: #111111;
  --bg-elevated: #1a1a1a;
  --bg-hover: #222222;

  --accent: #ff8001;
  --accent-dim: rgba(255, 128, 1, 0.15);
  --accent-hover: #ff9a2e;
  --accent-glow: rgba(255, 128, 1, 0.35);

  --text: #e5e5e5;
  --text-muted: #737373;
  --text-faint: #404040;

  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.15);

  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.15);

  --success: #22c55e;

  --sidenav-width: 196px;
  --topbar-height: 52px;

  --radius: 6px;
  --radius-lg: 10px;

  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Mono', monospace;

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);
}

/* Hide Alpine x-cloak elements until Alpine initialises */
[x-cloak] { display: none !important; }

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

html { font-size: 14px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

/* ---- Layout shell ---- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px 0 calc(var(--sidenav-width) + 20px);
  z-index: 100;
  gap: 12px;
}

.topbar-wordmark {
  position: absolute;
  left: 0;
  width: var(--sidenav-width);
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 100%;
  border-right: 1px solid var(--border);
}

.topbar-logo-img {
  height: 26px;
  width: auto;
  display: block;
}

.topbar-search {
  flex: 1;
  max-width: 400px;
}

.topbar-search input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font-body);
  outline: none;
  cursor: not-allowed;
}

.topbar-search input::placeholder { color: var(--text-faint); }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-bell {
  position: relative;
  display: flex;
  align-items: center;
}
.bell-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  position: relative;
  transition: background 0.15s, color 0.15s;
}
.bell-btn:hover {
  background: var(--surface);
  color: var(--text-primary);
}
.bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  background: #ff8001;
  color: #0a0a0a;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
  animation: badge-pulse 0.4s ease;
}
@keyframes badge-pulse {
  0%   { transform: scale(1.4); }
  100% { transform: scale(1); }
}
.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.48);
  z-index: 1000;
  overflow: hidden;
}
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.notif-mark-all {
  font-size: 12px;
  color: #ff8001;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.notif-mark-all:hover { text-decoration: underline; }
.notif-list {
  max-height: 360px;
  overflow-y: auto;
}
.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  text-decoration: none;
  color: inherit;
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { border-left: 3px solid #ff8001; }
.notif-item.unread { padding-left: 13px; }
.notif-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; line-height: 1.4; }
.notif-snippet { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--text-faint, #aaa); margin-top: 3px; }
.notif-empty {
  padding: 32px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.notif-loading {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* Avatar dropdown */
.avatar-dropdown {
  position: relative;
}

.avatar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  transition: background 0.15s;
}

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

.avatar-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  flex-shrink: 0;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  min-width: 160px;
  padding: 4px 0;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

.dropdown-item {
  display: block;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.1s;
}

.dropdown-item:hover { background: var(--bg-hover); color: var(--text); }

.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-dim); }

/* ---- Sidenav ---- */
.sidenav {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidenav-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding-top: var(--topbar-height);
  z-index: 99;
}

.sidenav-nav {
  padding: 12px 8px;
  flex: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 1px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-item .nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item .nav-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  display: block;
}

/* ---- Main content ---- */
.main-content {
  margin-left: var(--sidenav-width);
  margin-top: var(--topbar-height);
  flex: 1;
  min-height: calc(100vh - var(--topbar-height));
  padding: 28px 32px;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(255, 128, 1, 0.05) 0%, transparent 70%);
  background-size: 40px 40px, 40px 40px, 100% 100%;
  background-repeat: repeat, repeat, no-repeat;
  background-attachment: scroll, scroll, fixed;
}


/* ---- Page header ---- */
.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Stat cards ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  background: #0d0d0f;
  border: 1px solid #212121;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
}

/* Orange radial glow from top-left corner */
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 80% 70% at 0% 0%,
    rgba(255, 128, 1, 0.18) 0%,
    rgba(255, 128, 1, 0.08) 25%,
    rgba(255, 128, 1, 0.02) 50%,
    transparent 75%
  );
  pointer-events: none;
  z-index: 0;
}

/* Glowing top-edge line */
.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 128, 1, 0.4) 50%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 1;
}

/* Content sits above the pseudo-element layers */
.stat-content {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}

/* Icon badge */
.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff8001 0%, #d96a00 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  box-shadow:
    0 0 0 1px rgba(255, 128, 1, 0.25),
    0 0 24px rgba(255, 128, 1, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.stat-icon::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 128, 1, 0.4) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
}

.stat-icon svg {
  width: 18px;
  height: 18px;
  stroke: #ffffff;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Label + value stack below icon — margin-top:auto pushes it to the bottom */
.stat-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 20px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}

.stat-value.accent { color: var(--accent); }

/* ---- Panel / card ---- */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* Search result project name link */
.project-name-link {
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
}
.project-name-link:hover {
  text-decoration: underline;
}

/* ---- Table ---- */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

tbody td {
  padding: 12px 16px;
  color: var(--text);
  vertical-align: middle;
}

/* ---- Empty state ---- */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state-text {
  font-size: 14px;
  color: var(--text-muted);
}

.empty-state-subtext {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 4px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #000;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-strong);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

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

/* ---- Auth forms ---- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(255,255,255,0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.028) 1px, transparent 1px);
  background-size: 44px 44px;
}

.auth-box {
  width: 100%;
  max-width: 460px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo-img {
  height: 44px;
  width: auto;
}

.auth-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
  overflow: hidden;
}

.auth-card-accent {
  position: absolute;
  top: 0;
  left: 32px;
  right: 32px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 0 0 2px 2px;
}

.auth-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.auth-copyright {
  text-align: center;
  margin-top: 24px;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

/* Input with left icon */
.input-icon-wrap {
  position: relative;
}
.input-icon-wrap .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  pointer-events: none;
}
.input-icon-wrap input[type="email"],
.input-icon-wrap input[type="password"],
.input-icon-wrap input[type="text"] {
  padding-left: 38px;
}

/* JetBrains Mono for auth form */
.auth-card label,
.auth-card input[type="email"],
.auth-card input[type="password"],
.auth-card input::placeholder {
  font-family: 'JetBrains Mono', monospace;
}

/* ---- Form elements ---- */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  border-color: var(--accent);
}

input::placeholder { color: var(--text-faint); }

/* ---- Alerts ---- */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert-error {
  background: var(--danger-dim);
  border-color: var(--danger);
  color: #fca5a5;
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.alert-info {
  background: var(--accent-dim);
  border-color: rgba(255, 128, 1, 0.3);
  color: #fcd34d;
}

/* ---- Flash messages ---- */
.flash-messages {
  position: fixed;
  top: calc(var(--topbar-height) + 12px);
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---- Placeholder page ---- */
.placeholder-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.placeholder-card {
  text-align: center;
  padding: 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 420px;
}

.placeholder-card h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.placeholder-card p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- Error pages ---- */
.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 40px;
  gap: 16px;
}

.error-code {
  font-family: var(--font-mono);
  font-size: 64px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
}

.error-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.error-message {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 400px;
}

/* ---- Mono + muted helpers ---- */
.mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }

/* ---- Status badges ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-active {
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.badge-delivered {
  background: rgba(255, 128, 1, 0.12);
  color: var(--accent);
  border: 1px solid rgba(255, 128, 1, 0.25);
}

.badge-archived {
  background: rgba(115, 115, 115, 0.12);
  color: var(--text-muted);
  border: 1px solid rgba(115, 115, 115, 0.2);
}

.badge-admin {
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.badge-manager {
  background: rgba(255, 128, 1, 0.12);
  color: var(--accent);
  border: 1px solid rgba(255, 128, 1, 0.2);
}

.badge-user {
  background: rgba(115, 115, 115, 0.10);
  color: var(--text-faint);
  border: 1px solid rgba(115, 115, 115, 0.18);
}

/* ---- Project list filters ---- */
.project-filters { }

.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-input {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 7px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  outline: none;
  width: 240px;
  transition: border-color 0.15s;
}

.filter-input:focus { border-color: var(--accent); }

.status-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}

.status-tab {
  padding: 4px 12px;
  border-radius: calc(var(--radius) - 2px);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.status-tab:hover { color: var(--text); }
.status-tab.active {
  background: var(--bg-hover);
  color: var(--text);
}

/* ---- Checkbox styling ---- */
.cb {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---- Activity feed ---- */
.activity-feed { padding: 4px 0; }

.activity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.activity-row:last-child { border-bottom: none; }
.activity-row:hover { background: var(--bg-hover); }

.activity-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.activity-body {
  flex: 1;
  font-size: 13px;
  color: var(--text);
}

.activity-actor { font-weight: 500; }
.activity-verb { color: var(--text-muted); margin: 0 4px; }
.activity-target { color: var(--text-muted); font-style: italic; }
.activity-time { font-size: 11px; color: var(--text-faint); white-space: nowrap; font-family: var(--font-mono); }

/* ---- Member chips ---- */
.member-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text);
}

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

.modal-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
}

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

.modal-title { font-size: 14px; font-weight: 600; color: var(--text); }

.modal-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.1s;
}

.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.form-select,
.form-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 7px 11px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

/* Custom select caret — consistent across browsers */
.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

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

/* ---- Drag-drop upload zone ---- */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 36px 20px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  cursor: default;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.drop-zone-icon { font-size: 32px; margin-bottom: 8px; opacity: 0.5; }
.drop-zone-text { font-size: 14px; font-weight: 500; color: var(--text); }
.drop-zone-sub { font-size: 12px; color: var(--text-faint); margin: 4px 0; }

/* ---- Per-file upload rows ---- */
.upload-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-rows: auto auto;
  gap: 2px 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.upload-row:last-child { border-bottom: none; }
.upload-name { font-weight: 500; color: var(--text); grid-column: 1; grid-row: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-size { color: var(--text-faint); font-family: var(--font-mono); grid-column: 2; grid-row: 1; white-space: nowrap; }
.upload-status { color: var(--text-muted); grid-column: 3; grid-row: 1; white-space: nowrap; }
.upload-bar-wrap { grid-column: 1 / -1; grid-row: 2; background: var(--bg-hover); border-radius: 2px; height: 3px; overflow: hidden; }
.upload-bar { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.2s; }

/* ---- Topbar search form ---- */
.topbar-search form { display: flex; width: 100%; }
.topbar-search input[type="search"] {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  outline: none;
  cursor: text;
  transition: border-color 0.15s;
}

.topbar-search input[type="search"]:focus { border-color: var(--accent); }
.topbar-search input[type="search"]::placeholder { color: var(--text-faint); }

/* ---- Hamburger button (desktop: hidden) ---- */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius);
  font-size: 20px;
  line-height: 1;
  margin-right: 4px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---- Mobile nav backdrop (desktop: hidden) ---- */
.nav-backdrop {
  display: none;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  :root {
    --sidenav-width: 0px;
  }

  .hamburger-btn {
    display: flex;
  }

  /* Sidenav becomes a slide-in overlay on mobile */
  .sidenav {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    display: flex !important;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 220ms ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.6);
  }

  .sidenav.mobile-nav-open {
    transform: translateX(0);
  }

  /* Backdrop */
  .nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99;
  }

  .nav-backdrop.mobile-nav-open {
    display: block;
  }

  .topbar {
    padding-left: 16px;
  }

  .topbar-wordmark {
    position: static;
    width: auto;
    border-right: none;
  }

  .main-content {
    padding: 20px 16px;
  }

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

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* File tables: horizontal scroll on very small screens */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Narrow file tables: collapse to card view */
  .file-table-wrap table,
  .file-table-wrap thead,
  .file-table-wrap tbody,
  .file-table-wrap tr,
  .file-table-wrap th,
  .file-table-wrap td {
    display: block;
  }

  .file-table-wrap thead {
    display: none;
  }

  .file-table-wrap tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    padding: 10px 12px;
    background: var(--bg-surface);
  }

  .file-table-wrap td {
    border: none;
    padding: 3px 0;
    font-size: 12px;
  }
}

/* ============================================================
   Admin surface — Iteration 5
   ============================================================ */

/* Admin sub-nav bar */
.admin-wrap {
  max-width: 1280px;
}

.admin-subnav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 0 20px 0;
  flex-wrap: wrap;
}

.admin-subnav-item {
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  border: 1px solid transparent;
}

.admin-subnav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.admin-subnav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(255, 128, 1, 0.2);
}

/* Admin tab bar */
.admin-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: -1px;
  padding: 0 4px;
}

.admin-tab {
  padding: 8px 18px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.admin-tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.admin-tab.active {
  background: var(--bg-surface);
  color: var(--text);
  border-color: var(--border);
  border-bottom-color: var(--bg-surface);
}

/* Metric cards (admin dashboard) */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, background 0.12s;
  display: block;
}

.metric-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
}

.metric-card.metric-warn {
  border-color: rgba(239, 68, 68, 0.4);
}

.metric-card.metric-warn:hover {
  border-color: var(--danger);
}

.metric-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}

.metric-sub {
  font-size: 11px;
  color: var(--text-faint);
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: nowrap;
}

/* ---- Accordion filter (activity log) ---- */
.filter-accordion {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.filter-accordion-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  cursor: pointer;
  background: var(--bg-surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  user-select: none;
  transition: background 0.15s;
}

.filter-accordion-trigger:hover {
  background: var(--bg-hover);
}

.filter-accordion-icon {
  display: flex;
  align-items: center;
}

.filter-accordion-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  display: block;
}

.filter-accordion-chevron {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.filter-active-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.filter-accordion-body {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.filter-accordion-body .filter-bar {
  margin-bottom: 0;
}

/* Uniform height for all filter-bar controls */
.filter-bar .form-select,
.filter-bar .form-input,
.filter-bar .btn {
  height: 34px;
  padding-top: 0;
  padding-bottom: 0;
  box-sizing: border-box;
}

/* Selects: auto-size, never full-width */
.filter-bar .form-select {
  width: auto;
  min-width: 130px;
  max-width: 210px;
  flex-shrink: 0;
}

/* Text / date inputs: override width:100% */
.filter-bar .form-input {
  width: auto;
  min-width: 120px;
}

/* Search inputs that should grow */
.filter-bar .filter-search {
  flex: 1 1 0;
  min-width: 160px;
  max-width: 300px;
}

/* Date inputs: fixed natural width */
.filter-bar .form-input[type="date"] {
  flex-shrink: 0;
  min-width: 136px;
  width: 136px;
}

/* Clickable table rows */
.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: var(--bg-hover) !important;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  justify-content: center;
}

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

/* Badge: extra types */
.badge-operator {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.badge-archived {
  background: var(--bg-elevated);
  color: var(--text-faint);
}

.badge-active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.badge-partner {
  background: rgba(255, 128, 1, 0.15);
  color: var(--accent);
}

.badge-admin {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
}

.badge-manager {
  background: rgba(255, 128, 1, 0.12);
  color: #ff9a2e;
}

.badge-user {
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.badge-pending {
  background: rgba(255, 128, 1, 0.15);
  color: var(--accent);
}

.badge-sent {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.badge-failed, .badge-abandoned {
  background: var(--danger-dim);
  color: var(--danger);
}

.badge-webhook, .badge-manual {
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.badge-delivered {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.badge-disabled {
  background: var(--bg-elevated);
  color: var(--text-faint);
}

.badge-invited {
  background: rgba(255, 128, 1, 0.15);
  color: var(--accent);
}

/* Once-key-banner: show raw API key one time */
.once-key-banner {
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  color: var(--success);
}

/* Storage bar */
.storage-bar-wrap {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  margin-top: 6px;
  max-width: 160px;
  overflow: hidden;
}

.storage-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  min-width: 2px;
  transition: width 0.3s;
}

/* Utility */
.text-danger { color: var(--danger); }

/* ---- File icon SVG sizing ---- */
.file-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
}

.file-icon svg {
  width: 16px;
  height: 18px;
  display: block;
}

/* ---- Bell icon (Lucide) in topbar ---- */
.bell-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.bell-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  display: block;
}

/* ---- Chevron icon in avatar button ---- */
.avatar-caret {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
}

.avatar-caret svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  display: block;
}

/* ---- Error page grid background ---- */
.error-page-shell {
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px;
  background-repeat: repeat, repeat;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Alert banners (profile flash messages) ---- */
.alert {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid transparent;
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--success);
}

.alert-error {
  background: var(--danger-dim);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.alert-info {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
}

.alert-warning {
  background: rgba(255, 128, 1, 0.08);
  border-color: rgba(255, 128, 1, 0.25);
  color: var(--accent);
}

/* ---- Responsive tablet (769-1024px) ---- */
@media (min-width: 769px) and (max-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .main-content {
    padding: 22px 24px;
  }
}

/* ---- Responsive mobile improvements ---- */
@media (max-width: 768px) {
  .panel-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .filter-bar {
    gap: 6px;
    flex-wrap: wrap;
  }

  .filter-accordion-body .filter-bar {
    flex-wrap: wrap;
  }

  /* On mobile let controls wrap naturally — release fixed height */
  .filter-bar .form-select,
  .filter-bar .form-input,
  .filter-bar .btn {
    height: auto;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .filter-bar .form-input,
  .filter-bar .form-select,
  .filter-bar .filter-search {
    min-width: 0 !important;
    max-width: none !important;
    flex: 1 1 140px;
    width: auto;
  }

  .filter-bar .form-input[type="date"] {
    flex: 1 1 120px;
    width: auto;
    min-width: 0 !important;
  }

  .admin-subnav {
    gap: 4px;
  }

  table {
    font-size: 12px;
  }
}

