:root {
  color-scheme: dark;
  --bg: #090f18;
  --panel: #111a28;
  --panel-2: #0c131e;
  --field: #080e18;
  --button: #172233;
  --button-hover: #1f2d42;
  --stroke: #26364d;
  --stroke-strong: #3b516f;
  --text: #d7deea;
  --muted: #b6c0cf;
  --dim: #7f8da3;
  --gold: #f5c84c;
  --green: #2dd27b;
  --red: #ff5b57;
  --blue: #5ba7ff;
  --caution: #f5c84c;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(12px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
}

body.modal-open { overflow: hidden; }

button,
input,
textarea {
  font: inherit;
}

button,
.import-btn,
.entry-row,
.metric {
  -webkit-appearance: none;
  appearance: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(12px, 2vw, 22px);
  background: rgba(7, 11, 18, .94);
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(14px);
}

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

.brand-logo {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid rgba(244, 197, 66, .58);
  object-fit: cover;
}

.brand-logo-link {
  display: inline-flex;
  flex: 0 0 auto;
  border-radius: 999px;
}

.brand-logo-link:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

h1 {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.28rem, 2.35vw, 1.9rem);
  font-weight: 780;
  line-height: 1;
  letter-spacing: 0;
}

.now-line {
  margin-top: 5px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: .02em;
  white-space: nowrap;
}

h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.35;
}

.cao-line {
  color: var(--muted);
  font-size: .8rem;
  line-height: 1;
  font-weight: 820;
  letter-spacing: .02em;
  white-space: nowrap;
  text-align: right;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  align-self: flex-start;
  padding-top: clamp(.63rem, .95vw, .98rem);
}

.layout {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(10px, 1.6vw, 18px);
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

.panel,
.metric {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 8px;
}

.panel {
  padding: 14px;
}

.add-btn {
  width: 52px;
  height: 52px;
  min-height: 0;
  display: inline-grid;
  place-items: center;
  color: var(--text);
  background: var(--button);
  border: 1px solid var(--stroke-strong);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease, transform .08s ease;
}

.add-btn span {
  display: block;
  margin-top: -1px;
  color: var(--gold);
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
}

.totals-grid {
  grid-column: 1 / -1;
  position: sticky;
  top: var(--sticky-offset, 0);
  z-index: 19;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 8px 0;
  background: var(--bg);
}

.metric {
  min-height: 0;
  padding: 9px 12px;
  display: grid;
  align-content: center;
  gap: 6px;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease, transform .08s ease;
}

.metric span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 820;
  text-transform: uppercase;
}

.metric strong {
  color: var(--text);
  font-size: .86rem;
  font-weight: 850;
  line-height: 1.1;
}

.metric strong.is-negative {
  color: var(--red);
}

.message-center-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.message-center-panel[hidden],
.message-card[hidden],
.modal[hidden] {
  display: none;
}

.message-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  box-shadow: none;
}

.message-card b,
.message-card span {
  display: block;
}

.message-card b {
  color: var(--text);
  font-size: .86rem;
  font-weight: 850;
  line-height: 1.1;
}

.message-card span {
  margin-top: 2px;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.25;
}

.message-card button,
.mini-btn,
.primary-btn {
  min-height: 44px;
  padding: 9px 12px;
  color: var(--text);
  background: var(--button);
  border: 1px solid var(--stroke-strong);
  border-radius: 8px;
  font-weight: 850;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease, color .16s ease, transform .08s ease;
}

.message-card button {
  min-height: 38px;
  padding: 7px 10px;
  font-size: .86rem;
}

.mini-btn {
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 7px 10px;
  font-size: .86rem;
  text-decoration: none;
}

.primary-btn {
  min-width: 112px;
}

button:disabled {
  color: var(--dim);
  background: rgba(16, 27, 43, .52);
  border-color: rgba(72, 95, 128, .42);
  box-shadow: none;
  cursor: not-allowed;
  opacity: .62;
}

.danger-btn {
  color: #ffe8e6;
  border-color: rgba(255, 91, 87, .72);
  background: rgba(93, 24, 28, .72);
}

