:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-alt: #f0f2f7;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e4e7ee;
  --primary: #0a0a0a;
  --primary-contrast: #ffffff;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 1px rgba(15,23,42,.03);
  --shadow: 0 8px 24px rgba(15, 23, 42, .06), 0 2px 6px rgba(15, 23, 42, .04);
  --max: 1160px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; display: block; }

.container { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 720px; margin: 0 auto; padding: 0 24px; }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; color: var(--text); margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 2.5vw, 2.25rem); letter-spacing: -0.015em; }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1em; color: var(--text); }
.lead { font-size: 1.15rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- NAV ---------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { font-weight: 800; font-size: 1.1rem; letter-spacing: -.02em; color: var(--text); display: flex; align-items: center; gap: .6rem; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #0f172a, #334155);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: .75rem;
}
.nav-links { display: flex; gap: 6px; align-items: center; }
.nav-links a { padding: 8px 14px; color: var(--text); font-weight: 500; border-radius: 8px; font-size: .95rem; }
.nav-links a:hover { background: var(--surface-alt); color: var(--text); }
.nav-toggle { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: 11px 20px; border-radius: 10px; font-weight: 600; font-size: .95rem;
  border: 1px solid transparent; cursor: pointer; transition: all .15s ease;
  text-decoration: none; line-height: 1;
}
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: #1f2937; color: #fff; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--text); color: var(--text); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-sm { padding: 7px 14px; font-size: .85rem; }

/* ---------- HERO ---------- */
.hero {
  padding: 96px 0 72px;
  background:
    radial-gradient(1000px 400px at 90% -10%, rgba(37,99,235,.12), transparent 70%),
    radial-gradient(900px 500px at -10% 20%, rgba(16,185,129,.08), transparent 70%),
    var(--bg);
}
.hero h1 { margin-bottom: .4em; }
.hero-sub { font-size: 1.2rem; color: var(--muted); max-width: 620px; margin: 0 0 2rem; }
.hero-ctas { display: flex; gap: 12px; flex-wrap: wrap; }
.kicker {
  display: inline-block; padding: 5px 12px; font-size: .78rem; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--muted); margin-bottom: 1.25rem;
}

/* ---------- SECTIONS ---------- */
.section { padding: 72px 0; }
.section-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-head { text-align: center; max-width: 680px; margin: 0 auto 48px; }
.section-head .lead { margin-top: .6rem; }

/* ---------- GRIDS / CARDS ---------- */
.grid { display: grid; gap: 24px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .nav-links.open { display: flex; position: absolute; top: 68px; left: 0; right: 0; flex-direction: column; background: #fff; border-bottom: 1px solid var(--border); padding: 12px; }
  .nav-toggle { display: inline-flex; }
  .hero { padding: 64px 0 48px; }
  .section { padding: 56px 0; }
}

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d6dae3; }
.card h3 { margin-top: 12px; }
.card-icon {
  width: 44px; height: 44px; border-radius: 10px; background: var(--surface-alt);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem;
}

/* ---------- BLOG ---------- */
.post-card { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.post-card .cover { aspect-ratio: 16/9; background: var(--surface-alt); overflow: hidden; }
.post-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.post-card .body { padding: 24px; }
.post-card h3 { margin: 6px 0 8px; }
.post-card .meta { color: var(--muted); font-size: .85rem; }

.prose { max-width: 760px; margin: 0 auto; }
.prose h2 { margin-top: 1.8em; }
.prose h3 { margin-top: 1.4em; }
.prose p, .prose ul, .prose ol { font-size: 1.05rem; }
.prose img { border-radius: var(--radius-sm); margin: 1.5em 0; }

/* ---------- FORMS ---------- */
.form { display: grid; gap: 14px; max-width: 560px; }
.input, input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date], input[type=datetime-local], input[type=tel], select, textarea {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-family: inherit; font-size: .95rem;
  background: #fff; color: var(--text); transition: border-color .12s, box-shadow .12s;
}
.input:focus, input:focus, select:focus, textarea:focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { min-height: 110px; resize: vertical; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field .help, .helptext, .form small { display: block; color: var(--muted); font-size: .8rem; margin-top: 4px; }
.errorlist { list-style: none; padding: 0; margin: 6px 0 0; color: var(--danger); font-size: .85rem; }

/* ---------- MESSAGES ---------- */
.messages { margin: 18px 0; display: grid; gap: 8px; }
.msg { padding: 10px 14px; border-radius: var(--radius-sm); font-size: .92rem; border: 1px solid; }
.msg.success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.msg.error, .msg.warning { background: #fff1f2; border-color: #fecdd3; color: #9f1239; }
.msg.info, .msg.debug { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* ---------- FOOTER ---------- */
.footer { background: #0a0a0a; color: #d4d4d8; margin-top: 80px; padding: 56px 0 28px; }
.footer a { color: #d4d4d8; }
.footer a:hover { color: #fff; }
.footer h4 { color: #fff; font-size: .95rem; margin-bottom: 14px; }
.footer .grid { gap: 40px; }
.footer .bottom { border-top: 1px solid #262626; margin-top: 40px; padding-top: 20px; font-size: .85rem; color: #a1a1aa; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* ---------- PORTAL / CMS LAYOUT ---------- */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: #0a0a0a; color: #e5e7eb; padding: 24px 16px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { color: #fff; margin-bottom: 28px; padding: 0 8px; }
.sidebar .brand-mark { background: linear-gradient(135deg, #fff, #cbd5e1); color: #0a0a0a; }
.sidebar-section { color: #6b7280; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 6px; }
.sidebar a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: #d4d4d8; font-size: .92rem; font-weight: 500;
}
.sidebar a:hover { background: #171717; color: #fff; }
.sidebar a.active { background: #262626; color: #fff; }
.sidebar .logout { margin-top: auto; }

.app-main { padding: 28px 40px 80px; min-width: 0; }
.app-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; flex-wrap: wrap; gap: 12px; }
.app-header h1 { font-size: 1.75rem; margin: 0; }
.app-header .sub { color: var(--muted); margin-top: 2px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar-nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar-section { display: none; }
  .app-main { padding: 20px; }
}

/* ---------- STATS ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat .label { color: var(--muted); font-size: .82rem; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.75rem; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }

/* ---------- TABLE ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.panel-head h2 { font-size: 1.05rem; margin: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 14px 22px; font-size: .92rem; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-alt); }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafbfc; }
.empty { padding: 40px 22px; text-align: center; color: var(--muted); }

.actions { display: flex; gap: 8px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-muted { background: var(--surface-alt); color: var(--muted); }

/* reveal toggle for credentials */
.reveal { cursor: pointer; user-select: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.reveal[data-hidden="true"] { letter-spacing: .15em; }
