/* ── RESET & BASE ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #13161c;
  --bg2:       #1c2028;
  --bg3:       #242832;
  --bg4:       #2c3140;
  --accent:    #5b7cf6;
  --accent-h:  #7b97ff;
  --text:      #e2e5ee;
  --text2:     #8b93a8;
  --text3:     #5a6175;
  --border:    #2c3140;
  --success:   #27ae60;
  --danger:    #e74c3c;
  --warning:   #f39c12;
  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
  --sidebar-w: 220px;
  --topbar-h:  60px;
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ── LOGIN ───────────────────────────────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}

.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 360px;
  box-shadow: var(--shadow);
}

.login-logo { font-size: 40px; text-align: center; margin-bottom: 8px; }
.login-title { font-size: 22px; font-weight: 700; text-align: center; color: var(--text); }
.login-sub { font-size: 13px; color: var(--text2); text-align: center; margin: 4px 0 24px; min-height: 18px; }

.login-error {
  background: rgba(231,76,60,.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 8px;
}

/* ── LAYOUT ──────────────────────────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w); background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 22px; }
.brand-name { font-size: 17px; font-weight: 700; }

.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }

.nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: none; background: transparent;
  color: var(--text2); border-radius: var(--radius-sm);
  cursor: pointer; font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s; width: 100%; text-align: left;
  position: relative;
}
.nav-btn svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.nav-btn:hover { background: var(--bg3); color: var(--text); }
.nav-btn.active { background: rgba(91,124,246,.15); color: var(--accent); }

.nav-badge {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: var(--danger); color: #fff; border-radius: 10px;
  font-size: 10px; font-weight: 700; padding: 1px 6px; min-width: 18px; text-align: center;
}

.sidebar-user {
  padding: 12px 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sidebar-userinfo { flex: 1; min-width: 0; }
.sidebar-username { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-role { font-size: 11px; color: var(--text3); }
.logout-btn {
  background: none; border: none; color: var(--text3); cursor: pointer; font-size: 16px;
  padding: 3px; border-radius: 4px; transition: color .12s;
}
.logout-btn:hover { color: var(--danger); }

/* MAIN */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--topbar-h); background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; flex-shrink: 0;
}
.topbar h1 { font-size: 18px; font-weight: 600; }
#topbar-actions { display: flex; gap: 8px; align-items: center; }
.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── BOTTONI ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: opacity .15s, filter .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { filter: brightness(.95); }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--bg4); color: var(--text); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; }

/* ── CARD ────────────────────────────────────────────────────────────────── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-title { font-size: 12px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }

/* ── DASHBOARD ───────────────────────────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-label { font-size: 12px; color: var(--text2); }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-sub   { font-size: 12px; color: var(--text3); }

.dash-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.today-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.today-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg3); border-radius: var(--radius-sm); }
.today-name { font-weight: 500; flex: 1; }

/* ── CALENDARIO ──────────────────────────────────────────────────────────── */
.cal-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.cal-nav-btn { background: var(--bg2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 6px 12px; cursor: pointer; font-size: 16px; }
.cal-nav-btn:hover { background: var(--bg4); }
.cal-month-label { font-size: 18px; font-weight: 600; min-width: 180px; text-align: center; }

.cal-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text2); }
.legend-dot { width: 14px; height: 14px; border-radius: 3px; }

.cal-wrapper { overflow-x: auto; }
.cal-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 900px; }