.danger-outline {
  color: #ffd4d1;
  border-color: rgba(255, 91, 87, .48);
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.receivers-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
}

.receiver-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.receiver-heading-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.receiver-heading .mini-btn,
.receiver-heading .add-btn {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0;
}

.paw-icon-btn {
  color: var(--gold);
}

.paw-icon-btn::before {
  content: "";
  width: 23px;
  height: 23px;
  display: block;
  background: currentColor;
  filter: drop-shadow(0 0 5px rgba(245, 200, 76, .28));
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cellipse cx='14' cy='24' rx='6.5' ry='8.5' transform='rotate(-24 14 24)'/%3E%3Cellipse cx='28' cy='15' rx='6.8' ry='9.5' transform='rotate(-8 28 15)'/%3E%3Cellipse cx='42' cy='16' rx='6.8' ry='9.5' transform='rotate(12 42 16)'/%3E%3Cellipse cx='54' cy='26' rx='6.2' ry='8.2' transform='rotate(26 54 26)'/%3E%3Cpath d='M17 49c0-9 6.5-18 17-18 10.8 0 18 9.2 18 18.6 0 6.5-4.8 9-10.8 6.4-3.3-1.5-5.5-2.4-8.2-2.4-2.6 0-4.8.9-8.1 2.4-5.2 2.2-7.9-1-7.9-7z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cellipse cx='14' cy='24' rx='6.5' ry='8.5' transform='rotate(-24 14 24)'/%3E%3Cellipse cx='28' cy='15' rx='6.8' ry='9.5' transform='rotate(-8 28 15)'/%3E%3Cellipse cx='42' cy='16' rx='6.8' ry='9.5' transform='rotate(12 42 16)'/%3E%3Cellipse cx='54' cy='26' rx='6.2' ry='8.2' transform='rotate(26 54 26)'/%3E%3Cpath d='M17 49c0-9 6.5-18 17-18 10.8 0 18 9.2 18 18.6 0 6.5-4.8 9-10.8 6.4-3.3-1.5-5.5-2.4-8.2-2.4-2.6 0-4.8.9-8.1 2.4-5.2 2.2-7.9-1-7.9-7z'/%3E%3C/svg%3E") center / contain no-repeat;
  transform: translate(-2px, -1px) rotate(-7deg);
  transform-origin: 50% 50%;
}

.receiver-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.receiver-tools .mini-btn,
.receiver-tools .add-btn {
  width: 52px;
}

.mini-btn.active {
  color: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(245, 200, 76, .18);
}

.filter-status {
  padding: 7px 10px;
  color: var(--gold);
  background: rgba(245, 200, 76, .08);
  border: 1px solid rgba(245, 200, 76, .22);
  border-radius: 8px;
  font-size: .76rem;
  font-weight: 850;
}

.filter-status[hidden] {
  display: none;
}

.import-btn {
  cursor: pointer;
}

.receiver-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 12px;
}

.receiver-card {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 12px;
  background: var(--field);
  border: 1px solid var(--stroke);
  border-radius: 8px;
}

.receiver-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.receiver-title {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.receiver-title strong {
  color: var(--text);
  font-size: .86rem;
  font-weight: 850;
  line-height: 1.1;
  word-break: break-word;
}

.receiver-title span {
  color: var(--muted);
  font-size: .76rem;
}

.receiver-total {
  color: var(--green);
  font-size: .86rem;
  font-weight: 850;
  line-height: 1.1;
  text-align: right;
  white-space: nowrap;
}

.receiver-total.is-negative {
  color: var(--red);
}

.entry-list {
  display: grid;
  gap: 8px;
}

.entry-row {
  width: 100%;
  min-height: 54px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  color: var(--text);
  text-align: left;
  background: rgba(12, 19, 30, .78);
  border: 1px solid var(--stroke);
  border-radius: 8px;
  cursor: pointer;
}

.entry-row strong {
  display: block;
  font-size: .86rem;
  font-weight: 850;
}

.entry-row span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: .76rem;
}

