:root {
  color-scheme: light;
  --bg: #f5f5f4;
  --panel: #ffffff;
  --panel-soft: #fafaf9;
  --border: #d6d3d1;
  --text: #1c1917;
  --muted: #78716c;
  --accent: #1c1917;
  --accent-strong: #44403c;
  --danger: #991b1b;
  --success: #166534;
  --warning: #854d0e;
}

* { box-sizing: border-box; }

.file-warning {
  padding: 12px 16px;
  background: #fef3c7;
  border-bottom: 1px solid #d6d3d1;
  color: #713f12;
  font-weight: 800;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 3;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 2px; font-size: 20px; font-weight: 750; }
h2 { margin-bottom: 4px; font-size: 19px; font-weight: 750; }
h3 { margin-bottom: 8px; font-size: 15px; font-weight: 750; }

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.status-area {
  display: flex;
  gap: 8px;
  align-items: center;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.connection-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a8a29e;
}

.connection-status.online::before { background: #16a34a; }
.connection-status.offline { color: var(--danger); }
.connection-status.offline::before { background: #dc2626; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  background: #e7e5e4;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
  background: var(--accent);
  color: white;
}

button:hover { background: var(--accent-strong); }
button:active { transform: translateY(1px); }
button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

button.ghost {
  background: #efede9;
  color: var(--text);
  border: 1px solid var(--border);
}

button.ghost:hover { background: #e7e5e4; }

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.button-link.ghost {
  background: #efede9;
  color: var(--text);
  border: 1px solid var(--border);
}

.button-link.ghost:hover { background: #e7e5e4; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 6px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 53px;
  z-index: 2;
}

.tabs button {
  background: transparent;
  color: var(--muted);
  min-height: 32px;
}

.tabs button.active {
  background: var(--accent);
  color: white;
}

.tabs button[hidden] { display: none; }

main { padding: 16px; }

.tab { display: none; }
.tab.active { display: block; }

.kiosk-shell {
  max-width: 1120px;
  margin: 0 auto;
}

.kiosk-heading {
  display: flex;
  justify-content: center;
  margin: 0 0 14px;
}

.kiosk-heading h2 {
  font-size: 28px;
}

.kiosk-controls {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(180px, 240px);
  gap: 10px;
  align-items: end;
  margin: 0 0 12px;
}

.kiosk-controls input,
.kiosk-controls select {
  min-height: 44px;
  font-size: 16px;
}

.employee-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.employee-grid .empty-state {
  grid-column: 1 / -1;
}

.kiosk-section-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 0;
  padding: 6px 2px;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}

.kiosk-section-title small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: none;
}

.employee-button {
  min-height: 118px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  box-shadow: none;
}

.employee-button:hover {
  background: #fafaf9;
  border-color: var(--accent);
}

.employee-button.is-in {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #7f1d1d;
}

.employee-button.is-in:hover {
  background: #fee2e2;
  border-color: #dc2626;
}

