/* Biblioteca SMP — brand SMP Tax & Legal (Brandsheet 2025)
   Urban Teal #144A64 · Light Urban Teal #9AD6E5 · Charcoal #1E1E23
   Garnet Glow #F44039 · Aluminum #F7F7F9 · Off White #FFFFFF
   Carattere: Neue Haas Grotesk (fallback locali, nessun font remoto) */
:root {
  --navy: #144A64;          /* Urban Teal */
  --navy-dark: #0E3549;     /* Urban Teal scurito (hover) */
  --teal-light: #9AD6E5;    /* Light Urban Teal */
  --teal-wash: #EAF6FA;     /* velo di Light Urban Teal per sfondi */
  --ink: #1E1E23;           /* Charcoal */
  --muted: #5A6A74;
  --line: #DDE3E8;
  --bg: #F7F7F9;            /* Aluminum */
  --panel: #FFFFFF;         /* Off White */
  --accent: #F44039;        /* Garnet Glow */
  --danger: #F44039;        /* Garnet Glow */
  --ok: #2a7a2a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Neue Haas Grotesk Display Pro', 'Neue Haas Grotesk Text Pro',
    'Neue Haas Grotesk', 'Helvetica Neue', Helvetica, Arial,
    'Segoe UI', sans-serif;
  color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45;
}
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; color: var(--navy-dark); }
h2 { font-size: 1.02rem; margin: 0 0 .6rem; }
h3 { font-size: .92rem; margin: .8rem 0 .35rem; }

/* Header: fondo Off White, logo Urban Teal, filetto teal */
.topbar {
  display: flex; align-items: center; gap: 1.2rem; padding: .5rem 1.2rem;
  background: var(--panel); color: var(--ink); flex-wrap: wrap;
  border-bottom: 3px solid var(--navy);
}
.brand { display: flex; align-items: center; gap: .6rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 40px; width: auto; display: block; }
.brand-app {
  color: var(--navy); font-size: 1rem; font-weight: 600;
  letter-spacing: .02em; text-transform: uppercase;
  border-left: 2px solid var(--teal-light); padding-left: .6rem;
}
.topsearch { flex: 1; display: flex; max-width: 620px; }
.topsearch input {
  flex: 1; padding: .42rem .7rem; border: 1px solid var(--line);
  border-right: none; border-radius: 4px 0 0 4px; font-size: .95rem;
  background: var(--bg);
}
.topsearch button {
  padding: .42rem .9rem; border: none; background: var(--navy); color: #fff;
  border-radius: 0 4px 4px 0; cursor: pointer;
}
.topsearch button:hover { background: var(--navy-dark); }
.topnav { display: flex; gap: 1rem; margin-left: auto; }
.topnav a { color: var(--navy); font-size: .88rem; font-weight: 500; }

main { max-width: 1240px; margin: 0 auto; padding: 1.2rem; }
.foot {
  text-align: center; color: var(--muted); font-size: .8rem; padding: 1.4rem 0 2rem;
}

/* Home */
.hero { text-align: center; padding: 2.6rem 1rem 1.6rem; }
.hero-logo { height: 92px; width: auto; margin-bottom: 1rem; }
.hero h1 { font-size: 1.6rem; margin: 0; color: var(--navy); letter-spacing: .01em; }
.hero h1 span { color: var(--navy); }
.hero-sub { color: var(--muted); margin: .4rem 0 1.6rem; }
.herosearch { display: flex; max-width: 680px; margin: 0 auto; }
.herosearch input {
  flex: 1; padding: .8rem 1.1rem; font-size: 1.02rem; border: 1px solid var(--line);
  border-radius: 6px 0 0 6px; box-shadow: 0 2px 8px rgba(30, 61, 84, .07);
}
.herosearch button {
  padding: .8rem 1.6rem; font-size: 1rem; border: none; background: var(--navy);
  color: #fff; border-radius: 0 6px 6px 0; cursor: pointer;
}
.herosearch button:hover { background: var(--navy-dark); }
.hero-links { margin-top: .9rem; font-size: .88rem; color: var(--muted); }

.cards { display: flex; flex-wrap: wrap; gap: .8rem; justify-content: center; margin: 1rem 0 1.6rem; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: .8rem 1.4rem; min-width: 130px; text-align: center;
}
.card:hover { border-color: var(--navy); text-decoration: none; }
.card .v { font-size: 1.5rem; font-weight: 650; color: var(--navy); }
.card .l { font-size: .8rem; color: var(--muted); }

.home-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem;
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: .18rem .7rem;
  font-size: .84rem; background: #fff;
}
.chip:hover { border-color: var(--navy); text-decoration: none; }
.chip-n { color: var(--muted); font-size: .76rem; }

.doclist { list-style: none; margin: 0; padding: 0; }
.doclist li {
  padding: .32rem 0; border-bottom: 1px solid #edf1f5; display: flex;
  gap: .5rem; align-items: baseline;
}
.doclist li:last-child { border-bottom: none; }
.doclist a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doclist.small { font-size: .86rem; }
.saved-item button { margin-left: auto; }
.muted { color: var(--muted); font-size: .84rem; }

