/* =====================================================
   Pannello admin — tema chiaro & moderno
   ===================================================== */
:root {
  --bg:         #f6f7fb;
  --surface:    #ffffff;
  --surface-2:  #fbfbfd;
  --border:     #e7e9f1;
  --border-strong: #d8dbe7;
  --text:       #1a1d29;
  --text-soft:  #4a4f5e;
  --muted:      #8a8f9e;
  --accent:     #6366f1;          /* indigo */
  --accent-2:   #a855f7;          /* violet */
  --accent-soft:#eef0ff;
  --accent-soft-2:#f5edff;
  --success:    #10b981;
  --success-soft:#ecfdf5;
  --danger:     #ef4444;
  --danger-soft:#fef2f2;
  --warning:    #f59e0b;
  --warning-soft:#fffbeb;
  --shadow-sm:  0 1px 2px rgba(17,24,39,.04);
  --shadow:     0 4px 14px rgba(17,24,39,.06);
  --shadow-lg:  0 20px 40px -16px rgba(17,24,39,.18);
  --radius:     14px;
  --radius-sm:  10px;
  --gradient:   linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
}

*,*::before,*::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.inline { display: inline-block; }
code {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 13px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}

/* ------- Login ------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(99,102,241,.18), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(168,85,247,.18), transparent 60%),
    var(--bg);
  padding: 24px;
}
.login-card {
  background: var(--surface);
  padding: 40px 38px;
  width: 100%;
  max-width: 400px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.login-card .login-logo {
  height: 56px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.login-card .login-logo svg { width: 26px; height: 26px; color: #fff; }
.login-card .login-logo img {
  height: 56px;
  width: auto;
  max-width: 110px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 10px 24px rgba(99,102,241,.3));
}
.login-card .login-brand {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -.2px;
  color: var(--text);
  margin-bottom: 14px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.2px; }
.login-card form { margin-top: 22px; display: grid; gap: 14px; }
.login-card label { display: block; }
.login-card label span { display: block; font-size: 12.5px; color: var(--text-soft); margin-bottom: 6px; font-weight: 500; }
.login-card input {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14.5px; background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.login-card input:focus {
  outline: none; border-color: var(--accent); background: #fff;
  box-shadow: 0 0 0 4px rgba(99,102,241,.14);
}

/* ------- Layout ------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 22px 0;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 12px;
  padding: 0 22px 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.brand-dot {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--gradient);
  box-shadow: 0 8px 18px -8px rgba(99,102,241,.6);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.brand-dot svg { width: 18px; height: 18px; }
.sidebar .brand-logo {
  width: auto; height: 32px;
  max-height: 32px; max-width: 56px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 10px rgba(99,102,241,.2));
}
.brand-text { font-weight: 700; color: var(--text); font-size: 15.5px; letter-spacing: -.1px; }
.brand-text small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; margin-top: 1px; }

.sidebar nav ul { list-style: none; padding: 0 12px; margin: 0; }
.sidebar nav li { margin-bottom: 2px; }
.sidebar nav li a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; color: var(--text-soft);
  border-radius: var(--radius-sm);
  font-weight: 500; font-size: 14px;
  transition: background .15s, color .15s;
}
.sidebar nav li a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .75; }
.sidebar nav li a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar nav li.active a {
  background: var(--accent-soft); color: var(--accent);
}
.sidebar nav li.active a svg { opacity: 1; }
.sidebar-foot { margin-top: auto; padding: 16px 24px; color: var(--muted); }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.page-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.topbar-right { display: flex; gap: 10px; align-items: center; }

.content { padding: 28px 32px; max-width: 1280px; }
.content-wide {
  max-width: none;
  width: 100%;
}

/* ------- Pannelli & card ------- */
.panel {
  background: var(--surface);
  padding: 22px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}
.panel h2 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.1px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: -4px 0 18px;
}
.panel-head h2 { margin: 0; }

/* ------- Hero dashboard ------- */
.hero {
  background: var(--gradient);
  color: #fff;
  padding: 28px 30px;
  border-radius: var(--radius);
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 14px 40px -18px rgba(99,102,241,.6);
}
.hero::after {
  content: '';
  position: absolute;
  right: -60px; top: -60px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%);
  pointer-events: none;
}
.hero h1 { margin: 0 0 6px; font-size: 24px; font-weight: 700; letter-spacing: -.3px; }
.hero p { margin: 0; opacity: .9; font-size: 14.5px; }
.hero .hero-pill {
  margin-top: 18px;
  display: inline-flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.28);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 500; font-size: 13.5px;
  backdrop-filter: blur(6px);
}
.hero .hero-pill .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 8px rgba(34,197,94,.9);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ------- Stat cards ------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 14px;
  color: inherit;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.i-indigo { background: var(--accent-soft); color: var(--accent); }
