:root {
  --bg: #f4f8ff;
  --card: #ffffff;
  --text: #17324d;
  --primary: #0b5ed7;
  --secondary: #eef4ff;
  --border: #cfe0ff;
  --shadow: 0 10px 24px rgba(15,42,79,0.07);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); }
#app { max-width: 760px; margin: 0 auto; padding: 16px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
h1, h2 { margin: 0 0 8px; }
p { margin: 0; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.details-card { padding: 0; overflow: hidden; }
.details-card summary { cursor: pointer; padding: 14px 16px; font-weight: 700; }
.details-card[open] summary { border-bottom: 1px solid var(--border); }
.details-card:not([open]) {
  height: 34px;
  min-height: 34px;
  max-height: 34px;
}
.details-card:not([open]) .fishList {
  display: none;
}
.fishList { padding: 0 12px 8px; }
label { display: block; margin: 12px 0; font-weight: 600; }
input, select, button { width: 100%; padding: 14px; border-radius: 14px; border: 1px solid var(--border); font-size: 16px; }
button { background: var(--primary); color: white; border: none; font-weight: 700; cursor: pointer; }
button.secondary { background: var(--secondary); color: var(--text); border: 1px solid var(--border); }
button.large { font-size: 20px; padding: 18px; }
.row { display: flex; gap: 12px; }
.row.between { justify-content: space-between; align-items: center; }
.wrap { flex-wrap: wrap; }
.gap8 { gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0 16px; }
.status-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { border-radius: 999px; padding: 8px 12px; background: #e8fff2; color: #0a6c3f; font-weight: 700; }
.pill.neutral { background: #edf4ff; color: #315174; }
.pill.marine-safe {
  background: #e6f8ee;
  color: #075b35;
  border: 1px solid #a9e3c4;
}
.pill.marine-caution {
  background: #fff3cf;
  color: #7a4f00;
  border: 1px solid #f2c75d;
}
.pill.marine-unsafe {
  background: #ffe0df;
  color: #9b1c1c;
  border: 1px solid #f09a96;
}
.pill.marine-unknown {
  background: #edf4ff;
  color: #315174;
  border: 1px solid var(--border);
}
.marine-forecast-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.88);
  overflow: hidden;
}
.current-safety-details {
  display: grid;
  gap: 4px;
  margin: 8px 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f4f6f7;
  font-size: 0.78rem;
}
.safety-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.current-safety-details small,
.current-safety-details span {
  overflow-wrap: anywhere;
}
.current-safety-details.marine-safe { background: #eaf8f0; border-color: #81c9a4; }
.current-safety-details.marine-caution { background: #fff5d8; border-color: #d9a72f; }
.current-safety-details.marine-unsafe { background: #ffe5e3; border-color: #dc7772; }
.current-safety-details.marine-unknown,
.current-safety-details.marine-no-data { background: #eef1f3; border-color: #aab4bc; }
.safety-cache-warning { color: #9a3412; font-weight: 800; }
.marine-forecast-panel summary {
  min-height: 34px;
  padding: 7px 10px;
  cursor: pointer;
  color: #315174;
  font-size: 0.8rem;
  font-weight: 850;
  list-style-position: inside;
}
.marine-forecast {
  display: grid;
  grid-template-columns: repeat(7, minmax(86px, 1fr));
  gap: 6px;
  overflow-x: auto;
  padding: 0 8px 8px;
  scrollbar-width: thin;
}
.forecast-day {
  min-width: 86px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 8px;
  background: #ffffff;
  display: grid;
  gap: 2px;
}
.forecast-day strong {
  font-size: 0.72rem;
}
.forecast-day span {
  font-size: 0.74rem;
  font-weight: 850;
}
.forecast-day small {
  color: #516b86;
  font-size: 0.68rem;
  font-weight: 700;
}
.forecast-day em {
  color: #293d4f;
  font-size: 0.66rem;
  font-style: normal;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.forecast-day.marine-safe {
  background: #eaf8f0;
  border-color: #a9e3c4;
}
.forecast-day.marine-caution {
  background: #fff5d8;
  border-color: #f2c75d;
}
.forecast-day.marine-unsafe {
  background: #ffe5e3;
  border-color: #f09a96;
}
.forecast-day.marine-unknown {
  background: #eef1f3;
  border-color: var(--border);
}
.forecast-day.marine-no-data { background: #e7eaec; border-color: #aab4bc; }
.marine-no-data { background: #e7eaec !important; border-color: #aab4bc !important; color: #36454f !important; }

.history-filter-row {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr) minmax(130px, 1fr) minmax(130px, 1fr);
  gap: 8px;
  align-items: end;
  margin-bottom: 6px;
}
.history-filter-row label { font-weight: 800; }
.small { font-size: 13px; color: #516b86; margin-top: 8px; }
#mapWrap { position: relative; height: 480px; border-radius: 18px; overflow: hidden; margin: 12px 0 12px; border: 1px solid var(--border); background: #dff2ff; }
#map { height: 100%; width: 100%; }
.overlay-chip {
  position: absolute; z-index: 600; background: rgba(255,255,255,0.92); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px; padding: 8px 12px; box-shadow: var(--shadow);
  font-size: 13px; font-weight: 700;
}
#mapOverlayTop { top: 12px; left: 12px; }
#locationChip { left: 12px; bottom: 12px; max-width: calc(100% - 80px); }
.mapFab {
  position: absolute; right: 12px; bottom: 12px; z-index: 600; width: 52px; height: 52px; border-radius: 999px;
  display: grid; place-items: center; font-size: 20px; box-shadow: var(--shadow);
}
.legendRow { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.legendItem { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.legendDot { width: 12px; height: 12px; border-radius: 999px; display: inline-block; }
.legendLine {
  width: 24px;
  border-top: 3px dashed #111827;
  box-shadow: 0 1px 0 #ffffff;
  display: inline-block;
}
.legendDot.you { background: #1565c0; }
.legendDot.fish { background: #00a86b; }
.legendDot.wave-yellow {
  background: rgba(242, 199, 93, 0.62);
  border: 1px solid #b7791f;
  border-radius: 4px;
}
.legendDot.wave-orange {
  background: rgba(249, 115, 22, 0.55);
  border: 1px solid #c2410c;
  border-radius: 4px;
}
.legendDot.wave-red {
  background: rgba(220, 38, 38, 0.55);
  border: 1px solid #991b1b;
  border-radius: 4px;
}
.legendDot.coastal-near {
  background: rgba(242, 199, 93, 0.55);
  border: 1px solid #b7791f;
  border-radius: 4px;
}
.legendDot.coastal-offshore {
  background: rgba(42, 157, 143, 0.42);
  border: 1px solid #0f766e;
  border-radius: 4px;
}
.fish-item { background: rgba(255,255,255,0.9); border: 1px solid var(--border); border-radius: 14px; padding: 10px; margin: 8px 0; }
.fish-item strong { font-size: 18px; }
.stickyAction { position: sticky; bottom: 12px; box-shadow: 0 12px 24px rgba(11,94,215,0.25); }
.leaflet-popup-content-wrapper { border-radius: 14px; }
.leaflet-popup-content { font-size: 14px; line-height: 1.45; }
.fish-marker, .you-marker {
  width: 34px; height: 34px; border-radius: 999px; display: grid; place-items: center;
  font-size: 20px; background: rgba(255,255,255,0.95); border: 2px solid #ffffff; box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
.you-marker { background: #1565c0; color: white; font-size: 16px; }
.emptyState { padding: 14px; background: #f6fbff; border: 1px dashed var(--border); border-radius: 14px; color: #51708f; }
@media (max-width: 640px) {
  .history-filter-row {
    grid-template-columns: 1fr;
  }
  #app { padding: 12px; }
  #mapWrap { height: 58vh; min-height: 380px; }
  .grid2, .row { grid-template-columns: 1fr; flex-direction: column; }
  .mapFab { width: 48px; height: 48px; }
}
body {
  font-family: "Inter", "Noto Sans", "Noto Sans Devanagari", Arial, sans-serif;
}

/* FORCE CENTERED MAIN HEADER */
.main-title-header {
  width: 100% !important;
  max-width: 900px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding: 24px 16px 18px 16px !important;
  box-sizing: border-box !important;

  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
}

.main-title-header * {
  text-align: center !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

.main-title-header .gu-logo {
  width: 145px !important;
  max-width: 145px !important;
  display: block !important;
}

.main-title-header h1 {
  width: 100% !important;
  max-width: 800px !important;
  display: block !important;
  font-size: 2.25rem !important;
  line-height: 1.2 !important;
}

.main-title-header .sanskrit-title {
  display: block !important;
  width: 100% !important;
  font-size: 1.5rem !important;
}

.main-title-header .initiative-text,
.main-title-header .platform-text,
.main-title-header #statusText {
  width: 100% !important;
  max-width: 820px !important;
  display: block !important;
  text-align: center !important;
  line-height: 1.45 !important;
}

.developer-credit {
  display: block;
  width: 100%;
  max-width: 760px;
  text-align: center !important;
  color: #516b86;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  margin: 0 auto 16px;
  padding: 0 16px;
}

.map-screen-header {
  width: 100%;
  position: relative;
  text-align: center;
  margin-bottom: 10px;
}

.map-logo {
  width: 95px !important;
  height: auto !important;
  display: block !important;
  margin: 0 auto 8px auto !important;
}

.logout-btn {
  position: absolute !important;
  top: 8px !important;
  right: 8px !important;
  width: auto !important;
  min-width: 80px !important;
  padding: 7px 14px !important;
  border-radius: 999px !important;
  border: none !important;
  background: #d9534f !important;
  color: white !important;
  font-weight: 700 !important;
  cursor: pointer !important;
}

body.app-logged-in .main-title-header {
  display: none !important;
}

body.app-logged-in .developer-credit {
  display: none !important;
}

body.app-logged-out .main-title-header {
  display: flex !important;
}

.trip-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.trip-toolbar button {
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 700;
}

#tripStatusText {
  text-align: center;
  font-weight: 700;
  margin-bottom: 8px;
}
.popup-start-btn {
  margin-top: 8px;
  padding: 8px 12px;
  border: none;
  border-radius: 10px;
  background: #0b5ed7;
  color: white;
  font-weight: 700;
  cursor: pointer;
}

/* Catch input modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

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

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.24);
  border: 1px solid var(--border);
}

.modal-card h2 {
  text-align: center;
  margin-bottom: 12px;
}

.modal-actions {
  margin-top: 14px;
}

.popup-start-btn {
  margin-top: 8px;
  padding: 8px 12px;
  border: none;
  border-radius: 10px;
  background: #0b5ed7;
  color: white;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

.map-top-buttons {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-btn {
  width: auto !important;
  min-width: 80px !important;
  padding: 7px 14px !important;
  border-radius: 999px !important;
  border: none !important;
  background: #0b5ed7 !important;
  color: white !important;
  font-weight: 700 !important;
  cursor: pointer !important;
}

.logout-btn {
  position: static !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: white;
  border-radius: 18px;
  padding: 16px;
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close-btn {
  width: 42px !important;
  height: 42px !important;
  padding: 0 !important;
  border-radius: 999px !important;
  font-size: 26px !important;
  line-height: 1 !important;
  background: #d9534f !important;
}

.history-controls {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  gap: 8px;
  align-items: center;
  margin: 14px 0;
}

.history-month-title {
  text-align: center;
  font-weight: 800;
}

.history-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.calendar-day {
  min-height: 42px;
  padding: 8px !important;
  border-radius: 10px !important;
  background: #edf4ff !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

.calendar-day.blank {
  background: transparent !important;
  border: none !important;
  pointer-events: none;
}

.calendar-day.has-data {
  background: #0b5ed7 !important;
  color: white !important;
  box-shadow: 0 4px 12px rgba(11, 94, 215, 0.25);
}

.history-summary {
  background: #f6fbff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
  line-height: 1.5;
}

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

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.history-table th,
.history-table td {
  border: 1px solid var(--border);
  padding: 8px;
  text-align: center;
}

.history-table th {
  background: #edf4ff;
  font-weight: 800;
}

.forgot-btn {
  margin-top: 10px;
}

/* Professional field-app polish */
:root {
  --bg: #eef5f7;
  --card: #ffffff;
  --text: #12313f;
  --muted: #587280;
  --primary: #0f5b78;
  --primary-strong: #0a435a;
  --secondary: #eef6f8;
  --accent: #15936b;
  --warning: #c58a14;
  --danger: #b94a48;
  --border: #c9dde3;
  --shadow: 0 12px 28px rgba(9, 42, 56, 0.10);
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(15, 91, 120, 0.10), rgba(238, 245, 247, 0) 280px),
    var(--bg);
  color: var(--text);
  letter-spacing: 0;
  font-family: Inter, "Noto Sans", "Noto Sans Devanagari", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  max-width: 820px;
  min-height: 100vh;
  padding: 18px;
}

.main-title-header {
  padding: 24px 14px 14px !important;
}

.main-title-header .gu-logo {
  width: 118px !important;
  max-width: 118px !important;
  margin-bottom: 14px !important;
}

.main-title-header h1 {
  max-width: 680px !important;
  font-size: 2rem !important;
  line-height: 1.16 !important;
  color: #0b2f40;
}

.main-title-header .sanskrit-title {
  margin-top: 6px !important;
  font-size: 1.28rem !important;
  font-weight: 700;
  color: var(--primary);
}

.main-title-header .initiative-text {
  margin-top: 14px !important;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 650;
}

.main-title-header #statusText {
  margin-top: 8px !important;
  color: var(--primary-strong);
  font-size: 1.06rem;
  font-weight: 800;
}

.card {
  border-radius: 8px;
  border-color: rgba(120, 158, 170, 0.42);
  box-shadow: var(--shadow);
}

#authCard {
  max-width: 460px;
  margin: 10px auto 14px;
  padding: 22px;
}

#authCard h2 {
  margin-bottom: 16px;
  text-align: center;
  font-size: 1.25rem;
}

label {
  color: #24495a;
  font-size: 0.92rem;
}

input,
select {
  margin-top: 6px;
  border-radius: 8px;
  background: #fbfdfe;
  color: var(--text);
}

input:focus,
select:focus {
  outline: 3px solid rgba(21, 147, 107, 0.18);
  border-color: var(--accent);
}

button {
  border-radius: 8px;
  background: var(--primary);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

button:hover {
  background: var(--primary-strong);
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  background: #f7fbfc;
  color: var(--primary-strong);
  border: 1px solid var(--border);
}

button.secondary:hover {
  background: #e7f1f4;
}

.link-btn {
  width: auto;
  display: block;
  margin-left: auto;
  margin-right: auto;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 750;
}

.link-btn:hover {
  background: transparent;
  color: var(--primary-strong);
  text-decoration: underline;
}

.developer-credit {
  max-width: 520px;
  color: var(--muted);
}

.code-credit {
  margin-top: -10px;
}

.developer-credit a {
  color: var(--primary);
  text-decoration: none;
}

.developer-credit a:hover {
  text-decoration: underline;
}

.official-dashboard-link {
  margin-bottom: 16px;
}

#todayCard {
  padding: 12px;
  border-radius: 8px;
}

.map-screen-header {
  min-height: 54px;
  margin-bottom: 8px;
}

.map-logo {
  width: 72px !important;
  margin-bottom: 0 !important;
}

.map-top-buttons {
  top: 4px;
  right: 4px;
  flex-direction: row;
  gap: 6px;
}

.history-btn,
.logout-btn {
  min-width: 0 !important;
  width: auto !important;
  padding: 8px 12px !important;
  border-radius: 8px !important;
  font-size: 13px !important;
}

.language-switch {
  width: auto;
  min-width: 104px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  background: #ffffff;
}

.history-btn {
  background: var(--primary) !important;
}

.logout-btn {
  background: #f8eeee !important;
  color: var(--danger) !important;
  border: 1px solid #e9caca !important;
}

#todayCard h2 {
  font-size: 1.22rem;
  margin-bottom: 2px;
}

#updateText {
  color: var(--muted);
  font-size: 0.9rem;
}

.status-pills {
  justify-content: flex-end;
}

.pill {
  border-radius: 8px;
  padding: 8px 10px;
  background: #eaf8f2;
  color: #0e6d50;
  border: 1px solid #bee4d3;
  font-size: 13px;
  white-space: nowrap;
}

.pill.neutral {
  background: #edf5f8;
  color: #315565;
  border-color: var(--border);
}

.alert-banner {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid;
  box-shadow: 0 8px 20px rgba(9, 42, 56, 0.08);
}

.alert-title {
  font-size: 0.86rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.alert-text {
  margin-top: 4px;
  font-size: 0.94rem;
  line-height: 1.4;
}

.alert-warning {
  background: #fff6e4;
  border-color: #e6b75f;
  color: #684300;
}

.alert-muted {
  background: #f4fafb;
  border-color: var(--border);
  color: var(--muted);
}

.alert-error {
  background: #fff1ef;
  border-color: #e7b9b4;
  color: #7d2d28;
}

#mapWrap {
  height: 62vh;
  min-height: 460px;
  max-height: 660px;
  border-radius: 8px;
  border-color: rgba(67, 110, 125, 0.35);
  background: #d9edf2;
}

.overlay-chip {
  border-radius: 8px;
  color: #173847;
  font-size: 12px;
  box-shadow: 0 8px 22px rgba(9, 42, 56, 0.13);
}

.mapFab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #ffffff;
  color: var(--primary);
  border: 1px solid var(--border);
}

.mapFab:hover {
  background: #f0f8fa;
}

.legendRow {
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
}

.legendDot.fish {
  background: var(--accent);
}

.details-card {
  border-radius: 8px;
  box-shadow: none;
}

.details-card summary {
  color: var(--primary-strong);
}

.fish-item {
  border-radius: 8px;
  background: #fbfdfd;
  border-left: 4px solid var(--accent);
}

.fish-item strong {
  color: var(--primary-strong);
  font-size: 1rem;
}

.fish-item span {
  color: var(--muted);
  font-size: 0.9rem;
}

.fish-marker {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 8px;
  display: block;
  background: var(--accent);
  border: 3px solid #ffffff;
  box-shadow: 0 6px 18px rgba(4, 44, 32, 0.32);
  transform: rotate(-45deg);
}

.fish-marker span {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: #ffffff;
  opacity: 0.95;
}

.you-marker {
  background: var(--primary);
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
  box-shadow: 0 14px 30px rgba(9, 42, 56, 0.18);
}

.popup-start-btn {
  border-radius: 8px;
  background: var(--accent);
}

.popup-start-btn:hover {
  background: #107b59;
}

.trip-toolbar {
  position: sticky;
  bottom: 10px;
  z-index: 900;
  grid-template-columns: 1.3fr 1fr 1fr 1fr;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 30px rgba(9, 42, 56, 0.16);
  backdrop-filter: blur(8px);
}

.trip-toolbar button {
  min-height: 46px;
}

.trip-toolbar .primary {
  background: var(--accent);
}

.trip-toolbar .primary:hover {
  background: #107b59;
}

.danger-secondary {
  background: #fff4f2;
  color: var(--danger);
  border: 1px solid #e9caca;
}

.danger-secondary:hover {
  background: #f9e7e4;
}

#tripStatusText,
#offlineQueueText {
  text-align: center;
  color: var(--muted);
}

.modal-card {
  border-radius: 8px;
}

.history-card {
  max-width: 820px;
}

.calendar-day {
  border-radius: 8px !important;
}

.calendar-day.has-data {
  background: var(--accent) !important;
}

.history-summary {
  border-radius: 8px;
  background: #f7fbfc;
}

.history-table th {
  background: #edf5f8;
}

@media (max-width: 640px) {
  #app {
    padding: 10px;
  }

  .main-title-header h1 {
    font-size: 1.55rem !important;
  }

  .main-title-header .sanskrit-title {
    font-size: 1.08rem !important;
  }

  #authCard {
    padding: 18px;
  }

  .row {
    gap: 10px;
  }

  .map-screen-header {
    min-height: 48px;
  }

  .map-logo {
    width: 58px !important;
    margin-left: 0 !important;
  }

  #mapWrap {
    height: 60vh;
    min-height: 390px;
  }

  .status-pills {
    width: 100%;
    justify-content: flex-start;
  }

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

  .history-controls {
    grid-template-columns: 1fr;
  }

  .history-table,
  .history-table thead,
  .history-table tbody,
  .history-table tr,
  .history-table th,
  .history-table td {
    display: block;
  }

  .history-table thead {
    display: none;
  }

  .history-table tr {
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
  }

  .history-table td {
    border: 0;
    border-bottom: 1px solid var(--border);
    text-align: left;
  }

  .history-table td:last-child {
    border-bottom: 0;
  }
}

/* Release layout pass: prevent header controls from overlapping the logo. */
[hidden] {
  display: none !important;
}

#todayCard {
  padding: 14px;
}

.map-screen-header {
  position: static;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  padding: 4px 0 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(120, 158, 170, 0.34);
}

.map-brand {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  text-align: left;
}

.map-logo {
  width: 58px !important;
  max-width: 58px !important;
  margin: 0 !important;
}

.map-brand strong,
.map-brand span {
  display: block;
}

.map-brand strong {
  color: #082f3f;
  font-size: 1rem;
  line-height: 1.15;
}

.map-brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.2;
}

.map-sanskrit-title {
  font-family: "Noto Sans Devanagari", "Nirmala UI", "Mangal", system-ui, sans-serif;
  color: #315174 !important;
  font-size: 0.9rem !important;
  font-weight: 750 !important;
}

.map-top-buttons {
  position: static;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.language-switch,
.history-btn,
.logout-btn {
  min-height: 42px;
  width: 100% !important;
  min-width: 0 !important;
  padding: 9px 10px !important;
  border-radius: 8px !important;
  font-size: 0.82rem !important;
  line-height: 1.15;
  white-space: normal;
}

.language-switch {
  color: var(--primary-strong);
  border-color: var(--border);
}

#mapWrap {
  margin-top: 14px;
}

@media (min-width: 760px) {
  #app {
    max-width: 980px;
  }

  .map-screen-header {
    grid-template-columns: minmax(260px, 0.85fr) minmax(440px, 1.15fr);
    align-items: center;
  }
}

@media (max-width: 760px) {
  .map-top-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .language-switch {
    grid-column: 1 / -1;
  }

  .map-brand {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .map-logo {
    width: 52px !important;
    max-width: 52px !important;
  }
}

/* Viewport-fit application shell. The map screen uses the available height
   instead of forcing document-level vertical scrolling. */
html,
body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
}

body.app-logged-out {
  min-height: 100dvh;
  overflow-y: hidden;
}

body.app-logged-out #app {
  width: 100%;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto auto;
  align-content: center;
  padding: clamp(6px, 1.5vh, 16px);
  overflow: hidden;
}