/* Layout ricerca */
.layout { display: grid; grid-template-columns: 250px 1fr; gap: 1.2rem; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.sidebar {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 1rem; align-self: start; font-size: .88rem;
}
.sidebar h3 { margin-top: 0; }
.sidebar label { display: block; margin: .5rem 0; color: var(--muted); }
.sidebar input[type=text], .sidebar input[type=date], .sidebar select {
  width: 100%; padding: .32rem .45rem; border: 1px solid var(--line);
  border-radius: 4px; font-size: .88rem; margin-top: .15rem; background: #fff;
}
.checks label { display: flex; gap: .4rem; align-items: center; margin: .3rem 0; color: var(--ink); }
.btn {
  display: inline-block; padding: .4rem .9rem; border: 1px solid var(--line);
  border-radius: 5px; background: #fff; color: var(--navy); cursor: pointer;
  font-size: .88rem; margin: .5rem .3rem 0 0;
}
.btn:hover { border-color: var(--navy); text-decoration: none; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-dark); }
.savebox { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.savebox input[type=text] { width: 100%; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 4px; }
.linklike { border: none; background: none; color: var(--navy); cursor: pointer; }
.linklike.danger { color: var(--danger); font-size: 1rem; }

/* Risultati */
.results-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .8rem; flex-wrap: wrap; gap: .6rem;
}
.sortform label { color: var(--muted); font-size: .88rem; }
.sortform select { padding: .25rem .4rem; border: 1px solid var(--line); border-radius: 4px; }

