/**
 * Helicopter Landing Desk & Expense Billing System - Main Stylesheet
 */

:root {
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  
  --bg: #e9eef1;
  --surface: #ffffff;
  --ink: #14232e;
  --muted: #5d6f7b;
  --line: #cfd9df;
  --field: #f5f8fa;
  --accent: #e4572e;
  --accent-ink: #ffffff;
  --wa: #1a9d52;
  --wa-ink: #ffffff;
  --bubble: #d9f5c9;
  --paid-bg: #dcf3e4;
  --paid-ink: #14663a;
  --pend-bg: #fdebd2;
  --pend-ink: #8a4b06;
  --nav-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1a21;
    --surface: #17262f;
    --ink: #e8eff3;
    --muted: #93a6b2;
    --line: #2a3d48;
    --field: #1d303b;
    --accent: #ff7a52;
    --wa: #22b866;
    --bubble: #1f4d31;
    --paid-bg: #17402a;
    --paid-ink: #8fe0b1;
    --pend-bg: #4a3413;
    --pend-ink: #f5c98a;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1a21;
  --surface: #17262f;
  --ink: #e8eff3;
  --muted: #93a6b2;
  --line: #2a3d48;
  --field: #1d303b;
  --accent: #ff7a52;
  --wa: #22b866;
  --bubble: #1f4d31;
  --paid-bg: #17402a;
  --paid-ink: #8fe0b1;
  --pend-bg: #4a3413;
  --pend-ink: #f5c98a;
}

:root[data-theme="light"] {
  --bg: #e9eef1;
  --surface: #ffffff;
  --ink: #14232e;
  --muted: #5d6f7b;
  --line: #cfd9df;
  --field: #f5f8fa;
  --accent: #e4572e;
  --accent-ink: #ffffff;
  --wa: #1a9d52;
  --wa-ink: #ffffff;
  --bubble: #d9f5c9;
  --paid-bg: #dcf3e4;
  --paid-ink: #14663a;
  --pend-bg: #fdebd2;
  --pend-ink: #8a4b06;
}

html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
  height: 100%;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 14px 16px calc(var(--nav-h) + 28px);
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h1 {
  font-family: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  font-size: 26px;
  line-height: 1.1;
  margin: 4px 0 2px;
  letter-spacing: -0.01em;
}

h2 {
  font-family: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  font-size: 18px;
  margin: 0 0 10px;
}

.sub {
  color: var(--muted);
  font-size: 14px;
}

.brand {
  text-align: right;
  flex: none;
  max-width: 45%;
}

.brand img {
  max-height: 44px;
  max-width: 100%;
  display: block;
  margin-left: auto;
}

.wm {
  font-family: 'Bricolage Grotesque', 'Figtree', sans-serif;
  font-size: 17px;
  line-height: 1.1;
  color: var(--ink);
}