body.app-logged-out .main-title-header {
  padding: clamp(6px, 1.8vh, 18px) 12px 8px !important;
}

body.app-logged-out .main-title-header .gu-logo {
  width: clamp(68px, 12vh, 112px) !important;
  max-width: clamp(68px, 12vh, 112px) !important;
  margin-bottom: clamp(5px, 1vh, 12px) !important;
}

body.app-logged-out .main-title-header h1 {
  font-size: clamp(1.25rem, 3.5vh, 1.9rem) !important;
  margin-bottom: 4px !important;
}

body.app-logged-out .main-title-header .sanskrit-title {
  font-size: clamp(0.98rem, 2.5vh, 1.22rem) !important;
}

body.app-logged-out .main-title-header .initiative-text,
body.app-logged-out .main-title-header #statusText {
  margin-top: clamp(3px, 0.8vh, 8px) !important;
  font-size: clamp(0.78rem, 1.8vh, 0.98rem);
}

body.app-logged-out #authCard {
  width: min(440px, 100%);
  margin: clamp(3px, 0.8vh, 10px) auto;
  padding: clamp(12px, 2vh, 20px);
}

body.app-logged-out #authCard h2 {
  margin-bottom: clamp(5px, 1vh, 12px);
}

body.app-logged-out #authCard label {
  margin: clamp(5px, 1vh, 10px) 0;
}

