/* ============================================================================
   Maffei Labs Webapp — Brand aligned with maffeilabs.it (Step 16 Sprint 3 v2)
   Light theme, oro #B8860B accent, Bricolage Grotesque display + Instrument Serif
   italic + Inter body. Coerente con la vetrina.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wdth,wght@12..96,75..100,400..700&family=Instrument+Serif:ital@0;1&family=Inter:wght@400;500;600&display=swap');

:root {
  /* === BRAND (vetrina maffeilabs.it identica) === */
  --bg:          #ffffff;
  --bg-alt:      #f5f5f5;
  --bg-card:     #ffffff;
  --bg-hover:    #f0f0f0;
  --bg-input:    #ffffff;

  --fg:          #111111;
  --fg-dim:      #616161;
  --fg-faint:    #8a8a8a;
  --fg-on-accent: #ffffff;

  --rule:        #e6e6e6;
  --rule-strong: #d0d0d0;

  --accent:        #B8860B;  /* dark goldenrod, oro studio */
  --accent-hover:  #8a6608;
  --accent-bright: #FFD21A;
  --accent-soft:   rgba(184, 134, 11, 0.10);
  --accent-glow:   rgba(255, 210, 26, 0.15);

  /* Semantic (desaturati italian heritage) */
  --success:    #2E7D5A;
  --success-bg: rgba(46, 125, 90, 0.08);
  --warning:    #B8860B;
  --warning-bg: rgba(184, 134, 11, 0.08);
  --error:      #B83A3A;
  --error-bg:   rgba(184, 58, 58, 0.08);
  --info:       #3A6FB8;
  --info-bg:    rgba(58, 111, 184, 0.08);

  /* Typography (vetrina identica) */
  --serif:   "Instrument Serif", "Charter", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans:    "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
  --mono:    ui-monospace, "SF Mono", "JetBrains Mono", Consolas, monospace;

  /* Spacing 4px-based */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;  --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px;  --space-10: 40px;
  --space-12: 48px; --space-16: 64px; --space-20: 80px;

  /* Radius (sobrie, leggermente squadrate come vetrina) */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full: 9999px;

  /* Shadow (delicate, light theme) */
  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg:  0 16px 40px rgba(0, 0, 0, 0.10);
  --shadow-focus: 0 0 0 3px var(--accent-glow);

  /* Layout */
  --sidebar-width: 280px;
  --messages-max:  920px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.muted { color: var(--fg-dim); }
.small { font-size: 0.8125rem; }
.error { color: var(--error); margin: 0; }

em.serif-em {
  font-family: var(--serif);
  font-style: italic;
  color: var(--accent);
  font-weight: 400;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
button { cursor: pointer; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

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

/* ============================================================================
   LOGO + BRAND
   ============================================================================ */
.logo-wordmark {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.logo-wordmark .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}

.brand-tagline {
  font-family: var(--serif);
  font-style: italic;
  color: var(--fg-dim);
  font-size: 0.85rem;
  letter-spacing: 0.01em;
}

/* ============================================================================
   LOGIN PAGE
   ============================================================================ */
.page-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background:
    radial-gradient(ellipse at top, var(--accent-glow), transparent 60%),
    var(--bg);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: var(--space-10) var(--space-8);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.brand {
  text-align: center;
  margin-bottom: var(--space-8);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}
.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.625rem;
  letter-spacing: -0.025em;
  color: var(--fg);
}
.brand h1 em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
}
.brand .muted { font-size: 0.875rem; }

