:root {
  color-scheme: light;
  --bg: #f4f7f4;
  --panel: #ffffff;
  --ink: #15252b;
  --muted: #65747a;
  --line: #dbe4df;
  --brand: #15616d;
  --brand-strong: #103f49;
  --field: #eef4f1;
  --free: #2f8f62;
  --out: #c2761b;
  --danger: #bd3e3e;
  --shadow: 0 18px 44px rgba(25, 50, 54, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #e9f2ec 0%, rgba(244, 247, 244, 0) 280px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

svg {
  display: block;
}

svg path,
svg circle {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(94px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 14px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 2rem;
  line-height: 1;
}

.icon-button,
.primary-action,
.secondary-action,
.text-button,
.danger-action {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 44px;
  min-width: 44px;
  place-items: center;
  color: var(--brand-strong);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px rgba(21, 97, 109, 0.12);
}

.icon-button svg {
  width: 21px;
  height: 21px;
}

.map-summary {
  position: relative;
  display: grid;
  min-height: 174px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(12, 45, 53, 0.9), rgba(21, 97, 109, 0.74)),
    #153f48;
  box-shadow: var(--shadow);
}

.map-art {
  position: absolute;
  inset: 0;
}

.block,
.line,
.pin {
  position: absolute;
  display: block;
}

.block {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
}

.block-a {
  inset: 24px auto auto 18px;
  width: 44%;
  height: 54px;
  border-radius: 18px 8px 20px 8px;
}

.block-b {
  inset: 34px 22px auto auto;
  width: 34%;
  height: 72px;
  border-radius: 8px 24px 8px 18px;
}

.block-c {
  left: 42px;
  bottom: 24px;
  width: 36%;
  height: 62px;
  border-radius: 8px 18px 8px 24px;
}

.block-d {
  right: 40px;
  bottom: 18px;
  width: 30%;
  height: 46px;
  border-radius: 20px 8px 18px 8px;
}

.line {
  height: 3px;
  border-radius: 99px;
  background: rgba(252, 191, 73, 0.75);
  transform-origin: left center;
}

.line-a {
  left: 70px;
  top: 92px;
  width: 170px;
  transform: rotate(-14deg);
}

.line-b {
  right: 42px;
  bottom: 78px;
  width: 126px;
  transform: rotate(24deg);
}

.pin {
  width: 16px;
  height: 16px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: #fcbf49;
  box-shadow: 0 0 0 5px rgba(252, 191, 73, 0.22);
}

.pin-a {
  left: 72px;
  top: 82px;
}

.pin-b {
  right: 86px;
  top: 72px;
}

.summary-copy {
  position: relative;
  align-self: end;
  padding: 88px 18px 18px;
  color: white;
}

.summary-copy span {
  display: block;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.84rem;
  font-weight: 800;
}

.summary-copy strong {
  display: block;
  max-width: 19rem;
  font-size: 1.23rem;
  line-height: 1.2;
}

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

.stats-grid article {
  min-height: 86px;
  padding: 14px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

.stats-grid span {
  display: block;
  font-size: 1.65rem;
  font-weight: 850;
  line-height: 1;
}

.stats-grid p {
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.field-card {
  display: grid;
  gap: 12px;
  margin: 0 0 14px;
  padding: 13px;
  border: 1px solid rgba(194, 118, 27, 0.28);
  border-radius: 8px;
  background: #fff8ee;
}

.field-card[hidden] {
  display: none;
}

.field-card-header {
  display: grid;
  gap: 5px;
}

.field-label {
  justify-self: start;
  padding: 5px 8px;
  border-radius: 7px;
  color: #fff;
  background: var(--out);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.field-card-header strong {
  font-size: 1.05rem;
}

.field-card-body {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.field-card-body img {
  width: 120px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border: 1px solid rgba(194, 118, 27, 0.28);
  border-radius: 8px;
  background: #fff;
}

.field-card-body p {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
  line-height: 1.36;
}

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

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.search-box {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.search-box svg {
  width: 20px;
  min-width: 20px;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.primary-action,
.secondary-action,
.danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 850;
}

.primary-action {
  color: #fff;
  background: var(--brand);
}

.secondary-action {
  color: var(--brand-strong);
  background: #dcebe6;
}

.danger-action {
  width: 100%;
  color: #fff;
  background: var(--danger);
}

.field-cancel-action,
.assignment-cancel-action {
  grid-column: 1 / -1;
}

.primary-action svg,
.secondary-action svg,
.danger-action svg {
  width: 19px;
  height: 19px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e5eee9;
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.segmented button.active {
  color: var(--brand-strong);
  background: #fff;
  box-shadow: 0 6px 16px rgba(21, 37, 43, 0.08);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-heading h2 {
  font-size: 1.15rem;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
}

.history-actions .text-button {
  min-height: 40px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.territory-list,
.history-list,
.recommendation-list {
  display: grid;
  gap: 10px;
}

.batch-designation {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid rgba(21, 97, 109, 0.22);
  border-radius: 8px;
  background: #e8f1ee;
}

.batch-designation[hidden] {
  display: none;
}

.batch-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.batch-summary strong {
  min-width: 0;
  color: var(--ink);
}

.batch-summary .text-button {
  min-height: 36px;
}

.territory-card,
.recommendation-card,
.history-item,
.empty-state,
dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.territory-card {
  min-height: 88px;
  overflow: hidden;
}

.card-main {
  display: grid;
  grid-template-columns: 84px 14px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  width: 100%;
  min-width: 0;
  padding: 16px 12px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.territory-photo {
  width: 84px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.status-dot {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--free);
  box-shadow: 0 0 0 5px rgba(47, 143, 98, 0.13);
}

.status-campo .status-dot {
  background: var(--out);
  box-shadow: 0 0 0 5px rgba(194, 118, 27, 0.13);
}

.card-text {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.territory-title {
  overflow: hidden;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.territory-meta,
.history-item small {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.82rem;
  font-style: normal;
  line-height: 1.32;
}

.recommendation-card {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.recommendation-side {
  display: grid;
  gap: 8px;
  justify-items: center;
  align-content: start;
}

.rank-badge {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
  font-size: 0.92rem;
  font-weight: 900;
}

.recommendation-select {
  display: grid;
  justify-items: center;
  gap: 5px;
  color: var(--brand-strong);
  font-size: 0.68rem;
  font-weight: 900;
  text-align: center;
}

.recommendation-select input {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  accent-color: var(--brand);
}

.recommendation-main {
  display: grid;
  min-width: 0;
  gap: 10px;
}

.recommendation-header {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 11px;
  align-items: start;
}

.recommendation-photo {
  width: 104px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.recommendation-title {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.recommendation-title strong {
  overflow: hidden;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recommendation-title small,
.recommendation-facts span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

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

.recommendation-facts span {
  min-height: 48px;
  padding: 9px;
  border-radius: 8px;
  background: var(--field);
  font-weight: 800;
}

.quick-designation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 8px;
  align-items: end;
}

.quick-designation input {
  min-height: 46px;
}

.quick-designation .primary-action {
  grid-column: 1 / -1;
}

.batch-inputs .primary-action {
  grid-column: 1 / -1;
}

.recommendation-card .primary-action {
  width: 100%;
}

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

.share-map-card {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  text-align: left;
}

.share-map-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border-radius: 7px;
  background: #fff;
}

.share-map-card span {
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-card-body img,
.territory-photo,
.recommendation-photo {
  cursor: zoom-in;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: var(--field);
  color: var(--ink);
}

input,
select {
  min-height: 48px;
  padding: 0 12px;
}

textarea {
  min-height: 86px;
  resize: vertical;
  padding: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(21, 97, 109, 0.68);
  box-shadow: 0 0 0 4px rgba(21, 97, 109, 0.12);
}

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

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

.history-item {
  display: grid;
  gap: 5px;
  padding: 13px;
}

.history-item strong {
  font-size: 0.98rem;
}

.history-type {
  justify-self: start;
  padding: 5px 8px;
  border-radius: 7px;
  color: #fff;
  background: var(--brand);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.history-type.return {
  background: var(--free);
}

.s13-controls {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.s13-controls span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.s13-report {
  overflow: hidden;
  padding: 20px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.s13-title {
  margin: 18px 0 34px;
  color: #000;
  font-size: 1.05rem;
  font-weight: 900;
  text-align: center;
}

.s13-year {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
  color: #000;
  font-size: 0.92rem;
}

.s13-year strong {
  font-weight: 900;
}

.s13-year span {
  min-width: 86px;
  padding: 0 6px 5px;
  border-bottom: 3px solid #000;
  font-size: 1rem;
  font-weight: 900;
}

.s13-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.s13-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
  border: 3px solid #000;
  color: #000;
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.72rem;
}

.s13-table th,
.s13-table td {
  height: 24px;
  padding: 3px 4px;
  border: 1px solid #000;
  text-align: center;
  vertical-align: middle;
}

.s13-table th {
  background: #d9d9d9;
  font-weight: 500;
}

.s13-col-code {
  width: 6%;
}

.s13-col-last {
  width: 10%;
}

.s13-col-date {
  width: 10.5%;
}

.s13-person {
  font-weight: 500;
  white-space: nowrap;
}

.s13-person-row td {
  border-top-width: 3px;
}

.s13-date-row td,
.s13-code,
.s13-last {
  border-bottom-width: 3px;
}

.dialog-summary {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}

.correction-summary {
  display: grid;
  gap: 7px;
  padding: 10px;
  border-radius: 8px;
  background: var(--field);
}

.correction-summary strong {
  color: var(--ink);
}

.correction-summary span,
.correction-summary small {
  display: block;
}

.correction-summary small {
  color: var(--muted);
  font-size: 0.8rem;
}

.empty-state {
  padding: 20px 14px;
  color: var(--muted);
  line-height: 1.4;
  text-align: center;
}

.text-button {
  padding: 0 12px;
  color: var(--brand-strong);
  background: #dcebe6;
  font-weight: 850;
}

.bottom-tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(18, 44, 52, 0.12);
  background: rgba(250, 252, 250, 0.92);
  backdrop-filter: blur(18px);
}

.bottom-tabs button {
  display: grid;
  min-height: 58px;
  place-items: center;
  gap: 3px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
}

.bottom-tabs button.active {
  color: var(--brand-strong);
  background: #e0eee9;
}

.bottom-tabs svg {
  width: 22px;
  height: 22px;
}

dialog {
  width: min(calc(100% - 26px), 520px);
  max-height: min(760px, calc(100dvh - 32px));
  padding: 0;
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(9, 24, 29, 0.48);
}

dialog form {
  display: grid;
  gap: 13px;
  padding: 16px;
}

.map-dialog {
  width: min(calc(100% - 16px), 1120px);
  max-height: calc(100dvh - 16px);
  border: 0;
  background: #10282f;
}

.map-dialog::backdrop {
  background: rgba(4, 14, 18, 0.72);
}

.map-dialog-shell {
  display: grid;
  height: calc(100dvh - 18px);
  max-height: 780px;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
}

.map-dialog-header {
  color: #fff;
}

.map-dialog-header .icon-button {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.map-focus .territory-detail-panel {
  display: none;
}

.territory-detail-panel {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: #fff;
}

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

.territory-detail-card,
.territory-history-entry {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.territory-detail-card {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
}

.territory-detail-card span,
.territory-detail-history h3,
.territory-history-entry span,
.territory-history-entry small,
.territory-history-empty {
  color: rgba(255, 255, 255, 0.74);
}

.territory-detail-card span,
.territory-history-entry span {
  font-size: 0.74rem;
  font-weight: 800;
}

.territory-detail-card strong,
.territory-history-entry strong {
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.territory-detail-history {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.territory-detail-history h3 {
  font-size: 0.84rem;
  text-transform: uppercase;
}

.territory-history-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-height: 116px;
  overflow: auto;
}

.territory-history-entry {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
}

.territory-history-entry small {
  overflow-wrap: anywhere;
  font-size: 0.72rem;
}

.territory-history-empty {
  padding: 8px 0;
  font-weight: 800;
}

.map-zoom-stage {
  display: grid;
  min-height: 0;
  overflow: auto;
  align-items: start;
  justify-items: center;
  border-radius: 8px;
  background: #fff;
  cursor: grab;
  touch-action: none;
}

.map-zoom-stage.dragging {
  cursor: grabbing;
}

.map-zoom-stage img {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
}

.map-zoom-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.map-zoom-controls .secondary-action {
  min-width: 92px;
}

.undo-toast {
  position: fixed;
  right: 12px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  left: 12px;
  z-index: 30;
  display: flex;
  width: min(calc(100% - 24px), 536px);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 auto;
  padding: 11px 12px;
  border-radius: 8px;
  color: #fff;
  background: #10282f;
  box-shadow: var(--shadow);
}

.undo-toast span {
  min-width: 0;
  font-weight: 850;
}

.undo-toast .text-button {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-header h2 {
  font-size: 1.2rem;
}

.settings-block {
  display: grid;
  gap: 9px;
  padding: 12px;
  border-radius: 8px;
  background: var(--field);
}

.settings-block h3 {
  font-size: 0.98rem;
}

.settings-block p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.38;
}

.install-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: install-step;
}

.install-steps li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.3;
}

.install-steps li::before {
  counter-increment: install-step;
  content: counter(install-step);
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
  font-size: 0.82rem;
  font-weight: 900;
}

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

@media (max-width: 380px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

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

  .primary-action,
  .secondary-action {
    width: 100%;
  }

  .segmented button {
    font-size: 0.78rem;
  }

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

  .section-heading,
  .history-actions {
    align-items: stretch;
  }

  .section-heading {
    flex-direction: column;
  }

  .history-actions {
    justify-content: stretch;
  }

  .history-actions .text-button {
    flex: 1;
  }

  .recommendation-card,
  .recommendation-header,
  .recommendation-facts,
  .quick-designation,
  .field-card-body,
  .field-actions,
  .map-share-preview {
    grid-template-columns: 1fr;
  }

  .recommendation-side {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    justify-items: start;
  }

  .recommendation-select {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    text-align: left;
  }

  .rank-badge {
    width: 42px;
  }

  .field-card-body img {
    width: 100%;
    height: auto;
  }

  .territory-detail-grid,
  .territory-history-list {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 720px) {
  .app-shell {
    padding-top: 24px;
  }

  .map-summary {
    min-height: 198px;
  }

  .territory-detail-grid,
  .territory-history-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 12mm 9mm;
  }

  html,
  body {
    width: 100%;
    min-height: 0;
    background: #fff;
  }

  body {
    color: #000;
  }

  .app-shell {
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
  }

  .topbar,
  .map-summary,
  .stats-grid,
  .field-card,
  .segmented,
  #territoriesView,
  #nextView,
  .section-heading,
  .s13-controls,
  .bottom-tabs {
    display: none !important;
  }

  .undo-toast,
  .map-dialog {
    display: none !important;
  }

  #historyView {
    display: block !important;
  }

  .history-list {
    display: block;
  }

  .s13-report {
    overflow: visible;
    padding: 0;
    border: 0;
    border-radius: 0;
  }

  .s13-title {
    margin: 14mm 0 16mm;
    font-size: 16pt;
  }

  .s13-year {
    margin-bottom: 8mm;
    font-size: 12pt;
  }

  .s13-year span {
    font-size: 12pt;
  }

  .s13-scroll {
    overflow: visible;
  }

  .s13-table {
    min-width: 0;
    font-size: 8.4pt;
  }

  .s13-table th,
  .s13-table td {
    height: 17pt;
    padding: 2pt 3pt;
  }

  .s13-person-row,
  .s13-date-row {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