.cal-table th {
  background: var(--bg2); color: var(--text2); font-size: 11px; font-weight: 600;
  padding: 6px 4px; text-align: center; border-bottom: 2px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
.cal-table th.col-name { text-align: left; padding-left: 12px; min-width: 160px; position: sticky; left: 0; z-index: 3; }
.cal-table th.col-total { min-width: 70px; }

.cal-table td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--bg4); padding: 2px; text-align: center; vertical-align: middle; }
.cal-table td.td-name { text-align: left; padding: 8px 12px; font-weight: 500; background: var(--bg2); position: sticky; left: 0; z-index: 1; min-width: 160px; white-space: nowrap; }
.cal-table td.td-total { font-size: 12px; font-weight: 600; color: var(--text2); padding: 4px 8px; text-align: right; }
.cal-table th.th-weekend { color: var(--accent-h) !important; }
.cal-table th.th-today   { color: #ffd700 !important; }
.cal-table th.th-holiday { color: var(--warning) !important; }
.cal-table tr:hover td.td-name { background: var(--bg3); }
.cal-table tr.row-stats td { font-size: 11px; color: var(--text3); padding: 2px 1px; background: var(--bg); text-align: center; }
.cal-table tr.row-stats td.td-name { background: var(--bg); color: var(--text2); font-weight: 500; font-size: 11px; }
.cal-table tr.row-stats-hdr td { font-size: 9px; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); background: var(--bg3); padding: 4px 8px; border-top: 1px solid var(--border); font-weight: 600; }
.shift-day-cnt { display: block; min-width: 16px; }

.shift-cell {
  display: flex; align-items: center; justify-content: center;
  height: 32px; min-width: 32px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 700; cursor: pointer;
  transition: opacity .12s, transform .1s; letter-spacing: .02em; margin: 1px; color: #fff;
}
.shift-cell:hover:not(.readonly) { opacity: .85; transform: scale(1.08); }
.shift-cell.empty { background: var(--bg4); color: var(--text3); font-size: 14px; font-weight: 300; }
.shift-cell.readonly { cursor: default; }
.shift-cell.holiday-bg { outline: 2px solid rgba(243,156,18,.5); }

/* Calendario dipendente (read-only, singola riga) */
.my-cal-wrapper .cal-table td.td-name { min-width: 80px; }
.my-cal-wrapper .shift-cell { height: 36px; min-width: 36px; font-size: 12px; }

.emp-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; flex-shrink: 0; }

/* ── LOG GENERAZIONE ──────────────────────────────────────────────────────── */
.gen-log {
  margin-top: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  overflow: hidden;
}
.gl-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  background: var(--bg3); border-bottom: 1px solid var(--border);
}
.gl-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.gl-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px;
}
.gl-badge-ok   { background: rgba(39,174,96,.2);  color: var(--success); border: 1px solid rgba(39,174,96,.35); }
.gl-badge-warn { background: rgba(243,156,18,.2); color: var(--warning); border: 1px solid rgba(243,156,18,.35); }
.gl-dismiss {
  background: transparent; border: none; color: var(--text3);
  cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: 4px;
  transition: color .12s, background .12s;
}
.gl-dismiss:hover { color: var(--text); background: var(--bg4); }

.gl-ok {
  padding: 14px 16px; font-size: 13px; color: var(--success);
  display: flex; align-items: center; gap: 6px;
}
.gl-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.gl-section { display: flex; flex-direction: column; gap: 6px; }
.gl-section-title {
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
}
.gl-count {
  font-size: 10px; font-weight: 700; padding: 1px 6px;
  border-radius: 10px; background: var(--bg4); color: var(--text2);
}
.gl-list { list-style: none; display: flex; flex-direction: column; gap: 3px; padding-left: 4px; }
.gl-item {
  font-size: 12px; color: var(--text2); line-height: 1.5;
  padding: 3px 8px; border-radius: 4px; border-left: 3px solid transparent;
}
.gl-warn   .gl-item { border-left-color: var(--warning);  background: rgba(243,156,18,.06); }
.gl-danger .gl-item { border-left-color: var(--danger);   background: rgba(231,76,60,.06);  }
.gl-info    .gl-item { border-left-color: var(--accent);   background: rgba(91,124,246,.06); }
.gl-weekend .gl-item { border-left-color: #27ae60;         background: rgba(39,174,96,.07);  }

/* ── VISTA MENSILE CALENDARIO ─────────────────────────────────────────────── */
.cal-view-toggle { display: flex; gap: 3px; align-items: center; }
.cal-view-btn {
  padding: 5px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg3);
  color: var(--text2); cursor: pointer; font-size: 12px; font-weight: 600;
  transition: background .15s, color .15s, border-color .15s;
}
.cal-view-btn.active { background: rgba(91,124,246,.18); border-color: var(--accent); color: var(--accent); }
.cal-view-btn:hover:not(.active) { background: var(--bg4); color: var(--text); }