.form { display: flex; flex-direction: column; gap: var(--space-4); }
.form label {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: 0.8125rem;
  color: var(--fg-dim);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.form input {
  background: var(--bg-input);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  outline: none;
  color: var(--fg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form input::placeholder { color: var(--fg-faint); }
.form input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn-primary {
  background: var(--fg);
  color: var(--bg);
  border: 1px solid var(--fg);
  padding: 11px 20px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9375rem;
  letter-spacing: 0.01em;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  color: var(--fg);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s;
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}
.btn-full { width: 100%; }

.btn-link {
  background: transparent;
  border: none;
  color: var(--fg-dim);
  padding: var(--space-1) 0;
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: left;
}
.btn-link:hover { color: var(--accent); }

.btn-icon {
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  color: var(--fg-dim);
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: border-color 0.15s, color 0.15s;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

footer.muted {
  text-align: center;
  margin-top: var(--space-6);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

/* ============================================================================
   CHAT PAGE LAYOUT
   ============================================================================ */
.page-chat {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* ============================================================================
   SIDEBAR
   ============================================================================ */
.sidebar {
  background: var(--bg-alt);
  border-right: 1px solid var(--rule);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}

.sidebar-header {
  padding: var(--space-5) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sessions-list {
  overflow-y: auto;
  padding: var(--space-2) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.session-group-header {
  font-family: var(--sans);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
  padding: var(--space-3) var(--space-3) var(--space-1);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--bg-alt);
}

.session-item {
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--fg);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.12s;
}
.session-item:hover { background: var(--bg-hover); }
.session-item.active {
  background: var(--accent-soft);
}
.session-title {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg);
}
.session-item:not(.active) .session-title { color: var(--fg-dim); }
.session-meta { font-size: 0.6875rem; color: var(--fg-faint); }

.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#userLabel {
  font-size: 0.8125rem;
  color: var(--fg-dim);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 4px;
}

/* ============================================================================
   CHAT MAIN
   ============================================================================ */
.chat-main {
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
  min-height: 0;
  background: var(--bg);
}

.messages {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-8) var(--space-6) var(--space-4);
  max-width: var(--messages-max);
  margin: 0 auto;
  width: 100%;
}

/* === Empty state — hero === */
.empty-state {
  margin: auto;
  text-align: center;
  padding: var(--space-12) var(--space-6);
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}
.empty-title {
  font-family: var(--display);
  font-size: 2.5rem;
  font-weight: 500;
  letter-spacing: -0.025em;
  color: var(--fg);
  line-height: 1.1;
}
.empty-title em {
  font-family: var(--serif);
  font-style: italic;
  color: var(--accent);
  font-weight: 400;
}
.empty-sub {
  font-size: 1.0625rem;
  color: var(--fg-dim);
  max-width: 480px;
  line-height: 1.55;
}

/* === Messages === */
.msg {
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  max-width: 78%;
  white-space: pre-wrap;
  line-height: 1.65;
  word-wrap: break-word;
  font-size: 0.9375rem;
  margin-top: var(--space-3);
}

.msg.user {
  align-self: flex-end;
  background: var(--fg);
  color: var(--bg);
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--bg-alt);
  border: 1px solid var(--rule);
  color: var(--fg);
  border-bottom-left-radius: 4px;
}

.msg-meta {
  font-size: 0.6875rem;
  color: var(--fg-faint);
  padding: 0 var(--space-2);
  margin-top: 4px;
  margin-bottom: 0;
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.msg.user + .msg-meta { align-self: flex-end; text-align: right; }
.msg.assistant + .msg-meta { align-self: flex-start; }

/* Thinking indicator (no loading abstratti, frase semantica + bar pulse oro) */
.thinking {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--serif);
  font-style: italic;
  color: var(--fg-dim);
  font-size: 0.875rem;
}
.thinking .dots { display: inline-flex; gap: 3px; align-items: end; height: 12px; }
.thinking .dots i {
  width: 3px; background: var(--accent);
  border-radius: 1px;
  display: inline-block;
  animation: thinkBar 1s ease-in-out infinite;
}
.thinking .dots i:nth-child(2) { animation-delay: 0.15s; }
.thinking .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes thinkBar {
  0%, 100% { height: 3px; }
  50% { height: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .thinking .dots i { animation: none; height: 6px; opacity: 0.6; }
}

/* ============================================================================
   COMPOSER
   ============================================================================ */
.composer {
  border-top: 1px solid var(--rule);
  background: var(--bg);
  padding: var(--space-4) var(--space-6) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: var(--messages-max);
  margin: 0 auto;
  width: 100%;
}

.composer textarea {
  background: var(--bg-alt);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  resize: none;
  min-height: 64px;
  max-height: 220px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--fg);
  font-family: var(--sans);
}
.composer textarea::placeholder { color: var(--fg-faint); }
.composer textarea:focus {
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.composer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}

.composer-actions-left,
.composer-actions-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.composer-row select {
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 0.8125rem;
  color: var(--fg-dim);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.composer-row select:hover {
  border-color: var(--accent);
  color: var(--fg);
}

/* ============================================================================
   ATTACHMENTS
   ============================================================================ */
.attachments-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-alt);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 0.8125rem;
  color: var(--fg);
}
.attachment-chip .att-icon { font-size: 1.05rem; }
.attachment-chip .att-name {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip .att-size { color: var(--fg-faint); }
.attachment-chip .att-remove {
  background: transparent;
  border: none;
  color: var(--fg-faint);
  font-size: 1.2rem;
  padding: 0 4px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.attachment-chip .att-remove:hover { color: var(--error); }

/* === Drop overlay === */
.drop-overlay {
  position: fixed; inset: 0;
  background: rgba(255, 255, 255, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.drop-overlay.active { display: flex; }

.drop-card {
  border: 2px dashed var(--accent);
  background: var(--bg);
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-16);
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.drop-title {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin-bottom: var(--space-2);
  color: var(--fg);
}
.drop-sub { color: var(--fg-dim); font-size: 0.875rem; }

/* ============================================================================
   DIALOG
   ============================================================================ */
dialog {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  color: var(--fg);
  padding: var(--space-8);
  max-width: 460px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
dialog h2 {
  margin-top: 0;
  margin-bottom: var(--space-4);
  font-family: var(--display);
  font-size: 1.375rem;
  font-weight: 500;
  letter-spacing: -0.015em;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

/* ============================================================================
   TOAST
   ============================================================================ */
.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-left: 3px solid var(--info);
  color: var(--fg);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 9998;
  max-width: 420px;
  font-size: 0.9rem;
  animation: toastSlide 0.2s var(--ease);
}
@keyframes toastSlide {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
.toast.info { border-left-color: var(--info); }

/* ============================================================================
   SKELETONS
   ============================================================================ */
.skel {
  background: linear-gradient(90deg, var(--bg-alt) 0%, var(--bg-hover) 50%, var(--bg-alt) 100%);
  background-size: 200% 100%;
  animation: skelShimmer 1.4s linear infinite;
  border-radius: var(--radius-sm);
}
@keyframes skelShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; opacity: 0.4; }
}

/* ============================================================================
   MOBILE RESPONSIVE
   ============================================================================ */
@media (max-width: 768px) {
  .page-chat {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .composer, .messages {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
  .empty-title { font-size: 2rem; }
}

/* === Logo star (stessa stella della vetrina) === */
.brand-star {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(184, 134, 11, 0.18));
  transition: transform 0.35s var(--ease);
}
.brand-star:hover {
  transform: rotate(8deg) scale(1.05);
}
.brand-star-sm {
  width: 32px;
  height: 32px;
}
.empty-star {
  width: 72px;
  height: 72px;
  margin-bottom: var(--space-2);
  filter: drop-shadow(0 4px 8px rgba(184, 134, 11, 0.16));
  animation: starBob 4s ease-in-out infinite;
}
@keyframes starBob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}
@media (prefers-reduced-motion: reduce) {
  .empty-star { animation: none; }
}
.drop-star {
  width: 88px;
  height: 88px;
  margin-bottom: var(--space-3);
  filter: drop-shadow(0 6px 12px rgba(184, 134, 11, 0.20));
}

/* Sidebar brand layout (logo + wordmark + tagline) */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.sidebar-brand .brand-tagline {
  margin-top: 2px;
}

/* ============================================================================
   STEP 16 — Pagine secondarie (profile/settings/admin/agent-mind)
   ============================================================================ */

.page-app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar-spacer { flex: 1; }

.app-main {
  overflow-y: auto;
  padding: var(--space-10) var(--space-10) var(--space-12);
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.app-header { margin-bottom: var(--space-10); }
.display-title {
  font-family: var(--display);
  font-size: 2.5rem;
  font-weight: 500;
  letter-spacing: -0.025em;
  margin: 0 0 var(--space-2);
  color: var(--fg);
}

/* Page nav nella sidebar */
.page-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--space-3);
}
.page-nav-link {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--fg-dim);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.page-nav-link:hover { background: var(--bg-hover); color: var(--fg); }
.page-nav-link.active { background: var(--accent-soft); color: var(--fg); font-weight: 500; }

/* Card sections */
.card-section {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  margin-bottom: var(--space-6);
}
.section-title {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin: 0 0 var(--space-2);
}
.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

/* Form grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-top: var(--space-4);
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: 0.8125rem;
  color: var(--fg-dim);
}
.form-grid input {
  background: var(--bg-input);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  padding: 10px 13px;
  color: var(--fg);
  font-size: 0.9rem;
}
.form-grid input:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-focus); }
.form-grid input:disabled { background: var(--bg-alt); color: var(--fg-dim); }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* Radio cards */
.radio-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
}
.radio-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.radio-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.radio-card input { margin-top: 4px; accent-color: var(--accent); }
.radio-card strong { display: block; margin-bottom: 2px; font-size: 0.9375rem; }

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-3);
  font-size: 0.9rem;
}
.table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-faint);
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  font-weight: 600;
}
.table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.table tbody tr:hover { background: var(--bg-alt); }
.user-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--space-6);
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 12px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
}
.tab-btn:hover { color: var(--fg); }
.tab-btn.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.stat-card {
  background: var(--bg-alt);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
}
.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-faint);
  margin-bottom: var(--space-2);
}
.stat-value {
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--fg);
}

