:root {
  --bg-main: #000000;
  --panel: #161618;
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #ffffff;
  --muted: #8e8e93;
  --accent: #ed1b24; /* Rosso sportivo */
  --accent-dark: #cc161e;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-main);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  border-left: 1px solid #111;
  border-right: 1px solid #111;
}

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-title-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 1;
}

.top-title-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
}

.it-flag {
  display: inline-flex;
  border-radius: 2px;
  overflow: hidden;
}

.topbar-logo-ds {
  width: 24px;
  height: 24px;
  filter: brightness(0.8);
}

.topbar button.back {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 0 12px 0 0;
  display: none;
}
.topbar button.back.visible { display: block; }

/* VIEW LOGIC */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
}
.view { display: none; flex-direction: column; flex: 1; }
.view.active { display: flex; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* HOME SHIELD LOGO */
.main-logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 20px;
}
.logo-shield {
  width: 60px;
  height: 60px;
  border: 3px solid #fff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.logo-number {
  font-size: 36px;
  font-weight: 800;
  font-style: italic;
  margin-top: 5px;
}
.logo-text-proprietari {
  font-size: 12px;
  letter-spacing: 4px;
  color: #fff;
  font-weight: 600;
}

/* HOME TITLES */
.main-title {
  text-align: center;
  margin-top: 30px;
}
.main-title .brand {
  font-size: 28px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 2px;
}
.main-title .sub {
  font-size: 28px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 2px;
  color: var(--accent);
  margin-top: -5px;
}
.subtitle-red {
  color: var(--accent);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 8px;
  font-weight: 600;
}
.red-dot {
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
  margin: 15px auto 0;
}

/* HERO CAR */
.hero-photo {
  margin: 20px auto;
  text-align: center;
}
.hero-photo img {
  width: 100%;
  max-width: 320px;
}

/* HOME BUTTONS */
.home-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}
.menu-btn {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: 0.2s;
}
.menu-btn:hover { background: #1e1e20; }
.menu-icon-box {
  width: 40px;
  height: 40px;
  background: rgba(237, 27, 36, 0.1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu-icon-box .icon {
  color: var(--accent);
  font-size: 18px;
}
.menu-text h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; color: #fff; }
.menu-text p { margin: 0; font-size: 12px; color: var(--muted); }
.menu-btn .chevron { margin-left: auto; color: var(--muted); font-size: 20px; }

/* RICERCA */
.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.search-box input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.search-box input::placeholder { color: var(--muted); }
.search-icon { color: var(--muted); }

.mic-btn, .go-btn {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 16px;
}
.mic-btn.listening { background: var(--accent); color: #fff; border-color: var(--accent); }
.go-btn { background: var(--accent); color: #fff; border-color: var(--accent); }

/* CHAT AI (MANUALE) */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-bottom: 20px;
}
.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}
.chat-message.user {
  align-self: flex-end;
}
.chat-message.ai {
  align-self: flex-start;
}
.bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
}
.chat-message.user .bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-message.ai .bubble {
  background: var(--panel);
  color: #e5e5ea;
  border-bottom-left-radius: 4px;
  border: 1px solid var(--panel-border);
}
.chat-input-area {
  margin-top: auto;
  display: flex;
  gap: 8px;
  padding-top: 10px;
}
.chat-input-area .search-box { margin-bottom: 0; }

/* CATEGORIE COMANDI */
.comandi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.comandi-title {
  font-size: 16px;
  font-weight: 600;
}
.comandi-replace {
  font-size: 12px;
  color: var(--muted);
}
.section-lead {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.cat-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
}
.cat-icon { font-size: 24px; margin-bottom: 12px; }
.cat-card h4 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.cat-card span { font-size: 11px; color: var(--muted); }

/* LISTA COMANDI FORMATTATA */
.cat-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 0 4px;
}
.cat-header-row .cat-title {
  font-size: 14px;
  font-weight: 600;
}
.cat-header-row .chiudi {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.cmd-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
}
.cmd-card .cmd-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  display: block;
}
.cmd-card .cmd-phrase {
  font-size: 14px;
  color: var(--accent);
  font-weight: 600;
  display: block;
}

.show-all-btn {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--panel-border);
  color: var(--muted);
  padding: 14px;
  border-radius: var(--radius);
  margin-top: 16px;
  font-size: 13px;
  cursor: pointer;
}

/* VARIE */
.load-error { background: #3a0a0a; color: #fecaca; padding: 10px; font-size: 12px; text-align: center;}
.install-banner { background: #1c1c1e; padding: 12px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #333;}
.install-action { background: var(--accent); color: #fff; border: none; padding: 6px 12px; border-radius: 15px; font-weight: bold;}