.wm b {
  color: var(--accent);
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 4px;
  max-width: 100%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.user-badge a, 
.user-badge a:link, 
.user-badge a:visited, 
.user-badge a:hover, 
.user-badge a:active {
  text-decoration: none !important;
  outline: none;
}

.user-badge .user-name-link,
.user-badge .user-name-link:link,
.user-badge .user-name-link:visited {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink) !important;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.user-badge .role-tag {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  color: #ffffff !important;
}

/* Distinct Role Tag Colors */
.user-badge .role-tag.role-admin {
  background: #d97706; /* Amber Gold */
  color: #ffffff !important;
}

.user-badge .role-tag.role-staff {
  background: #0d9488; /* Emerald Teal */
  color: #ffffff !important;
}

.user-badge .role-tag.role-viewer {
  background: #475569; /* Slate Gray */
  color: #ffffff !important;
}

.user-badge .user-key-link,
.user-badge .user-key-link:link,
.user-badge .user-key-link:visited {
  color: var(--muted) !important;
  font-size: 14px;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.user-badge .user-key-link:hover {
  transform: scale(1.2);
}

/* High-Contrast Rose Logout Button (No Default Blue Link Colors) */
.user-badge .user-logout-link,
.user-badge .user-logout-link:link,
.user-badge .user-logout-link:visited {
  background: rgba(225, 29, 72, 0.14) !important;
  color: #e11d48 !important;
  border: 1px solid rgba(225, 29, 72, 0.35) !important;
  padding: 3px 10px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 2px;
  flex-shrink: 0;
  text-decoration: none !important;
  transition: all 0.15s ease;
}

.user-badge .user-logout-link:hover,
.user-badge .user-logout-link:active {
  background: #e11d48 !important;
  color: #ffffff !important;
  border-color: #e11d48 !important;
}

@media (max-width: 520px) {
  .top {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .top > div:first-child {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }
  .brand {
    max-width: 100%;
    text-align: left;
  }
  .brand img {
    margin-left: 0;
  }
  .user-badge {
    margin-top: 2px;
    padding: 5px 10px;
    width: auto;
  }
  .user-badge .user-name-link {
    max-width: 110px;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  gap: 10px;
}

.grid > * {
  min-width: 0;
}

input[type=date], input[type=time] {
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  text-align: left;
}

.full {
  grid-column: 1 / -1;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

input, select, textarea {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  min-height: 46px;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.withbtn {
  display: flex;
  gap: 6px;
}

.withbtn input {
  flex: 1;
  min-width: 0;
}

.mini {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 0 10px;
  min-height: 46px;
  font-weight: 600;
  cursor: pointer;
}

.money {
  position: relative;
}

.money span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-weight: 600;
}

.money input {
  padding-left: 28px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--field);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 36px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.chip.on {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--surface);
}

.chipw {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  overflow: hidden;
}

.chipw.on {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--surface);
}

.chipw button {
  border: 0;
  background: none;
  cursor: pointer;
  min-height: 36px;
  font-weight: 600;
  font-size: 13px;
}

.chipw .cm {
  padding: 6px 6px 6px 14px;
}

.chipw .cx {
  padding: 0 12px 0 6px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.chip.add {
  border-style: dashed;
  color: var(--muted);
}

.seg {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.seg button, .seg a {
  flex: 1;
  border: 0;
  background: var(--field);
  padding: 11px 8px;
  min-height: 46px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.seg button[aria-pressed="true"], .seg a.active {
  background: var(--ink);
  color: var(--bg);
}

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 11px 14px;
  min-height: 46px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  font-size: 15px;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.wa {
  background: var(--wa);
  border-color: var(--wa);
  color: var(--wa-ink);
}

.btn.small {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 13px;
}

.btn.danger {
  color: #ef4444;
  border-color: rgba(239,68,68,0.3);
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.row .btn {
  flex: 1;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0 0;
}

.bigtotal {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.bigtotal span {
  color: var(--muted);
  font-weight: 600;
}

.bigtotal strong {
  font-family: 'Bricolage Grotesque', 'Figtree', sans-serif;
  font-size: 30px;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  z-index: 90;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
}

.actionbar .in {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.actionbar .tot {
  flex: 1;
  line-height: 1.1;
}

.actionbar .tot small {
  display: block;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.actionbar .tot strong {
  font-family: 'Bricolage Grotesque', 'Figtree', sans-serif;
  font-size: 24px;
}

.actionbar .btn {
  flex: none;
  min-width: 150px;
}

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 100;
}

.nav .in {
  max-width: 680px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.nav a, .nav button {
  border: 0;
  background: none;
  min-height: var(--nav-h);
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  border-top: 3px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  gap: 2px;
  transition: color 0.15s ease;
}

.nav a[aria-current="page"], .nav button[aria-current="page"] {
  color: var(--ink);
  border-top-color: var(--accent);
}

.nav a.nav-settings {
  color: #d97706; /* Amber Gold for Settings */
}

.nav a.nav-settings[aria-current="page"] {
  color: #d97706;
  border-top-color: #d97706;
  font-weight: 700;
}

.nav a.nav-logout, 
.nav a.nav-logout:link, 
.nav a.nav-logout:visited {
  color: #e11d48 !important; /* Vibrant Rose Red for Logout */
  font-weight: 700;
}

.nav a.nav-logout:hover,
.nav a.nav-logout:active {
  background: rgba(225, 29, 72, 0.12);
  color: #be123c !important;
}

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tile {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.tile small {
  display: block;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.tile strong {
  font-family: 'Bricolage Grotesque', 'Figtree', sans-serif;
  font-size: 20px;
  letter-spacing: -0.01em;
  word-break: break-word;
}

.tile.big {
  grid-column: 1 / -1;
  border-color: var(--accent);
}

.tile.big strong {
  font-size: 26px;
  color: var(--accent);
}

.scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: right;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th:first-child, td:first-child {
  text-align: left;
  white-space: normal;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.filters {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.rec {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.rec-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.rec-top b {
  font-family: 'Bricolage Grotesque', 'Figtree', sans-serif;
  font-size: 17px;
}

.meta {
  color: var(--muted);
  font-size: 14px;
  margin-top: 3px;
}

.rec-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 10px 0;
}

.rec-total strong {
  font-size: 20px;
  font-family: 'Bricolage Grotesque', sans-serif;
}

.idtxt {
  font-size: 12px;
  color: var(--muted);
}

.badge {
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 10px;
}

.badge.paid {
  background: var(--paid-bg);
  color: var(--paid-ink);
}

.badge.pend {
  background: var(--pend-bg);
  color: var(--pend-ink);
}

.acts {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.acts button, .acts a {
  border: 1px solid var(--line);
  background: var(--field);
  border-radius: 10px;
  padding: 8px 2px;
  min-height: 52px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.acts button span, .acts a span {
  display: block;
  font-size: 17px;
  margin-bottom: 2px;
}

.acts button.wa, .acts a.wa {
  background: var(--wa);
  border-color: var(--wa);
  color: var(--wa-ink);
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 32px 10px;
}

/* Modal Sheet */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 28, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-top: env(safe-area-inset-top, 0px);
  z-index: 1000;
}

.sheet {
  background: var(--surface);
  width: min(640px, 100%);
  max-height: 90vh;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  border-radius: 20px 20px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.3);
  overflow: hidden;
}

.sheet > form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sheet-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 10px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--surface);
}

.sheet-h h2 {
  margin: 0;
}

.sheet .x {
  border: 0;
  background: none;
  font-size: 28px;
  line-height: 1;
  padding: 0 6px;
  cursor: pointer;
  color: var(--muted);
}

.sheet-b {
  padding: 16px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
}

.sheet-b::-webkit-scrollbar {
  width: 6px;
}
.sheet-b::-webkit-scrollbar-track {
  background: transparent;
}
.sheet-b::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}
.sheet-b::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.sheet-f {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--surface);
}

.sheet-f .btn {
  flex: 1 1 40%;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.kv .k {
  color: var(--muted);
}

.kv .v {
  text-align: right;
  font-weight: 500;
  word-break: break-word;
}

.kv.tot .v, .kv.tot .k {
  font-weight: 700;
  color: var(--ink);
  font-size: 17px;
}

.sec {
  font-family: 'Bricolage Grotesque', 'Figtree', sans-serif;
  font-weight: 600;
  margin: 16px 0 6px;
  font-size: 16px;
}

.bubble {
  background: var(--bubble);
  color: #12281a;
  border-radius: 14px 14px 14px 4px;
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}

.bill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.bill img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.bill .pdf {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: var(--field);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
}

.bill .nm {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  word-break: break-all;
}

.audit {
  font-size: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.audit li {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.audit small {
  color: var(--muted);
}

iframe.stmt {
  width: 100%;
  height: 460px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 78px + env(safe-area-inset-bottom, 0px));
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  max-width: 90%;
  text-align: center;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.toast.on {
  opacity: 1;
}

[hidden] {
  display: none !important;
}
