/* ====== Piattaforma ECM Irecoop Veneto ====== */
:root {
  --blu: #17365D;
  --blu-2: #2a5298;
  --blu-3: #4f7fd9;
  --accent: #38bdf8;
  --oro: #f6b93b;
  --verde: #22c55e;
  --rosso: #ef4444;
  --ambra: #f59e0b;
  --bg: #f1f5fb;
  --card: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(23, 54, 93, .08);
  --shadow-lg: 0 12px 48px rgba(23, 54, 93, .16);
  --font-display: 'Sora', sans-serif;
  --font-body: 'Inter', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-body); background: var(--bg); color: var(--ink); font-size: 14px; }
h1,h2,h3,h4 { font-family: var(--font-display); color: var(--blu); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--blu-2); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #0d2240 0%, #17365D 45%, #2a5298 100%);
}
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; animation: float 14s ease-in-out infinite; }
.blob.b1 { width: 480px; height: 480px; background: #38bdf8; top: -140px; left: -120px; }
.blob.b2 { width: 420px; height: 420px; background: #6d5df6; bottom: -130px; right: -100px; animation-delay: -5s; }
.blob.b3 { width: 300px; height: 300px; background: #f6b93b; bottom: 20%; left: 12%; opacity: .25; animation-delay: -9s; }
@keyframes float { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(40px,-30px) scale(1.08); } }

.login-card {
  position: relative; z-index: 2; width: min(420px, 92vw); padding: 44px 40px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.22);
  border-radius: 24px; backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 24px 80px rgba(0,0,0,.35); animation: rise .6s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes rise { from { opacity: 0; transform: translateY(26px) scale(.97); } to { opacity: 1; transform: none; } }
.login-logo { display: block; margin: 0 auto 20px; height: 116px; filter: drop-shadow(0 6px 22px rgba(56,189,248,.45)); animation: rise .8s cubic-bezier(.2,.9,.3,1.2); }
.login-card .badge-ecm {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px;
  background: rgba(56,189,248,.18); border: 1px solid rgba(56,189,248,.4); color: #aee7ff;
  font-size: 12px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase;
}
.login-card h1 { color: #fff; font-size: 26px; margin: 18px 0 4px; letter-spacing: -.5px; }
.login-card .sub { color: #b8c9e8; font-size: 13.5px; margin-bottom: 30px; line-height: 1.5; }
.login-card label { display: block; color: #cfe0ff; font-size: 12px; font-weight: 600; margin: 16px 0 6px; letter-spacing: .4px; }
.login-card input {
  width: 100%; padding: 13px 16px; border-radius: 12px; border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08); color: #fff; outline: none; transition: .2s;
}
.login-card input:focus { border-color: var(--accent); background: rgba(255,255,255,.14); box-shadow: 0 0 0 4px rgba(56,189,248,.15); }
.login-card input::placeholder { color: rgba(255,255,255,.4); }
.btn-login {
  width: 100%; margin-top: 26px; padding: 14px; border: 0; border-radius: 12px;
  background: linear-gradient(90deg, #38bdf8, #6d5df6); color: #fff; font-weight: 700; font-size: 15px;
  font-family: var(--font-display); letter-spacing: .3px; transition: .25s; box-shadow: 0 8px 24px rgba(56,189,248,.35);
}
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(56,189,248,.45); filter: brightness(1.06); }
.login-err { margin-top: 14px; color: #ffb4b4; font-size: 13px; text-align: center; min-height: 18px; }
.login-foot { position: absolute; bottom: 22px; width: 100%; text-align: center; color: rgba(255,255,255,.45); font-size: 12px; z-index: 2; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #0d2240, #17365D); color: #cbd8ee; padding: 26px 16px;
  display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 24px; }
.sidebar .brand .brand-logo { height: 46px; width: auto; filter: drop-shadow(0 4px 12px rgba(56,189,248,.35)); }
.sidebar .brand b { color: #fff; font-family: var(--font-display); font-size: 15px; display: block; letter-spacing: -.2px; }
.sidebar .brand small { color: #7d95bd; font-size: 11px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 11px;
  color: #b6c6e2; text-decoration: none; font-weight: 500; font-size: 13.5px; transition: .18s; border: 0; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(56,189,248,.22), rgba(109,93,246,.16)); color: #fff; box-shadow: inset 0 0 0 1px rgba(56,189,248,.28); }
.nav-item .ic { font-size: 17px; width: 22px; text-align: center; }
.sidebar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.09); }
.user-chip .avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #f6b93b, #f08a24); font-size: 14px; flex-shrink: 0;
}
.user-chip .who b { display: block; color: #fff; font-size: 13px; }
.user-chip .who span { color: #7d95bd; font-size: 11px; text-transform: capitalize; }

.main { padding: 34px 42px; max-width: 1500px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head h2 { font-size: 25px; letter-spacing: -.6px; }
.page-head .crumbs { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- Componenti ---------- */
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; margin-bottom: 30px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
  position: relative; overflow: hidden; transition: .25s; border: 1px solid var(--line);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--sc, linear-gradient(90deg, #38bdf8, #6d5df6)); }
.stat-card .num { font-family: var(--font-display); font-size: 32px; font-weight: 800; color: var(--blu); letter-spacing: -1px; }
.stat-card .lbl { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; margin-top: 4px; }
.stat-card .ic { position: absolute; right: 18px; top: 18px; font-size: 26px; opacity: .85; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 26px; margin-bottom: 24px; }
.card h3 { font-size: 16px; margin-bottom: 18px; display: flex; align-items: center; gap: 9px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 11px; border: 0;
  font-weight: 600; font-size: 13.5px; transition: .2s; text-decoration: none;
}
.btn-primary { background: linear-gradient(90deg, var(--blu-2), var(--blu-3)); color: #fff; box-shadow: 0 6px 18px rgba(42,82,152,.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(42,82,152,.4); filter: brightness(1.07); }
.btn-accent { background: linear-gradient(90deg, #0ea5e9, #38bdf8); color: #fff; box-shadow: 0 6px 18px rgba(14,165,233,.3); }
.btn-accent:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn-ghost { background: #eef3fb; color: var(--blu); border: 1px solid var(--line); }
.btn-ghost:hover { background: #e2ebf8; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 10px; outline: none; transition: .2s; background: #fbfdff; color: var(--ink);
}
.field input:focus, .field select:focus { border-color: var(--blu-3); box-shadow: 0 0 0 4px rgba(79,127,217,.12); background: #fff; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.fields-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 18px; }

/* Tabelle */
.tbl-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
th { background: #f5f8fd; color: var(--blu); font-family: var(--font-display); font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; padding: 12px 14px; text-align: left; white-space: nowrap; border-bottom: 2px solid var(--line); position: sticky; top: 0; }
td { padding: 11px 14px; border-bottom: 1px solid #eef2f8; vertical-align: middle; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: #f7faff; }
tbody tr:last-child td { border-bottom: 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.wait { background: #fef3c7; color: #b45309; }
.badge.err { background: #fee2e2; color: #b91c1c; }
.badge.info { background: #e0f2fe; color: #0369a1; }
.badge.neutral { background: #f1f5f9; color: #64748b; }

.progress { height: 7px; background: #e8eef7; border-radius: 99px; overflow: hidden; min-width: 70px; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #38bdf8, #6d5df6); transition: width .4s; }

/* Aziende grid */
.grid-companies { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.company-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line);
  padding: 24px; cursor: pointer; transition: .25s; position: relative; overflow: hidden;
}
.company-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: rgba(79,127,217,.4); }
.company-card .logo-box {
  height: 56px; display: flex; align-items: center; margin-bottom: 16px;
}
.company-card .logo-box img { max-height: 52px; max-width: 170px; object-fit: contain; }
.company-card .logo-fallback {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 20px;
  background: linear-gradient(135deg, var(--blu-2), var(--blu-3));
}
.company-card h4 { font-size: 16.5px; margin-bottom: 12px; }
.company-card .meta { display: flex; gap: 16px; color: var(--muted); font-size: 12.5px; }
.company-card .meta b { color: var(--blu); font-size: 15px; display: block; font-family: var(--font-display); }

/* Tabs */
.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--line); margin-bottom: 24px; flex-wrap: wrap; }
.tab { padding: 11px 20px; border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 13.5px; border-bottom: 3px solid transparent; margin-bottom: -2px; transition: .2s; }
.tab:hover { color: var(--blu); }
.tab.active { color: var(--blu); border-bottom-color: var(--blu-3); }

/* Filtri */
.filter-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.filter-bar input, .filter-bar select { padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; outline: none; font-size: 13px; }
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--blu-3); }

/* Dropzone */
.dropzone {
  border: 2.5px dashed #b9cbe8; border-radius: var(--radius); padding: 46px 26px; text-align: center;
  background: linear-gradient(180deg, #f8fbff, #eef4fc); transition: .25s; cursor: pointer;
}
.dropzone:hover, .dropzone.over { border-color: var(--blu-3); background: #e8f1ff; transform: scale(1.005); }
.dropzone .ic { font-size: 44px; margin-bottom: 12px; }
.dropzone b { color: var(--blu); font-size: 15.5px; font-family: var(--font-display); display: block; margin-bottom: 5px; }
.dropzone span { color: var(--muted); font-size: 13px; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(13,34,64,.55); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 100; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } }
.modal { background: #fff; border-radius: 20px; padding: 30px; width: min(560px, 94vw); max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: rise .3s cubic-bezier(.2,.9,.3,1.15); }
.modal h3 { margin-bottom: 20px; font-size: 18px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* Toast */
#toast-root { position: fixed; bottom: 26px; right: 26px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 14px 20px; border-radius: 13px; color: #fff; font-weight: 600; font-size: 13.5px; box-shadow: 0 10px 34px rgba(0,0,0,.25);
  animation: slidein .35s cubic-bezier(.2,.9,.3,1.2); display: flex; align-items: center; gap: 9px; max-width: 380px;
}
.toast.ok { background: linear-gradient(90deg, #16a34a, #22c55e); }
.toast.err { background: linear-gradient(90deg, #dc2626, #ef4444); }
.toast.info { background: linear-gradient(90deg, var(--blu-2), var(--blu-3)); }
@keyframes slidein { from { opacity: 0; transform: translateX(60px); } }

/* Vuoto */
.empty { text-align: center; padding: 54px 20px; color: var(--muted); }
.empty .ic { font-size: 46px; margin-bottom: 12px; opacity: .6; }
.empty b { display: block; color: var(--blu); font-family: var(--font-display); font-size: 16px; margin-bottom: 6px; }

.chip-list { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { background: #eef3fb; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 12px; color: var(--blu); font-weight: 500; }

.skel { background: linear-gradient(90deg, #eef2f8 25%, #e2e9f4 50%, #eef2f8 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; align-items: center; padding: 12px; }
  .sidebar .brand { padding: 0 10px; }
  .sidebar .brand small, .user-chip .who { display: none; }
  .sidebar .nav-item span.txt { display: none; }
  .main { padding: 20px 16px; }
  .fields-2, .fields-3 { grid-template-columns: 1fr; }
}
