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

/* MMW Platform shared stylesheet.
   App shell: GHL-style left sidebar + slim top header + wide calm canvas.
   Brand accents (green glow, mono tags, circuit grid) are reserved for
   badges, status pips, and the login page so the app itself stays friendly.
   Class contracts (.card, .btn, .tabs, table, .field, .msg, .badge, etc.)
   are stable; module pages depend on them. */

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

:root {
  --green: #28AB83;
  --green-bright: #1e9472;
  --green-deep: #0d5d48;
  --green-light: #E5F5F0;
  --green-lighter: #f0faf7;
  --green-glow: rgba(40, 171, 131, 0.28);
  --bg: #f6f8f9;
  --grid-line: rgba(40, 171, 131, 0.09);
  --grid-line-strong: rgba(40, 171, 131, 0.22);
  --text: #35424a;
  --text-dim: #64707a;
  --text-bright: #101d26;
  --amber: #B45309;
  --amber-bright: #D97706;
  --navy: #323547;
  --shadow-deep: rgba(24, 40, 50, 0.07);
  --card: #ffffff;
  --border: rgba(30, 45, 60, 0.1);
  --border-soft: rgba(30, 45, 60, 0.12);
  --danger: #b91c1c;
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
  --sidebar-w: 240px;
  /* legacy token aliases still referenced by module pages */
  --green-dark: #1e9472;
  --dark: #323547;
  --muted: #64707a;
}

html { height: 100%; }

body {
  font-family: 'Barlow', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14.5px;
}

/* circuit-grid backdrop, login page only */
body.bg-grid::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}
body.bg-grid::after {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background: radial-gradient(ellipse at center, transparent 0%, var(--bg) 78%);
  pointer-events: none;
}

a { color: var(--green-bright); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--green-deep);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ══════════ APP SHELL ══════════ */
.shell { display: flex; min-height: 100vh; }

/* ── sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0;
  height: 100vh;
  z-index: 60;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  height: 60px; padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  display: block; object-fit: contain;
  box-shadow: 0 2px 8px var(--green-glow);
}
.brand-name {
  font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 14.5px;
  color: var(--text-bright); letter-spacing: -0.01em;
}
.brand-name span { color: var(--green-bright); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-group { margin-bottom: 18px; }
.nav-group-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 10px; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; margin-bottom: 1px;
  border-radius: 8px;
  font-size: 14px; font-weight: 500;
  color: var(--text);
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item svg { color: var(--text-dim); flex-shrink: 0; transition: color 0.15s ease; }
.nav-item:hover { background: var(--bg); color: var(--text-bright); text-decoration: none; }
.nav-item:hover svg { color: var(--text); }
.nav-item.active {
  background: var(--green-lighter);
  color: var(--green-deep);
  font-weight: 600;
}
.nav-item.active svg { color: var(--green-bright); }

.sidebar-profile {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-deep) 100%);
  color: #fff;
  font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 12.5px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar.small { width: 30px; height: 30px; font-size: 11px; }
.profile-meta { flex: 1; min-width: 0; }
.profile-name {
  font-weight: 600; font-size: 13.5px; color: var(--text-bright);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-role { font-size: 11.5px; color: var(--text-dim); }

.icon-btn {
  background: none; border: none; cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg); color: var(--text-bright); }

/* ── main column ── */
.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.shell-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  height: 60px; padding: 0 28px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-title {
  font-family: 'Poppins', sans-serif; font-weight: 700;
  font-size: 16px; color: var(--text-bright); letter-spacing: -0.01em;
  flex: 1;
}
.header-right { display: flex; align-items: center; gap: 14px; }
.nav-toggle { display: none; }

.shell-content { flex: 1; }
.shell-backdrop { display: none; }

/* mobile: sidebar becomes a slide-over */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: -280px; top: 0; bottom: 0;
    transition: left 0.25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,0.15);
  }
  .shell.nav-open .sidebar { left: 0; }
  .shell.nav-open .shell-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(16, 29, 38, 0.35);
  }
  .nav-toggle { display: flex; }
  .shell-header { padding: 0 16px; }
}

