:root {
  /* Light theme palette with black/green accents */
  --bg: #f4faf5;
  --panel: #ffffff;
  --panel-2: #f1f7f2;
  --text: #0e1a12;
  --muted: #2c7a4a;
  --muted-2: #0aa25e;
  --accent: #00cc66;
  --accent-2: #009a4d;
  --border: #d7e7db;
  --shadow: rgba(0, 32, 16, 0.15);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Inter", "Segoe UI Variable", sans-serif;
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 800px at 50% -20%, rgba(0, 204, 102, 0.08), transparent 50%), var(--bg);
  color: var(--text);
}
header, footer {
  background: linear-gradient(180deg, rgba(0, 204, 102, 0.06), rgba(0, 204, 102, 0.02));
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
}
main { padding: 1.25rem; }
a { color: var(--muted-2); text-decoration: none; }
a:hover { color: var(--accent); }
.container { max-width: 1100px; margin: 0 auto; }
.header-bar { display:flex; align-items:center; justify-content: space-between; gap: 1rem; }
.brand-wrap { display:flex; align-items:center; gap: .6rem; }
.main-nav { display:flex; align-items:center; justify-content: space-between; gap: .75rem; font-size: .95rem; flex-wrap: wrap; }
.nav-links { display:flex; gap: .4rem; flex-wrap: wrap; }
.nav-link { display:inline-block; padding: .4rem .6rem; border-radius: 999px; border: 1px solid var(--border); background: var(--panel); color: var(--text); box-shadow: 0 6px 16px var(--shadow); }
.nav-link:hover { color: var(--muted-2); border-color: #bfe8cd; }
.nav-link.danger { background: #fff5f5; border-color: #ffd1d1; color: #a00020; }
.nav-link.danger:hover { background: #ffe8e8; }
.nav-meta { display:flex; gap: .5rem; align-items:center; }
.user-tag { padding: .3rem .5rem; border-radius: 8px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }

/* Burger toggle */
.nav-toggle { display:none; position: relative; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); align-items: center; justify-content: center; box-shadow: 0 8px 20px var(--shadow); transition: background .2s ease, border-color .2s ease; }
.nav-toggle:focus { outline: 2px solid var(--accent-2); }
.nav-toggle-bar { display:block; width: 20px; height: 2px; background: var(--text); border-radius: 3px; position: relative; transition: transform .2s ease, opacity .2s ease; }
.nav-toggle-bar + .nav-toggle-bar { margin-top: 4px; }
.nav-toggle.is-active .nav-toggle-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.is-active .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle.is-active .nav-toggle-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Overlay for mobile nav */
.nav-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 800; display: none; }
.nav-overlay.show { display: block; }


.brand-logo { height: 28px; width: auto; display: block; border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 204, 102, 0.2); }
@media (min-width: 880px) { .brand-logo { height: 32px; } }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px var(--shadow);
}

input, button, select {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
}
input:focus, select:focus { outline: 2px solid var(--accent-2); }
button { cursor: pointer; }

.btn { display: inline-block; padding: 0.65rem 0.8rem; border-radius: 10px; border: 1px solid var(--border); background: #ffffff; color: var(--text); text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border: none;
  box-shadow: 0 10px 30px rgba(0, 204, 102, 0.22);
}
.btn-primary:hover { background: var(--accent-2); }
.btn-lg { padding: 0.85rem 1.2rem; border-radius: 12px; font-weight: 700; }

/* Divider */
.divider { height: 1px; background: linear-gradient(90deg, transparent, var(--border), transparent); margin: 1rem auto; max-width: 900px; }