body.app-logged-out #authCard input,
body.app-logged-out #authCard select,
body.app-logged-out #authCard button {
  padding: clamp(9px, 1.5vh, 13px);
}

body.app-logged-out .developer-credit {
  margin-bottom: clamp(2px, 0.6vh, 8px);
  font-size: clamp(10px, 1.5vh, 13px);
  line-height: 1.25;
}

body.app-logged-out .code-credit {
  margin-top: 0;
}

body.app-logged-in {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

body.app-logged-in #app {
  width: 100%;
  max-width: 1400px;
  height: 100dvh;
  min-height: 0;
  padding: clamp(6px, 1.2vw, 14px);
  overflow: hidden;
}

body.app-logged-in #todayCard:not([hidden]) {
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: clamp(8px, 1.2vw, 14px);
  display: grid !important;
  grid-template-rows:
    max-content
    max-content
    max-content
    max-content
    minmax(360px, 1fr)
    max-content
    max-content
    max-content
    max-content;
  gap: clamp(4px, 0.7vh, 8px);
  overflow: hidden;
}

body.app-logged-in .map-screen-header {
  gap: 8px;
  margin: 0;
  padding: 0 0 8px;
}

body.app-logged-in .map-top-buttons {
  gap: 6px;
}

body.app-logged-in .language-switch,
body.app-logged-in .history-btn,
body.app-logged-in .logout-btn {
  min-height: 36px;
  padding: 7px 8px !important;
  font-size: 0.75rem !important;
}

