:root {
  --bg: #f7f3ee;
  --surface: #ffffff;
  --surface-2: #f1ebe4;
  --ink: #2b211c;
  --ink-2: #6b5d55;
  --line: #e4dbd2;
  --accent: #9c4f2e;
  --accent-ink: #ffffff;
  --accent-soft: #f6e6dc;
  --ok: #2f6b4a;
  --ok-soft: #e3f0e8;
  --err: #a1322a;
  --err-soft: #f9e3e0;
  --mark-bg: #2b211c;
  --mark-ink: #e9c9a8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(43, 33, 28, .06), 0 6px 20px rgba(43, 33, 28, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120f;
    --surface: #211a16;
    --surface-2: #2b231e;
    --ink: #f2e9e1;
    --ink-2: #b4a69b;
    --line: #3a302a;
    --accent: #e09a72;
    --accent-ink: #1d1410;
    --accent-soft: #3a261c;
    --ok: #8fd1aa;
    --ok-soft: #1d3127;
    --err: #f0a39a;
    --err-soft: #3a1f1c;
    --mark-bg: #e9c9a8;
    --mark-ink: #2b211c;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); }
img { max-width: 100%; }
code { font: 0.92em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
small { color: var(--ink-2); font-weight: 400; }
.muted { color: var(--ink-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-txt { display: flex; flex-direction: column; line-height: 1.1; }
.brand-txt strong { font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 18px; }
.brand-txt small { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.mark {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: var(--mark-bg); color: var(--mark-ink); font: 600 15px Fraunces, Georgia, serif; letter-spacing: .02em;
}
.mark-lg { width: 56px; height: 56px; border-radius: 16px; font-size: 22px; }
.nav { display: flex; align-items: center; gap: 14px; }
.nav > a:not(.btn) { color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px; }
.nav > a:not(.btn):hover { color: var(--accent); }
.me { position: relative; }
.me summary { list-style: none; cursor: pointer; }
.me summary::-webkit-details-marker { display: none; }
.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px;
}
.me-menu {
  position: absolute; right: 0; top: 44px; min-width: 210px; padding: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.me-name { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; font-weight: 600; }
.me-name small { display: block; }
.me-menu a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.me-menu a:hover { background: var(--surface-2); }

/* layout */
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; flex: 1; }
.foot { text-align: center; color: var(--ink-2); font-size: 13px; padding: 20px 16px 28px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 16px; }
.narrow { max-width: 480px; margin: 0 auto; }
.narrow-form { max-width: 560px; margin-top: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.h1 { font: 600 clamp(26px, 4vw, 34px)/1.15 Fraunces, Georgia, serif; margin: 4px 0 6px; letter-spacing: -.01em; }
.h3 { font: 600 17px/1.3 Fraunces, Georgia, serif; margin: 0 0 10px; }
.lead { margin: 0; color: var(--ink-2); }
.back { font-size: 14px; text-decoration: none; font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.sec { display: flex; flex-direction: column; gap: 12px; }
.sec-h { display: flex; align-items: center; gap: 10px; font: 600 19px/1.2 Fraunces, Georgia, serif; margin: 0 0 4px; }
.num {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--mark-bg); color: var(--mark-ink); font: 700 13px Manrope, sans-serif;
}

/* forms */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
label.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.req { color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 700 15px Manrope, sans-serif; color: var(--accent-ink); background: var(--accent);
  border: 1px solid var(--accent); border-radius: 999px; padding: 10px 20px; min-height: 44px;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-sm { padding: 6px 14px; min-height: 36px; font-size: 14px; }
.btn-block { width: 100%; }
.link-del { background: none; border: 0; color: var(--err); font: 600 14px Manrope, sans-serif; cursor: pointer; padding: 6px; text-decoration: underline; }

.drop {
  position: relative; border: 2px dashed var(--line); border-radius: 12px; padding: 22px;
  text-align: center; cursor: pointer; background: var(--bg); font-weight: 500;
}
.drop:hover { border-color: var(--accent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-txt { display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.drop-sm { padding: 14px; flex: 1; }
.upload-row { display: flex; gap: 10px; align-items: stretch; }
.upload-row .btn { align-self: center; }

.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-ok::before { content: "✓ "; }
.flash-err { background: var(--err-soft); color: var(--err); }
.flash-err::before { content: "! "; }
.alert {
  display: block; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; text-decoration: none;
  background: var(--accent-soft); color: var(--ink); border: 1px solid var(--accent); font-weight: 600;
}

/* login */
.login { display: grid; place-items: center; min-height: 72vh; }
.login-card { width: 100%; max-width: 380px; }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand h1 { font: 600 30px Fraunces, Georgia, serif; margin: 14px 0 2px; }
.login-brand p { margin: 0; color: var(--ink-2); }
.hint { text-align: center; color: var(--ink-2); font-size: 14px; margin-top: 18px; }

/* pipeline */
.pipeline { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 18px; scrollbar-width: thin; }
.pipeline a {
  flex: 0 0 auto; display: flex; flex-direction: column; min-width: 108px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink);
}
.pipeline a.on { background: var(--mark-bg); color: var(--mark-ink); border-color: var(--mark-bg); }
.pipeline .n { font: 600 22px Fraunces, Georgia, serif; }
.pipeline .l { font-size: 13px; font-weight: 600; white-space: nowrap; }

.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input[type=search] { flex: 1 1 220px; }
.filters select { flex: 0 1 200px; }

/* elenco saloni */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; gap: 14px; align-items: center; text-decoration: none; color: var(--ink); padding: 14px; }
.item:hover { border-color: var(--accent); }
.logo { flex: 0 0 56px; width: 56px; height: 56px; border-radius: 12px; overflow: hidden; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; }
.logo img { width: 100%; height: 100%; object-fit: contain; }
.logo-ph { font: 600 24px Fraunces, Georgia, serif; color: var(--ink-2); background: var(--surface-2); width: 100%; height: 100%; display: grid; place-items: center; }
.item-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.item-title { font-weight: 700; font-size: 17px; }
.item-meta { color: var(--ink-2); font-size: 14px; }
.item-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }

.badge, .tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink); white-space: nowrap;
}
.tag { font-weight: 600; }
.tag-warn { background: var(--accent-soft); color: var(--accent); }
.st-demo_richiesta { background: var(--accent-soft); color: var(--accent); }
.st-demo_pronta, .st-presentata, .st-prova { background: var(--mark-bg); color: var(--mark-ink); }
.st-cliente { background: var(--ok-soft); color: var(--ok); }
.st-perso { background: transparent; color: var(--ink-2); border: 1px solid var(--line); text-decoration: line-through; }

.empty { text-align: center; padding: 32px 20px; }
.empty p { margin: 0 0 10px; }

.agenda { list-style: none; margin: 0; padding: 0; }
.agenda a { display: flex; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.agenda li:first-child a { border-top: 0; }
.agenda .date { font-weight: 700; color: var(--accent); min-width: 86px; }
.how ol { margin: 0 0 12px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }

/* scheda */
.files { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.file { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: var(--bg); }
.file-prev { display: grid; place-items: center; aspect-ratio: 4 / 3; border-radius: 8px; background: #fff; overflow: hidden; text-decoration: none; }
.file-prev img { width: 100%; height: 100%; object-fit: contain; }
.file-ext { font: 700 18px Manrope, sans-serif; color: #6b5d55; }
.file-info { display: flex; flex-direction: column; font-size: 13px; min-width: 0; }
.file-info a { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file form { margin-top: auto; }
.file .link-del { padding: 0; font-size: 13px; }

.demo-ready { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; padding: 14px; border-radius: 12px; background: var(--ok-soft); }
.demo-ready p { margin: 0; }
.cred { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.cred dt { font-weight: 700; }
.cred dd { margin: 0; }
.note-box { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); font-weight: 600; }
.admin-box { border-top: 1px dashed var(--line); padding-top: 14px; }
.admin-lbl { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }

.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.thread li { padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.thread li.from-admin { background: var(--accent-soft); border-color: transparent; }
.thread .who { font-size: 14px; }
.thread p { margin: 4px 0 0; white-space: normal; overflow-wrap: anywhere; }
.danger { text-align: center; }

/* agenti */
.table-wrap { padding: 0; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.off td { opacity: .55; }
.tbl .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.pw-show { margin-bottom: 16px; border-color: var(--accent); }
.pw-show p { margin: 0 0 8px; }
.pw code { font-size: 20px; padding: 6px 12px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .wrap { padding-top: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .brand-txt small { display: none; }
  .nav { gap: 10px; }
  .nav > a.btn { padding: 6px 12px; }
  .nav > a:not(.btn)[href="index.php"] { display: none; }
  .page-head .btn { width: 100%; }
  .upload-row { flex-direction: column; }
  .upload-row .btn { align-self: stretch; }
  .sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; }
  .sticky-actions .btn { flex: 1; }
}