/* Auth */
.center-wrap { display: grid; place-items: center; min-height: calc(100vh - 140px); }
.auth-card { width: 100%; max-width: 440px; padding: 1.5rem; border-radius: 16px; border: 1px solid var(--border); background: linear-gradient(180deg, #0f1610, #0a120b); box-shadow: 0 20px 40px var(--shadow); }
.brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.logo { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--accent); color: #001b0b; font-weight: 900; box-shadow: 0 10px 30px rgba(0,255,136,0.3); }
.brand-text small { color: var(--muted); display: block; margin-top: -2px; }
.form-grid { display: grid; gap: .75rem; }

/* Hero */
.hero { position: relative; display: grid; place-items: center; padding: 3rem 1rem; }
.hero-inner { max-width: 860px; text-align: center; }
.login-hero .hero-inner { text-align: center; }
.hero-logo { width: clamp(80px, 12vw, 140px); height: auto; filter: drop-shadow(0 12px 28px rgba(0,255,136,0.25)); border-radius: 12px; }
.logo-badge { width: 64px; height: 64px; border-radius: 14px; background: var(--accent); color: #001b0b; display: grid; place-items: center; font-weight: 900; margin: 0 auto 1rem; box-shadow: 0 10px 30px rgba(0,255,136,0.35); }
.hero-title { font-size: clamp(2rem, 5vw, 3rem); margin: 0.25rem 0; letter-spacing: .02em; }
.hero-sub { font-size: clamp(1.1rem, 2.6vw, 1.35rem); color: var(--muted); font-weight: 500; margin: 0 0 1rem; }
.hero-copy { color: #1d2f23; opacity: 0.9; line-height: 1.65; margin: 0.5rem auto; max-width: 70ch; }
.hero-tag { color: var(--muted-2); font-weight: 700; margin: 1rem 0 1.25rem; }
.hero-glow { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(600px 300px at 50% 0%, rgba(0,255,136,0.07), transparent 60%); }

.two-col { display: grid; grid-template-columns: 1fr; gap: 1.25rem; align-items: start; }
.single-col { display: block; }
.two-col .features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; max-width: 1000px; margin: 0 auto; justify-items: center; }
.single-col .features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; max-width: 1000px; margin: 0 auto; justify-items: center; }
.feature-card { background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; box-shadow: 0 8px 20px var(--shadow); text-align: center; width: 100%; }
.feature-card h3 { margin: 0 0 .35rem; color: var(--muted-2); }

.auth-hero { padding: 2.5rem 1rem; }
.auth-hero .auth-copy { background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; box-shadow: 0 8px 20px var(--shadow); }
.bullets { margin: .5rem 0 0; padding-left: 1.1rem; }
.bullets li { margin: .25rem 0; }

@media (min-width: 880px) {
  .two-col { grid-template-columns: 1.1fr .9fr; }
  .hero-inner { text-align: left; }
  .login-hero .hero-inner { text-align: center; }
}

@media (max-width: 600px) {
  header, footer { padding: .75rem 1rem; }
  main { padding: 1rem; }
}

/* Responsive header/nav */
@media (max-width: 880px) {
  .nav-toggle { display:inline-flex; }
  /* Use logo for the menu button on mobile */
  .nav-toggle { background-image: url('/static/images/mantis_logo.png'); background-repeat: no-repeat; background-position: center; background-size: 22px; }
  .nav-toggle .nav-toggle-bar { display: none; }
  .main-nav { display:none; width: 100%; margin-top: .4rem; border: 1px solid var(--border); background: linear-gradient(180deg, var(--panel), var(--panel-2)); border-radius: 12px; padding: .6rem; box-shadow: 0 18px 40px var(--shadow); position: relative; z-index: 999; }
  .main-nav.is-open { display:grid; gap: .5rem; }
  .main-nav .nav-links, .main-nav .nav-meta { display: grid; gap: .5rem; }
  .main-nav .nav-link { width: 100%; text-align: center; padding: .75rem 1rem; }
  .user-tag { justify-self: center; }
  .header-bar { align-items: center; }
}

/* Header quick login */
.nav-login-form { display: grid; grid-auto-flow: column; grid-template-columns: 1fr 1fr auto auto; gap: .5rem; align-items: center; }
.nav-login-form input { width: 100%; min-width: 180px; }
.nav-login-form button { white-space: nowrap; }
@media (max-width: 880px) {
  .nav-login-form { grid-auto-flow: row; grid-template-columns: 1fr; }
  .nav-login-form input, .nav-login-form button { width: 100%; }
}

/* Bottom login section */
.login-bottom { display: grid; place-items: center; padding: 1rem 0 1.5rem; }
.login-bottom .auth-card { margin: 0 auto; }
.auth-card .brand { justify-content: center; }
.auth-card .form-grid { max-width: 360px; margin: 0 auto; }

/* Subtle animations (always on, kept gentle) */
.hero-logo { animation: fadeUp .7s ease-out both; }
.hero-title { animation: fadeUp .7s ease-out .05s both; }
.hero-sub { animation: fadeUp .7s ease-out .1s both; }
.hero-copy { animation: fadeUp .7s ease-out .15s both; }
.feature-card { transition: transform .2s ease, box-shadow .2s ease; animation: fadeUp .7s ease-out .2s both; }
.feature-card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px var(--shadow); }
.btn-primary { transition: transform .15s ease, box-shadow .2s ease; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(0, 204, 102, 0.3); }
.features .feature-card:nth-child(1) { animation-delay: .1s; }
.features .feature-card:nth-child(2) { animation-delay: .16s; }
.features .feature-card:nth-child(3) { animation-delay: .22s; }
.features .feature-card:nth-child(4) { animation-delay: .28s; }
.login-bottom .auth-card { animation: fadeUp .65s ease-out .2s both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Fine tuning on very small screens */
@media (max-width: 480px) {
  body { font-size: 15px; }
  .nav-link { padding: .35rem .55rem; }
  .chip { padding: .3rem .5rem; }
  .stat-value { font-size: 1.3rem; }
  .log-table th, .log-table td { padding: .5rem; font-size: .9rem; }
}

/* Mobile button ergonomics */
@media (max-width: 880px) {
  .btn { padding: .75rem 1rem; font-size: 1rem; }
  /* Bot card action buttons */
  .bot-card .footer { gap: .6rem; }
  .bot-card .footer > div:first-child { width: 100%; }
  .bot-card .footer form { flex: 1; }
  .bot-card .footer .btn { width: 100%; }
  .bot-card .footer .brand-bar + div > div { display: flex; flex-direction: column; gap: .35rem; }
  /* General action rows */
  .stat-actions .btn { flex: 1 1 auto; }
}

/* Portfolio stats */
.stats-card { overflow: hidden; position: relative; }
.stats-header { display:flex; align-items: end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.filters { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: .35rem .6rem; border-radius: 999px; box-shadow: 0 6px 16px var(--shadow); }
.chip.active { background: #e6fff2; border-color: #bfe8cd; color: var(--muted-2); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-top: .9rem; }
.stat-card { background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid var(--border); border-radius: 12px; padding: .9rem; box-shadow: 0 8px 20px var(--shadow); }
.stat-label { font-size: .9rem; color: var(--muted); }
.stat-value { font-size: 1.5rem; font-weight: 800; letter-spacing: .01em; margin-top: .15rem; }
.fadeIn { animation: fadeUp .6s ease-out both; }
.stat-actions { display:flex; gap:.5rem; margin-top: .9rem; flex-wrap: wrap; }

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Logs UI */
.logs-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.logs-title h2 { margin: 0; }
.logs-title .muted { color: var(--muted); margin: .25rem 0 0; font-size: .95rem; }
.tabs { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.tab { background: transparent; border: none; padding: .45rem .7rem; cursor: pointer; color: var(--text); }
.tab.active { background: var(--panel); color: var(--muted-2); font-weight: 600; }
.tab:disabled { opacity: .6; cursor: default; }
.logs-filter { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; margin-top: .75rem; }
.logs-filter > div { display: grid; gap: .25rem; }
.filter-actions { margin-left: auto; }
.logs-table-wrap { margin-top: 1rem; overflow: auto; }
.log-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.log-table th, .log-table td { padding: .6rem .7rem; border-bottom: 1px solid var(--border); text-align: left; }
.log-table thead th { background: var(--panel-2); position: sticky; top: 0; z-index: 1; }
.log-table tbody tr:nth-child(odd) { background: linear-gradient(180deg, var(--panel), var(--panel-2)); }
.pill { display: inline-block; padding: .1rem .45rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.pill-debug { background: #e6f7ff; color: #006699; }
.pill-info { background: #e7f7ee; color: #0a8c5a; }
.pill-warning { background: #fff7e6; color: #9a6a00; }
.pill-error { background: #ffecec; color: #b00020; }
.pill-critical { background: #ffe6f0; color: #a00038; }

.user-chip { display: inline-block; width: 12px; height: 12px; border-radius: 999px; background: var(--chip, #0aa25e); box-shadow: 0 0 0 2px var(--panel); margin-right: 6px; vertical-align: -1px; }

/* Simple anchored modal (no JS) */
.modal { display: none; }
.modal:target { display: grid; position: fixed; inset: 0; place-items: center; background: rgba(0,0,0,0.35); z-index: 9999; }
.modal-card { background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid var(--border); border-radius: 14px; max-width: 600px; width: calc(100% - 2rem); padding: 1rem; box-shadow: 0 30px 60px var(--shadow); }

/* Toast notifications */
.toast-container {
  position: fixed;
  right: 1rem;
  top: 1rem;
  display: grid;
  gap: .5rem;
  z-index: 10000;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 6px solid var(--accent);
  color: var(--text);
  box-shadow: 0 12px 30px var(--shadow);
  padding: .65rem .8rem;
  border-radius: 10px;
  min-width: 220px;
  max-width: 420px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.hide { opacity: 0; transform: translateY(-6px); }
.toast.success { border-left-color: #00b35a; }
.toast.warning { border-left-color: #ffb300; }
.toast.error { border-left-color: #e53935; }

/* Mobile toasts at bottom center with safe-area support */
@media (max-width: 600px) {
  .toast-container { left: 0; right: 0; top: auto; bottom: calc(env(safe-area-inset-bottom, 0) + 0.75rem); justify-items: center; padding: 0 .75rem; }
  .toast { width: 100%; max-width: 560px; border-left-width: 4px; }
}