.stat-icon.i-violet { background: var(--accent-soft-2); color: var(--accent-2); }
.stat-icon.i-green  { background: var(--success-soft); color: var(--success); }
.stat-icon.i-amber  { background: var(--warning-soft); color: var(--warning); }
.stat-icon.i-pink   { background: #fdf2f8; color: #ec4899; }

.stat-body { display: flex; flex-direction: column; line-height: 1.2; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.4px; }

/* ------- Mini grid preview (dashboard 2x2 mock) ------- */
.dash-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}
@media (max-width: 1000px) { .dash-row { grid-template-columns: 1fr; } }

.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.mini-cell {
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--accent-soft-2) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  min-height: 90px;
  display: flex; flex-direction: column; justify-content: center;
}
.mini-cell .mini-machine {
  font-size: 12px; color: var(--accent); font-weight: 600;
  text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px;
}
.mini-cell .mini-employee {
  font-size: 17px; font-weight: 700; color: var(--text);
  white-space: pre-line;
  line-height: 1.25;
}
.mini-cell.unassigned .mini-employee {
  color: var(--muted); font-style: italic; font-weight: 500;
}
.mini-shift-message {
  margin-top: 14px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--accent-soft-2) 100%);
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  white-space: pre-wrap;
}

/* Quick actions */
.quick-list {
  display: grid; gap: 8px; margin-top: 14px;
}
.quick-link {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500; font-size: 14px;
  transition: all .15s ease;
}
.quick-link:hover {
  background: var(--accent-soft); color: var(--accent);
  border-color: transparent;
  text-decoration: none;
}
.quick-link svg { width: 18px; height: 18px; opacity: .7; }
.quick-link span.arrow { margin-left: auto; opacity: .5; }

/* ------- Form ------- */
.form-inline {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}
.form-inline input[type="text"],
.form-inline input[type="number"],
.form-inline input[type="time"],
.form-inline input[type="date"],
.form-inline select {
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface-2);
  color: var(--text);
  transition: all .15s ease;
}
.form-inline input:focus,
.form-inline select:focus {
  outline: none; border-color: var(--accent); background: #fff;
  box-shadow: 0 0 0 4px rgba(99,102,241,.14);
}
.time-label {
  display: flex; flex-direction: column;
  font-size: 12px; color: var(--text-soft); gap: 4px;
  font-weight: 500;
}
.time-label input, .time-label select { font-size: 14px; color: var(--text); }
.setting-check {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.setting-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}
.setting-check span {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.setting-check strong {
  font-size: 13.5px;
  font-weight: 600;
}
.setting-check small {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}

.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
}
.form-grid > .grid-2 { grid-column: 1 / -1; }
.form-grid label span {
  display: block; font-size: 12.5px; color: var(--text-soft);
  margin-bottom: 6px; font-weight: 500;
}
.form-grid input[type="text"],
.form-grid input[type="date"],
.form-grid input[type="datetime-local"],
.form-grid input[type="file"],
.form-grid textarea,
.form-grid select {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--text);
  transition: all .15s ease;
}
.form-grid input:focus,
.form-grid textarea:focus,
.form-grid select:focus {
  outline: none; border-color: var(--accent); background: #fff;
  box-shadow: 0 0 0 4px rgba(99,102,241,.14);
}
.form-grid textarea { resize: vertical; min-height: 90px; }
.guest-readonly {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.guest-signature-thumb {
  width: 260px;
  max-width: 260px;
  max-height: 130px;
  display: block;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
}

/* ------- Buttons ------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
  text-decoration: none;
  transition: all .15s ease;
}
.btn:hover {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.btn-primary {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 20px -10px rgba(99,102,241,.6);
}
.btn-primary:hover {
  background: var(--gradient);
  color: #fff;
  filter: brightness(1.08);
  border-color: transparent;
}
.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-soft);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover { background: var(--danger); color: #fff; border-color: transparent; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }

/* ------- Table ------- */
.table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  margin-top: 6px;
}
.table th, .table td {
  text-align: left; padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  background: var(--surface-2);
  font-weight: 600; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px;
}
.table th:first-child { border-top-left-radius: 10px; }
.table th:last-child { border-top-right-radius: 10px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }
.guest-report-table {
  min-width: 1450px;
  width: 100%;
  font-size: 14px;
}
.guest-report-table th,
.guest-report-table td {
  padding: 15px 16px;
}
.guest-report-table th:nth-child(8),
.guest-report-table td:nth-child(8) {
  min-width: 300px;
}
.guest-report-panel {
  max-width: none;
  padding: 18px;
}
.guest-report-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  padding: 0 0 14px;
  scrollbar-gutter: stable;
}
.guest-report-scroll::-webkit-scrollbar {
  height: 14px;
}
.guest-report-scroll::-webkit-scrollbar-track {
  background: var(--surface-2);
  border-radius: 999px;
}
.guest-report-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 3px solid var(--surface-2);
}
.row-active td { background: var(--accent-soft) !important; }
.actions { white-space: nowrap; text-align: right; }
.actions .btn { margin-left: 6px; }
.actions form.inline { display: inline-block; margin: 0; }