body.app-logged-in #todayCard > .row {
  min-height: 0;
  flex-direction: row;
  flex-wrap: nowrap;
}

body.app-logged-in #todayCard > .row > div:first-child {
  min-width: 0;
}

body.app-logged-in #updateText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.app-logged-in .status-pills {
  width: auto;
  display: grid;
  justify-items: end;
  gap: 4px;
  flex-wrap: nowrap;
}

body.app-logged-in .status-pills .current-safety-details {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: right;
}

body.app-logged-in #todayCard h2 {
  font-size: 1.05rem;
}

body.app-logged-in #updateText {
  font-size: 0.78rem;
}

body.app-logged-in .alert-banner {
  margin: 0;
  padding: 8px 10px;
}

body.app-logged-in #mapWrap {
  grid-row: 5;
  height: 100%;
  min-height: 260px;
  max-height: none;
  margin: 0;
}

body.app-logged-in .legendRow {
  margin: 0;
  font-size: 0.75rem;
}

body.app-logged-in .details-card {
  min-height: 0;
  max-height: 20vh;
  margin: 0;
  overflow-y: auto;
}

body.app-logged-in .details-card:not([open]) {
  height: 34px;
  min-height: 34px;
  max-height: 34px;
  overflow: hidden;
}

body.app-logged-in .details-card summary {
  padding: 8px 10px;
  font-size: 0.8rem;
}

