:root {
  --yellow: #f7cb42;
  --yellow-soft: #fff6d5;
  --brown: #4b2f19;
  --brown-2: #6b4528;
  --green: #1d5b45;
  --green-soft: #eaf4ef;
  --cream: #fffdf7;
  --ink: #1f2421;
  --muted: #6d746f;
  --line: #e7e2d8;
  --white: #ffffff;
  --red: #b83b38;
  --red-soft: #fbeceb;
  --orange: #bd7518;
  --orange-soft: #fff2dd;
  --shadow: 0 20px 55px rgba(67, 46, 24, .10);
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f6f4ee;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.eyebrow { display: inline-block; font-size: .75rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; color: rgba(255,255,255,.72); }
.eyebrow.dark { color: var(--green); }
.muted { color: var(--muted); }

.login-body { background: var(--yellow); display: grid; place-items: center; padding: 34px; }
.login-shell { width: min(1120px, 100%); min-height: 650px; display: grid; grid-template-columns: 1.15fr .85fr; overflow: hidden; border-radius: 28px; background: var(--white); box-shadow: 0 36px 90px rgba(67, 46, 24, .22); }
.login-brand { position: relative; padding: 64px; overflow: hidden; color: white; background: radial-gradient(circle at 15% 10%, #2b795e 0, var(--green) 42%, #124634 100%); display: flex; flex-direction: column; justify-content: center; }
.login-brand::before, .login-brand::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.13); }
.login-brand::before { width: 430px; height: 430px; right: -220px; top: -160px; }
.login-brand::after { width: 260px; height: 260px; left: -130px; bottom: -80px; }
.brand-logo-card { display: inline-flex; align-items: center; justify-content: center; width: fit-content; max-width: min(460px, 88%); padding: 0; border-radius: 0; background: transparent; box-shadow: none; position: relative; z-index: 1; }
.login-brand .brand-logo-card img { display: block; width: min(400px, 100%); height: auto; }
.brand-copy { margin-top: 42px; max-width: 490px; position: relative; z-index: 1; }
.brand-copy h1 { margin: 10px 0 14px; font-size: clamp(2.2rem, 4.4vw, 4.4rem); line-height: .95; letter-spacing: -.055em; }
.brand-copy p { margin: 0; max-width: 430px; color: rgba(255,255,255,.76); font-size: 1.05rem; line-height: 1.65; }
.powered { position: absolute; left: 64px; bottom: 42px; display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,.78); font-size: .78rem; }
.powered img { width: 34px; height: 40px; object-fit: contain; filter: none; }
.login-card { padding: 58px; display: grid; align-items: center; background: linear-gradient(145deg, #fff 0%, var(--cream) 100%); }
.login-card-inner { width: min(380px, 100%); margin: auto; }
.login-card h2 { font-size: 2.45rem; letter-spacing: -.04em; margin: 10px 0 8px; color: var(--brown); }
.login-card p { line-height: 1.55; }
.login-card form { margin-top: 34px; }
.login-card label { display: block; margin: 18px 0 8px; font-size: .86rem; font-weight: 800; color: var(--brown); }
.login-card input { width: 100%; border: 1px solid var(--line); background: white; padding: 14px 15px; border-radius: 13px; outline: none; transition: .2s ease; }
.login-card input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(29,91,69,.11); }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 52px; }
.icon-button { position: absolute; right: 7px; top: 6px; width: 39px; height: 39px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; }
.form-error { min-height: 24px; margin: 12px 0 4px; color: var(--red); font-size: .88rem; }
.primary-button, .secondary-button, .ghost-button { border: 0; cursor: pointer; border-radius: 12px; font-weight: 800; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 9px; transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease; }
.primary-button { color: white; background: var(--green); padding: 13px 18px; box-shadow: 0 10px 24px rgba(29,91,69,.18); }
.primary-button:hover, .secondary-button:hover, .ghost-button:hover { transform: translateY(-1px); }
.primary-button:disabled { opacity: .55; cursor: wait; transform: none; }
.primary-button.full { width: 100%; justify-content: space-between; margin-top: 8px; padding: 15px 17px; }
.secondary-button { padding: 12px 17px; color: var(--brown); background: white; border: 1px solid var(--line); }
.ghost-button { padding: 10px 13px; background: transparent; color: var(--brown); }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 82px; padding: 12px clamp(20px, 4vw, 60px); background: var(--yellow); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(75,47,25,.10); position: sticky; top: 0; z-index: 20; }
.top-brand { display: block; }
.capatoast-logo { display: block; height: 56px; width: auto; border-radius: 9px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 6px 10px 6px 6px; border-radius: 999px; background: rgba(255,255,255,.43); color: var(--brown); font-weight: 800; font-size: .9rem; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--brown); color: var(--yellow); }
.main-content { width: min(1460px, calc(100% - 38px)); margin: 0 auto; padding: 46px 0 32px; flex: 1; }
.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px; }
.hero-row h1 { margin: 8px 0 8px; color: var(--brown); font-size: clamp(2rem, 3.4vw, 3.65rem); letter-spacing: -.055em; line-height: 1.02; }
.hero-row p { margin: 0; color: var(--muted); max-width: 700px; }
.hero-actions { display: flex; gap: 10px; flex-shrink: 0; }
.refresh-icon { font-size: 1.1rem; }
.refreshing .refresh-icon { display: inline-block; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.warning-banner { margin-top: 22px; padding: 13px 16px; border-radius: 13px; background: var(--orange-soft); color: #78501f; border: 1px solid #f0d4a3; }
.summary-grid { display: grid; grid-template-columns: 1.2fr repeat(4, 1fr); gap: 14px; margin: 32px 0 20px; }
.summary-card { position: relative; overflow: hidden; min-height: 140px; padding: 20px; border-radius: 18px; border: 1px solid var(--line); background: white; box-shadow: 0 8px 25px rgba(54,44,31,.04); }
.summary-card::after { content: ""; position: absolute; width: 72px; height: 72px; border-radius: 50%; right: -24px; bottom: -26px; opacity: .16; background: currentColor; }
.summary-card .summary-label { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 850; color: var(--muted); }
.summary-card strong { display: block; margin: 11px 0 4px; font-size: 2.5rem; line-height: 1; letter-spacing: -.05em; color: var(--brown); }
.summary-card small { color: var(--muted); }
.summary-card.neutral { color: var(--brown); background: linear-gradient(145deg, #fff7d9, #fff); }
.summary-card.good { color: var(--green); }
.summary-card.low { color: var(--orange); }
.summary-card.critical { color: var(--red); }
.summary-card.out { color: #6f2726; }
.panel { background: white; border-radius: 20px; border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0 0 5px; font-size: 1.25rem; color: var(--brown); }
.panel-head p { margin: 0; font-size: .85rem; }
.filters { display: flex; gap: 9px; }
.search-box { min-width: 290px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfaf7; }
.search-box input { width: 100%; padding: 11px 0; border: 0; outline: 0; background: transparent; }
.filters select { padding: 10px 36px 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fbfaf7; color: var(--ink); outline: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid #eeeae2; }
th { color: #747870; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; background: #fbfaf7; cursor: pointer; user-select: none; }
th:hover { color: var(--brown); }
td { font-size: .9rem; }
tbody tr:hover { background: #fffcf3; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.code-cell { font-weight: 850; color: var(--brown); white-space: nowrap; }
.description-cell { min-width: 330px; }
.description-main { font-weight: 650; }
.source-code { display: block; margin-top: 3px; color: #92958f; font-size: .69rem; }
.existence-value { font-size: 1.15rem; font-weight: 900; color: var(--brown); }
.status-badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 999px; font-size: .72rem; font-weight: 850; white-space: nowrap; }
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-disponibile { color: var(--green); background: var(--green-soft); }
.status-basso { color: var(--orange); background: var(--orange-soft); }
.status-critico { color: var(--red); background: var(--red-soft); }
.status-esaurito { color: #772522; background: #f5dddc; }
.status-non_trovato { color: #5c6160; background: #eceeee; }
.empty-state { padding: 52px 24px; text-align: center; color: var(--muted); }
.panel-foot { padding: 14px 20px; display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; background: #fbfaf7; }
.legend { display: flex; align-items: center; gap: 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-left: 7px; }
.critical-dot { background: var(--red); }
.low-dot { background: var(--orange); }
.footer { display: flex; align-items: center; justify-content: space-between; padding: 24px clamp(20px, 4vw, 60px); color: #858981; font-size: .78rem; }
.footer-brand { display: flex; align-items: center; gap: 8px; }
.footer-brand img { width: 28px; height: 34px; object-fit: contain; }
.toast { position: fixed; z-index: 50; right: 24px; bottom: 24px; max-width: min(390px, calc(100vw - 48px)); padding: 13px 16px; border-radius: 12px; color: white; background: var(--green); box-shadow: 0 15px 40px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transform: translateY(12px); transition: .22s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
@media (max-width: 1000px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 470px; padding: 44px; }
  .powered { position: static; margin-top: 55px; }
  .login-card { padding: 48px 30px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-card.neutral { grid-column: span 2; }
  .panel-head { align-items: stretch; flex-direction: column; }
  .filters { width: 100%; }
  .search-box { min-width: 0; flex: 1; }
}
@media (max-width: 680px) {
  .login-body { padding: 0; background: white; }
  .login-shell { min-height: 100vh; border-radius: 0; box-shadow: none; }
  .login-brand { min-height: 400px; padding: 32px 24px; }
  .brand-logo-card { max-width: 92%; padding: 0; }
  .brand-copy { margin-top: 28px; }
  .powered { margin-top: 34px; }
  .topbar { height: 70px; padding: 9px 14px; }
  .capatoast-logo { height: 48px; }
  .user-chip span:last-child { display: none; }
  .main-content { width: min(100% - 24px, 1460px); padding-top: 28px; }
  .hero-row { align-items: stretch; flex-direction: column; }
  .hero-actions { width: 100%; }
  .hero-actions > * { flex: 1; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .summary-card { min-height: 125px; padding: 16px; }
  .summary-card strong { font-size: 2rem; }
  .filters { flex-direction: column; }
  .panel-head { padding: 18px; }
  .panel-foot { flex-direction: column; gap: 8px; }
  .footer { flex-direction: column; gap: 12px; }
}