.entry-row b {
  color: var(--green);
  font-size: .86rem;
  font-weight: 850;
  line-height: 1.1;
  white-space: nowrap;
}

.entry-row b.is-negative {
  color: var(--red);
}

.card-actions {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.card-actions .receiver-info {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  margin-right: auto;
  color: var(--muted);
  display: block;
  font-size: .76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-actions .mini-btn {
  flex: 0 0 40px;
  width: 40px;
  min-width: 40px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  font-size: .86rem;
  line-height: 1;
}

.card-actions .add-to-receiver {
  color: var(--gold);
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  color: var(--muted);
  background: rgba(8, 14, 24, .72);
  border: 1px dashed var(--stroke-strong);
  border-radius: 8px;
}

.empty-state[hidden] {
  display: none;
}

.empty-state strong {
  color: var(--text);
}

.empty-state span {
  font-size: .88rem;
}

.back-top-btn {
  justify-self: stretch;
}

.back-top-btn[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding:
    max(14px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  background: rgba(2, 6, 12, .9);
  backdrop-filter: blur(10px);
}

#filterModal {
  place-items: start center;
  padding-top: max(14px, env(safe-area-inset-top));
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(840px, calc(100dvh - 28px));
  overflow: auto;
  display: grid;
  gap: 14px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--stroke-strong);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
}

.confirm-card {
  width: min(480px, 100%);
}

#confirmModal.technique-modal {
  padding: 0;
  place-items: stretch;
}

#confirmModal.technique-modal .technique-card {
  width: 100%;
  max-width: 100vw;
  min-height: 100dvh;
  max-height: 100dvh;
  padding:
    calc(14px + env(safe-area-inset-top))
    calc(14px + env(safe-area-inset-right))
    calc(14px + env(safe-area-inset-bottom))
    calc(14px + env(safe-area-inset-left));
  border: 0;
  border-radius: 0;
}

.technique-word {
  color: #6f7f99;
  font-family: "Segoe Script", "Brush Script MT", cursive;
  font-size: 1em;
  font-weight: 400;
  font-style: italic;
  letter-spacing: .02em;
  opacity: .44;
}

.technique-purpose {
  color: var(--muted);
}

.cg-card {
  width: min(720px, 100%);
}

.modal-close {
  width: 44px;
  min-height: 44px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 1.25rem;
  line-height: 1;
}

#offloadModal .modal-card,
#cgModal .modal-card {
  gap: 10px;
  padding: 10px;
  align-content: start;
}

#offloadModal .section-row,
#cgModal .section-row {
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 6px;
}

#offloadModal h2,
#cgModal h2 {
  min-width: 0;
  flex: 0 1 auto;
}

#offloadModal .modal-close,
#cgModal .modal-close {
  width: 38px;
  min-height: 38px;
  flex: 0 0 38px;
  font-size: 1rem;
}

#cgModal .cg-header-btn {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  flex: 0 0 38px;
  font-size: .8rem;
}

#cgModal h2 + .cg-header-btn {
  margin-left: auto;
}

#offloadModal h2,
#cgModal h2 {
  font-size: .95rem;
}

#offloadModal label,
#cgModal label {
  font-size: .76rem;
}

#offloadModal input,
#cgModal input {
  min-height: 40px;
  padding: 8px 10px;
  font-size: .86rem;
}

#offloadModal .unit-input input {
  min-height: 38px;
}

#offloadModal .unit-input span {
  padding: 0 8px;
  font-size: .76rem;
}

#offloadModal .formula-card,
#cgModal .formula-card {
  padding: 10px;
}

#offloadModal .formula-card strong,
#cgModal .formula-card strong {
  font-size: .95rem;
}

#cgModal .formula-card span {
  font-weight: 760;
}

#offloadModal .formula-card small,
#cgModal .formula-card small {
  font-size: .78rem;
}

.cg-result-card strong {
  color: var(--green);
}

.cg-result-card strong.is-warning {
  color: var(--gold);
}

.cg-result-card strong.is-negative {
  color: var(--red);
}