.employee-button-name {
  display: block;
  font-size: 28px;
  line-height: 1.12;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.employee-button-state {
  display: block;
  min-width: 92px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
  background: #efede9;
  color: var(--muted);
}

.employee-button-open-time {
  display: block;
  color: #991b1b;
  font-size: 13px;
  font-weight: 750;
}

.employee-button.is-in .employee-button-state {
  background: #dc2626;
  color: #fff;
}

.employee-button.is-in .employee-button-name {
  color: #7f1d1d;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  box-shadow: none;
}

.panel-header,
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.help {
  color: var(--muted);
  margin: 4px 0 0;
  font-size: 14px;
}

.filters,
.inline {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

input,
select {
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.checkbox-label {
  flex-direction: row;
  align-items: center;
  min-height: 32px;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  min-height: auto;
}

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

.list .item,
.empty-state,
.locked-note {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
}

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

.list .item .info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.list .item.time-adjusted {
  border-color: #fecdd3;
  background: #fff1f2;
}

.list .item.time-adjusted strong,
.list .item.time-adjusted .adjusted-label {
  color: var(--danger);
}

.list .item.open-shift-history {
  border-left: 4px solid #dc2626;
  background: #fef2f2;
}

.open-shift-history-label {
  display: inline-flex;
  width: fit-content;
  margin-top: 3px;
  padding: 3px 6px;
  border-radius: 4px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 12px;
  font-weight: 800;
}

.list .item.merge-selected {
  border-color: #a8a29e;
  background: #f5f5f4;
}

.list .item .actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.list .item.employee-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  align-items: center;
  justify-content: stretch;
  gap: 10px;
}

.employee-row .info {
  min-width: 0;
}

.employee-row .actions {
  justify-self: end;
  min-width: max-content;
}

.employee-row .actions button {
  white-space: nowrap;
}

.employee-merge-check {
  width: 76px;
  justify-content: flex-start;
  align-items: center;
  gap: 4px;
  color: var(--text);
}

.employee-merge-check input {
  width: 18px;
  height: 18px;
  min-height: auto;
}

.merge-panel {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.merge-choice {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
}

.merge-choice .info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.table {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

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

.table th,
.table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  font-size: 12px;
  line-height: 1.25;
}

.table th {
  background: #efede9;
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
}

.table tr:last-child td { border-bottom: none; }
.table tr.is-paid { color: var(--muted); background: #fafaf9; }
.table tr.is-unpaid {
  background: #fff1f2;
}
.table tr.is-unpaid td:last-child {
  color: #991b1b;
  font-weight: 800;
}

.admin-block,
.admin-section {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.employee-form { margin-bottom: 0; }

.payments-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 8px;
}

.pay-summary {
  min-height: 32px;
  margin-bottom: 8px;
  padding: 7px 9px;
  border-radius: 6px;
  background: #efede9;
  color: var(--text);
  font-weight: 800;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.warning-text {
  display: block;
  margin-top: 3px;
  color: var(--warning);
  font-size: 11px;
  font-weight: 800;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f5f5f4;
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
}

.mini-badge.success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: var(--success);
}

.mini-badge.danger {
  background: #fff1f2;
  border-color: #fecdd3;
  color: var(--danger);
}

.mini-badge.warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: var(--warning);
}

.mini-badge.muted {
  color: var(--muted);
}

.import-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.import-preview-table {
  max-height: 56vh;
}

.import-preview-table input {
  min-width: 120px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  overflow-y: auto;
}

.modal[hidden] { display: none !important; }

.modal-content {
  background: white;
  border-radius: 8px;
  padding: 14px;
  max-width: 560px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
  margin: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.clock-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.clock-action {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  font-size: 24px;
}

.clock-action-in {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.clock-action-out {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #991b1b;
}

.optional-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

#clock-comment {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  font: inherit;
}

.clock-comment {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-style: italic;
}

.open-shifts-panel {
  margin-bottom: 14px;
}

.open-shifts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border: 1px solid #fca5a5;
  border-bottom: 0;
  background: #fef2f2;
  color: #991b1b;
}

.open-shifts-header span {
  min-width: 26px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #dc2626;
  color: white;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.open-shifts-clear {
  padding: 9px 10px;
  border-left: 3px solid #16a34a;
  background: #f0fdf4;
  color: #166534;
  font-size: 13px;
  font-weight: 700;
}

.open-shift-duration {
  display: block;
  margin-top: 2px;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}

.orphan-open-shift { background: #fff7ed; }
.current-open-shift { background: #fef2f2; }

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

.choice-card {
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text);
  font-size: 18px;
}

.choice-card input {
  width: 20px;
  height: 20px;
  min-height: auto;
}

.field-label input { width: 100%; }

.tablet-time-editor {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
}

.large-time-input {
  min-height: 68px;
  font-size: 38px;
  font-weight: 850;
  text-align: center;
  letter-spacing: 0;
}

.time-buttons {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.time-buttons button {
  min-height: 46px;
  padding: 8px;
}

.payment-history-item strong {
  color: var(--text);
}

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    padding: 14px 16px;
  }

  .status-area { display: none; }
  .tabs { top: 58px; padding: 6px 12px; }
  main { padding: 12px; }
  .kiosk-controls { grid-template-columns: 1fr; }
  .employee-grid { grid-template-columns: 1fr; }
  .employee-button { min-height: 126px; }
  .employee-button-name { font-size: 24px; }
  .panel-header, .section-title { flex-direction: column; }
  .list .item { align-items: stretch; flex-direction: column; }
  .list .item .actions { justify-content: flex-start; }
  .list .item.employee-row {
    grid-template-columns: 1fr;
  }
  .employee-row .actions {
    justify-self: stretch;
    min-width: 0;
  }
  .employee-merge-check {
    flex-direction: row;
    justify-content: flex-start;
    width: auto;
  }
  .merge-choice { grid-template-columns: 1fr; }
  .choice-grid { grid-template-columns: 1fr; }
  .tablet-time-editor { grid-template-columns: 1fr; }
  .large-time-input { font-size: 36px; }
  .time-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
