:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --bg-2: #eef3f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #eaf1ff;
  --accent: #0f766e;
  --accent-soft: #e6f5f2;
  --warn: #b45309;
  --warn-soft: #fff4dc;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #15803d;
  --ok-soft: #e6f6ed;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 8px;
  --sidebar: 248px;
  --content-max: 1480px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.09), transparent 32rem),
    linear-gradient(135deg, var(--bg), var(--bg-2));
  color: var(--text);
  font-family: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  min-height: 40px;
  padding: 0 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}

button:hover {
  background: var(--primary-strong);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.16);
}

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

button.secondary {
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

button.secondary:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
  box-shadow: none;
}

button.danger {
  border-color: #fecaca;
  background: var(--danger-soft);
  color: var(--danger);
}

button.danger:hover {
  background: #fecaca;
  box-shadow: none;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 40px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea {
  min-height: 92px;
  padding-top: 10px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100vh;
  min-width: 0;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  box-shadow: 10px 0 30px rgba(15, 23, 42, 0.04);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 14px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  overflow: hidden;
  background: #2563eb;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
  letter-spacing: 0;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  justify-content: start;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  width: 100%;
  min-height: 42px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 800;
}

.nav-item:hover {
  background: var(--panel-soft);
  color: var(--text);
  box-shadow: none;
}

.nav-item.active {
  border-color: #c7d2fe;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.icon {
  display: grid;
  place-items: center;
  width: 24px;
  color: currentColor;
  font-size: 16px;
}

.api-box {
  display: grid;
  gap: 7px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.api-box label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.api-box input {
  min-height: 38px;
  font-size: 12px;
}

main {
  min-width: 0;
  overflow-x: clip;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(21px, 2.3vw, 28px);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: 0;
}

#siteLabel,
.hint,
.muted {
  color: var(--muted);
}

#siteLabel {
  margin-top: 5px;
  font-size: 13px;
}

.session {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

#userLabel {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-panel {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 82px);
  padding: 24px;
}

.login-form {
  display: grid;
  gap: 12px;
  width: min(420px, calc(100vw - 40px));
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-form h2 {
  margin-bottom: 4px;
  font-size: 22px;
}

.form-error,
.app-status {
  margin: 0;
  padding: 11px 13px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.45;
}

.form-error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

#appPanel {
  width: min(var(--content-max), 100%);
  margin: 0 auto;
  padding: 22px 28px 40px;
}

.app-status {
  margin-bottom: 16px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.app-status.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(3, minmax(150px, 0.8fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
}

.toolbar label,
.event-form label,
.check-row {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 20px;
}

.view > *,
.split > *,
.management-grid > *,
.detail-grid > *,
.payroll-grid > *,
.device-detail-panel > section {
  min-width: 0;
}

.owner-calendar {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  min-width: 840px;
}

.calendar-weekdays {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.calendar-weekdays span {
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  min-height: 138px;
  padding: 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.calendar-day.empty {
  background: var(--panel-soft);
}

.calendar-day header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.calendar-day header strong {
  font-size: 15px;
}

.calendar-day header span {
  color: var(--muted-2);
  font-size: 10px;
}

.calendar-worker {
  display: flex;
  justify-content: space-between;
  width: 100%;
  min-height: 28px;
  margin: 0 0 4px;
  padding: 4px 7px;
  border: 0;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 11px;
}

.calendar-worker:hover {
  background: #dbe7ff;
  box-shadow: none;
}

.calendar-worker.needs_review {
  background: var(--warn-soft);
  color: var(--warn);
}

.calendar-worker.correction_pending {
  background: var(--info-soft, #e1f3f8);
  color: #0e7490;
}

.calendar-worker.owner_confirmed,
.calendar-worker.month_closed {
  background: var(--ok-soft);
  color: var(--ok);
}

.calendar-more {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
}

.metric,
.panel-block,
.split > section,
.analyticsView > section {
  min-width: 0;
}

.metric {
  min-height: 102px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.85fr);
  gap: 18px;
}

.split > section,
.panel-block,
#analyticsView > section,
#attendanceView,
#reportsView > .table-wrap,
#payrollView > .payroll-settings,
#payrollView > .settlement-note,
#payrollView > .payroll-grid {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-soft);
}

#attendanceView,
#reportsView,
#payrollView {
  min-width: 0;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.device-list,
.bar-chart {
  overflow: hidden;
}

.table-wrap,
.device-list,
.bar-chart {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

tbody tr:hover {
  background: #f8fbff;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.status.pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.status.confirmed,
.status.online {
  background: var(--ok-soft);
  color: var(--ok);
}

.status.offline {
  background: var(--danger-soft);
  color: var(--danger);
}

.status.stale {
  background: var(--warn-soft);
  color: var(--warn);
}

.device {
  display: grid;
  gap: 7px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.device:last-child {
  border-bottom: 0;
}

.device strong {
  font-size: 14px;
}

.bar-chart {
  display: grid;
  gap: 12px;
  min-height: 260px;
  padding: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(92px, 140px) minmax(100px, 1fr) 70px;
  align-items: center;
  gap: 10px;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #e8edf2;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.report-actions {
  display: flex;
  justify-content: flex-end;
}

.management-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(380px, 1.15fr);
  gap: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2 {
  margin-bottom: 0;
}

.compact-form,
.event-form,
.device-detail-form,
.payroll-settings {
  display: grid;
  gap: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}


.compact-metrics {
  grid-template-columns: repeat(6, minmax(130px, 1fr));
}

.detail-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.detail-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 10px;
}

.detail-fields > div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.detail-fields span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-fields strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
}

.payroll-settings {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  align-items: end;
}

.payroll-settings label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.payroll-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.settlement-note {
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 800;
}

#attendanceWorkerSummary table,
#payrollWorkerTable table,
#payrollDetailTable table {
  min-width: 780px;
}

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

.worker-form button {
  grid-column: 1 / -1;
}

.event-form {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.check-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  min-height: 40px;
  color: var(--text);
}

.check-row input {
  min-height: auto;
}

.button-row,
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.button-row button,
.table-actions button {
  min-height: 34px;
  padding: 0 11px;
}

.list-stack {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.list-item strong,
.list-item span {
  display: block;
}

.event-result,
.enrollment-result,
.token-result {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.event-result,
.qr-payload {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.device-detail-panel {
  display: grid;
  gap: 16px;
  overflow: visible;
}

.device-detail-form {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  align-items: end;
}

.device-detail-form textarea,
.device-detail-form .detail-actions {
  grid-column: 1 / -1;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 18px;
}

.device-detail-panel .table-wrap {
  overflow-x: auto;
  overflow-y: visible;
}

.device-detail-panel table {
  min-width: 560px;
}

#deviceWorkerSignalTable table,
#deviceEventTable table {
  min-width: 720px;
}

.device-detail-panel th,
.device-detail-panel td {
  white-space: normal;
  overflow-wrap: anywhere;
  vertical-align: top;
}

.token-result {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.token-result .qr-payload {
  background: #fff;
}

.enrollment-result.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.enrollment-code {
  width: 100%;
  padding: 16px;
  border: 1px dashed #9ab7d1;
  border-radius: var(--radius);
  background: #f8fbff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 900;
  text-align: center;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.enrollment-meta {
  display: grid;
  gap: 8px;
  margin: 0;
}

.enrollment-meta div {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
}

.enrollment-meta dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.enrollment-meta dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.qr-payload {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f6f7f9;
  overflow-wrap: anywhere;
}

.table-wrap td:last-child {
  min-width: 112px;
}

@media (max-width: 1200px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .toolbar {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .toolbar button {
    width: 100%;
  }

  .split,
  .management-grid,
  .detail-grid,
  .payroll-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    z-index: 4;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    height: auto;
    padding: 10px 12px;
    overflow-x: visible;
  }

  .brand {
    flex: 1 1 180px;
    padding: 0 12px 0 0;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand strong,
  .brand span {
    white-space: nowrap;
  }

  nav {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 18px;
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: 6px;
  }

  .nav-item {
    display: inline-flex;
    grid-template-columns: none;
    flex: 1 1 108px;
    width: auto;
    min-height: 38px;
    padding: 0 12px;
  }

  .nav-item .icon {
    width: auto;
  }

  .api-box {
    display: none;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    padding: 18px;
  }

  #appPanel {
    padding: 18px 16px 32px;
  }

  .worker-form,
  .event-form,
  .device-detail-form,
  .payroll-settings {
    grid-template-columns: 1fr;
  }

  .device-detail-form textarea,
  .device-detail-form .detail-actions,
  .worker-form button {
    grid-column: auto;
  }
}

@supports not (overflow: clip) {
  main {
    overflow-x: hidden;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 13px;
  }

  .topbar {
    display: grid;
    gap: 12px;
  }

  .session {
    justify-content: space-between;
    width: 100%;
  }

  .toolbar,
  .metric-grid,
  .payroll-settings {
    grid-template-columns: 1fr;
  }

  .section-head,
  .list-item,
  .report-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .section-head .button-row,
  .button-row,
  .table-actions {
    width: 100%;
  }

  .section-head button,
  .button-row button,
  .table-actions button,
  .report-actions button {
    flex: 1 1 auto;
    width: 100%;
  }

  .split > section,
  .panel-block,
  #analyticsView > section,
  #attendanceView,
  #reportsView > .table-wrap,
  #payrollView > .payroll-settings,
  #payrollView > .settlement-note,
  #payrollView > .payroll-grid {
    padding: 13px;
    border-radius: 10px;
  }

  .login-panel {
    padding: 16px;
  }

  .login-form {
    width: 100%;
    padding: 20px;
  }
}

/* 2026-07 responsive admin shell */

:root {
  --bg: #f3f6fb;
  --bg-2: #edf2f8;
  --panel-soft: #f7f9fc;
  --text: #152033;
  --muted: #64748b;
  --line: #dbe3ee;
  --line-strong: #c6d1df;
  --primary: #245fdc;
  --primary-strong: #174bb9;
  --primary-soft: #eaf1ff;
  --shadow: 0 20px 54px rgba(26, 45, 78, 0.11);
  --shadow-soft: 0 8px 24px rgba(26, 45, 78, 0.06);
  --radius: 10px;
  --sidebar: 260px;
}

.material-symbols-rounded {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  font-size: 21px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: "liga";
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 50%;
  z-index: 20;
  transform: translate(-50%, -150%);
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--text);
  color: #fff;
  font-weight: 800;
}

.skip-link:focus {
  transform: translate(-50%, 0);
}

body:not(.is-authenticated) {
  display: block;
}

body:not(.is-authenticated) .sidebar,
body:not(.is-authenticated) .topbar,
body:not(.is-authenticated) .nav-scrim {
  display: none;
}

body:not(.is-authenticated) main {
  min-height: 100vh;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar .api-box {
  display: none;
}

.sidebar-head .brand {
  flex: 1;
}

.sidebar-close,
.menu-button,
.nav-scrim {
  display: none;
}

.icon-button {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
  color: var(--text);
  box-shadow: none;
}

.nav-item {
  grid-template-columns: 30px 1fr;
  border-radius: 9px;
  min-height: 44px;
  padding: 0 12px;
}

.nav-item .icon {
  width: 24px;
  font-size: 21px;
}

.topbar {
  min-height: 86px;
  padding: 16px 28px;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.page-eyebrow,
.section-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.page-eyebrow {
  display: none;
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 19px;
}

.login-panel {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 14%, rgba(37, 99, 235, 0.14), transparent 30rem),
    linear-gradient(145deg, #f7f9fc, #edf2f8);
}

.login-form {
  width: min(440px, calc(100vw - 32px));
  gap: 14px;
  padding: 30px;
  border-radius: 16px;
}

.login-form label,
.compact-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
}

.login-brand .brand-mark {
  width: 36px;
  height: 36px;
}

#appPanel {
  padding-top: 24px;
}

.toolbar {
  display: block;
  padding: 12px;
}

.toolbar-summary {
  display: none;
}

.toolbar-fields {
  display: grid;
  grid-template-columns: minmax(220px, 1.25fr) repeat(3, minmax(150px, 0.8fr)) auto;
  gap: 10px;
  align-items: end;
}

.toolbar-fields label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.toolbar-fields button .material-symbols-rounded,
.button-row button .material-symbols-rounded {
  font-size: 18px;
}

.dashboard-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 20px;
  border: 1px solid #cddcf5;
  border-radius: 14px;
  background:
    radial-gradient(circle at 100% 0, rgba(37, 99, 235, 0.11), transparent 22rem),
    var(--panel);
  box-shadow: var(--shadow-soft);
}

.dashboard-hero h2 {
  margin: 0;
  font-size: clamp(18px, 2vw, 24px);
}

.dashboard-hero p {
  margin-top: 7px;
  color: var(--muted);
}

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

.health-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 5px 11px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.health-badge.online {
  background: var(--ok-soft);
  color: var(--ok);
}

.health-badge.offline {
  background: var(--danger-soft);
  color: var(--danger);
}

.health-badge.paused {
  background: #eef2f7;
  color: var(--muted);
}

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

.connection-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 82px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.connection-card > .material-symbols-rounded {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 22px;
}

.connection-card.online > .material-symbols-rounded {
  background: var(--ok-soft);
  color: var(--ok);
}

.connection-card.offline > .material-symbols-rounded {
  background: var(--danger-soft);
  color: var(--danger);
}

.connection-card.warning > .material-symbols-rounded {
  background: var(--warn-soft);
  color: var(--warn);
}

.connection-card div {
  min-width: 0;
}

.connection-card span:not(.material-symbols-rounded) {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.connection-card strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--text);
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-grid {
  gap: 10px;
}

.metric {
  min-height: 94px;
  padding: 14px 15px;
}

.metric-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.metric-label .material-symbols-rounded {
  color: var(--muted-2);
  font-size: 19px;
}

.metric.primary {
  border-color: #b9cdf6;
  background: #f5f8ff;
}

.metric.warning {
  border-color: #f6d7a6;
  background: #fffaf0;
}

.device-title-row,
.device-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.device-list-panel {
  display: grid;
  gap: 16px;
}

.device-list-head {
  align-items: flex-end;
  margin-bottom: 0;
}

.device-list-head h2 {
  margin: 0 0 4px;
}

.inline-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-stats > span {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.inline-stats strong {
  color: var(--text);
}

.inline-stats .online {
  background: var(--ok-soft);
  color: var(--ok);
}

.inline-stats .offline {
  background: var(--danger-soft);
  color: var(--danger);
}

.device-operations-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: visible;
  background: var(--panel);
}

.device-operation {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 1.2fr) minmax(360px, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-width: 0;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.device-operation:last-child {
  border-bottom: 0;
}

.device-operation::before {
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--muted-2);
  content: "";
}

.device-operation.online::before {
  background: var(--ok);
}

.device-operation.offline::before {
  background: var(--danger);
}

.device-operation.stale::before {
  background: var(--warn);
}

.device-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.device-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
}

.device-main > div:last-child {
  min-width: 0;
}

.device-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-main span:not(.status) {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.device-signal div {
  min-width: 0;
}

.device-signal dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.device-signal dd {
  margin: 4px 0 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.more-menu {
  position: relative;
}

.more-menu summary {
  list-style: none;
}

.more-menu summary::-webkit-details-marker {
  display: none;
}

.more-menu > div {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 5;
  display: grid;
  gap: 6px;
  width: 150px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.more-menu > div button {
  width: 100%;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 220px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state .material-symbols-rounded {
  font-size: 34px;
}

.app-dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.app-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(2px);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.dialog-head h2 {
  margin: 0;
}

@media (max-width: 1200px) {
  .toolbar-fields {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .toolbar-fields button {
    width: 100%;
  }

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

  .device-operation {
    grid-template-columns: minmax(240px, 1fr) minmax(300px, 1fr);
  }

  .device-row-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 1023px) {
  body,
  body.is-authenticated {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 12;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 18px;
    width: min(320px, calc(100vw - 48px));
    height: 100dvh;
    padding: 16px 14px;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }

  .sidebar-head .brand {
    padding: 4px 0 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-close,
  .menu-button {
    display: inline-flex;
  }

  .sidebar-head {
    flex: 0 0 auto;
  }

  .sidebar nav {
    display: grid;
    flex: 0 0 auto !important;
    width: 100%;
    margin: 0;
    gap: 5px;
  }

  .sidebar .nav-item {
    display: grid;
    width: 100%;
    min-height: 44px;
  }

  .nav-scrim {
    position: fixed;
    inset: 0;
    z-index: 11;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    border-radius: 0;
    padding: 0;
    background: rgba(15, 23, 42, 0.48);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .nav-open {
    overflow: hidden;
  }

  .nav-open .sidebar {
    transform: translateX(0);
  }

  .nav-open .nav-scrim {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .topbar {
    position: sticky;
    top: 0;
    min-height: 74px;
    padding: 12px 18px;
  }

  .page-eyebrow {
    display: block;
  }

  h1 {
    font-size: 21px;
  }

  #siteLabel {
    display: none;
  }

  #appPanel {
    padding: 18px 16px 32px;
  }

  .device-operation {
    grid-template-columns: 1fr;
  }

  .device-row-actions {
    grid-column: auto;
    justify-content: flex-start;
  }
}

@media (max-width: 767px) {
  body {
    font-size: 13px;
  }

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

  .topbar-title {
    flex: 1;
  }

  .topbar .session {
    width: auto;
    gap: 7px;
  }

  .topbar .user-avatar,
  .topbar #userLabel {
    display: none;
  }

  .topbar #logoutButton {
    width: auto;
    min-height: 38px;
    padding: 0 10px;
  }

  #appPanel {
    padding: 14px 12px 28px;
  }

  .toolbar {
    padding: 12px 13px;
  }

  .toolbar-summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
  }

  .toolbar-summary > div {
    flex: 1 1 auto;
    min-width: 0;
  }

  .toolbar-summary span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
  }

  .toolbar-summary strong {
    display: block;
    margin-top: 3px;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .toolbar .filter-toggle {
    flex: 0 0 auto;
    width: auto;
    min-height: 38px;
  }

  .toolbar-fields {
    display: none;
    grid-template-columns: 1fr;
    margin-top: 13px;
    padding-top: 13px;
    border-top: 1px solid var(--line);
  }

  .toolbar.open .toolbar-fields {
    display: grid;
  }

  .dashboard-hero {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
  }

  .dashboard-hero h2 {
    font-size: 18px;
  }

  .hero-actions {
    justify-content: space-between;
  }

  .hero-actions button {
    width: auto;
  }

  .connection-grid,
  .metric-grid,
  .compact-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .connection-card {
    align-items: flex-start;
    min-height: 92px;
    padding: 13px;
  }

  .connection-card > .material-symbols-rounded {
    width: 34px;
    height: 34px;
    font-size: 20px;
  }

  .connection-card strong {
    font-size: 16px;
    white-space: normal;
  }

  .metric {
    min-height: 86px;
  }

  .metric strong {
    margin-top: 10px;
    font-size: 24px;
  }

  .split > section,
  .panel-block,
  #analyticsView > section,
  #attendanceView,
  #reportsView > .table-wrap,
  #payrollView > .payroll-settings,
  #payrollView > .settlement-note,
  #payrollView > .payroll-grid {
    padding: 13px;
  }

  .table-wrap {
    border: 0;
    overflow: visible;
    background: transparent;
  }

  .table-wrap table,
  #attendanceWorkerSummary table,
  #payrollWorkerTable table,
  #payrollDetailTable table,
  .device-detail-panel table,
  #deviceWorkerSignalTable table,
  #deviceEventTable table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .table-wrap thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .table-wrap tbody {
    display: grid;
    gap: 10px;
  }

  .table-wrap tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
  }

  .table-wrap td,
  .device-detail-panel td {
    display: grid;
    grid-template-columns: minmax(88px, 0.72fr) minmax(0, 1.28fr);
    gap: 10px;
    padding: 10px 11px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .table-wrap td:last-child {
    min-width: 0;
    border-bottom: 0;
  }

  .table-wrap td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 11px;
    font-weight: 900;
    text-align: left;
  }

  .table-wrap td .table-actions {
    justify-content: flex-end;
  }

  .table-wrap td .table-actions button {
    width: auto;
  }

  .device-list-head {
    align-items: stretch;
  }

  .device-list-head .button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .device-list-head .button-row button {
    width: 100%;
  }

  .device-operation {
    gap: 14px;
    padding: 14px;
  }

  .device-name-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .device-signal {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 11px;
    border-radius: 9px;
    background: var(--panel-soft);
  }

  .device-signal dd {
    white-space: normal;
  }

  .device-row-actions > button {
    flex: 1;
  }

  .app-dialog {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    padding: 18px;
  }
}

@media (max-width: 420px) {
  .topbar #logoutButton {
    font-size: 12px;
  }

  .connection-card {
    display: grid;
    gap: 8px;
  }

  .device-signal {
    grid-template-columns: 1fr 1fr;
  }
}