.mv-grid-hdr { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-bottom: 5px; }
.mv-hcell { text-align: center; font-size: 11px; font-weight: 700; color: var(--text3); padding: 3px 0; text-transform: uppercase; letter-spacing: .05em; }

.mv-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }

.mv-cell {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 6px;
  min-height: 80px; display: flex; flex-direction: column; gap: 5px;
}
.mv-cell-empty { background: transparent; border-color: transparent; min-height: 80px; }
.mv-weekend { background: rgba(255,255,255,.018); }
.mv-today { border-color: var(--accent) !important; }
.mv-today .mv-day-n { color: var(--accent); }

.mv-day-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.mv-day-n { font-size: 13px; font-weight: 700; color: var(--text); }
.mv-weekend .mv-day-n { color: var(--accent-h); }
.mv-fest-badge { font-size: 9px; background: rgba(243,156,18,.25); color: var(--warning); border: 1px solid rgba(243,156,18,.4); border-radius: 3px; padding: 1px 4px; font-weight: 700; line-height: 1.3; text-align: right; max-width: 100%; word-break: break-word; }

.mv-shift-grp { display: flex; flex-direction: column; gap: 3px; }
.mv-shift-lbl { font-size: 10px; font-weight: 700; padding: 1px 5px; margin-bottom: 2px; background: rgba(255,255,255,.04); border-radius: 3px; }
.mv-workers { display: flex; flex-direction: column; gap: 2px; padding-left: 3px; }
.mv-worker { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text2); line-height: 1.4; }
.mv-worker-sr { color: var(--text); font-weight: 600; }
.mv-wdot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.mv-wname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mv-sr-pill {
  display: inline-block; font-size: 9px; font-weight: 700; padding: 1px 4px;
  border-radius: 3px; background: rgba(255,215,0,.18); color: #ffd700;
  border: 1px solid rgba(255,215,0,.35); flex-shrink: 0; white-space: nowrap;
}
.mv-no-shift { font-size: 11px; color: var(--text3); text-align: center; padding-top: 6px; }