/* ══════════ PAGE ══════════ */
.page { position: relative; max-width: 1360px; margin: 0 auto; padding: 30px 32px 72px; }
@media (max-width: 900px) { .page { padding: 20px 16px 56px; } }

.page h1 {
  font-family: 'Poppins', sans-serif; font-weight: 700;
  font-size: 23px; letter-spacing: -0.02em; color: var(--text-bright);
  margin-bottom: 4px;
}
.page .sub { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; line-height: 1.6; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--green-bright);
  background: rgba(40, 171, 131, 0.06);
  border: 1px solid rgba(40, 171, 131, 0.2);
  padding: 6px 14px; border-radius: 4px;
  margin-bottom: 16px;
}
.eyebrow::before { content: '◆'; font-size: 8px; }

/* ══════════ CARDS ══════════ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px var(--shadow-deep);
}
.card h2 {
  font-family: 'Poppins', sans-serif; font-weight: 600;
  font-size: 15px; color: var(--text-bright); letter-spacing: -0.01em;
  margin-bottom: 14px;
}

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 760px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

/* ══════════ FORMS ══════════ */
label {
  display: block;
  font-size: 12.5px; font-weight: 600;
  color: var(--text); margin-bottom: 5px;
}
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border-soft); border-radius: 8px;
  font-size: 14px; font-family: 'Barlow', sans-serif;
  background: #fff; color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(40, 171, 131, 0.12);
}
textarea { resize: vertical; min-height: 72px; line-height: 1.55; }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; line-height: 1.5; }

/* ══════════ BUTTONS ══════════ */
button.btn {
  font-family: 'Barlow', sans-serif;
  background: var(--green); color: #fff;
  border: none; border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 4px var(--green-glow);
}
button.btn:hover { background: var(--green-bright); box-shadow: 0 3px 12px var(--green-glow); }
button.btn:disabled { opacity: 0.55; cursor: default; box-shadow: none; }
button.btn.secondary {
  background: #fff; color: var(--text);
  border: 1px solid var(--border-soft); box-shadow: none;
}
button.btn.secondary:hover { border-color: var(--text-dim); background: #fff; color: var(--text-bright); }
button.btn.small { padding: 6px 12px; font-size: 13px; }
button.btn.danger { background: var(--danger); box-shadow: none; }
button.btn.danger:hover { background: #991b1b; }

/* ══════════ TABLES ══════════ */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-dim);
  padding: 9px 10px; border-bottom: 1px solid var(--border);
}
td { padding: 12px 10px; border-bottom: 1px solid rgba(30, 45, 60, 0.06); vertical-align: middle; }
tr:hover td { background: rgba(40, 171, 131, 0.03); }
td strong { color: var(--text-bright); font-weight: 600; }