.assignments-table th:nth-child(3),
.assignments-table th:nth-child(4) {
  width: 36%;
}
.assignment-action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.assignment-action-bar .day-nav,
.assignment-action-bar .form-inline {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.assignment-action-bar .day-nav {
  align-items: center;
}
.assignment-action-bar .btn-primary {
  min-height: 43px;
}
.assignment-shift-form select {
  min-width: 260px;
}
.assignment-copy-form input[type="date"] {
  min-width: 170px;
}
.assignment-cell,
.assignment-note-cell {
  vertical-align: top;
}
.shift-message-editor {
  margin: 2px 0 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.shift-message-editor label span {
  display: block;
  font-size: 12.5px;
  color: var(--text-soft);
  margin-bottom: 6px;
  font-weight: 600;
}
.shift-wide-note {
  min-height: 120px;
  background: #fff;
}
.assignment-workers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  max-width: 640px;
}
.worker-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
}
.worker-choice input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.assignment-note {
  width: 100%;
  min-height: 92px;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--text);
  resize: vertical;
  transition: all .15s ease;
}
.assignment-note:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(99,102,241,.14);
}

/* ------- Badges / alerts ------- */
.badge {
  display: inline-block; padding: 3px 9px;
  font-size: 10.5px; font-weight: 600;
  border-radius: 999px;
  background: var(--surface-2); color: var(--text-soft);
  letter-spacing: .5px;
  text-transform: uppercase;
  border: 1px solid var(--border);
}
.badge-green { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-amber { background: var(--warning-soft); color: var(--warning); border-color: transparent; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 14px;
  display: flex; align-items: center; gap: 10px;
}
.alert-success { background: var(--success-soft); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: var(--danger-soft); color: #991b1b; border: 1px solid #fecaca; }

.thumb {
  max-width: 80px; max-height: 60px; border-radius: 8px;
  border: 1px solid var(--border); object-fit: cover;
}
.thumb-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }

/* ------- Hamburger + backdrop (mobile drawer) ------- */
.hamburger {
  display: none;
  width: 40px; height: 40px;
  padding: 0; margin-right: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.hamburger:active { background: var(--accent-soft); }
.hamburger svg { width: 22px; height: 22px; }
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(17,24,39,.45);
  z-index: 40;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-backdrop.open { display: block; }

/* ------- Responsive table wrapper ------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
  padding: 0 4px;
}

/* ------- Tablet ------- */
@media (max-width: 1024px) {
  .content { padding: 22px 20px; max-width: none; }
  .topbar { padding: 16px 20px; }
  .hero { padding: 22px 22px; }
  .hero h1 { font-size: 20px; }
  .dash-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ------- Mobile (drawer sidebar) ------- */
@media (max-width: 900px) {
  .layout { display: block; }
  .main { width: 100%; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 280px; max-width: 86vw;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 0 transparent;
    overflow-y: auto;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 0 20px 60px -20px rgba(17,24,39,.4);
  }
  /* prevent background scroll while drawer is open */
  body.sidebar-open { overflow: hidden; }

  .hamburger { display: inline-flex; }

  .topbar {
    padding: 12px 14px;
    gap: 8px;
    position: sticky; top: 0; z-index: 10;
  }
  .page-title { font-size: 17px; flex: 1; min-width: 0; }
  .page-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right { gap: 6px; }
  .topbar-user { display: none; }

  .content { padding: 16px 14px; }

  /* Buttons: bigger tap targets, hide text label on icon-only context */
  .btn { padding: 10px 14px; font-size: 14px; min-height: 40px; }
  .btn-sm { padding: 8px 12px; font-size: 13px; min-height: 36px; }
  .topbar .btn { padding: 9px 12px; }
  .topbar .btn .btn-label { display: none; }
  .topbar .btn svg { margin: 0; }

  /* Panels and hero: tighter padding */
  .panel { padding: 18px 16px; border-radius: 12px; }
  .hero { padding: 20px 18px; border-radius: 12px; }
  .hero h1 { font-size: 18px; }
  .hero p { font-size: 13.5px; }

  /* Stats: stack to single column on small phones */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 14px; gap: 12px; }
  .stat-icon { width: 38px; height: 38px; border-radius: 10px; }
  .stat-icon svg { width: 19px; height: 19px; }
  .stat-value { font-size: 21px; }
  .stat-label { font-size: 12px; }

  /* Forms */
  .form-inline { flex-direction: column; align-items: stretch; gap: 12px; }
  .form-inline .btn { width: 100%; justify-content: center; }
  .form-inline input[type="text"],
  .form-inline input[type="number"],
  .form-inline input[type="time"],
  .form-inline input[type="date"],
  .form-inline select {
    width: 100%; font-size: 16px; /* 16px avoids iOS zoom-on-focus */
    padding: 12px 14px;
  }
  .form-grid input,
  .form-grid textarea,
  .form-grid select { font-size: 16px; padding: 12px 14px; }
  .login-card input { font-size: 16px; padding: 12px 14px; }

  /* Tables: card-style stacked rows on phone */
  .table { display: block; }
  .table thead { display: none; }
  .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    padding: 6px 4px;
    background: var(--surface);
  }
  .table tr:hover td { background: transparent; }
  .table td {
    border-bottom: 1px dashed var(--border);
    padding: 9px 10px;
    text-align: left;
    word-break: break-word;
  }
  .table td:last-child { border-bottom: none; }
  .table td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
    margin-bottom: 2px;
  }
  .table td.actions {
    text-align: left;
    display: flex; flex-wrap: wrap; gap: 6px;
    padding-top: 12px;
  }
  .table td.actions::before { display: none; }
  .table td.actions .btn { margin-left: 0; flex: 1 1 auto; justify-content: center; min-width: 110px; }
  .table td.actions form.inline { display: flex; flex: 1 1 auto; }
  .table td.actions form.inline .btn { width: 100%; }
  .assignment-workers { grid-template-columns: 1fr; max-width: none; }
  .assignment-action-bar,
  .assignment-action-bar .day-nav,
  .assignment-action-bar .form-inline {
    flex-direction: column;
    align-items: stretch;
  }
  .assignment-action-bar .day-nav .btn,
  .assignment-action-bar > .btn,
  .assignment-shift-form select,
  .assignment-copy-form input[type="date"] {
    width: 100%;
    min-width: 0;
  }
  .assignments-table th:nth-child(3),
  .assignments-table th:nth-child(4) { width: auto; }

  /* Login card on phone */
  .login-card { padding: 28px 22px; }

  /* Topbar logo a bit smaller on mobile, sidebar logo unaffected */
  .sidebar .brand-logo { height: 30px; max-width: 50px; }
}

