/* SpecGen - design system (nessun framework, nessun build step) */

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e4e8f0;
  --text: #131a2a;
  --text-soft: #5b6474;
  --text-faint: #8b93a5;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0fe;
  --success: #0e9f6e;
  --success-soft: #e3f6ef;
  --warn: #b7791f;
  --warn-soft: #fdf3e3;
  --danger: #d64545;
  --danger-soft: #fdecec;
  --info-soft: #e5f0fd;
  --info: #2570c0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --sidebar-bg: #101427;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  color: #cdd3e0;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 10px 22px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .5px;
  flex: none;
}

.brand-name { font-weight: 700; color: #fff; font-size: 16px; letter-spacing: .2px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: #aab2c5;
  font-weight: 500;
  font-size: 13.5px;
  transition: background .15s, color .15s;
}

.nav a svg { width: 17px; height: 17px; opacity: .8; }

.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }

.nav a.is-active { background: rgba(99, 102, 241, .22); color: #fff; }

.sidebar-footer { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 14px; }

.user-chip { display: flex; gap: 10px; align-items: center; padding: 4px 8px 10px; }

.avatar {
  width: 32px; height: 32px; flex: none;
  border-radius: 50%;
  background: rgba(99, 102, 241, .35);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}

.user-meta { display: flex; flex-direction: column; min-width: 0; }

.user-name { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.user-email { color: #7c869c; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.logout { display: block; text-align: center; padding: 7px; border-radius: var(--radius-sm); color: #8b93a5; font-size: 12.5px; }
.logout:hover { background: rgba(255, 255, 255, .06); color: #fff; }

.content { padding: 30px 36px 60px; max-width: 1200px; }

/* ---------- flash ---------- */

.flash-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }

.flash {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
}

.flash-success { background: var(--success-soft); color: #067a53; border-color: #bfe8d7; }
.flash-error { background: var(--danger-soft); color: #a03030; border-color: #f3c8c8; }
.flash-info { background: var(--info-soft); color: #1c5da0; border-color: #c5ddf8; }

.plain-list { margin: 0; padding-left: 18px; }

/* ---------- page ---------- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.page-head h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }

.page-sub { margin: 0; color: var(--text-soft); font-size: 13.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.head-actions { display: flex; gap: 10px; align-items: center; }

.crumbs { display: flex; gap: 7px; font-size: 12.5px; color: var(--text-faint); margin-bottom: 4px; }

.muted { color: var(--text-faint); }

.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 22px;
}

.card-danger { border-color: #f3c8c8; background: #fff7f7; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}

.card-head h2 { margin: 0; font-size: 15px; letter-spacing: .01em; }

.link { font-size: 13px; font-weight: 500; }

.section-sub { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin: 18px 0 6px; }

/* ---------- stats ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label { color: var(--text-soft); font-size: 12.5px; font-weight: 500; }

.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }

/* ---------- table ---------- */

.table { width: 100%; border-collapse: collapse; }

.table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }

.table tr:last-child td { border-bottom: none; }

.table-flush th, .table-flush td { padding: 8px 0; }

.row-title { font-weight: 600; color: var(--text); display: block; }
.row-title:hover { color: var(--accent); }

.row-sub { display: block; color: var(--text-faint); font-size: 12px; margin-top: 1px; }

.cell-actions { text-align: right; white-space: nowrap; }

/* ---------- badges ---------- */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-neutral { background: #eef0f5; color: var(--text-soft); }
.badge-success { background: var(--success-soft); color: #067a53; }
.badge-warn { background: var(--warn-soft); color: #8a5a12; }
.badge-danger { background: var(--danger-soft); color: #a03030; }
.badge-info { background: var(--info-soft); color: #1c5da0; }

/* ---------- forms ---------- */

.field { display: block; margin-bottom: 16px; }

.field > span:first-child {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field-hint { display: block; font-size: 12px; color: var(--text-faint); font-weight: 400 !important; margin-top: 6px; }

input[type="text"], input[type="email"], input[type="password"], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #0c8a5f; color: #fff; }

.btn-ghost { background: var(--surface); color: var(--text-soft); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: #c9d0dd; }

.btn-danger-ghost { background: transparent; color: var(--danger); border-color: #f3c8c8; }
.btn-danger-ghost:hover { background: var(--danger-soft); }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-lg { padding: 12px 22px; font-size: 14.5px; }
.btn-block { width: 100%; }

/* ---------- segmented ---------- */

.segmented { display: flex; gap: 8px; margin-bottom: 18px; }

.seg-option { flex: 1; position: relative; }

.seg-option input { position: absolute; opacity: 0; }

.seg-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-soft);
  cursor: pointer;
  transition: all .15s;
}

.seg-option input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- misc ---------- */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }

.grid-2-compact { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.stack > * + * { margin-top: 0; }

.empty-state { text-align: center; padding: 44px 20px; color: var(--text-soft); }
.empty-state p { margin: 0 0 16px; }

.callout {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 22px;
}

.callout-warn { background: var(--warn-soft); color: #8a5a12; border: 1px solid #f0dcb8; }

.detail-list { margin: 0 0 8px; display: flex; flex-direction: column; gap: 10px; }
.detail-list div { display: grid; grid-template-columns: 130px 1fr; gap: 10px; }
.detail-list dt { color: var(--text-faint); font-size: 12.5px; font-weight: 600; padding-top: 1px; }
.detail-list dd { margin: 0; font-size: 13.5px; }

.prose { line-height: 1.7; }

.source-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }

.source-list a { font-weight: 600; font-size: 13.5px; }

/* ---------- admin console ---------- */

.card-active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }

.check-inline {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-soft);
  margin: 8px 0 0;
}

.check-inline input { width: auto; margin: 0; }

.admin-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.spaced li { margin-bottom: 8px; }

.callout-info { background: var(--accent-soft); border: 1px solid #d9defb; color: #3f3a9e; }

/* ---------- auth ---------- */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(99, 102, 241, .14), transparent),
    radial-gradient(800px 400px at -10% 110%, rgba(139, 92, 246, .1), transparent),
    var(--bg);
}

.auth-wrap { width: 100%; max-width: 400px; padding: 24px; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(16, 24, 40, .1);
  padding: 34px 32px;
}

.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-weight: 700; }

.auth-card h1 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.01em; }

.auth-sub { margin: 0 0 20px; color: var(--text-soft); font-size: 13.5px; }

.auth-alt { margin: 18px 0 0; text-align: center; color: var(--text-soft); font-size: 13px; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; }
  .brand { padding-bottom: 6px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-footer { border-top: none; padding-top: 0; margin-left: auto; }
  .grid-2, .grid-2-compact, .stat-grid { grid-template-columns: 1fr; }
  .content { padding: 20px; }
  .page-head { flex-direction: column; }
}