body.app-logged-in .trip-toolbar {
  position: static;
  margin: 0;
  padding: 6px;
  gap: 6px;
}

body.app-logged-in .trip-toolbar button {
  min-height: 36px;
  padding: 7px 8px;
  font-size: 0.78rem;
}

body.app-logged-in #tripStatusText,
body.app-logged-in #offlineQueueText {
  margin: 0;
  font-size: 0.7rem;
  line-height: 1.15;
}

@media (max-width: 760px) {
  body.app-logged-in .map-screen-header {
    grid-template-columns: 1fr;
  }

  body.app-logged-in .map-top-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.app-logged-in .language-switch {
    grid-column: auto;
  }

  body.app-logged-in .map-brand {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  body.app-logged-in .map-logo {
    width: 42px !important;
    max-width: 42px !important;
  }

  body.app-logged-in .map-brand strong {
    font-size: 0.88rem;
  }

  body.app-logged-in .map-brand span {
    font-size: 0.72rem;
  }

  body.app-logged-in .trip-toolbar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-height: 650px) {
  body.app-logged-out .main-title-header .initiative-text,
  body.app-logged-out .developer-credit {
    display: none !important;
  }

  body.app-logged-in .map-brand span,
  body.app-logged-in .legendRow,
  body.app-logged-in .details-card,
  body.app-logged-in #offlineQueueText {
    display: none;
  }

  body.app-logged-in #todayCard:not([hidden]) {
    grid-template-rows:
      max-content
      max-content
      max-content
      max-content
      minmax(220px, 1fr)
      max-content
      max-content
      max-content
      max-content;
  }

  body.app-logged-in #mapWrap {
    min-height: 170px;
  }
}