/* ── DIPENDENTI ──────────────────────────────────────────────────────────── */
.emp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.emp-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; cursor: pointer; transition: border-color .15s, background .15s; position: relative; }
.emp-card:hover { border-color: var(--accent); background: var(--bg3); }
.emp-card-avatar { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; color: #fff; margin-bottom: 12px; }
.emp-card-name { font-size: 15px; font-weight: 600; }
.emp-card-role { font-size: 12px; color: var(--text2); margin-top: 2px; }
.emp-card-cycle { font-size: 11px; color: var(--text3); margin-top: 8px; }

.qualifica-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.qualifica-senior { background: rgba(243,156,18,.15); color: #f39c12; border: 1px solid rgba(243,156,18,.3); }
.qualifica-radio  { background: rgba(91,124,246,.12); color: var(--accent); border: 1px solid rgba(91,124,246,.25); }

/* Preferenze turni nella card */
.emp-card-prefs { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 7px; }
.pref-chip { display: inline-flex; align-items: center; gap: 2px; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 3px; border: 1px solid; }
.pref-chip-ok { border-color: rgba(39,174,96,.4); background: rgba(39,174,96,.1); color: var(--success); }
.pref-chip-no { border-color: rgba(231,76,60,.35); background: rgba(231,76,60,.1); color: var(--danger); }

/* Cycle picker nel modal dipendente */
.cycle-picker { display: flex; flex-wrap: wrap; gap: 5px; }
.cycle-pick-day {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 38px; height: 42px; border-radius: var(--radius-sm); border: 2px solid;
  cursor: pointer; transition: all .12s; user-select: none;
}
.cycle-pick-day:hover { filter: brightness(1.2); transform: translateY(-2px); }
.cycle-pick-day.selected { box-shadow: 0 0 0 2px rgba(255,255,255,.3); }
.cpd-num { font-size: 9px; opacity: .7; line-height: 1; }
.cpd-shift { font-size: 12px; font-weight: 700; line-height: 1.2; }

/* Toggle preferenze nel modal */
.pref-toggles { display: flex; gap: 8px; flex-wrap: wrap; }
.pref-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--bg3);
  color: var(--text2); cursor: pointer; font-size: 12px; font-weight: 600;
  transition: border-color .15s, background .15s, color .15s;
}
.pref-toggle:hover { border-color: var(--text3); color: var(--text); }
.emp-card-del { position: absolute; top: 12px; right: 12px; background: transparent; border: none; color: var(--text3); cursor: pointer; font-size: 16px; border-radius: 4px; padding: 2px 5px; transition: color .12s, background .12s; }
.emp-card-del:hover { color: var(--danger); background: rgba(231,76,60,.1); }
.emp-add-card { background: var(--bg2); border: 2px dashed var(--border); border-radius: var(--radius); padding: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--text3); font-size: 14px; transition: border-color .15s, color .15s; min-height: 130px; }
.emp-add-card:hover { border-color: var(--accent); color: var(--accent); }

/* ── RICHIESTE ───────────────────────────────────────────────────────────── */
.requests-list { display: flex; flex-direction: column; gap: 12px; }

.request-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; align-items: flex-start; gap: 14px;
  transition: border-color .15s;
}
.request-card:hover { border-color: var(--bg4); }

.request-icon { font-size: 24px; flex-shrink: 0; margin-top: 2px; }
.request-info { flex: 1; }
.request-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.request-type { font-size: 14px; font-weight: 600; }
.request-emp  { font-size: 12px; color: var(--text2); }
.request-dates { font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.request-notes { font-size: 12px; color: var(--text3); font-style: italic; }
.request-rejection { font-size: 12px; color: var(--danger); margin-top: 4px; }
.request-actions { display: flex; gap: 8px; margin-top: 8px; }
.request-meta { font-size: 11px; color: var(--text3); white-space: nowrap; text-align: right; }

/* Status badge */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; letter-spacing: .03em;
}
.badge-pending  { background: rgba(243,156,18,.15); color: var(--warning); border: 1px solid rgba(243,156,18,.3); }
.badge-approved { background: rgba(39,174,96,.15);  color: var(--success); border: 1px solid rgba(39,174,96,.3); }
.badge-rejected { background: rgba(231,76,60,.15);  color: var(--danger);  border: 1px solid rgba(231,76,60,.3); }

.requests-filter { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-btn { padding: 5px 12px; border: 1px solid var(--border); background: var(--bg2); color: var(--text2); border-radius: 20px; cursor: pointer; font-size: 12px; transition: all .15s; }
.filter-btn:hover, .filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── UTENTI ──────────────────────────────────────────────────────────────── */
.users-table { width: 100%; border-collapse: collapse; }
.users-table th { color: var(--text2); font-size: 11px; font-weight: 600; text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border); }
.users-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 13px; }
.users-table tr:hover td { background: var(--bg3); }
.role-badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.role-admin      { background: rgba(91,124,246,.2); color: var(--accent); }
.role-supervisor { background: rgba(243,156,18,.2); color: var(--warning); }
.role-employee   { background: rgba(39,174,96,.2);  color: var(--success); }

