:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #1f2933;
  --muted: #6b7684;
  --accent: #14487a;
  --accent-dark: #0e3358;
  --danger: #a4262c;
  --warn: #8a5a00;
  --ok: #1c6b3c;
  --radius: 8px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

.wrap { max-width: 1060px; margin: 0 auto; padding: 0 20px; }

/* --- Barra superiore ----------------------------------------------------- */
.topbar {
  background: var(--accent);
  color: #fff;
  border-bottom: 3px solid var(--accent-dark);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 62px; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand strong { display: block; font-size: 1.05rem; letter-spacing: .2px; }
.brand small { display: block; font-size: .78rem; opacity: .8; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 6px;
  background: rgba(255,255,255,.16); font-weight: 700; font-size: .85rem;
}
.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-user .muted { color: rgba(255,255,255,.85); font-size: .9rem; }

/* --- Struttura ----------------------------------------------------------- */
main.wrap { padding-top: 26px; padding-bottom: 26px; }
.grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 900px) { .grid { grid-template-columns: 1.6fr 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card-narrow { max-width: 430px; margin: 40px auto; }

h1 { font-size: 1.4rem; margin: 0 0 8px; }
h2 { font-size: 1.1rem; margin: 22px 0 10px; }
h3 { font-size: .98rem; margin: 18px 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; margin: 4px 0 14px; }
code { background: #eef1f4; padding: 1px 5px; border-radius: 4px; font-size: .87em; }

/* --- Form ---------------------------------------------------------------- */
label { display: block; font-weight: 600; font-size: .9rem; margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=number] {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 1rem; background: #fff; color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.row { display: grid; grid-template-columns: 1fr; gap: 0 18px; }
@media (min-width: 620px) { .row { grid-template-columns: 1fr 1fr; } }
.checkbox { display: flex; align-items: flex-start; gap: 9px; font-weight: 500; margin-top: 16px; }
.checkbox input { margin-top: 4px; }

.btn {
  display: inline-block; padding: 10px 18px; border: 1px solid transparent;
  border-radius: 6px; font-size: .95rem; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.3;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary[disabled] { background: #9aa7b4; cursor: not-allowed; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; margin-top: 20px; }
.inline { display: inline; }

/* --- Messaggi ------------------------------------------------------------ */
.alert { padding: 12px 14px; border-radius: 6px; margin: 14px 0; font-size: .92rem; border: 1px solid; }
.alert-error { background: #fdf1f1; border-color: #f0c8c8; color: var(--danger); }
.alert-warn  { background: #fdf6e7; border-color: #efdcae; color: var(--warn); }
.alert-info  { background: #eef4fa; border-color: #c9dcef; color: var(--accent-dark); }

.notice { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); }
.notice ul { margin: 0; padding-left: 20px; color: var(--muted); font-size: .89rem; }
.notice li { margin-bottom: 5px; }

/* --- Stato lavorazione --------------------------------------------------- */
.job-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 20px; margin: 18px 0; }
.meta dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.meta dd { margin: 2px 0 0; font-size: .93rem; }
.status-line { font-weight: 600; }
.current { display: flex; align-items: baseline; gap: 8px; font-size: .88rem; margin-bottom: 14px; min-width: 0; }
.current code { min-width: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 18px 0 22px; }
.stat { background: #f7f9fb; border: 1px solid var(--border); border-radius: 6px; padding: 12px; text-align: center; }
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; }
.stat-label { display: block; font-size: .78rem; color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #e5e8ec; color: var(--text); white-space: nowrap; }
.badge-in_corso { background: #e3eefb; color: var(--accent-dark); }
.badge-in_attesa { background: #eceff2; color: var(--muted); }
.badge-completato { background: #e3f3e9; color: var(--ok); }
.badge-interrotto { background: #fdf6e7; color: var(--warn); }
.badge-errore { background: #fdf1f1; color: var(--danger); }

/* --- Tabelle ed elenchi -------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }
.list-compact { font-size: .85rem; color: var(--muted); padding-left: 18px; margin: 0 0 12px; }
.list-compact li { margin-bottom: 4px; word-break: break-word; }
.ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.footer { padding-bottom: 30px; font-size: .82rem; }
[hidden] { display: none !important; }