/* Operational audit: keep every app-shell row at its natural height and give
   the remaining space to the map. Short viewports scroll inside the screen. */
body.app-logged-in #todayCard:not([hidden]) {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows:
    max-content
    max-content
    max-content
    max-content
    minmax(260px, 1fr)
    max-content
    max-content
    max-content
    max-content;
  overflow-x: hidden;
  overflow-y: auto;
}

body.app-logged-in #todayCard > * {
  min-width: 0;
}

body.app-logged-in .map-screen-header {
  min-height: max-content;
}

body.app-logged-in #todayCard > .row {
  min-height: max-content;
}

body.app-logged-in #mapWrap {
  height: 100%;
}

@media (max-height: 520px) {
  body.app-logged-out .main-title-header {
    padding: 2px 8px !important;
  }

  body.app-logged-out .main-title-header .gu-logo {
    width: 42px !important;
    max-width: 42px !important;
    margin-bottom: 2px !important;
  }

  body.app-logged-out .main-title-header h1 {
    font-size: 1rem !important;
    line-height: 1.05 !important;
  }

  body.app-logged-out .main-title-header .sanskrit-title {
    font-size: 0.78rem !important;
  }

  body.app-logged-out .main-title-header #statusText,
  body.app-logged-out #authCard h2,
  body.app-logged-out #authCard .small {
    display: none !important;
  }

  body.app-logged-out #authCard {
    padding: 8px 12px;
  }

  body.app-logged-out #authCard label {
    margin: 3px 0;
    font-size: 0.75rem;
  }

  body.app-logged-out #authCard input,
  body.app-logged-out #authCard select,
  body.app-logged-out #authCard button {
    padding: 7px 9px;
    font-size: 0.8rem;
  }
}