/* ── IMPOSTAZIONI ────────────────────────────────────────────────────────── */
.settings-section { margin-bottom: 28px; }
.settings-section h3 { font-size: 13px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 180px; }
.form-group label { font-size: 12px; color: var(--text2); font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 7px 10px; font-size: 13px; outline: none; transition: border-color .15s; width: 100%;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); }
.form-group input[type="color"] { padding: 3px 6px; height: 34px; cursor: pointer; }
.form-group textarea { resize: vertical; min-height: 72px; font-family: inherit; }

.cycle-pattern-editor { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; background: var(--bg3); border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 10px; }
.cycle-slot { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 38px; height: 42px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 700; color: #fff; cursor: pointer; transition: transform .12s; }
.cycle-slot:hover { transform: scale(1.1); }

/* Planning rules grid */
.planning-rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 4px; }
.rule-card { display: flex; gap: 14px; padding: 16px; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); }
.rule-icon { font-size: 22px; line-height: 1; padding-top: 2px; flex-shrink: 0; }
.rule-body { flex: 1; }
.rule-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.rule-desc { font-size: 11px; color: var(--text3); margin-bottom: 10px; line-height: 1.4; }
.rule-input-row { display: flex; align-items: center; gap: 8px; }
.rule-input { width: 70px; padding: 5px 8px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 14px; font-weight: 600; }
.rule-unit { font-size: 11px; color: var(--text3); }

/* Staffing rules — blocchi per tipo turno */
.staffing-shift-block { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 12px; }
.staffing-shift-header { display: flex; align-items: center; gap: 10px; padding: 8px 14px; }
.staffing-shift-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.staffing-shift-time { font-size: 11px; color: var(--text2); margin-left: auto; }

.staffing-table { width: 100%; border-collapse: collapse; }
.staffing-table th { color: var(--text2); font-size: 11px; font-weight: 600; text-align: left; padding: 6px 12px; border-bottom: 2px solid var(--border); background: var(--bg); }
.staffing-table td { padding: 4px 6px; border-bottom: 1px solid var(--bg3); vertical-align: middle; }
.staffing-table td.staffing-day { font-size: 13px; font-weight: 500; color: var(--text); padding-left: 14px; min-width: 110px; }
.staffing-table input { background: var(--bg3); border: 1px solid var(--border); color: var(--text); border-radius: 4px; padding: 4px 6px; font-size: 13px; font-weight: 600; width: 62px; text-align: center; }
.staffing-table input:focus { border-color: var(--accent); outline: none; }

