:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #eff6ff;
  --success: #047857;
  --success-soft: #ecfdf5;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --leave-soft: #fef3c7;
  --leave-text: #92400e;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  font-size: 14px;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.app-page, .admin-page { background: var(--bg); }

.app-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 14px calc(88px + env(safe-area-inset-bottom));
}

.admin-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 14px calc(32px + env(safe-area-inset-bottom));
}

.login-wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: 16px 16px calc(88px + env(safe-area-inset-bottom));
}

.text-muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---- Top bar ---- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.top-bar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.top-bar-info { min-width: 0; }

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

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.username {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.btn-logout {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.btn-admin-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  white-space: nowrap;
}

/* ---- Metrics ---- */
.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.admin-metrics {
  grid-template-columns: repeat(5, 1fr);
}

.metric-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
}

.metric-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  white-space: nowrap;
}

.metric-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.metric-value.accent { color: var(--accent); }
.metric-value.green { color: var(--success); }
.metric-value.red { color: var(--danger); }
.metric-value.blue { color: var(--accent); }
.metric-value.muted { color: var(--muted); }

.metric-unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 1px;
}

/* ---- Panel ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.panel-leave {
  background: #fffbeb;
  border-color: #fde68a;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-sub { white-space: nowrap; }

/* ---- Date nav ---- */
.date-nav,
.admin-date-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.date-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #f9fafb;
  color: var(--text);
  text-decoration: none;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.date-nav-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.date-nav-input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}

.date-nav-today {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  white-space: nowrap;
}

.date-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ---- Record table (grid list) ---- */
.record-table {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.record-table-head,
.record-table-row {
  display: grid;
  grid-template-columns: 64px 52px 1fr;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
}

.record-table-head {
  background: #f9fafb;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.record-table-row {
  border-bottom: 1px solid #f3f4f6;
  min-height: 44px;
}

.record-table-row:last-child { border-bottom: none; }

.leave-multi-check {
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text);
}

/* ---- Leave list ---- */
.leave-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leave-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #fafafa;
}

.leave-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.leave-item-main {
  flex: 1;
  min-width: 0;
}

.leave-item-date {
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
}

.leave-item-meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
}

.leave-item-actions {
  margin-top: 8px;
}

.status-badge {
  flex-shrink: 0;
  align-self: flex-start;
  min-width: 2.6em;
  text-align: center;
  border: 1px solid transparent;
}