.cg-info-btn {
  width: 22px;
  min-width: 22px;
  min-height: 22px;
  margin-left: 4px;
  padding: 0;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 850;
  line-height: 1;
  vertical-align: middle;
}

.cg-main-max {
  align-self: end;
  min-height: 40px;
  justify-content: center;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 400;
  text-align: right;
}

.cg-formula {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  color: var(--text);
  font-size: .78rem;
  font-weight: 760;
}

.cg-formula-token.is-over-max {
  color: var(--red);
}

.cg-formula-text {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  min-width: 0;
}

.cg-formula .cg-alt-warning {
  margin-left: auto;
  color: var(--gold);
  font-size: .78rem;
  font-weight: 760;
  line-height: 1;
}

.stack-frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  margin: 0 1px;
  font-size: .72em;
  line-height: 1;
  vertical-align: middle;
}

.stack-frac span:first-child {
  width: 100%;
  padding-bottom: 1px;
  border-bottom: 1px solid currentColor;
}

.stack-frac span:last-child {
  padding-top: 1px;
}

.cg-formula .stack-frac {
  color: inherit;
  font-size: .72em;
  font-weight: inherit;
}

.cg-formula .stack-frac span {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.cg-reference {
  display: grid;
  gap: 7px;
  padding: 10px;
  background: rgba(8, 14, 24, .72);
  border: 1px solid var(--stroke);
  border-radius: 8px;
}

.cg-reference div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
}

.cg-reference h3 {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 500;
}

.cg-reference span {
  min-width: 0;
  color: var(--text);
  font-size: .78rem;
  font-weight: 500;
}

.cg-reference b {
  color: var(--text);
  font-size: .78rem;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.cg-reference b .stack-frac {
  display: inline-grid;
}

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

.burn-time-card strong {
  color: var(--green);
}

.burn-time-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
  justify-content: stretch;
}

.burn-time-grid .field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

#cgModal .burn-time-card .unit-input input {
  min-height: 38px;
}

#cgModal .burn-time-card .unit-input span {
  padding: 0 8px;
  font-size: .76rem;
}

#offloadModal .form-actions {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  align-self: start;
}

#offloadModal .form-actions .primary-btn {
  width: auto;
  height: 40px;
  min-height: 40px;
  min-width: 96px;
  padding: 8px 12px;
  align-self: center;
}

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

.field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.wide-field {
  grid-column: 1 / -1;
}

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

.modal-block-toggle {
  width: min(170px, 42vw);
  margin-left: auto;
}

.block-option {
  min-height: 38px;
  padding: 7px 10px;
  color: var(--text);
  background: var(--button);
  border: 1px solid var(--stroke-strong);
  border-radius: 8px;
  font-weight: 850;
  cursor: pointer;
}

.block-option.active {
  color: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(245, 200, 76, .18);
}

[hidden] {
  display: none !important;
}

label {
  color: var(--muted);
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  font-size: .83rem;
  font-weight: 760;
}

.label-note {
  flex: 1;
  font-weight: 400;
  text-align: center;
  white-space: nowrap;
}

.label-note.is-over-max {
  color: var(--red);
}

input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--stroke-strong);
  border-radius: 8px;
  outline: none;
}

input[type="datetime-local"] {
  appearance: none;
  -webkit-appearance: none;
  color-scheme: dark;
  max-width: 100%;
  min-width: 0;
}

.date-sync-row {
  display: grid;
  grid-template-columns: minmax(0, calc(100% - 62px)) 52px;
  gap: 10px;
  align-items: stretch;
  overflow: hidden;
}

.date-sync-label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 10px;
  align-items: center;
}

.date-sync-row input {
  display: block;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

.date-sync-label > span:first-child {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.date-now-btn {
  min-height: 48px;
  width: 52px;
  min-width: 52px;
  padding: 7px;
  color: var(--gold);
  font-size: 1rem;
}

.date-sync-status {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  color: var(--gold);
  font-size: .76rem;
  font-weight: 760;
  text-align: right;
  white-space: nowrap;
}

#callsign {
  text-transform: uppercase;
}

input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(245, 200, 76, .25), 0 0 16px rgba(245, 200, 76, .12);
}