/* ------- Small phones ------- */
@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar-display .btn-label { display: none; }
}

/* ===================================================== */
/* Assignment calendar                                    */
/* ===================================================== */
.cal-head { display: flex; align-items: center; gap: 12px; }
.cal-title { flex: 1 1 auto; text-align: center; font-size: 20px; font-weight: 700; letter-spacing: .2px; }
.cal-head-right { display: flex; align-items: center; gap: 8px; }

/* Round month-nav arrows */
.cal-nav {
  width: 38px; height: 38px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 20px; line-height: 1;
}

.day-nav { display: flex; flex-wrap: wrap; gap: 8px; }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 16px;
}
.cal-dow {
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .6px;
  color: var(--muted);
  text-transform: uppercase;
  padding: 2px 0 8px;
}
.cal-dow:nth-child(6),
.cal-dow:nth-child(7) { color: var(--accent); }

.cal-cell {
  position: relative;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 9px 11px;
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease, transform .06s ease, background .15s ease;
}
a.cal-cell:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
a.cal-cell:active { transform: translateY(0); }
.cal-blank { background: transparent; border-color: transparent; pointer-events: none; }

.cal-day {
  font-weight: 600;
  font-size: 14px;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.cal-weekend { background: var(--bg); }
.cal-past .cal-day { color: var(--muted); }

.cal-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-today .cal-day { background: var(--accent); color: #fff; }

/* Count chip pinned to the bottom-left */
.cal-count {
  margin-top: auto;
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  font-size: 11.5px; font-weight: 700;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.cal-count svg { display: block; }

/* Subtle "add" affordance on empty days */
.cal-add {
  position: absolute; right: 10px; bottom: 7px;
  font-size: 19px; line-height: 1; font-weight: 400;
  color: var(--muted); opacity: 0;
  transition: opacity .15s ease;
}
a.cal-cell:hover .cal-add { opacity: .55; }
.cal-has .cal-add { display: none; }

@media (max-width: 640px) {
  .cal-title { font-size: 16px; }
  .cal-nav { width: 34px; height: 34px; font-size: 18px; }
  .calendar { gap: 5px; }
  .cal-cell { min-height: 62px; padding: 6px; border-radius: 9px; }
  .cal-day { width: 24px; height: 24px; font-size: 13px; }
  .cal-dow { font-size: 10px; }
  .cal-count { padding: 2px 6px; font-size: 10px; }
  .cal-count svg { display: none; }
  .cal-add { display: none; }
}

/* ===================================================== */
/* Report page — schedule/assignments report            */
/* ===================================================== */

/* Date range selection form */
.date-range-form {
  padding: 0;
}

.date-range-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
  align-items: flex-end;
}

.date-range-form .form-group {
  display: flex;
  flex-direction: column;
}

.date-range-form label {
  display: block;
  margin-bottom: 0;
}

.date-range-form label span {
  display: block;
  font-size: 12.5px;
  color: var(--text-soft);
  margin-bottom: 7px;
  font-weight: 500;
}

.date-range-form input[type="date"] {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.date-range-form input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(99,102,241,.14);
}

.date-range-form .form-actions {
  display: flex;
  gap: 8px;
}

/* Report action buttons */
.report-actions {
  display: flex;
  gap: 10px;
  margin: 20px 0;
  justify-content: flex-end;
}

/* Report week container */
.report-week {
  margin-bottom: 32px;
  page-break-inside: avoid;
}

.week-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(99,102,241,.05) 0%, rgba(168,85,247,.05) 100%);
  border-radius: var(--radius);
  margin-bottom: 18px;
  border-left: 4px solid var(--accent);
}

