/* Layout applicazione (admin + portale) */
.app { display: grid; grid-template-rows: 60px 1fr; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px 0 16px;
  background: var(--ink); color: #fff;
  border-bottom: 3px solid var(--accent);
  position: relative; z-index: 5;
}
.topbar .brand { width: 244px; flex: none; }
.topbar .search { flex: 1; max-width: 640px; }
.topbar .search .input { background: var(--ink-2); border-color: var(--ink-3); color: #fff; height: 38px; }
.topbar .search .input::placeholder { color: #8f98a5; }
.topbar .search .input:focus { background: #fff; color: var(--text); border-color: #fff; }
.topbar .search .ti { color: #8f98a5; }
.topbar .spacer { flex: 1; }
.topbar .btn-ghost { color: #dfe3e8; }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.08); color: #fff; }
.topbar .icon-btn:hover { background: rgba(255,255,255,.1); }
.topbar .who { display: flex; align-items: center; gap: 8px; color: #aab2bd; font-size: 13px; padding-left: 8px; border-left: 1px solid var(--ink-3); }

.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 0; }
.sidebar {
  display: flex; flex-direction: column; gap: 14px; min-height: 0;
  padding: 16px 12px 12px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.sidebar .new-btn { width: 100%; height: 44px; justify-content: flex-start; padding: 0 16px; font-size: 15px; box-shadow: var(--shadow-1); }
.tree { flex: 1; overflow: auto; min-height: 0; margin: 0 -4px; padding: 0 4px; }
.tree-node {
  display: flex; align-items: center; gap: 4px;
  height: 34px; padding-right: 8px; border-radius: 5px;
  cursor: pointer; user-select: none; color: var(--ink-3); font-size: 14px;
}
.tree-node:hover { background: var(--surface-2); color: var(--text); }
.tree-node.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.tree-node.drop-target { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.tree-node .tw { width: 22px; height: 22px; display: grid; place-items: center; border: 0; background: none; padding: 0; color: var(--faint); cursor: pointer; border-radius: 3px; flex: none; }
.tree-node .tw:hover { background: rgba(0,0,0,.06); color: var(--text); }
.tree-node .tw .ti { font-size: 15px; transition: transform .12s; }
.tree-node .tw.open .ti { transform: rotate(90deg); }
.tree-node > .ti { font-size: 18px; flex: none; }
.tree-node .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-node .off { color: var(--faint); font-size: 15px; }

.cartiglio {
  border: 1.5px solid var(--ink); border-radius: 3px; font-size: 12px;
  display: grid; grid-template-columns: 1fr 1fr;
}
.cartiglio > div { padding: 6px 9px; border-top: 1px solid var(--ink); }
.cartiglio > div:nth-child(-n+2) { border-top: 0; }
.cartiglio > div:nth-child(even) { border-left: 1px solid var(--ink); }
.cartiglio .k { display: block; font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.cartiglio .v { display: block; font-size: 15px; font-weight: 700; }
.cartiglio .full { grid-column: 1 / -1; border-left: 0 !important; }

.main { min-width: 0; min-height: 0; overflow: auto; position: relative; }
.main-inner { padding: 18px 26px 80px; max-width: 1600px; }
.toolbar {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  min-height: 60px; padding: 10px 26px;
  background: rgba(243, 244, 241, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.toolbar .crumbs { flex: 1; }
.toolbar .tools { display: flex; align-items: center; gap: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 2px; }
.seg .icon-btn { width: 30px; height: 28px; border-radius: 4px; }
.select {
  height: 34px; padding: 0 30px 0 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23687280' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none; cursor: pointer; font-size: 14px;
}

.selbar {
  display: flex; align-items: center; gap: 6px; flex: 1;
  background: var(--ink); color: #fff; border-radius: 8px; padding: 4px 6px 4px 8px; min-height: 42px;
}
.selbar .count { font-weight: 700; padding: 0 10px 0 4px; margin-right: auto; }
.selbar .btn-ghost { color: #fff; }
.selbar .btn-ghost:hover { background: rgba(255,255,255,.12); }

/* Area di rilascio */
.drop-overlay {
  position: fixed; inset: 0; z-index: 800; pointer-events: none;
  display: grid; place-items: center;
  background: rgba(226, 83, 29, .08);
  border: 3px dashed var(--accent);
}
.drop-overlay .box {
  background: var(--ink); color: #fff; padding: 18px 26px; border-radius: 10px;
  display: flex; align-items: center; gap: 14px; font-weight: 600; font-size: 17px; box-shadow: var(--shadow-2);
}
.drop-overlay .box .ti { font-size: 30px; color: var(--accent); }

/* Pannello caricamenti */
.uploads {
  position: fixed; right: 20px; bottom: 20px; z-index: 700;
  width: 380px; max-width: calc(100vw - 40px);
  background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-2); overflow: hidden;
  border: 1px solid var(--line);
}
.uploads header { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 16px; background: var(--ink); color: #fff; font-weight: 600; }
.uploads header span { flex: 1; }
.uploads header .icon-btn:hover { background: rgba(255,255,255,.12); }
.uploads ul { list-style: none; margin: 0; padding: 4px 0; max-height: 280px; overflow: auto; }
.uploads li { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 10px; padding: 8px 14px; font-size: 13.5px; }
.uploads li .ti { font-size: 19px; color: var(--muted); }
.uploads li .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.uploads li .bar { grid-column: 2 / 3; height: 3px; background: var(--line-2); border-radius: 2px; overflow: hidden; margin-top: 5px; }
.uploads li .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.uploads li .st { color: var(--muted); font-size: 12.5px; }
.uploads li.done .st { color: var(--ok); }
.uploads li.err .st { color: var(--danger); }
.uploads.min ul { display: none; }

.vis { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; }
.vis.on { color: var(--ok); }
.vis.off { color: var(--danger); }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { width: 38px; height: 22px; appearance: none; background: var(--line); border-radius: 11px; position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(16px); }

.hint-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.mobile-only { display: none !important; }
@media (max-width: 900px) {
  .topbar .brand { width: auto; }
  .topbar .brand-text small { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 600; top: 60px; bottom: 0; left: 0; width: 280px;
    transform: translateX(-100%); transition: transform .18s; box-shadow: var(--shadow-2);
  }
  .sidebar.open { transform: none; }
  .mobile-only { display: inline-grid !important; }
  .hide-mobile { display: none !important; }
  .toolbar { padding: 10px 14px; }
  .main-inner { padding: 14px 14px 80px; }
}
@media (max-width: 600px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar .brand-text { display: none; }
}