input.is-over-max,
input.is-over-max:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 1px rgba(238, 91, 91, .28), 0 0 16px rgba(238, 91, 91, .12);
}

input:disabled {
  color: var(--dim);
  background: rgba(8, 14, 24, .48);
  border-color: var(--stroke);
  opacity: .72;
}

.unit-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  background: var(--field);
  border: 1px solid var(--stroke-strong);
  border-radius: 8px;
}

.unit-input:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(245, 200, 76, .25), 0 0 16px rgba(245, 200, 76, .12);
}

.unit-input input {
  min-height: 46px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.unit-input span {
  padding: 0 10px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 820;
  white-space: nowrap;
}

.control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: stretch;
}

.contacts-control-row {
  grid-template-columns: minmax(0, 1fr) 44px;
}

.field-tool-btn {
  width: 44px;
  min-height: 40px;
  padding: 7px;
  color: var(--gold);
  font-size: .92rem;
}

.contacts-control-row .field-tool-btn {
  font-size: .95rem;
}

.toggle-row {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  accent-color: var(--gold);
}

.formula-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  background: rgba(8, 14, 24, .78);
  border: 1px solid var(--stroke);
  border-radius: 8px;
}

.formula-card div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.formula-card span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 820;
}

.formula-card strong {
  color: var(--green);
  font-size: 1.45rem;
  line-height: 1;
}

.formula-card small,
.callout {
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.35;
}

.formula-card .burn-time-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.formula-card .burn-time-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
  justify-content: stretch;
}

.formula-card .burn-time-grid .field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.burn-time-timer-btn {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  color: var(--gold);
}

.formula-card .burn-time-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px 38px;
  gap: 8px;
  align-items: center;
}

.burn-time-info-btn {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  margin-left: 0;
}

.burn-time-card #burnTimeResult {
  color: var(--text);
  font-size: .95rem;
  font-weight: 760;
  white-space: nowrap;
}

.burn-time-card #burnTimeResult span {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.burn-time-card #burnTimeResult .burn-time-required {
  color: var(--green);
}

.burn-time-card .burn-time-left.is-complete {
  animation: burnTimeCompleteBlink .8s step-end 5;
  color: var(--gold);
}

@keyframes burnTimeCompleteBlink {
  50% {
    opacity: .28;
  }
}

#confirmBody {
  white-space: pre-line;
}

#confirmBody p {
  margin: 0 0 14px;
}

#confirmBody p:last-child {
  margin-bottom: 0;
}

.cg-info-table {
  width: 100%;
  margin: -4px 0 14px;
  border-collapse: collapse;
}

.cg-info-table td {
  padding: 2px 0;
  vertical-align: baseline;
}

.cg-info-table td:first-child {
  width: 8ch;
  padding-right: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.cg-info-table td:last-child {
  color: var(--text);
  overflow-wrap: anywhere;
}

.inline-input-chip {
  display: inline-block;
  min-width: 36px;
  padding: 2px 8px;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--stroke-strong);
  border-radius: 6px;
  font-weight: 760;
  text-align: center;
  white-space: nowrap;
}

#confirmBody.summary-table {
  width: 100%;
  max-width: 100%;
  white-space: normal;
}

.summary-table-inner {
  width: auto;
  max-width: 100%;
  border-collapse: separate;
  border-spacing: 0 7px;
}

.summary-table-inner td {
  padding: 0;
  vertical-align: baseline;
}

