@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&display=swap");

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e6e8ee;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #ff7a1a;
  --accent-dark: #e66300;
  --ink: #111827;
  --success: #16a34a;
  --danger: #dc2626;
  --shadow: 0 8px 20px rgba(17, 24, 39, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
}

.dashboard-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-stack {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
}

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  color: #ffffff;
  background: linear-gradient(160deg, #ff8c2a, #f05b00);
}

.brand-title {
  margin: 0;
  font-size: 1.03rem;
  font-weight: 800;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.sidebar-label {
  margin: 4px 8px 2px;
  color: #8a91a1;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  font-weight: 700;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #4b5563;
  font-weight: 700;
  font-size: 0.92rem;
  border-radius: 12px;
  padding: 11px 12px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.side-link::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: transparent;
}

.side-link:hover {
  background: #f6f7f9;
  color: #111827;
}

.side-link.active {
  background: linear-gradient(180deg, #2f2924, #161312);
  color: #ffffff;
  box-shadow: 0 8px 16px rgba(17, 24, 39, 0.22);
}

.side-link.active::before {
  background: var(--accent);
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbfc;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.main-area {
  min-width: 0;
  padding: 22px clamp(14px, 2vw, 30px) 30px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}

.title-group h1 {
  margin: 0;
  font-size: clamp(1.3rem, 0.95rem + 1.1vw, 1.95rem);
  line-height: 1.2;
}

.title-group p {
  margin: 7px 0 0;
}

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

.sync-chip {
  margin: 0;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #374151;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.stat-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  margin: 8px 0 4px;
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
}

.stat-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.success {
  color: var(--success);
}

.danger {
  color: var(--danger);
}

.hint {
  margin: 0 0 10px;
  color: var(--muted);
}

.stack p {
  margin: 0 0 7px;
}

label {
  display: block;
  margin: 0 0 10px;
  color: #374151;
  font-weight: 700;
  font-size: 0.9rem;
}

input,
select {
  width: 100%;
  margin-top: 6px;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid #d9dde6;
  border-radius: 12px;
  background: #ffffff;
  color: #111827;
}

input:focus,
select:focus {
  outline: none;
  border-color: #ffb37b;
  box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.16);
}

input[type="file"] {
  padding: 8px;
}

button,
.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.15;
  color: #ffffff;
  background: linear-gradient(180deg, #ff8f32, #f46a09);
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 14px rgba(244, 106, 9, 0.26);
}

button:hover,
.btn:hover {
  background: linear-gradient(180deg, #ffa34e, #e85f00);
}

button:active,
.btn:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  color: #d1d5db;
  background: #9ca3af;
  box-shadow: none;
}

.btn.ghost,
button.ghost,
#refresh-table,
#refresh-gps,
#reload-btn {
  background: #ffffff;
  color: #374151;
  border-color: var(--line);
  box-shadow: none;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

#check-out {
  background: linear-gradient(180deg, #344154, #161f2f);
  box-shadow: 0 8px 14px rgba(22, 31, 47, 0.25);
}

#check-out:disabled {
  background: #9ca3af;
  box-shadow: none;
}

.grid-three {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #4b5563;
}

.result {
  margin: 10px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: #0f172a;
  color: #f8fafc;
  padding: 12px;
  border-radius: 12px;
}

.table-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  font-size: 13px;
  background: #ffffff;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid #edf0f5;
  padding: 9px 8px;
  vertical-align: top;
}

thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  background: #fafbfc;
}

.controls-inline {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
}

.checkbox-line input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.table-action {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.table-action.danger {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fff5f5;
}

.controls-inline label {
  margin: 0;
  flex: 1;
  min-width: 200px;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.steps {
  margin: 8px 0 0 19px;
  padding: 0;
  color: #374151;
}

.steps li {
  margin: 0 0 7px;
}

.scan-page {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at top left, #fff4ea 0%, #f5f6f8 46%, #eef1f6 100%);
}

.scan-wrap {
  width: min(930px, 100%);
  margin: 0 auto;
  padding: 18px 14px 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scan-header {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.scan-header h1 {
  margin: 0 0 6px;
  font-size: clamp(1.25rem, 0.95rem + 1vw, 1.8rem);
}

.top-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.pill-link {
  text-decoration: none;
  color: #4b5563;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 800;
}

.pill-link:hover {
  border-color: #c8ced9;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 4px 0 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.84rem;
  font-weight: 700;
  color: #4b5563;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
}

.legend-dot.checked {
  background: #16a34a;
  border-color: #15803d;
}

.legend-dot.missed {
  background: #ef4444;
  border-color: #dc2626;
}

.legend-dot.future {
  background: #9ca3af;
  border-color: #6b7280;
}

.period-calendar {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: #f9fafb;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-weekday {
  text-align: center;
  font-size: 0.76rem;
  color: #6b7280;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calendar-cell {
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
}

.calendar-empty {
  border-style: dashed;
  background: #f3f4f6;
  opacity: 0.45;
}

.calendar-day {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 7px;
  font-weight: 800;
}

.calendar-day.checked {
  background: rgba(22, 163, 74, 0.15);
  border-color: rgba(22, 163, 74, 0.45);
  color: #166534;
}

.calendar-day.missed {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(220, 38, 38, 0.45);
  color: #991b1b;
}

.calendar-day.future {
  background: #e5e7eb;
  border-color: #cbd5e1;
  color: #475569;
}

.day-number {
  font-size: 0.9rem;
}

.warning-modal[hidden] {
  display: none;
}

.warning-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(2px);
}

.warning-modal-card {
  width: min(520px, 100%);
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 20px 42px rgba(15, 23, 42, 0.28);
}

.warning-modal-card h2 {
  margin: 0 0 8px;
}

.warning-modal-card p {
  margin: 0 0 12px;
  color: #374151;
}

.qr-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.qr-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  break-inside: avoid;
  page-break-inside: avoid;
  box-shadow: var(--shadow);
}

.qr-card img {
  width: 220px;
  height: 220px;
  display: block;
  margin: 0 auto 10px;
  image-rendering: -webkit-optimize-contrast;
}

.qr-card h3 {
  margin: 6px 0;
  font-size: 1.02rem;
}

.qr-card p {
  margin: 4px 0;
  font-size: 0.88rem;
}

.url {
  font-size: 11px;
  color: #6b7280;
  word-break: break-all;
}

.qr-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

@media (max-width: 1150px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 14px;
  }

  .side-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-foot {
    margin-top: 0;
  }

  .stats-grid,
  .grid-three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .main-area {
    padding: 16px 12px 24px;
  }

  .side-nav,
  .stats-grid,
  .grid-three,
  .actions,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .btn {
    flex: 1;
  }

  .controls-inline {
    align-items: stretch;
  }

  .controls-inline label {
    min-width: 0;
  }

  .calendar-grid {
    gap: 6px;
  }

  .calendar-cell {
    min-height: 42px;
  }
}

@media print {
  .sidebar,
  .top-links,
  .qr-toolbar,
  #status,
  .warning-modal {
    display: none !important;
  }

  .dashboard-shell,
  .main-area,
  .scan-wrap {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }

  .panel,
  .qr-card {
    box-shadow: none;
  }
}
