:root {
  color-scheme: light;
  --forest-950: #1e0f19;
  --forest-900: #2b1724;
  --forest-800: #47243b;
  --forest-700: #6f4b60;
  --forest-100: #f0e6ea;
  --forest-50: #faf6f7;
  --ink: #12100f;
  --muted: #746970;
  --canvas: #f5f0e7;
  --surface: #fffdfb;
  --line: #e3d8d5;
  --sand: #b99782;
  --sand-light: #f5efe7;
  --lime: #b7db65;
  --amber: #c9872d;
  --amber-bg: #fff3dd;
  --red: #a94943;
  --red-bg: #fbeae8;
  --green: #267455;
  --green-bg: #e7f5ee;
  --blue: #326d89;
  --blue-bg: #e7f3f8;
  --shadow: 0 16px 40px rgba(43, 23, 36, .10);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { background: var(--forest-950); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 100% 0, rgba(185, 151, 130, .18), transparent 34rem),
    var(--canvas);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.48;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(185, 151, 130, .46);
  outline-offset: 2px;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.025em; }
h1 { margin-bottom: 0; font-size: clamp(1.18rem, 4vw, 1.52rem); }
h2 { margin-bottom: 0; font-size: clamp(1.62rem, 7vw, 2.35rem); line-height: 1.1; }
h3 { margin-bottom: 0; font-size: 1rem; }

.app-header {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  color: white;
  background: rgba(43, 23, 36, .97);
  border-bottom: 1px solid rgba(255, 255, 255, .11);
  backdrop-filter: blur(18px);
}

.brand-lockup { display: flex; align-items: center; min-width: 0; }
.brand-wordmark { display: block; width: 96px; height: auto; }
.brand-subtitle { margin: 2px 0 0; color: rgba(255, 255, 255, .62); font-size: 8px; font-weight: 720; letter-spacing: .14em; white-space: nowrap; }
.header-status { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }
.status-chip {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 999px;
  color: rgba(255, 255, 255, .84);
  background: rgba(255, 255, 255, .08);
  font-size: 9px;
  font-weight: 750;
  white-space: nowrap;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(183, 219, 101, .12); }