/* ══════════ BADGES ══════════ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; }
.badge.green { background: rgba(40, 171, 131, 0.1); color: var(--green-deep); border: 1px solid rgba(40, 171, 131, 0.3); }
.badge.green::before { background: var(--green-bright); box-shadow: 0 0 6px var(--green-bright); animation: pulse 2.2s infinite; }
.badge.gray { background: rgba(50, 53, 71, 0.06); color: var(--text-dim); border: 1px solid rgba(50, 53, 71, 0.14); }
.badge.gray::before { background: var(--text-dim); }
.badge.amber { background: rgba(217, 119, 6, 0.09); color: var(--amber); border: 1px solid rgba(217, 119, 6, 0.35); }
.badge.amber::before { background: var(--amber-bright); box-shadow: 0 0 6px var(--amber-bright); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

/* ══════════ TABS ══════════ */
.tabs { display: flex; gap: 2px; margin-bottom: 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs button {
  font-family: 'Barlow', sans-serif;
  background: none; border: none;
  padding: 10px 16px;
  font-size: 14px; font-weight: 600;
  color: var(--text-dim); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.15s ease;
}
.tabs button:hover { color: var(--text-bright); }
.tabs button.active { color: var(--green-deep); border-bottom-color: var(--green); }

/* ══════════ MESSAGES / MISC ══════════ */
.msg { padding: 11px 15px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; display: none; }
.msg.err { background: #fee2e2; color: var(--danger); border: 1px solid rgba(185, 28, 28, 0.2); display: block; }
.msg.ok { background: rgba(40, 171, 131, 0.09); color: var(--green-deep); border: 1px solid rgba(40, 171, 131, 0.28); display: block; }

.count { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--text-dim); }
.count.over { color: var(--danger); font-weight: 600; }

pre.release {
  white-space: pre-wrap; font-family: Georgia, serif; font-size: 14.5px; line-height: 1.7;
  background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 22px; color: var(--text);
}

.spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite;
  vertical-align: -2px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════ LOGIN (keeps the hub look) ══════════ */
.login-wrap { position: relative; z-index: 2; display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: linear-gradient(160deg, #ffffff 0%, var(--green-lighter) 100%);
  border: 1px solid rgba(40, 171, 131, 0.35);
  border-radius: 16px;
  padding: 40px 36px;
  width: 400px; max-width: 100%;
  box-shadow: 0 0 0 1px rgba(40, 171, 131, 0.1), 0 24px 60px rgba(20, 60, 50, 0.14);
  text-align: center;
}
.login-card .login-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--green-bright);
  background: rgba(40, 171, 131, 0.07);
  border: 1px solid rgba(40, 171, 131, 0.22);
  padding: 5px 12px; border-radius: 4px;
  margin-bottom: 18px;
}
.login-card .login-eyebrow::before { content: '◆'; font-size: 8px; }
.login-card h1 {
  font-family: 'Poppins', sans-serif; font-weight: 800;
  font-size: 24px; letter-spacing: -0.02em; color: var(--text-bright);
  margin-bottom: 6px;
}
.login-card h1 em { font-style: normal; color: var(--green-bright); }
.login-card .sub { color: var(--text-dim); font-size: 13px; margin-bottom: 26px; }
.login-card form { text-align: left; }

/* ══════════ DASHBOARD TOOL CARDS ══════════ */
.hero { padding: 4px 0 22px; }
.hero h1 {
  font-family: 'Poppins', sans-serif; font-weight: 700;
  font-size: 26px; letter-spacing: -0.02em; color: var(--text-bright);
}
.hero h1 em { font-style: normal; color: var(--green-bright); }
.hero .hero-desc { font-size: 14px; color: var(--text-dim); margin-top: 6px; line-height: 1.65; max-width: 560px; }

.module-tile, .tool-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-decoration: none; color: inherit;
  box-shadow: 0 1px 3px var(--shadow-deep);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.module-tile:hover, .tool-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: rgba(40, 171, 131, 0.45);
  box-shadow: 0 8px 24px var(--shadow-deep), 0 0 0 1px rgba(40, 171, 131, 0.12);
}
.tool-card-head { display: flex; align-items: center; gap: 13px; margin-bottom: 10px; }
.tool-card-icon {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 10px;
  background: var(--green-lighter);
  border: 1px solid rgba(40, 171, 131, 0.25);
  display: flex; align-items: center; justify-content: center;
  color: var(--green-bright);
}
.tool-card-icon svg { width: 21px; height: 21px; }
.module-tile h3, .tool-card-title {
  font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 14.5px;
  color: var(--text-bright); letter-spacing: -0.01em; margin-bottom: 3px;
}
.tool-card-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--green-deep);
}
.tool-card-tag::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--green-bright); }
.module-tile p, .tool-card-desc { font-size: 13px; color: var(--text-dim); line-height: 1.55; }

.section-divider { display: flex; align-items: center; gap: 14px; margin: 30px 0 16px; }
.section-divider::before, .section-divider::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--grid-line-strong), transparent);
}
.section-divider span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 500; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--text-dim); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px;
}
.section-divider span::before { content: '◇'; font-size: 9px; }

/* legacy .topbar kept as a no-crash fallback for any stale markup */
.topbar { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