.badge.status-badge.leave-pending { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.badge.status-badge.leave-approved { background: var(--success-soft); color: var(--success); border-color: #a7f3d0; }
.badge.status-badge.leave-rejected { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.badge.status-badge.leave-cancelled { background: #f3f4f6; color: #4b5563; border-color: #e5e7eb; }

.admin-leave-list .leave-item-top {
  align-items: flex-start;
}

.admin-leave-list .leave-action-form {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f3f4f6;
}

.admin-leave-list .leave-action-form .cell-input {
  flex: 1 1 100%;
  min-width: 0;
}

.admin-leave-list .leave-action-form .btn-sm {
  flex: 1 1 calc(50% - 3px);
  min-width: 5em;
}

.record-table-head.admin-head,
.record-table-row.admin-head {
  grid-template-columns: 1.4fr 48px 48px 56px 56px;
}

.record-type {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.record-time {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.record-addr {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-period {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.record-sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.record-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.record-name strong {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.record-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: nowrap;
}

.row-leave {
  background: #fffef5;
}

/* ---- Admin employee list ---- */
.emp-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.emp-row {
  padding: 12px;
  border-bottom: 1px solid #f3f4f6;
}

.emp-row:last-child { border-bottom: none; }
.emp-row-leave { background: #fffef5; }

.emp-row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.emp-row-name {
  min-width: 0;
  flex: 1;
}

.emp-row-name strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.emp-row-times {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.emp-list-compact .emp-row {
  padding: 10px 12px;
}

.emp-list-compact .emp-row-name strong {
  font-size: 14px;
}

.emp-list-compact .emp-row-times span {
  flex: 0 1 auto;
  min-width: 0;
  padding: 5px 8px;
  font-size: 11px;
}

.emp-row-times span {
  font-size: 12px;
  color: var(--muted);
  background: #f9fafb;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.emp-row-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f3f4f6;
}

.btn-checkin-sm {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.btn-checkout-sm {
  background: var(--surface);
  color: var(--text);
}

/* ---- Time grid ---- */
.time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.time-grid.compact {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 10px;
}

.time-cell {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}

.time-cell-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.time-cell-val {
  display: block;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---- Clock / buttons ---- */
.clock-inline {
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.loc-line {
  font-size: 12px;
  color: var(--muted);
  background: #f9fafb;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 12px;
}

.btn-row { display: flex; gap: 8px; }

button { font: inherit; cursor: pointer; border: none; }

.btn-checkin, .btn-checkout {
  flex: 1;
  padding: 14px 10px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  min-height: 48px;
  touch-action: manipulation;
}

.btn-checkin { background: var(--success); color: #fff; }
.btn-checkin:hover:not(:disabled) { background: #065f46; }
.btn-checkout { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-checkout:hover:not(:disabled) { background: #f9fafb; }
.btn-checkin:disabled, .btn-checkout:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  min-height: 46px;
  touch-action: manipulation;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-full { width: 100%; }

.btn-sm {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.btn-highlight {
  background: var(--accent-soft);
  border-color: #bfdbfe;
  color: var(--accent);
  font-weight: 600;
}

.btn-export {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--border);
  background: #f9fafb;
  white-space: nowrap;
}

.btn-danger { color: var(--danger); border-color: #fecaca; }

.check-msg {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  min-height: 18px;
}

/* ---- GPS ---- */
.gps-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f3f4f6;
}

.gps-block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.gps-block-head .btn-sm { margin-left: auto; }

.gps-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d1d5db;
  flex-shrink: 0;
}

.gps-dot.active { background: var(--success); }

.gps-addr { font-size: 12px; font-weight: 500; word-break: break-all; }
.gps-range { margin-top: 4px; font-size: 12px; font-weight: 500; }
.gps-help { margin-top: 4px; font-size: 11px; }

/* ---- Badge / chip ---- */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-green { background: var(--success-soft); color: var(--success); }
.badge-gray { background: #f3f4f6; color: #4b5563; }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-blue { background: var(--accent-soft); color: var(--accent); }

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid #fde68a;
}

.chip-leave { color: var(--leave-text); }

.chip-sub {
  font-weight: 500;
  color: var(--muted);
}

.leave-pending { background: #fffbeb; color: #92400e; }
.leave-approved { background: var(--success-soft); color: var(--success); }
.leave-rejected { background: var(--danger-soft); color: var(--danger); }
.leave-cancelled { background: #f3f4f6; color: var(--muted); }

/* ---- Forms ---- */
.form-group { margin-bottom: 10px; }

.form-group label,
.leave-form label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 5px;
}

.form-group input,
.leave-form input,
.leave-form select,
.cell-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  min-height: 42px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---- Alert ---- */
.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-bottom: 10px;
  line-height: 1.5;
}

.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid #a7f3d0; }
.alert-leave { background: var(--leave-soft); color: var(--leave-text); border: 1px solid #fde68a; }

.empty-state {
  text-align: center;
  padding: 24px 12px;
  color: #9ca3af;
  font-size: 13px;
}

/* ---- Stats ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-item {
  text-align: center;
  padding: 12px 8px;
  background: #f9fafb;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.stat-num { font-size: 18px; font-weight: 700; }
.stat-num.red { color: var(--danger); }
.stat-lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---- Login ---- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 24px;
  border: 1px solid var(--border);
  width: 100%;
}

.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo-img { width: 52px; height: 52px; border-radius: 12px; object-fit: contain; margin-bottom: 12px; }
.login-logo h1 { font-size: 17px; font-weight: 700; }
.login-system-name { font-size: 13px; color: var(--muted); margin-top: 4px; }
.login-sub { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 20px; }

.login-chrome-hint {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 12px;
  text-align: center;
}

.login-chrome-hint a { color: var(--accent); font-weight: 600; }

/* ---- Admin legacy pages ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-header h2 { font-size: 18px; font-weight: 700; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.card-header h3 { font-size: 15px; font-weight: 600; }

.card-toolbar, .action-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.action-bar { margin-top: 10px; }

.admin-nav-top {
  margin-top: 0;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.admin-nav-top .btn-secondary {
  font-size: 12px;
  padding: 8px 10px;
}

.action-bar .btn-secondary.nav-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.table-wrap { overflow-x: auto; }

.att-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.att-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.att-table td {
  padding: 10px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.table-expand-cell { padding: 10px !important; }

.filter-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.filter-tabs a {
  padding: 7px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
}
.filter-tabs a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.form-row-grid, .user-form .form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.user-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.loc-edit-card { border-bottom: 1px solid #f3f4f6; padding: 14px 0; }
.loc-edit-card:last-child { border-bottom: none; }
.loc-edit-actions, .edit-actions, .leave-action-form {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 16px 2px 8px;
}

.mb-20 { margin-bottom: 16px; }

/* ---- PWA ---- */
.pwa-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1000;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(240, 242, 245, 0.98) 30%);
}

.pwa-banner-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: 0 4px 20px rgba(17, 24, 39, 0.1);
  max-width: 480px;
  margin: 0 auto;
}

.pwa-banner-icon { border-radius: 8px; flex-shrink: 0; }
.pwa-banner-text { flex: 1; min-width: 0; font-size: 11px; color: var(--muted); line-height: 1.4; }
.pwa-banner-text strong { display: block; font-size: 13px; color: var(--text); margin-bottom: 2px; }
.pwa-guide { margin: 0; }

.btn-pwa-install {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  flex-shrink: 0;
}

.pwa-close {
  border: none;
  background: none;
  font-size: 20px;
  color: #9ca3af;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
}

.pwa-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

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

.pwa-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.4);
}

.pwa-modal-sheet {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
}

.pwa-modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
}

.pwa-modal-steps {
  margin: 0 0 16px 18px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.pwa-modal-steps li { margin-bottom: 8px; }

.pwa-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .admin-metrics {
    grid-template-columns: repeat(3, 1fr);
  }
  .form-row-2 { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .record-table-head,
  .record-table-row {
    grid-template-columns: 52px 48px 1fr;
    gap: 6px;
    padding: 8px 10px;
  }
}

/* ---- Brand logo ---- */
.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand-link {
  display: flex;
  flex-shrink: 0;
  text-decoration: none;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
  border: 1px solid var(--border);
  background: var(--surface);
}

.loc-select-wrap { margin-bottom: 12px; }

/* ---- Device ---- */
.device-status-box {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: #f9fafb;
  border: 1px solid var(--border);
  font-size: 13px;
  margin-bottom: 12px;
}

.device-status-box.ok { background: var(--success-soft); border-color: #a7f3d0; color: var(--success); }
.device-status-box.pending { background: #fffbeb; border-color: #fde68a; color: var(--leave-text); }
.device-status-box.error { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }

.device-reset-btn { margin-top: 8px; }

.device-info-box {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 14px;
  line-height: 1.6;
  font-size: 12px;
}

.device-info-box strong { color: var(--text); }

.record-table-head.device-head,
.record-table-row.device-head {
  grid-template-columns: 1.2fr 0.9fr 0.7fr minmax(100px, auto);
}

.inline-form { display: inline; }

/* ---- Leave matrix ---- */
.leave-export-bar { margin-bottom: 12px; }

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -2px;
}

.leave-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 720px;
}

.leave-matrix th,
.leave-matrix td {
  border: 1px solid var(--border);
  padding: 8px 6px;
  text-align: center;
  white-space: nowrap;
}

.leave-matrix th {
  background: #f9fafb;
  font-weight: 600;
  color: var(--muted);
  font-size: 11px;
}

.leave-matrix .sticky-col {
  position: sticky;
  left: 0;
  background: var(--surface);
  text-align: left;
  z-index: 1;
  min-width: 88px;
}

.leave-matrix td.num { font-variant-numeric: tabular-nums; }
.leave-matrix td.num.has-value { font-weight: 600; }
.leave-matrix td.num.accent { color: var(--accent); font-weight: 700; }

.emp-export-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  margin-left: 4px;
}

.chip-link {
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
}

.chip-link:hover { background: var(--accent-soft); }

/* ---- Responsive: mobile / desktop ---- */
@media (max-width: 479px) {
  .admin-nav-top .btn-secondary {
    flex: 1 1 calc(50% - 3px);
    text-align: center;
    padding: 9px 6px;
  }

  .filter-tabs a {
    flex: 1 1 calc(33.33% - 4px);
    text-align: center;
    padding: 8px 4px;
    font-size: 12px;
  }

  .metric-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .top-bar {
    flex-wrap: wrap;
  }

  .username {
    white-space: normal;
    font-size: 14px;
    line-height: 1.3;
  }
}

@media (min-width: 768px) {
  .app-wrap,
  .admin-wrap,
  .login-wrap {
    max-width: 720px;
    padding-left: 20px;
    padding-right: 20px;
  }

  .metric-row {
    grid-template-columns: repeat(5, 1fr);
  }

  .admin-metrics {
    grid-template-columns: repeat(5, 1fr);
  }

  .admin-nav-top .btn-secondary {
    font-size: 13px;
    padding: 9px 12px;
  }

  .leave-item {
    padding: 14px 16px;
  }

  .admin-leave-list .leave-action-form .cell-input {
    flex: 1 1 auto;
    min-width: 180px;
  }

  .admin-leave-list .leave-action-form .btn-sm {
    flex: 0 0 auto;
  }

  .panel-head {
    align-items: center;
  }

  .record-table-head,
  .record-table-row {
    grid-template-columns: 64px 64px 1fr;
  }
}

@media (min-width: 1024px) {
  .app-wrap,
  .admin-wrap {
    max-width: 880px;
  }

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

  .admin-leave-list {
    grid-template-columns: 1fr;
  }

  .table-scroll {
    max-height: none;
  }
}

@media (display-mode: standalone) {
  .pwa-banner { display: none !important; }
  body { overscroll-behavior-y: contain; }
}