.shift-type-table { width: 100%; border-collapse: collapse; }
.shift-type-table th { color: var(--text2); font-size: 11px; font-weight: 600; text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.shift-type-table td { padding: 6px 8px; border-bottom: 1px solid var(--bg3); vertical-align: middle; }
.shift-type-table input { background: var(--bg3); border: 1px solid var(--border); color: var(--text); border-radius: 4px; padding: 4px 6px; font-size: 12px; width: 100%; }
.shift-type-table input[type="color"] { width: 40px; height: 26px; padding: 1px 3px; cursor: pointer; }

/* ── MODAL ───────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; animation: fadeIn .15s ease; }
.modal-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); width: 90%; max-width: 480px; max-height: 85vh; display: flex; flex-direction: column; animation: slideUp .2s ease; }
.modal-wide { max-width: 700px; }
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text2); font-size: 22px; cursor: pointer; line-height: 1; transition: color .12s; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* Shift picker */
.shift-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shift-pick-btn { padding: 12px 8px; border: none; border-radius: var(--radius-sm); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: filter .12s, transform .1s; }
.shift-pick-btn span.sub { font-size: 11px; font-weight: 400; opacity: .8; }
.shift-pick-btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.shift-pick-btn.selected { outline: 3px solid #fff; }
.shift-pick-clear { grid-column: 1/-1; background: var(--bg4); color: var(--text2); padding: 10px; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 500; transition: background .12s; }
.shift-pick-clear:hover { background: var(--danger); color: #fff; }

/* Genera modal */
.genera-employee-list { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.genera-emp-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg3); border-radius: var(--radius-sm); }
.genera-emp-name { flex: 1; font-weight: 500; font-size: 13px; }
.genera-offset-input { background: var(--bg4); border: 1px solid var(--border); color: var(--text); border-radius: 4px; padding: 4px 8px; width: 65px; font-size: 12px; text-align: center; }

/* ── VISTA DIPENDENTE ────────────────────────────────────────────────────── */
.my-shift-today {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; text-align: center; margin-bottom: 20px;
}
.my-shift-today .label { font-size: 12px; color: var(--text2); margin-bottom: 8px; }
.my-shift-today .shift-big {
  display: inline-block; padding: 10px 28px; border-radius: var(--radius); font-size: 22px; font-weight: 700; color: #fff; margin-bottom: 6px;
}
.my-shift-today .shift-time { font-size: 14px; color: var(--text2); }
.my-shift-today .no-shift { font-size: 18px; color: var(--text3); }

/* ── TOAST ───────────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 18px; font-size: 13px; color: var(--text); box-shadow: var(--shadow); z-index: 2000; animation: slideInRight .2s ease; max-width: 320px; }
.toast.hidden { display: none; }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }
.toast.warning { border-color: #f59e0b;         color: #f59e0b; }
@keyframes slideInRight { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── UTILITÀ ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt-4  { margin-top: 4px; }  .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.flex  { display: flex; } .gap-8 { gap: 8px; }
.text-muted { color: var(--text2); } .text-sm { font-size: 12px; }
.empty-state { text-align: center; color: var(--text3); padding: 40px 20px; }
.empty-state .big { font-size: 48px; margin-bottom: 12px; }
.separator { height: 1px; background: var(--border); margin: 16px 0; }
.emp-account-box { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; font-size: 13px; }

/* ── INSERIMENTO DIRETTO ─────────────────────────────────────────────────── */
.ins-swap-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: start; }
.ins-swap-col  { display: flex; flex-direction: column; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.ins-swap-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text2); margin-bottom: 10px; }
.ins-swap-icon  { font-size: 26px; color: var(--accent); display: flex; align-items: center; justify-content: center; padding-top: 36px; }
.ins-turno-prev { font-size: 12px; margin-top: 6px; min-height: 18px; font-style: italic; color: var(--text3); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg4); }

/* ── NUOVI BADGE STATUS ──────────────────────────────────────────────────── */
.badge-warning { background: rgba(243,156,18,.15); color: var(--warning); border: 1px solid rgba(243,156,18,.3); }
.badge-info    { background: rgba(91,124,246,.15); color: var(--accent);  border: 1px solid rgba(91,124,246,.3); }

/* ── RICHIESTE: sezione titolo e card in entrata ─────────────────────────── */
.req-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text3); margin-bottom: 8px; margin-top: 4px; }
.req-incoming { border-color: var(--accent); background: rgba(91,124,246,.05); }

/* ── HAMBURGER + SIDEBAR MOBILE ──────────────────────────────────────────── */
.hamburger-btn {
  display: none;
  background: none; border: none; color: var(--text); cursor: pointer;
  font-size: 22px; padding: 4px 8px; border-radius: var(--radius-sm);
  line-height: 1; flex-shrink: 0; transition: background .12s;
}
.hamburger-btn:hover { background: var(--bg4); }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 199;
}
.sidebar-backdrop.active { display: block; }