.status-chip.offline .status-dot { background: #f2b067; }
.status-chip.neutral .status-dot { background: var(--sand); box-shadow: none; }

.app-main { width: min(100%, 1120px); margin: 0 auto; padding: 18px 14px calc(96px + env(safe-area-inset-bottom)); }
.surface { background: var(--surface); border: 1px solid rgba(71, 36, 59, .11); border-radius: var(--radius-lg); box-shadow: var(--shadow); }

.session-panel { padding: 17px; }
.session-heading, .page-heading, .section-heading, .dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 13px;
}
.session-heading { align-items: center; margin-bottom: 15px; }
.eyebrow { margin-bottom: 4px; color: var(--forest-700); font-size: 9px; font-weight: 840; letter-spacing: .18em; }
.role-pill, .secure-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--forest-800);
  background: var(--forest-100);
  font-size: 9px;
  font-weight: 780;
  white-space: nowrap;
}
.employee-session { display: grid; gap: 12px; }
.employee-search-field, .employee-profile label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 720; }
.employee-combobox { position: relative; }
.employee-profile { display: grid; grid-template-columns: 1fr; gap: 10px; }
.employee-profile input[readonly] { color: var(--forest-800); border-color: #e6dcdf; background: var(--forest-50); font-weight: 680; cursor: default; }
.employee-options {
  position: absolute;
  z-index: 80;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  overflow: auto;
  max-height: min(360px, 52dvh);
  padding: 6px;
  border: 1px solid #d9cccf;
  border-radius: 13px;
  background: white;
  box-shadow: 0 20px 55px rgba(43, 23, 36, .22);
  overscroll-behavior: contain;
}
.employee-option { display: grid; width: 100%; min-height: 58px; gap: 2px; padding: 10px 11px; border: 0; border-radius: 9px; color: var(--ink); background: transparent; text-align: left; cursor: pointer; }
.employee-option:hover, .employee-option:focus-visible, .employee-option[aria-selected="true"] { background: var(--forest-50); }
.employee-option strong { color: var(--forest-900); font-size: 12px; letter-spacing: .02em; }
.employee-option span { color: var(--ink); font-size: 11px; font-weight: 720; }
.employee-option small { color: var(--muted); font-size: 9px; font-weight: 620; }
.employee-empty { padding: 13px; color: var(--muted); font-size: 11px; text-align: center; }
.field-hint { margin: 0; color: var(--muted); font-size: 9px; font-weight: 600; }
.employee-apply { width: 100%; }
.privacy-note { margin: 13px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }

input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid #ddd2d5;
  border-radius: 11px;
  color: var(--ink);
  background: white;
  appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, #74676e 50%), linear-gradient(135deg, #74676e 50%, transparent 50%); background-position: calc(100% - 17px) 20px, calc(100% - 12px) 20px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea { resize: vertical; min-height: 120px; }
input::placeholder, textarea::placeholder { color: #a2989d; }

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 780;
  cursor: pointer;
}
.button:disabled { cursor: not-allowed; opacity: .42; }
.button.primary { color: var(--sand-light); background: var(--forest-900); box-shadow: 0 8px 22px rgba(43, 23, 36, .20); }
.button.secondary { color: var(--forest-900); border-color: #d8cccf; background: white; }
.button.ghost { color: var(--forest-800); background: var(--forest-50); }
.button.danger { color: var(--red); border-color: #efc5c1; background: var(--red-bg); }
.button.compact { min-height: 40px; padding: 8px 12px; font-size: 11px; }
.button.role-action { color: var(--forest-800); border-color: #e5dade; background: white; }
.button.role-action.active { color: white; border-color: var(--forest-900); background: var(--forest-900); }
.text-button { min-height: 40px; padding: 6px; border: 0; color: var(--forest-700); background: transparent; font-size: 11px; font-weight: 800; cursor: pointer; }
.icon-button { width: 44px; height: 44px; flex: 0 0 44px; border: 0; border-radius: 50%; color: var(--muted); background: var(--forest-50); font-size: 24px; }

.install-card { display: grid; grid-template-columns: auto 1fr; gap: 12px; margin-top: 12px; padding: 16px; background: linear-gradient(135deg, var(--sand-light), white 74%); }
.install-card.installed { display: none; }
.install-icon, .backup-symbol { display: grid; width: 43px; height: 43px; place-items: center; border-radius: 13px; color: white; background: var(--forest-900); font-size: 20px; }
.install-copy h2 { font-size: 1rem; }
.install-copy p:last-child { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.install-card .button { grid-column: 1 / -1; }

.view { display: none; padding-top: 25px; }
.view.active { display: block; }
.page-heading { align-items: flex-end; margin: 0 2px 16px; }
.page-heading .eyebrow { margin-bottom: 6px; }

.uat-console { overflow: hidden; }
.uat-progress { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.uat-step { position: relative; min-height: 67px; padding: 14px 10px; color: var(--muted); background: #fbfcfb; font-size: 9px; font-weight: 780; }
.uat-step + .uat-step { border-left: 1px solid var(--line); }
.uat-step strong { display: block; margin-bottom: 3px; color: var(--ink); font-size: 11px; }
.uat-step.complete { color: var(--green); background: var(--green-bg); }
.uat-step.active { color: var(--forest-900); background: var(--sand-light); }
.uat-next { display: grid; gap: 16px; padding: 18px; }
.uat-next h3 { font-size: 1.15rem; }
.uat-next p:last-child { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.uat-role-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0; }
.stat-card { min-height: 102px; padding: 15px; border-radius: var(--radius-md); color: var(--ink); background: white; border: 1px solid rgba(43, 23, 36, .10); box-shadow: 0 8px 24px rgba(43, 23, 36, .05); }
.stat-card .stat-value { display: block; margin: 8px 0 2px; font-size: 1.55rem; font-weight: 850; letter-spacing: -.04em; }
.stat-card small { color: var(--muted); font-size: 9px; }
.stat-card.alert { background: var(--amber-bg); }
.stat-card.success { background: var(--green-bg); }

.action-surface, .storage-surface, .policy-surface { margin-top: 12px; padding: 17px; }
.section-heading { align-items: center; margin-bottom: 13px; }
.storage-surface { display: grid; gap: 12px; }
.storage-detail { color: var(--muted); font-size: 11px; }
.storage-meter { overflow: hidden; height: 7px; margin: 9px 0 5px; border-radius: 99px; background: var(--forest-100); }
.storage-meter span { display: block; height: 100%; border-radius: inherit; background: var(--forest-700); }

.form-surface { display: grid; gap: 14px; padding: 18px; }
.conditional-fields { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(135deg, var(--forest-50), #fff); }
.conditional-heading { margin-bottom: 12px; }
.conditional-grid { display: grid; gap: 12px; }
.conditional-grid.nested { padding-top: 4px; }
.field { display: grid; gap: 6px; color: var(--ink); font-size: 11px; font-weight: 760; }
.field > span, .field-label > span { color: var(--red); }
.field small { color: var(--muted); font-size: 9px; font-weight: 520; }
.field.full { grid-column: 1 / -1; }
.field-label { display: block; margin-bottom: 6px; color: var(--ink); font-size: 11px; font-weight: 760; }
.upload-zone { display: grid; min-height: 116px; place-items: center; align-content: center; gap: 4px; padding: 18px; border: 1px dashed var(--sand); border-radius: 14px; color: var(--forest-800); background: var(--forest-50); text-align: center; cursor: pointer; }
.upload-zone.small { min-height: 84px; }
.upload-zone small { color: var(--muted); font-size: 9px; }
.upload-symbol { font-size: 27px; font-weight: 300; }
.image-preview, .image-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 9px; }
.preview-item, .gallery-item { overflow: hidden; position: relative; aspect-ratio: 1; border-radius: 11px; background: var(--forest-100); }
.preview-item img, .gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item button { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border: 0; border-radius: 50%; color: white; background: rgba(43, 23, 36, .78); }
.form-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 9px; }
.form-errors { padding: 11px 12px; border: 1px solid #edc6c1; border-radius: 11px; color: var(--red); background: var(--red-bg); font-size: 11px; font-weight: 700; }

.filter-bar { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; padding: 10px; box-shadow: none; }
.request-list { display: grid; gap: 9px; }
.request-card { display: grid; gap: 10px; width: 100%; min-height: 116px; padding: 15px; border: 1px solid rgba(43, 23, 36, .10); border-radius: var(--radius-md); color: inherit; background: white; box-shadow: 0 7px 22px rgba(43, 23, 36, .05); text-align: left; cursor: pointer; }
.request-topline, .request-meta, .detail-meta { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.request-code { color: var(--forest-700); font-size: 10px; font-weight: 850; letter-spacing: .08em; }
.request-card h3 { font-size: 14px; }
.request-description { display: -webkit-box; overflow: hidden; margin: 0; color: var(--muted); font-size: 11px; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.request-meta { color: var(--muted); font-size: 9px; }
.badge { display: inline-flex; min-height: 25px; align-items: center; padding: 4px 8px; border-radius: 999px; color: var(--blue); background: var(--blue-bg); font-size: 8px; font-weight: 850; white-space: nowrap; }
.badge.amber { color: #8b5c1b; background: var(--amber-bg); }
.badge.green { color: var(--green); background: var(--green-bg); }
.badge.red { color: var(--red); background: var(--red-bg); }
.empty-state { padding: 34px 20px; border: 1px dashed #d8cccf; border-radius: var(--radius-lg); color: var(--muted); background: rgba(255,255,255,.54); text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--ink); }

.request-detail { display: grid; gap: 11px; }
.detail-back { width: fit-content; min-height: 44px; padding: 7px 3px; border: 0; color: var(--forest-700); background: transparent; font-weight: 800; }
.detail-hero, .timeline-surface { padding: 18px; }
.detail-hero h2 { margin: 7px 0 5px; font-size: 1.4rem; }
.detail-copy { margin: 14px 0; padding: 13px; border-radius: 12px; color: var(--ink); background: var(--forest-50); white-space: pre-wrap; }
.key-grid { display: grid; grid-template-columns: 112px 1fr; gap: 8px 11px; margin-top: 15px; font-size: 10px; }
.key-grid dt { color: var(--muted); }
.key-grid dd { margin: 0; font-weight: 720; overflow-wrap: anywhere; }
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 15px; }
.quick-actions .button { font-size: 11px; }
.quick-actions .button.done { color: var(--forest-950); background: var(--lime); }
.role-bridge { margin-bottom: 11px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(135deg, var(--forest-50), white); }
.role-bridge p { margin: 5px 0 10px; color: var(--muted); font-size: 10px; }
.role-bridge .button { width: 100%; }
.timeline { display: grid; gap: 15px; }
.timeline-item { position: relative; padding-left: 24px; }
.timeline-item::before { content: ""; position: absolute; top: 5px; left: 3px; width: 9px; height: 9px; border: 2px solid white; border-radius: 50%; background: var(--forest-700); box-shadow: 0 0 0 2px var(--forest-100); }
.timeline-item::after { content: ""; position: absolute; top: 19px; bottom: -19px; left: 7px; width: 1px; background: var(--line); }
.timeline-item:last-child::after { display: none; }
.timeline-item header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.timeline-item h4 { margin: 0; font-size: 11px; }
.timeline-item time { color: var(--muted); font-size: 8px; }
.timeline-item p { margin: 5px 0 0; color: var(--muted); font-size: 10px; white-space: pre-wrap; }

.month-input { width: 150px; }
.bonus-list { display: grid; gap: 10px; }
.bonus-card { padding: 15px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.bonus-card h3 { margin: 5px 0; font-size: 13px; }
.bonus-card p { margin: 5px 0; color: var(--muted); font-size: 10px; }
.bonus-amount { color: var(--forest-900); font-size: 1.15rem; font-weight: 850; }
.bonus-controls { display: grid; gap: 8px; margin-top: 12px; }
.bonus-controls .control-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.policy-grid { display: grid; gap: 8px; margin-top: 12px; }
.policy-item { padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); font-size: 9px; }
.policy-item strong { display: block; margin-bottom: 4px; font-size: 11px; }
.money { font-variant-numeric: tabular-nums; font-weight: 840; }

.backup-grid { display: grid; gap: 11px; }
.backup-card { display: grid; gap: 11px; align-content: start; padding: 18px; }
.backup-card p { margin: 0; color: var(--muted); font-size: 11px; }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; cursor: pointer; opacity: 0; }
.backup-status { margin-top: 11px; padding: 15px; color: var(--muted); font-size: 11px; }

.bottom-nav {
  position: fixed;
  z-index: 45;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 6px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  border-top: 1px solid rgba(255, 255, 255, .1);
  background: rgba(43, 23, 36, .97);
  backdrop-filter: blur(18px);
}
.nav-button { display: grid; min-height: 53px; place-items: center; align-content: center; gap: 1px; border: 0; border-radius: 11px; color: rgba(255,255,255,.58); background: transparent; cursor: pointer; }
.nav-button span { font-size: 19px; line-height: 1; }
.nav-button small { font-size: 8px; font-weight: 720; }
.nav-button.active { color: white; background: rgba(255,255,255,.11); }

.action-dialog { width: min(calc(100% - 24px), 560px); max-height: calc(100dvh - 32px); margin: auto; padding: 0; border: 0; border-radius: var(--radius-xl); color: var(--ink); background: white; box-shadow: 0 30px 100px rgba(43, 23, 36, .38); }
.action-dialog::backdrop { background: rgba(18, 16, 15, .62); backdrop-filter: blur(5px); }
.action-dialog form { display: grid; gap: 14px; max-height: calc(100dvh - 32px); overflow: auto; padding: 20px; }
.dialog-heading { align-items: center; }
.dialog-help { margin: 0; color: var(--muted); font-size: 11px; }
.recipient-box { margin: 0; padding: 10px 12px; border-radius: 10px; color: var(--forest-800); background: var(--forest-50); font-size: 10px; font-weight: 720; }
.done-grid { display: grid; grid-template-columns: 1fr 110px; gap: 9px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 8px; }

.toast { position: fixed; z-index: 100; right: 14px; bottom: calc(76px + env(safe-area-inset-bottom)); left: 14px; display: none; max-width: 520px; margin: 0 auto; padding: 12px 14px; border-radius: 12px; color: white; background: var(--forest-950); box-shadow: 0 14px 45px rgba(43, 23, 36, .28); font-size: 11px; font-weight: 720; }
.toast.show { display: block; animation: toast-in .18s ease-out; }
.toast.error { background: #7f302d; }
.noscript { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 30px; color: white; background: var(--forest-950); text-align: center; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; }
[hidden] { display: none !important; }

@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } }

@media (min-width: 700px) {
  .app-main { padding-top: 27px; }
  .employee-session { grid-template-columns: minmax(230px, .8fr) minmax(420px, 1.8fr) auto; align-items: end; }
  .employee-profile { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .employee-apply { width: auto; min-width: 132px; }
  .install-card { grid-template-columns: auto 1fr auto; align-items: center; }
  .install-card .button { grid-column: auto; }
  .uat-next { grid-template-columns: 1fr auto; align-items: center; }
  .uat-role-actions { grid-template-columns: repeat(3, auto); }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .form-surface { grid-template-columns: 1fr 1fr; padding: 24px; }
  .conditional-grid { grid-template-columns: 1fr 1fr; }
  .filter-bar { grid-template-columns: 1fr 220px; }
  .request-card { grid-template-columns: 1fr auto; align-items: center; }
  .request-card .request-topline, .request-card h3, .request-card .request-description { grid-column: 1; }
  .request-card .request-meta { grid-column: 2; grid-row: 1 / 4; align-self: stretch; flex-direction: column; justify-content: center; align-items: flex-end; }
  .backup-grid { grid-template-columns: 1fr 1fr; }
  .policy-grid { grid-template-columns: repeat(3, 1fr); }
  .bonus-controls { grid-template-columns: 1fr auto; align-items: end; }
  .bottom-nav { right: auto; top: 110px; bottom: auto; left: max(12px, calc((100vw - 1180px) / 2)); width: 74px; grid-auto-flow: row; grid-auto-rows: auto; grid-auto-columns: auto; border: 0; border-radius: 18px; padding: 7px; }
  .app-main { padding-left: 98px; padding-bottom: 38px; }
  .toast { bottom: 24px; }
}

@media (max-width: 420px) {
  .brand-subtitle { display: none; }
  .header-status .status-chip:last-child { display: none; }
  .session-heading { align-items: flex-start; }
  .role-pill { max-width: 118px; overflow: hidden; text-overflow: ellipsis; }
  .page-heading { align-items: flex-start; }
  .page-heading h2 { font-size: 1.72rem; }
  .uat-step { padding: 12px 7px; }
  .uat-step strong { font-size: 9px; }
  .image-preview, .image-gallery { grid-template-columns: repeat(2, 1fr); }
}

@media (display-mode: standalone) {
  .app-header { padding-top: max(13px, env(safe-area-inset-top)); }
}

@media print {
  .app-header, .bottom-nav, .session-panel, .install-card, .button, .filter-bar { display: none !important; }
  body { background: white; }
  .app-main { max-width: none; padding: 0; }
  .view { display: none !important; }
  #view-bonus.active { display: block !important; }
  .surface, .stat-card { box-shadow: none; break-inside: avoid; }
}