.summary-table-inner .summary-label {
  max-width: min(22ch, 46vw);
  padding-right: 18px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.summary-table-inner .summary-value {
  min-width: 6ch;
  padding-right: 6px;
  color: var(--text);
  font-weight: 400;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.summary-table-inner .summary-unit {
  color: var(--text);
  white-space: nowrap;
}

.formula-card.warn strong {
  color: var(--caution);
}

.formula-card.bad strong {
  color: var(--red);
}

.form-actions,
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (hover: hover) and (pointer: fine) {
  button:hover,
  .import-btn:hover,
  .metric:hover {
    background: var(--button-hover);
    border-color: var(--gold);
    box-shadow: 0 0 0 1px rgba(245, 200, 76, .26), 0 0 16px rgba(245, 200, 76, .16);
  }

  .danger-btn:hover,
  .danger-outline:hover {
    color: #ffe8e6;
    background: var(--button-hover);
    border-color: var(--red);
    box-shadow: 0 0 0 1px rgba(255, 91, 87, .28), 0 0 16px rgba(255, 91, 87, .16);
  }

  .entry-row:hover {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px rgba(245, 200, 76, .18);
  }

  button:active,
  .import-btn:active,
  .entry-row:active,
  .metric:active {
    transform: translateY(1px) scale(.99);
  }
}

body.modal-open .entry-row,
body.modal-open .metric,
body.modal-open .receiver-tools .mini-btn,
body.modal-open .receiver-tools .add-btn,
body.modal-open .import-btn {
  transform: none !important;
  box-shadow: none !important;
}

body.modal-open .entry-row {
  border-color: var(--stroke) !important;
}

button:focus-visible,
.import-btn:focus-visible,
.metric:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

input:focus-visible {
  outline: none;
}

@media (pointer: coarse) {
  input,
  #offloadModal input,
  #filterModal input,
  #cgModal input {
    font-size: 16px;
  }
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 1100px) {
  #filterModal .form-grid {
    grid-template-columns: 1fr;
  }

  #filterModal input[type="datetime-local"] {
    font-size: .86rem;
  }

  #filterModal {
    padding-top: max(14px, env(safe-area-inset-top));
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  #filterModal .confirm-card {
    width: 100%;
    max-width: 100vw;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  #filterModal .confirm-actions .primary-btn {
    min-height: 38px;
    padding: 7px 10px;
    font-size: .86rem;
  }
}

@media (max-width: 640px) {
  .app-header {
    align-items: center;
  }

  .brand-logo {
    width: 48px;
    height: 48px;
  }

  .header-actions {
    align-self: center;
    padding-top: 0;
  }

  .layout {
    gap: 8px;
    padding: 8px 0;
  }

  .totals-grid,
  .message-center-panel,
  .receivers-panel {
    background: var(--panel);
    border: 1px solid var(--stroke);
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .totals-grid {
    gap: 8px;
    padding: 10px;
  }

  .message-center-panel {
    padding: 10px;
  }

  .message-card {
    box-shadow: none;
  }

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

  .receiver-heading {
    width: 100%;
    justify-content: space-between;
  }

  .receiver-heading .mini-btn,
  .receiver-heading .add-btn {
    width: 100%;
  }

  .receiver-heading-actions {
    width: calc((((100% - 32px) / 5) * 2) + 8px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .receiver-tools {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .receiver-tools .mini-btn,
  .receiver-tools .add-btn {
    width: 100%;
  }

  .section-row {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 8px;
    row-gap: 10px;
  }

  .modal {
    padding:
      max(14px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
    place-items: center;
  }

  #offloadModal,
  #cgModal {
    padding: 0;
    place-items: stretch;
  }

  #offloadModal .modal-card,
  #cgModal .modal-card {
    width: 100%;
    max-width: 100vw;
    min-height: 100dvh;
    max-height: 100dvh;
    padding:
      calc(10px + env(safe-area-inset-top))
      calc(10px + env(safe-area-inset-right))
      calc(10px + env(safe-area-inset-bottom))
      calc(10px + env(safe-area-inset-left));
    border: 0;
    border-radius: 0;
  }

  .confirm-card {
    width: min(440px, calc(100vw - 28px));
    min-height: 0;
    max-height: calc(100dvh - 28px);
    align-content: start;
    gap: 16px;
    padding: 14px;
  }

  .confirm-card .section-row {
    align-items: center;
    flex-wrap: nowrap;
  }

  .confirm-card .modal-close {
    flex: 0 0 44px;
  }

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

  .confirm-actions .primary-btn {
    min-height: 44px;
    min-width: 0;
  }

}