/* ── TABLET (769 – 1024px) ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 190px; }
  .content { padding: 18px 16px; }
}

/* ── MOBILE (≤ 768px) ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 240px; --topbar-h: 52px; }

  /* Hamburger visibile */
  .hamburger-btn { display: flex; align-items: center; }

  /* Sidebar come drawer laterale fisso */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 200;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }

  /* Layout principale — pieno schermo */
  #app { display: block; height: 100vh; overflow: hidden; }
  .main { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

  /* Topbar */
  .topbar { padding: 0 10px; }
  .topbar h1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Content */
  .content { padding: 14px 12px; padding-bottom: 20px; }

  /* Login */
  .login-box { width: calc(100% - 32px); padding: 28px 20px; }

  /* Dashboard */
  .dash-row { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: repeat(2, 1fr); }

  /* Calendario */
  .cal-month-label { font-size: 15px; min-width: 0; }
  .cal-table { min-width: 600px; }
  .shift-cell { height: 28px; min-width: 28px; font-size: 10px; }
  .cal-table td.td-name { min-width: 110px; font-size: 12px; }
  .cal-table th.col-name { min-width: 110px; }

  /* Vista mensile */
  .mv-grid { gap: 2px; }
  .mv-cell { min-height: 56px; padding: 3px 2px; }
  .mv-wname { display: none; }
  .mv-wdot { width: 7px; height: 7px; }
  .mv-worker { gap: 3px; }
  .mv-shift-lbl { font-size: 9px; }

  /* Modali — slide dal basso */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal, .modal-wide {
    width: 100%; max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 90vh;
    animation: slideUpMobile .25s ease;
  }
  @keyframes slideUpMobile { from { transform: translateY(100%); } to { transform: translateY(0); } }

  /* Form */
  .form-row { flex-direction: column; gap: 8px; }
  .form-group { min-width: 0; }

  /* Dipendenti */
  .emp-grid { grid-template-columns: 1fr; }

  /* Richieste */
  .request-card { flex-direction: column; gap: 10px; }
  .request-meta { text-align: left; }
  .requests-filter { gap: 6px; }
  .filter-btn { font-size: 11px; padding: 4px 10px; }

  /* Tabella utenti */
  .users-table { font-size: 12px; }
  .users-table th, .users-table td { padding: 7px 6px; }

  /* Toast */
  .toast { bottom: 16px; right: 12px; left: 12px; max-width: none; font-size: 13px; }

  /* Log generazione */
  .gen-log { margin-top: 14px; }
  .gl-body { padding: 10px 12px; }

  /* Genera modal employee list */
  .genera-employee-list { max-height: 180px; overflow-y: auto; }
  .genera-emp-row { padding: 6px 10px; }

  /* Inserimento diretto — swap a colonna unica */
  .ins-swap-grid { grid-template-columns: 1fr; }
  .ins-swap-icon { padding-top: 4px; transform: rotate(90deg); }
}

/* ══════════════════════════════════════════════════════════════════════════
   AUDIT LOG TABLE
══════════════════════════════════════════════════════════════════════════ */
.audit-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg3);
}
.audit-footer {
  display: flex; justify-content: center; gap: 10px; align-items: center;
  padding: 10px 16px; border-top: 1px solid var(--border); background: var(--bg3);
}
.audit-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  min-width: 800px;
}
.audit-table thead th {
  background: var(--bg3); padding: 8px 12px; text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text3);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.audit-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.audit-table tbody tr:hover { background: var(--bg3); }
.audit-table tbody tr.audit-row-error { background: #fff0f0; }
.audit-table tbody tr.audit-row-error:hover { background: #ffe8e8; }
.audit-table td { padding: 7px 12px; vertical-align: middle; }
.audit-ts { font-size: 12px; color: var(--text2); white-space: nowrap; }
.audit-time { color: var(--text3); font-size: 11px; }
.audit-user {
  font-weight: 600; font-size: 12px;
  background: var(--bg4); padding: 2px 7px;
  border-radius: 12px; white-space: nowrap;
}
.audit-ip { font-size: 11px; color: var(--text3); font-family: monospace; }
.audit-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.audit-details { font-size: 12px; color: var(--text2); max-width: 280px; }
.audit-err {
  font-size: 11px; color: #c0392b; cursor: help;
  display: inline-block; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
