:root {
  --crimson: #80153B;
  --ruby: #B82453;
  --on-brand: #FFFFFF;

  --bg: #FFFFFF;
  --fg: #1A1D20;
  --fg-soft: #3A4048;
  --muted: #5F6670;
  --placeholder: #9AA0A8;
  --line: #E1E3E8;
  --surface: #F4F5F7;
  --card: #FFFFFF;
  --accent: #80153B;        /* testo/dettagli in colore brand */
  --logo: #80153B;
  --pattern: rgba(128, 21, 59, .09);
  --shadow: 0 1px 2px rgba(26, 29, 32, .08), 0 8px 24px rgba(26, 29, 32, .10);
  --hover-shadow: 0 1px 6px rgba(26, 29, 32, .12);

  --sans: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 8px;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121417;
  --fg: #E8EAED;
  --fg-soft: #C4C8CE;
  --muted: #9AA0A8;
  --placeholder: #6B727B;
  --line: #2A2F35;
  --surface: #1A1D20;
  --card: #1E2125;
  --accent: #E0587F;
  --logo: #B82453;
  --pattern: rgba(224, 88, 127, .13);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .45);
  --hover-shadow: 0 1px 8px rgba(0, 0, 0, .5);

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; background: var(--bg); }
body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 400 15px/1.55 var(--sans);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; }
a { color: inherit; }

:focus-visible { outline: 2px solid var(--ruby); outline-offset: 2px; }

/* Logo colorato via CSS, così segue il tema */
.logo {
  display: inline-block;
  aspect-ratio: 2048 / 1712;
  background: var(--logo);
  -webkit-mask: url(/assets/dm.svg) center / contain no-repeat;
  mask: url(/assets/dm.svg) center / contain no-repeat;
}

/* --- Bottoni ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: 600 14px/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--crimson); color: var(--on-brand); }
.btn-primary:hover { background: var(--ruby); }
.btn-surface { background: var(--surface); color: var(--fg); font-weight: 500; }
.btn-surface:hover { border-color: var(--line); }
.btn-outline { background: var(--card); border-color: var(--line); color: var(--accent); }
.btn-outline:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--fg); font-weight: 500; }
.btn-ghost:hover { background: var(--surface); }
.btn-block { width: 100%; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--surface); color: var(--fg); }

.theme-btn svg { display: none; }
:root[data-theme-mode="light"] .theme-btn .i-light,
:root[data-theme-mode="dark"] .theme-btn .i-dark,
:root[data-theme-mode="auto"] .theme-btn .i-auto { display: block; }

.theme-panel { width: 170px; padding: 6px; display: grid; gap: 2px; }
.theme-panel button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--fg);
  font: 500 14px var(--sans);
  text-align: left;
  cursor: pointer;
}
.theme-panel button:hover { background: var(--surface); }
.theme-panel button[aria-checked="true"] { color: var(--accent); }
.theme-panel button[aria-checked="true"]::after { content: '✓'; font-weight: 700; }

/* --- Topbar ------------------------------------------------------------- */

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  min-height: 60px;
}
.topbar-links { display: flex; gap: 20px; font-size: 13px; }
.topbar-links a { text-decoration: none; color: var(--muted); }
.topbar-links a:hover { color: var(--fg); text-decoration: underline; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.menu { position: relative; }

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-left: 4px;
  border: 0;
  border-radius: 50%;
  background: var(--crimson);
  color: var(--on-brand);
  font: 600 13px/1 var(--sans);
  letter-spacing: .02em;
  cursor: pointer;
}
button.avatar:hover, button.avatar[aria-expanded="true"] { box-shadow: 0 0 0 4px var(--surface); }
.avatar-lg { width: 48px; height: 48px; margin: 0; font-size: 17px; cursor: default; flex: none; }

/* --- Pannelli a tendina ------------------------------------------------- */

.panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.apps-panel { width: 340px; max-width: calc(100vw - 24px); }
.apps-grid {
  list-style: none;
  margin: 0;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  max-height: min(460px, 70vh);
  overflow-x: hidden;
  overflow-y: auto;
}
.apps-grid a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 6px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  text-align: center;
  font-size: 13px;
  line-height: 1.25;
}
.apps-grid a { position: relative; }
.apps-grid a:hover { background: var(--surface); }
.apps-grid .dot { position: absolute; top: 12px; right: 18px; }
.apps-grid img { width: 48px; height: 48px; object-fit: contain; }
.apps-grid .app-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-letter {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: var(--bg);
  font: 600 18px/1 var(--sans);
}
.app-letter::before {
  content: '';
  position: absolute;
  inset: 2px 3px;
  background: var(--fg);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.app-letter span { position: relative; }

.apps-state { padding: 28px 24px; text-align: center; color: var(--muted); font-size: 14px; }
.apps-state .logo { display: block; width: 44px; margin: 0 auto 14px; }
.apps-state p { margin: 0 0 16px; }
.apps-state strong { display: block; color: var(--fg); font-size: 15px; margin-bottom: 4px; }

.panel-foot { border-top: 1px solid var(--line); padding: 12px; text-align: center; }
.panel-foot a { font-size: 13px; color: var(--accent); text-decoration: none; font-weight: 500; }
.panel-foot a:hover { text-decoration: underline; }

.user-panel { width: 300px; padding: 20px; display: grid; gap: 10px; }
.user-panel form { margin: 0; }
.user-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; min-width: 0; }
.user-head > div { min-width: 0; }
.user-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { font: 400 12px/1.4 var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Sfondo a nido d'ape (esagoni del logo) ----------------------------- */

.backdrop {
  position: absolute;
  inset: 0 0 auto;
  height: 100vh;
  max-height: 900px;
  z-index: 0;
  pointer-events: none;
  background: var(--pattern);
  -webkit-mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100'%3E%3Cpath d='M28 66 0 50V16L28 0l28 16v34L28 66v34M28 0v-1' fill='none' stroke='%23000' stroke-width='1'/%3E%3C/svg%3E") 0 0 / 56px 100px,
    radial-gradient(ellipse 60% 55% at 50% 42%, transparent 35%, #000 85%),
    linear-gradient(#000 55%, transparent);
  -webkit-mask-composite: source-in, source-in;
  mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100'%3E%3Cpath d='M28 66 0 50V16L28 0l28 16v34L28 66v34M28 0v-1' fill='none' stroke='%23000' stroke-width='1'/%3E%3C/svg%3E") 0 0 / 56px 100px,
    radial-gradient(ellipse 60% 55% at 50% 42%, transparent 35%, #000 85%),
    linear-gradient(#000 55%, transparent);
  mask-composite: intersect;
}

/* --- Hero / ricerca ----------------------------------------------------- */

.hero {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14vh 20px 12vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0;
  font: 700 64px/1 var(--sans);
  letter-spacing: -.035em;
  color: var(--fg);
}
.brand .logo { width: 68px; }
.brand-tag {
  margin: 12px 0 34px;
  font: 400 13px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
}

.search { width: 100%; max-width: 600px; }
.search-box {
  display: flex;
  align-items: center;
  height: 50px;
  padding: 0 8px 0 18px;
  border: 1px solid var(--line);
  border-radius: 25px;
  background: var(--card);
  transition: border-color .15s, box-shadow .15s;
}
.search-box:hover { box-shadow: var(--hover-shadow); border-color: transparent; }
.search-box:focus-within { border-color: var(--accent); box-shadow: var(--hover-shadow); }
.search-icon { color: var(--muted); flex: none; }
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  margin: 0 10px 0 12px;
  border: 0;
  outline: 0;
  background: transparent;
  font: 400 16px var(--sans);
  color: var(--fg);
}
.search input::placeholder { color: var(--placeholder); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.search-clear:hover { color: var(--fg); background: var(--surface); }
.search-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

/* --- About -------------------------------------------------------------- */

.about { position: relative; z-index: 1; background: var(--surface); border-top: 1px solid var(--line); }
.about-inner { max-width: 1040px; margin: 0 auto; padding: 72px 24px 80px; }
.eyebrow { margin: 0 0 10px; font: 500 13px/1 var(--mono); color: var(--accent); }
.about h2 { margin: 0 0 16px; font-size: 32px; line-height: 1.15; letter-spacing: -.02em; }
.lead { max-width: 640px; margin: 0 0 48px; font-size: 17px; color: var(--fg-soft); }

.pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.pillars article {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--crimson);
  border-radius: var(--radius);
  padding: 24px;
}
.pillar-n { font: 500 12px/1 var(--mono); color: var(--muted); }
.pillars h3 { margin: 12px 0 8px; font-size: 17px; }
.pillars p { margin: 0; font-size: 14px; color: var(--muted); }

/* --- Footer ------------------------------------------------------------- */

.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  color: var(--muted);
}
.footer nav { display: flex; gap: 20px; }
.footer a { text-decoration: none; }
.footer a:hover { color: var(--fg); text-decoration: underline; }

/* --- Responsive --------------------------------------------------------- */

@media (max-width: 760px) {
  .pillars { grid-template-columns: 1fr; }
  .brand { font-size: 46px; gap: 14px; }
  .brand .logo { width: 50px; }
  .hero { padding-top: 10vh; }
  .topbar-links { display: none; }
  .topbar { justify-content: flex-end; }
}

.avatar { padding: 0; background-size: cover; background-position: center; background-repeat: no-repeat; }
.avatar.has-photo { color: transparent; }

/* --- Servizi ------------------------------------------------------------ */

.services { position: relative; z-index: 1; background: var(--bg); border-top: 1px solid var(--line); }
.section-inner { max-width: 1040px; margin: 0 auto; padding: 64px 24px 72px; }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.section-head h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.section-head h2 { margin: 0; font-size: 32px; line-height: 1.15; letter-spacing: -.02em; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.status-pill:hover { border-color: var(--accent); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--placeholder); }
.dot-up { background: #1F9D55; }
.dot-down { background: #D93025; }
.dot-pending { background: #E3A008; }
.dot-maintenance { background: #3B82F6; }



.status-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.status-list li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; font-size: 14px; }
.status-list li + li { border-top: 1px solid var(--line); }
.status-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-meta { font: 400 12px/1 var(--mono); color: var(--muted); }


/* --- 404 ---------------------------------------------------------------- */

.admin-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.admin-brand .logo { width: 30px; }

.notfound {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12vh 24px 14vh;
}
.notfound-code {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
  font: 500 112px/1 var(--mono);
  color: var(--fg);
  letter-spacing: -.04em;
}
.notfound-hex {
  width: 88px;
  height: 100px;
  background: var(--crimson);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  position: relative;
}
.notfound-hex::after {
  content: '';
  position: absolute;
  inset: 22px 19px;
  background: var(--bg);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.notfound h1 { margin: 0 0 12px; font-size: 32px; letter-spacing: -.02em; }
.notfound-text { max-width: 520px; margin: 0 0 32px; color: var(--muted); }
.notfound-text code { font: 400 13px var(--mono); color: var(--accent); word-break: break-all; }
.notfound-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

@media (max-width: 760px) {
  .notfound-code { font-size: 76px; }
  .notfound-hex { width: 60px; height: 68px; }
  .notfound-hex::after { inset: 15px 13px; }
}