.result {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: .75rem 1rem; margin-bottom: .7rem;
}
.result-line { display: flex; align-items: center; gap: .55rem; }
.result-title { font-size: 1.02rem; font-weight: 600; flex: 1; }
.result-meta { color: var(--muted); font-size: .84rem; margin: .2rem 0; display: flex; gap: .4rem; flex-wrap: wrap; }
.snippet { margin: .3rem 0; font-size: .9rem; color: #33404d; }
.snippet mark, mark { background: var(--teal-light); color: var(--ink); padding: 0 .1rem; border-radius: 2px; }
.result-foot { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-top: .3rem; }
.tag {
  font-size: .76rem; border: 1px solid #cfd9e2; border-radius: 999px;
  padding: .08rem .55rem; background: #f2f6f9; color: var(--navy-dark);
}
.tag:hover { border-color: var(--navy); text-decoration: none; }
.tag-tema { background: var(--teal-wash); border-color: var(--teal-light); }

/* Indice dei temi */
.page-title { font-size: 1.35rem; margin: 0 0 .2rem; }
.letter-nav {
  display: flex; flex-wrap: wrap; gap: .35rem; margin: .6rem 0 1rem;
  position: sticky; top: 0; background: var(--bg); padding: .5rem 0;
  z-index: 5;
}
.letter-nav a {
  border: 1px solid var(--line); border-radius: 4px; padding: .1rem .55rem;
  font-weight: 600; background: var(--panel);
}
.letter-nav a:hover { border-color: var(--navy); text-decoration: none; }
.chip-vuoto { opacity: .55; }
.small-note { display: block; font-size: .76rem; margin-top: .2rem; }

/* Accesso e registrazione */
.auth-box { max-width: 560px; margin: 2.5rem auto; }
.auth-form label { display: block; color: var(--muted); font-size: .88rem; margin: .55rem 0; }
.auth-form input, .auth-form select {
  width: 100%; padding: .45rem .6rem; border: 1px solid var(--line);
  border-radius: 4px; font-size: .95rem; margin-top: .2rem; background: #fff;
  color: var(--ink);
}
.auth-form button { margin-top: .8rem; }
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .9rem; }
@media (max-width: 560px) { .auth-grid { grid-template-columns: 1fr; } }
.topnav-user { color: var(--muted); font-size: .88rem; }
.btn-nav {
  border: 1px solid var(--navy); border-radius: 5px; padding: .25rem .8rem;
  color: var(--navy); font-weight: 600;
}
.btn-nav:hover { text-decoration: none; background: var(--teal-wash); }
.btn-nav-primary { background: var(--navy); color: #fff; }
.btn-nav-primary:hover { background: var(--navy-dark); }
.mail-item summary { cursor: pointer; padding: .3rem 0; }
.path { margin-left: auto; color: var(--muted); font-size: .78rem; font-family: Consolas, monospace; }
.flag {
  background: #FEECEB; color: #C0281C; border: 1px solid #F8C1BD;
  border-radius: 4px; padding: 0 .4rem; font-size: .76rem;
}
.flag-box {
  background: #FEECEB; border: 1px solid #F8C1BD; color: #C0281C;
  border-radius: 6px; padding: .5rem .8rem; font-size: .86rem;
}
.flag-ok { background: #e6f4ea; color: #1e6b34; border-color: #bfe0c8; }
.flag-conf { background: #1E1E23; color: #F7F7F9; border-color: #1E1E23; }

/* Pannello di verifica */
.verify-panel { border-left: 4px solid var(--accent); }
.verify-head { display: flex; justify-content: space-between; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.verify-form {
  display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .9rem;
  margin-top: .5rem;
}
.verify-form label { display: block; color: var(--muted); font-size: .86rem; }
.verify-form label.wide { grid-column: 1 / -1; }
.verify-form input[type=text], .verify-form select {
  width: 100%; padding: .38rem .5rem; border: 1px solid var(--line);
  border-radius: 4px; font-size: .92rem; margin-top: .18rem; background: #fff;
  color: var(--ink);
}
.temi-select { margin-top: .3rem; color: var(--muted); }
.temi-slots {
  display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .9rem;
}
@media (max-width: 700px) { .temi-slots { grid-template-columns: 1fr; } }
.verify-actions {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap;
}
.verify-actions .check {
  display: flex; gap: .4rem; align-items: center; color: var(--ink);
  font-size: .88rem;
}
.verify-tools { border-top: 1px dashed var(--line); margin-top: .9rem; padding-top: .3rem; align-items: center; }
.verify-tools form { display: inline-block; }
.verify-tools .muted { font-size: .82rem; }
.empty { color: var(--muted); padding: 2rem; text-align: center; }
.pagination { display: flex; gap: 1rem; justify-content: center; padding: 1rem; color: var(--muted); }

/* Badge formato */
.badge {
  display: inline-block; min-width: 2.6rem; text-align: center; font-size: .68rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: .14rem .4rem; border-radius: 4px; color: #fff; background: #78909c;
}
.ext-pdf { background: #b3392e; }
.ext-doc, .ext-docx { background: #2b579a; }
.ext-xls, .ext-xlsx { background: #1e6e42; }
.ext-ppt, .ext-pptx { background: #c4531d; }
.ext-txt, .ext-csv { background: #5f6b76; }
.ext-html, .ext-htm { background: #7a4a9e; }
.ext-zip { background: #8d6e2f; }
.ext-mp4, .ext-m4v { background: #444; }
.ext-png, .ext-jpg, .ext-jpeg, .ext-jfif, .ext-gif { background: #3a7ca5; }

.fav {
  border: none; background: none; font-size: 1.15rem; cursor: pointer;
  color: #c9d2da;
}
.fav.active { color: var(--accent); }
.fav:hover { color: var(--accent); }

/* Pagina documento */
.doc-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.2rem; }
@media (max-width: 960px) { .doc-layout { grid-template-columns: 1fr; } }
.doc-head { display: flex; align-items: center; gap: .7rem; }
.doc-head h1 { font-size: 1.35rem; margin: .2rem 0; flex: 1; }
.doc-meta-line { color: var(--muted); font-size: .9rem; display: flex; gap: .4rem; flex-wrap: wrap; margin: .2rem 0 .6rem; }
.doc-tags { margin-bottom: .8rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.doc-actions { margin-bottom: .8rem; }
.preview-frame { width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.preview-img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; }
.preview-text {
  background: #fbfcfd; border: 1px solid var(--line); border-radius: 6px;
  padding: .9rem; white-space: pre-wrap; font-size: .84rem; max-height: 60vh; overflow: auto;
}
.proplist { margin: 0; font-size: .87rem; }
.proplist dt { color: var(--muted); margin-top: .5rem; }
.proplist dd { margin: 0; }
.mono { font-family: Consolas, monospace; }
.small { font-size: .78rem; word-break: break-all; }
.conf { font-weight: 600; }
.conf-high { color: var(--ok); }
.conf-mid { color: #8a5200; }
.conf-low { color: var(--danger); }
.conf-na { color: var(--muted); }
.refs { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem; }
.refs ul { margin: 0; padding-left: 1.1rem; font-size: .86rem; }

/* Ingestion */
.dropzone {
  border: 2px dashed var(--line); border-radius: 10px; background: var(--panel);
  padding: 2.2rem 1rem; text-align: center; color: var(--muted); margin: 1rem 0;
  transition: border-color .15s, background .15s;
}
.dropzone.dragging { border-color: var(--navy); background: var(--teal-wash); }
.dropzone.busy { opacity: .6; pointer-events: none; }
.queue-item { border-left: 4px solid var(--navy); }
.queue-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .6rem 1rem; margin: .6rem 0;
}
.queue-grid label { display: block; font-size: .84rem; color: var(--muted); }
.queue-grid input, .queue-grid select {
  width: 100%; padding: .34rem .5rem; border: 1px solid var(--line);
  border-radius: 4px; font-size: .9rem; background: #fff; color: var(--ink);
}
.queue-wide { grid-column: 1 / -1; }
.danger-btn { color: var(--danger); }
.dupgroup { border-top: 1px solid #edf1f5; padding-top: .5rem; margin-top: .5rem; }
.plain-table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.plain-table th, .plain-table td {
  border-bottom: 1px solid #edf1f5; padding: .4rem .5rem; text-align: left;
  vertical-align: top;
}
.plain-table .num { text-align: right; white-space: nowrap; }