.week-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.2px;
}

/* Date section within a week */
.date-section {
  margin-bottom: 22px;
  page-break-inside: avoid;
}

.date-title {
  display: flex;
  align-items: center;
  padding: 12px 0 10px 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 14px;
}

.date-title h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.1px;
}

/* Shift block */
.shift-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
  page-break-inside: avoid;
}

.shift-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.shift-name {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.shift-time {
  font-size: 13px;
  color: var(--muted);
  background: rgba(99,102,241,.1);
  padding: 3px 9px;
  border-radius: 6px;
  font-weight: 500;
}

/* Shift message (when entire shift is a message) */
.shift-message {
  padding: 14px 16px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13.5px;
  line-height: 1.6;
}

.shift-message strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
}

/* Machines table */
.machines-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.machines-table thead {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.machines-table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.machines-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background-color .12s ease;
}

.machines-table tbody tr:last-child {
  border-bottom: none;
}

.machines-table tbody tr:hover {
  background-color: var(--surface-2);
}

.machines-table td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
}

.machine-cell {
  font-weight: 600;
  width: 25%;
  color: var(--accent);
}

.assignment-cell {
  width: 75%;
  line-height: 1.5;
  word-break: break-word;
}

.assignment-cell .unassigned {
  color: var(--muted);
  font-style: italic;
}

/* Alert for empty results */
.alert-muted {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 30px 20px;
  border-radius: var(--radius-sm);
  text-align: center;
}

