:root {
  --ink: #121b18;
  --muted: #66706d;
  --line: #e8eeeb;
  --panel: #ffffff;
  --page: #f7f8fa;
  --green: #0f5f55;
  --green-2: #0f8f82;
  --gold: #c7a557;
  --gold-soft: #f7edd2;
  --teal: #0d9488;
  --red: #b42318;
  --amber: #a65f00;
  --blue: #2456a6;
  --soft: #edf4ef;
  --shadow: 0 20px 50px rgba(20, 40, 35, 0.08);
  --shadow-sm: 0 8px 22px rgba(20, 40, 35, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(13, 148, 136, 0.1), transparent 320px),
    linear-gradient(180deg, #fbfcfd 0%, var(--page) 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}

body.modal-open {
  overflow: hidden;
}

.user-select {
  width: min(230px, 100%);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  width: min(460px, 100%);
  display: grid;
  gap: 22px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.login-brand span {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.app-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  max-width: min(420px, calc(100vw - 32px));
  padding: 13px 15px;
  border-radius: 14px;
  color: #fff;
  background: var(--green);
  box-shadow: 0 18px 50px rgba(18, 27, 24, 0.24);
  font-weight: 800;
}

.app-toast[hidden] {
  display: none;
}

.app-toast.error {
  background: var(--red);
}

.app-toast.warning {
  color: #3e2600;
  background: #ffd978;
}

.mobile-app-header {
  display: none;
}

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

.app-shell.auth-locked {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--line);
  box-shadow: 10px 0 34px rgba(20, 40, 35, 0.04);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(199, 165, 87, 0.38);
  box-shadow: 0 10px 24px rgba(20, 40, 35, 0.12);
}

.brand strong {
  display: block;
  font-size: 16px;
  line-height: 1.18;
}

.brand span,
.sidebar-note span,
.eyebrow,
.hint,
.panel-head span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.brand span,
.sidebar-note span {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 7px;
}

.nav-section {
  margin: 12px 10px 4px;
  color: #8b9692;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.nav-item {
  border: 1px solid transparent;
  text-align: left;
  color: #43504c;
  background: transparent;
  padding: 10px 11px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 750;
  min-height: 44px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  transition: background 0.16s ease, transform 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.nav-item::before {
  content: attr(data-icon);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #f2f6f4;
  color: var(--green);
  font-size: 16px;
  font-weight: 900;
}

.nav-item span {
  display: block;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-count {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  padding: 0 7px;
  color: var(--green);
  background: #dff5ef;
  border: 1px solid #b9e6d9;
  font-size: 12px;
  font-weight: 900;
}

.nav-count[hidden] {
  display: none;
}

.nav-item:hover,
.nav-item.active {
  background: linear-gradient(135deg, #0d9488 0%, #0f5f55 100%);
  color: #fff;
  border-color: rgba(13, 148, 136, 0.12);
  box-shadow: 0 12px 24px rgba(13, 148, 136, 0.2);
}

.nav-item:hover::before,
.nav-item.active::before {
  color: var(--green);
  background: rgba(255, 255, 255, 0.9);
}

.nav-item:hover .nav-count,
.nav-item.active .nav-count {
  color: #0f5f55;
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.6);
}

.nav-item.active {
  box-shadow: 0 12px 24px rgba(13, 148, 136, 0.2);
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid #dbe9e4;
  border-radius: 14px;
  background: #f6fbf9;
}

.main {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding: 2px 0 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 700;
  color: var(--gold);
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
}

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

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

.db-status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 5px 11px;
  background: #fff3d6;
  color: var(--amber);
  border: 1px solid #f1d38b;
  font-size: 12px;
  font-weight: 800;
}

.db-status.online {
  background: #e6f5ed;
  color: #176043;
  border-color: #b8dec9;
}

.people-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.people-toolbar select {
  width: auto;
  min-width: 170px;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(47, 107, 87, 0.72);
  box-shadow: 0 0 0 4px rgba(47, 107, 87, 0.12);
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.top-actions input {
  width: auto;
}

.button,
.icon-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.icon-button {
  width: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  background: #fff;
  border-color: var(--line);
}

.primary {
  background: linear-gradient(135deg, #0d9488 0%, #0f5f55 100%);
  color: #fff;
}

.quick-attendance-button {
  flex: 1 1 100%;
  min-height: 58px;
  font-size: 16px;
  box-shadow: 0 16px 34px rgba(13, 148, 136, 0.2);
}

.secondary {
  background: #fff;
  color: var(--green);
  border-color: var(--line);
}

.sidebar-account-actions {
  display: grid;
  gap: 8px;
}

.sidebar-password,
.sidebar-logout {
  width: 100%;
}

.sidebar-password {
  background: #fff;
  color: var(--green);
  border-color: var(--line);
}

.sidebar-logout {
  background: #fff;
  color: var(--red);
  border-color: #f0d5d1;
}

.danger {
  background: var(--red);
  color: #fff;
}

.action-main {
  min-width: 132px;
  min-height: 50px;
  font-size: 15px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid,
.panel-grid,
.kiosk-layout,
.people-layout,
.rule-grid {
  display: grid;
  gap: 16px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

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

.metric {
  padding: 20px 18px 18px;
  position: relative;
  overflow: hidden;
  min-height: 112px;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--teal), var(--gold));
}

.metric::after {
  position: absolute;
  right: 17px;
  top: 18px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--green);
  background: #eef8f5;
  font-size: 18px;
  font-weight: 900;
}

.metric:nth-child(1)::after {
  content: "◇";
}

.metric:nth-child(2)::after {
  content: "!";
  color: var(--amber);
  background: #fff5df;
}

.metric:nth-child(3)::after {
  content: "□";
}

.metric:nth-child(4)::after {
  content: "◷";
}

.metric:nth-child(5)::after {
  content: "✓";
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.metric strong {
  font-size: 32px;
  line-height: 1;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.panel {
  padding: 20px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.85fr);
  gap: 16px;
}

.dashboard-trend-panel,
.dashboard-summary-panel {
  min-height: 286px;
}

.trend-chart {
  height: 210px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
  padding: 16px 10px 4px;
  border-radius: 16px;
  background:
    linear-gradient(to top, rgba(232, 238, 235, 0.95) 1px, transparent 1px) 0 0 / 100% 25%,
    #fbfcfb;
}

.trend-bar-item {
  min-width: 0;
  display: grid;
  justify-items: center;
  align-items: end;
  gap: 8px;
}

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

.trend-bar {
  width: min(36px, 72%);
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, #0d9488 0%, #0f5f55 100%);
  box-shadow: 0 12px 22px rgba(13, 148, 136, 0.2);
}

.trend-bar-item small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.donut-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  height: 210px;
  align-items: center;
}

.donut-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.donut-ring {
  --value: 0%;
  width: min(150px, 100%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--teal) var(--value), #edf2f0 0);
  position: relative;
}

.donut-ring::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.donut-ring strong {
  position: relative;
  z-index: 1;
  font-size: 24px;
  color: var(--ink);
}

.donut-ring.amber {
  background: conic-gradient(var(--gold) var(--value), #edf2f0 0);
}

.panel-grid,
.kiosk-layout,
.people-layout {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
}

.people-layout {
  grid-template-columns: minmax(0, 1fr);
}

.people-create-panel {
  display: none;
}

.settings-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.settings-menu {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 10px;
}

.settings-menu-item {
  width: 100%;
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.settings-menu-item strong {
  font-size: 15px;
}

.settings-menu-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.settings-menu-item.active {
  color: #fff;
  background: var(--green);
  border-color: rgba(199, 165, 87, 0.48);
}

.settings-menu-item.active span {
  color: rgba(255, 255, 255, 0.75);
}

.settings-content {
  min-width: 0;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

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

.verify-grid,
.report-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-top: 14px;
}

.verify-card,
.report-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fbfcfb;
}

.verify-card strong,
.report-card strong {
  display: block;
  margin-bottom: 6px;
}

.verify-badge {
  color: var(--amber);
  font-size: 13px;
  font-weight: 800;
}

.verify-badge.ok {
  color: #176043;
}

.face-box {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
}

.face-box[hidden] {
  display: none;
}

.face-box video,
.face-box canvas {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #101816;
}

.qr-scanner-card {
  width: min(460px, 100%);
}

.qr-scanner-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #101816;
  aspect-ratio: 1 / 1;
}

.qr-scanner-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qr-scan-target {
  position: absolute;
  inset: 18%;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.32);
}

.dynamic-qr-box {
  margin: 18px 0;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.dynamic-qr-box canvas {
  width: 220px;
  height: 220px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.dynamic-qr-box strong {
  font-size: 32px;
  letter-spacing: 0;
  color: var(--green);
}

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

.kiosk-panel {
  border-color: rgba(47, 112, 89, 0.24);
}

.mobile-punch-card {
  display: none;
}

.browser-notice {
  margin: 10px 0 14px;
  border: 1px solid #f1d38b;
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff8e6;
  color: #915f00;
  font-size: 13px;
  font-weight: 750;
}

.quick-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 14px;
}

.quick-step {
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.quick-step.active {
  border-color: rgba(13, 148, 136, 0.45);
  background: rgba(13, 148, 136, 0.11);
  color: var(--green);
  box-shadow: 0 8px 18px rgba(13, 148, 136, 0.1);
}

.quick-step.done {
  border-color: rgba(47, 112, 89, 0.25);
  background: #eaf7ef;
  color: #1c6b45;
}

.quick-step.error {
  border-color: rgba(183, 28, 28, 0.25);
  background: #fff1f0;
  color: #b42318;
}

.manual-tools {
  flex: 1 1 100%;
  width: 100%;
  border: 1px dashed rgba(47, 112, 89, 0.25);
  border-radius: 14px;
  padding: 10px;
  background: #fbfcfb;
}

.manual-tools summary {
  cursor: pointer;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.manual-action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

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

.form-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kiosk-actions {
  margin: 16px 0 10px;
}

.list,
.approval-list,
.people-list,
.coverage {
  display: grid;
  gap: 10px;
}

.list-item,
.approval-card,
.person-card,
.coverage-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fbfcfb;
}

.list-item,
.approval-card,
.person-card {
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.list-item:hover,
.approval-card:hover,
.person-card:hover {
  border-color: rgba(47, 112, 89, 0.24);
  box-shadow: var(--shadow-sm);
}

.list-item strong,
.person-card strong {
  display: block;
  margin-bottom: 3px;
}

.people-section {
  display: grid;
  gap: 10px;
}

.people-section + .people-section {
  margin-top: 8px;
}

.people-section-head,
.person-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.people-section-head {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #eef5f1;
  color: var(--green);
}

.people-section-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.person-card.resigned {
  background: #f7f7f5;
}

.person-card.resigned strong,
.person-card.resigned .meta {
  color: #777;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 27, 24, 0.42);
  backdrop-filter: blur(8px);
}

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

.modal-card {
  width: min(720px, 100%);
  max-height: min(88vh, 820px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(18, 27, 24, 0.22);
  padding: 22px;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head {
  margin-bottom: 18px;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.employee-modal-card .form-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.payroll-modal-card {
  width: min(640px, 100%);
}

.payroll-modal-meta,
.payroll-formula-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.payroll-modal-meta > div,
.payroll-formula-box > div {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  background: #fbfcfb;
}

.payroll-modal-meta span,
.payroll-formula-box span,
.payroll-net-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.payroll-modal-meta strong,
.payroll-formula-box strong {
  display: block;
  margin-top: 4px;
}

.payroll-formula-box {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 12px;
  border-radius: 16px;
  background: #eef8f4;
  border: 1px solid #ccebe1;
}

.payroll-formula-box > div {
  background: rgba(255, 255, 255, 0.78);
}

.full-field {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.payroll-net-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 16px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--green-2), var(--green));
}

.payroll-net-box strong {
  font-size: 28px;
}

#salaryTemplateList {
  margin-top: 16px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge.valid,
.badge.approved {
  background: #e6f5ed;
  color: #176043;
}

.badge.flagged,
.badge.open {
  background: #fff3d6;
  color: var(--amber);
}

.badge.rejected {
  background: #ffe7e4;
  color: var(--red);
}

.badge.info {
  background: #e8efff;
  color: var(--blue);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

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

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f8faf8;
  position: sticky;
  top: 0;
}

.approval-card {
  display: grid;
  gap: 10px;
}

.approval-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 22px;
  text-align: center;
  color: var(--muted);
  background: #fbfcfb;
}

.coverage-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.coverage-bar {
  height: 8px;
  background: #e7ece9;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 7px;
}

.coverage-bar span {
  display: block;
  height: 100%;
  background: var(--teal);
}

.rule-panel ul {
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

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

  .sidebar {
    position: fixed;
    inset: auto 0 0;
    z-index: 40;
    height: auto;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    gap: 0;
    border-right: 0;
    border-top: 1px solid var(--line);
    box-shadow: 0 -12px 32px rgba(20, 40, 35, 0.08);
  }

  .nav {
    display: flex;
    justify-content: space-around;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-section {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    min-width: 82px;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 3px;
    text-align: center;
    white-space: nowrap;
    padding: 7px 8px;
    min-height: 58px;
    font-size: 12px;
    border-radius: 14px;
    position: relative;
  }

  .nav-item::before {
    width: 26px;
    height: 26px;
    font-size: 14px;
  }

  .nav-count {
    position: absolute;
    top: 4px;
    right: 8px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    font-size: 11px;
  }

  .nav-item.active {
    box-shadow: 0 10px 22px rgba(13, 148, 136, 0.2);
  }

  .sidebar .brand,
  .sidebar-note {
    display: none;
  }

  .sidebar-account-actions {
    display: none;
  }

  .sidebar-password,
  .sidebar-logout {
    width: auto;
    min-height: 40px;
    padding: 8px 12px;
    box-shadow: var(--shadow-sm);
  }

  .main {
    padding-top: 16px;
    padding-bottom: 112px;
  }

  .mobile-app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 18px;
    padding: 0 2px;
  }

  .mobile-app-logo {
    width: 72px;
    height: 42px;
    object-fit: contain;
  }

  .mobile-role-pill {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 14px;
    border: 1px solid #a8e2d6;
    border-radius: 999px;
    color: var(--teal);
    background: #eefbf8;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0;
  }

  .metric-grid,
  .panel-grid,
  .settings-shell,
  .dashboard-grid,
  .kiosk-layout,
  .people-layout,
  .rule-grid,
  .verify-grid,
  .report-grid,
  .face-box,
  .form-grid,
  .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .settings-menu {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .employee-modal-card .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 16px;
  }

  .topbar h1 {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .top-subtitle {
    max-width: 100%;
  }

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

  .top-actions input,
  .top-actions .button,
  .top-actions select,
  .top-actions .db-status,
  .top-actions .icon-button {
    width: 100%;
    min-width: 0;
    min-height: 48px;
  }

  .top-actions .icon-button {
    max-width: 58px;
  }

  #kiosk .kiosk-layout,
  #requests .people-layout {
    gap: 18px;
  }

  #kiosk .kiosk-panel,
  #requests .request-form-panel {
    padding: 22px;
    border-radius: 18px;
  }

  .mobile-punch-card {
    display: grid;
    justify-items: center;
    gap: 8px;
    margin: 8px 0 18px;
    padding: 28px 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background:
      radial-gradient(circle at 50% 0%, rgba(13, 148, 136, 0.12), transparent 52%),
      #fbfcfb;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
    text-align: center;
  }

  .mobile-punch-card::before {
    content: "◷";
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 3px solid #119386;
    border-radius: 50%;
    color: var(--green);
    font-size: 24px;
    font-weight: 900;
  }

  .mobile-punch-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0;
  }

  .mobile-punch-card strong {
    font-size: clamp(36px, 10vw, 54px);
    line-height: 1;
    color: #111827;
  }

  .mobile-punch-card small {
    color: #1f2937;
    font-size: 16px;
    font-weight: 750;
  }

  #kiosk .form-grid,
  #requests .form-grid.compact {
    gap: 16px;
  }

  .mobile-detail-panel {
    margin-top: 10px;
  }

  .mobile-detail-panel summary {
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    color: var(--green);
    font-weight: 900;
    cursor: pointer;
  }

  .mobile-detail-panel summary::after {
    content: "⌄";
    font-size: 18px;
    color: var(--muted);
  }

  .mobile-detail-panel[open] summary::after {
    content: "⌃";
  }

  #kiosk label,
  #requests label,
  #payroll label {
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0;
  }

  #kiosk input,
  #kiosk select,
  #requests input,
  #requests select,
  #payroll input,
  #payroll select {
    min-height: 58px;
    border-radius: 16px;
    padding: 14px 16px;
    font-size: 16px;
  }

  #requests #requestReason {
    min-height: 86px;
  }

  #kiosk .kiosk-actions,
  #requests .kiosk-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  #kiosk .quick-attendance-button {
    min-height: 62px;
    border-radius: 18px;
    font-size: 18px;
    box-shadow: 0 16px 34px rgba(13, 148, 136, 0.2);
  }

  #kiosk .manual-tools {
    padding: 12px;
    border-radius: 16px;
  }

  #kiosk .manual-action-grid {
    grid-template-columns: 1fr;
  }

  #requests #submitRequest {
    width: 100%;
    min-height: 58px;
    border-radius: 16px;
    margin-top: 4px;
    font-size: 17px;
  }

  body:has(#kiosk.view.active) .nav-item:not([data-view="dashboard"]):not([data-view="kiosk"]):not([data-view="requests"]):not([data-view="payroll"]),
  body:has(#requests.view.active) .nav-item:not([data-view="dashboard"]):not([data-view="kiosk"]):not([data-view="requests"]):not([data-view="payroll"]),
  body:has(#payroll.view.active) .nav-item:not([data-view="dashboard"]):not([data-view="kiosk"]):not([data-view="requests"]):not([data-view="payroll"]),
  body:has(#dashboard.view.active) .nav-item:not([data-view="dashboard"]):not([data-view="kiosk"]):not([data-view="requests"]):not([data-view="payroll"]) {
    display: none;
  }

  #kiosk .verify-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  #kiosk .verify-card {
    min-height: 82px;
    display: grid;
    align-content: center;
    justify-items: center;
    text-align: center;
    border-radius: 16px;
  }

  #kiosk .quick-flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 560px) {
  .main {
    padding: 12px 12px 112px;
  }

  .brand {
    min-height: auto;
  }

  h1 {
    font-size: 23px;
  }

  .metric strong {
    font-size: 25px;
  }

  .trend-chart,
  .donut-grid {
    height: auto;
  }

  .trend-chart {
    gap: 9px;
  }

  .donut-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel,
  .metric {
    border-radius: 10px;
  }

  .panel {
    padding: 14px;
  }

  .modal-backdrop {
    padding: 12px;
    align-items: end;
  }

  .modal-card {
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    padding: 18px;
  }

  .kiosk-actions .button,
  .kiosk-actions .icon-button {
    flex: 1 1 100%;
  }

  #kiosk .panel-head {
    align-items: start;
  }

  #kiosk .panel-head span {
    font-size: 13px;
  }

  #kiosk .verify-grid {
    grid-template-columns: 1fr;
  }

  #kiosk .verify-card {
    min-height: 64px;
  }

  #kiosk .quick-flow {
    gap: 7px;
  }

  #kiosk .quick-step {
    min-height: 42px;
    padding: 7px;
    font-size: 11.5px;
  }

  .top-actions {
    grid-template-columns: 1fr 1fr;
  }

  body:has(#kiosk.view.active) .top-actions {
    display: none;
  }

  .top-actions #dbStatus,
  .top-actions #currentRoleBadge {
    font-size: 12px;
    justify-content: center;
    text-align: center;
  }

  .top-actions #workDate {
    font-size: 15px;
  }

  .top-actions #exportCsv {
    font-size: 15px;
  }

  .top-actions #resetDemo {
    grid-column: 1 / -1;
    justify-self: start;
    width: 52px;
  }

  .action-main {
    min-height: 54px;
    font-size: 16px;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .settings-menu {
    grid-template-columns: 1fr;
  }
}