/* Memory cards */
.memories-list { display: flex; flex-direction: column; gap: var(--space-3); }
.memory-card {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  transition: border-color 0.12s;
}
.memory-card:hover { border-color: var(--accent); }
.memory-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}
.memory-category {
  background: var(--accent-soft);
  color: var(--accent-hover);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.memory-content { color: var(--fg); line-height: 1.55; }
.memory-actions { margin-top: var(--space-3); display: flex; justify-content: flex-end; }

.empty-info {
  padding: var(--space-8);
  text-align: center;
  background: var(--bg-alt);
  border-radius: var(--radius-md);
  border: 1px dashed var(--rule-strong);
}

/* Feedback buttons (sotto risposte assistant) */
.feedback-row {
  align-self: flex-start;
  display: flex;
  gap: var(--space-2);
  padding: 0 var(--space-2);
  margin-top: 4px;
  margin-bottom: var(--space-3);
  opacity: 0.4;
  transition: opacity 0.18s;
}
.feedback-row:hover, .feedback-row:focus-within { opacity: 1; }
.feedback-row.submitted { opacity: 1; }
.fb-btn {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--fg-dim);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.fb-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Password show box (admin temp password) */
.pwd-show-box {
  font-family: var(--mono);
  font-size: 1.25rem;
  background: var(--bg-alt);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
  letter-spacing: 0.05em;
  user-select: all;
  margin: var(--space-3) 0;
}

/* Dark theme via data-theme */
:root[data-theme="dark"] {
  --bg: #0E1116;
  --bg-alt: #161A21;
  --bg-card: #161A21;
  --bg-hover: #1E232C;
  --bg-input: #1E232C;
  --fg: #E8EAED;
  --fg-dim: #A8B0BB;
  --fg-faint: #6B7280;
  --rule: #232932;
  --rule-strong: #2F3742;
}

@media (max-width: 768px) {
  .page-app { grid-template-columns: 1fr; }
  .page-app .sidebar { display: none; }
  .app-main { padding: var(--space-4); }
  .display-title { font-size: 1.875rem; }
}