/* Print styles */
@media print {
  body {
    background: #fff;
    color: #000;
  }

  .layout {
    display: block;
  }

  .sidebar,
  .sidebar-backdrop,
  .topbar,
  .hamburger,
  .topbar-right,
  .topbar-display,
  .date-range-form,
  .report-actions,
  .hero,
  .footer {
    display: none !important;
  }

  main.main {
    margin-left: 0;
  }

  .content {
    padding: 0;
  }

  .panel {
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 0;
    margin-bottom: 0;
  }

  .panel-head {
    display: none;
  }

  /* Report styling for print */
  .report-week {
    page-break-after: avoid;
    margin-bottom: 24px;
  }

  .week-header {
    background: #f0f0f0 !important;
    border-left: 3px solid #333 !important;
    page-break-after: avoid;
    margin-bottom: 12px;
  }

  .week-header h2 {
    color: #000 !important;
    font-size: 16px;
  }

  .date-section {
    page-break-inside: avoid;
    margin-bottom: 18px;
  }

  .date-title {
    border-bottom: 2px solid #333;
    margin-bottom: 10px;
  }

  .date-title h3 {
    color: #000;
  }

  .shift-block {
    border: 1px solid #ccc;
    background: #fff;
    margin-bottom: 10px;
    page-break-inside: avoid;
  }

  .shift-header {
    background: #f9f9f9;
    border-bottom: 1px solid #ccc;
    padding: 10px 14px;
  }

  .shift-name {
    color: #000;
    font-size: 13px;
  }

  .shift-time {
    background: #e8e8e8 !important;
    color: #333 !important;
    font-size: 12px;
  }

  .shift-message {
    background: #f0f0f0 !important;
    color: #000 !important;
    padding: 10px 14px;
  }

  .shift-message strong {
    color: #000 !important;
  }

  .machines-table {
    font-size: 13px;
    margin: 0;
    width: 100%;
  }

  .machines-table thead {
    background: #f5f5f5;
  }

  .machines-table th {
    color: #000;
    font-size: 11px;
    padding: 8px 12px;
    border-bottom: 1px solid #ccc;
  }

  .machines-table td {
    padding: 8px 12px;
    color: #000;
    border-bottom: 1px solid #eee;
  }

  .machines-table tbody tr:hover {
    background-color: transparent;
  }

  .machine-cell {
    color: #333;
    font-weight: 600;
    width: 25%;
  }

  .assignment-cell {
    width: 75%;
  }

  .assignment-cell .unassigned {
    color: #999;
  }

  /* Page break optimization */
  .report-week { break-inside: avoid; }
  .date-section { break-inside: avoid; }
  .shift-block { break-inside: avoid; }

  /* Minimal margins for print */
  .content { margin: 0; padding: 0 20px; }
  section { margin-bottom: 16px; }
  h1, h2, h3 { margin: 0 0 8px 0; color: #000; }
  p { margin: 0 0 8px 0; }
}

@media (max-width: 768px) {
  .date-range-form .form-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .date-range-form .form-actions {
    width: 100%;
  }

  .date-range-form .form-actions .btn {
    width: 100%;
  }

  .report-actions {
    justify-content: center;
  }

  .machines-table {
    font-size: 13px;
  }

  .machines-table th,
  .machines-table td {
    padding: 9px 12px;
  }

  .machine-cell {
    width: 30%;
    font-size: 13px;
  }

  .assignment-cell {
    width: 70%;
    font-size: 13px;
  }
}

.guest-report-scroll .guest-report-table {
  display: table;
}
.guest-report-scroll .guest-report-table thead {
  display: table-header-group;
}
.guest-report-scroll .guest-report-table tbody {
  display: table-row-group;
}
.guest-report-scroll .guest-report-table tr {
  display: table-row;
  width: auto;
}
.guest-report-scroll .guest-report-table th,
.guest-report-scroll .guest-report-table td {
  display: table-cell;
  width: auto;
}
.guest-report-scroll .guest-report-table td::before {
  display: none;
}

@media print {
  .content-wide .guest-report-filters,
  .content-wide .guest-report-actions {
    display: none !important;
  }

  .content-wide {
    max-width: none !important;
    width: 100% !important;
    padding: 0 !important;
  }

  .content-wide .guest-report-table-panel {
    display: block !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .content-wide .guest-report-table-panel .panel-head {
    display: block !important;
    margin: 0 0 8px !important;
  }

  .content-wide .guest-report-scroll {
    overflow: visible !important;
    padding: 0 !important;
  }

  .content-wide .guest-report-table {
    min-width: 0 !important;
    width: 100% !important;
    font-size: 9.5px !important;
    border-collapse: collapse !important;
  }

  .content-wide .guest-report-table th,
  .content-wide .guest-report-table td {
    padding: 5px 6px !important;
    border: 1px solid #999 !important;
    color: #000 !important;
    background: #fff !important;
  }

  .content-wide .guest-report-table th {
    background: #eee !important;
  }

  .content-wide .guest-signature-thumb {
    width: 110px !important;
    max-width: 110px !important;
    max-height: 60px !important;
    padding: 2px !important;
  }
}
