:root {
  color-scheme: light;
  --ink: #13212b;
  --muted: #61717d;
  --paper: #ffffff;
  --line: #ccd5dd;
  --soft-line: #e3e9ef;
  --header: #123142;
  --header-2: #1f4e79;
  --accent: #0f8a8a;
  --accent-dark: #0a6667;
  --danger: #9f341f;
  --warning: #f5b942;
  --excel-soft: #ddebf7;
  --blue: #00b0f0;
  --blue-dark: #008fc6;
  --yellow: #fff2cc;
  --yellow-strong: #ffd966;
  --panel: #ffffff;
  --surface: #f5f7f8;
  --surface-strong: #edf2f4;
  --shadow: 0 24px 70px rgba(15, 33, 46, 0.16);
  --shadow-soft: 0 12px 32px rgba(15, 33, 46, 0.1);
  --radius: 8px;
  font-family:
    "Gill Sans MT", "Gill Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: pan-x pan-y pinch-zoom;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface);
}

.portal-view,
.app,
.mamy-app-shell {
  display: none;
}

body:not([data-app]) .portal-view,
body[data-app="portal"] .portal-view {
  display: grid;
}

body[data-app="soro"] .app,
body[data-app="mamy"] .mamy-app-shell {
  display: block;
}

.portal-view {
  min-height: 100dvh;
  grid-template-rows: auto 1fr;
  gap: 1rem;
  padding: clamp(1rem, 3vw, 2rem);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(231, 246, 243, 0.78)),
    linear-gradient(45deg, #f4f8fb, #e7f2ef 48%, #fff7e8);
}

.portal-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: #173241;
}

.portal-brand span {
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.portal-brand strong {
  font-size: clamp(1.05rem, 2vw, 1.45rem);
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(0.8rem, 2vw, 1.25rem);
  min-height: 0;
}

.portal-card {
  position: relative;
  display: grid;
  align-content: end;
  min-height: calc(100dvh - 6.2rem);
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 18px;
  padding: clamp(1.1rem, 3vw, 2.2rem);
  overflow: hidden;
  text-align: left;
  color: #102633;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: 0 30px 80px rgba(20, 49, 62, 0.18);
  backdrop-filter: blur(24px) saturate(1.28);
}

.portal-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.64), rgba(255, 255, 255, 0.08)),
    linear-gradient(135deg, rgba(15, 138, 138, 0.16), rgba(245, 185, 66, 0.14));
  pointer-events: none;
}

.portal-card > * {
  position: relative;
  z-index: 1;
}

.portal-card strong {
  max-width: 12ch;
  margin: 0.35rem 0 0.5rem;
  font-size: clamp(2rem, 5vw, 5.2rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.portal-card span:last-child {
  max-width: 44rem;
  color: rgba(16, 38, 51, 0.78);
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  font-weight: 750;
}

.portal-kicker {
  width: max-content;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  padding: 0.36rem 0.68rem;
  color: #0a6667;
  background: rgba(255, 255, 255, 0.44);
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

.portal-card-mamy .portal-kicker {
  color: #7b4315;
}

@media (max-width: 760px) {
  .portal-view {
    padding: 0.75rem;
  }

  .portal-brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.25rem;
  }

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

  .portal-card {
    min-height: calc((100dvh - 5rem) / 2);
    border-radius: 14px;
  }

  .portal-card strong {
    max-width: 14ch;
    font-size: clamp(1.9rem, 11vw, 3.5rem);
  }
}

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

button {
  cursor: pointer;
  touch-action: manipulation;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 0.86rem 0.92rem;
  color: var(--ink);
  font-size: 16px;
  background: #fbfcfd;
  outline: none;
  touch-action: manipulation;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(15, 138, 138, 0.14);
}

textarea {
  min-height: 128px;
  resize: vertical;
}

.app {
  min-height: 100vh;
}

.login-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  background: var(--surface);
}

.login-view.is-hidden,
.sheet-view.is-hidden {
  display: none;
}

.login-card {
  width: 100%;
  max-width: 440px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 1rem;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card::before {
  display: block;
  width: 48px;
  height: 3px;
  margin-bottom: 1rem;
  border-radius: 999px;
  background: var(--accent);
  content: "";
}

.login-brand {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.85rem;
}

.login-mark {
  display: grid;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(15, 138, 138, 0.2);
  border-radius: 8px;
  place-items: center;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 900;
  background: var(--header);
  box-shadow: var(--shadow-soft);
}

.login-card h1,
.sheet-title h1,
.header-card h2,
.editor-heading h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.12;
}

.login-card h1 {
  font-size: 1.6rem;
  font-weight: 900;
}

.muted {
  color: var(--muted);
  line-height: 1.45;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.form-stack {
  display: grid;
  gap: 0.8rem;
  margin-top: 1.15rem;
}

.form-stack label,
.header-grid label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 44px;
  border-radius: 8px;
  font-weight: 850;
  letter-spacing: 0;
}

.primary-button {
  border: 1px solid var(--accent-dark);
  padding: 0.72rem 1rem;
  color: #fff;
  background: var(--accent-dark);
  box-shadow: 0 10px 22px rgba(10, 102, 103, 0.2);
}

.primary-button:hover {
  background: #075657;
}

.ghost-button {
  border: 1px solid var(--soft-line);
  padding: 0.72rem 1rem;
  color: var(--ink);
  background: #f8fafb;
}

.danger-button {
  border: 1px solid #7f2517;
  padding: 0.72rem 1rem;
  color: #fff;
  background: var(--danger);
  box-shadow: 0 10px 22px rgba(159, 52, 31, 0.16);
}

.danger-button:hover {
  background: #7f2517;
}

.compact {
  min-height: 36px;
  padding: 0.5rem 0.75rem;
}

.mini {
  min-height: 32px;
  padding: 0.38rem 0.56rem;
  font-size: 0.78rem;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  border: 1px solid rgba(18, 49, 66, 0.12);
  place-items: center;
  color: #fff;
  background: var(--header);
}

.icon-button.dark {
  color: var(--header);
  background: #f2f6f7;
}

.sheet-view {
  position: fixed;
  inset: 0;
  min-height: 100vh;
  overflow: hidden;
  padding: 0;
  background: var(--surface);
}

.sheet-title {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  min-height: 64px;
  gap: 0;
  padding: calc(0.6rem + env(safe-area-inset-top)) 5rem 0.6rem;
  border: 0;
  color: #fff;
  text-align: center;
  background: var(--header);
}

.sheet-title h1 {
  color: #fff;
  font-size: clamp(1.2rem, 4.6vw, 2.4rem);
  font-weight: 900;
  text-transform: uppercase;
}

.sheet-title .eyebrow {
  display: none;
}

.sheet-title .icon-button,
.sheet-title .ghost-button {
  position: absolute;
  top: calc(0.75rem + env(safe-area-inset-top));
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  color: #fff;
  background: rgba(0, 0, 0, 0.08);
}

.sheet-title .icon-button {
  left: 0.75rem;
}

.sheet-title .ghost-button {
  right: 0.75rem;
  width: auto;
}

.sheet-note {
  display: flex;
  align-items: flex-start;
  min-height: 108px;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0.72rem 0.85rem;
  color: #000;
  font-size: clamp(1.2rem, 2.1vw, 2rem);
  font-style: italic;
  line-height: 1.1;
  background: var(--excel-soft);
}

.header-card,
.status-strip,
.entry-focus {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

.header-card {
  min-height: 192px;
  padding: 0.7rem 0.85rem 0.95rem;
  background: var(--excel-soft);
}

.header-card.is-locked {
  background: var(--excel-soft);
}

.header-card.is-locked .header-grid {
  grid-template-columns: 1fr;
  gap: 0;
}

.header-card.is-locked .header-grid label {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.header-card.is-locked input {
  min-height: 0;
  border: 0;
  padding: 0;
  color: var(--ink);
  font-weight: 850;
  background: transparent;
  box-shadow: none;
}

.header-card-title {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 0.8rem;
  min-height: 0;
  margin-bottom: 0;
}

.header-card-title > div {
  display: none;
}

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

.header-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  max-width: 760px;
  margin-top: 1rem;
}

.header-grid label {
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: center;
  min-height: 54px;
  color: #000;
  font-size: clamp(1.25rem, 2.1vw, 2rem);
  font-style: italic;
  font-weight: 900;
}

.header-grid input {
  border: 0;
  border-radius: 0;
  padding: 0.2rem 0;
  color: #000;
  font-size: clamp(1rem, 3.2vw, 1.55rem);
  font-style: normal;
  font-weight: 800;
  background: transparent;
  box-shadow: none;
}

.header-grid input::placeholder {
  color: rgba(0, 0, 0, 0.35);
}

.status-strip {
  display: none;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  padding: 0.85rem;
}

.status-strip div,
.entry-focus .focus-row {
  display: grid;
  gap: 0.2rem;
}

.status-strip strong {
  font-size: 1rem;
}

.status-strip span,
.entry-focus span {
  color: var(--muted);
  font-size: 0.86rem;
}

.entry-focus {
  display: none;
  padding: 0.85rem;
}

.focus-row {
  display: flex;
  justify-content: space-between;
}

.sheet-wrap {
  margin: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  scroll-snap-type: x proximity;
}

.sheet-grid {
  min-width: 1180px;
}

.sheet-row {
  display: grid;
  grid-template-columns:
    82px 170px 180px 150px 220px 200px 110px 200px 185px 155px 160px
    220px;
}

.sheet-header {
  position: sticky;
  top: 0;
  z-index: 2;
}

.sheet-header .sheet-cell {
  min-height: 92px;
  border-top: 0;
  color: #fff;
  font-size: clamp(1rem, 1.8vw, 1.45rem);
  font-weight: 900;
  line-height: 1.12;
  text-align: center;
  word-break: normal;
  overflow-wrap: normal;
  background: var(--blue);
}

.sheet-spacer .sheet-cell {
  min-height: 64px;
  background: #fff;
}

.sheet-cell {
  display: flex;
  align-items: center;
  min-height: 54px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.65rem;
  overflow: hidden;
  color: var(--ink);
  text-align: left;
  word-break: break-word;
  background: #fff;
}

button.sheet-cell {
  width: 100%;
}

.sheet-cell:last-child {
  border-right: 0;
}

.sheet-row:not(.sheet-header) .sheet-cell {
  background: #fffdf0;
}

.sheet-row:not(.sheet-header) .sheet-cell.is-filled {
  background: #fff;
}

.sheet-row:not(.sheet-header) .sheet-cell.is-active {
  outline: 3px solid rgba(14, 173, 215, 0.28);
  outline-offset: -3px;
  background: #e9f8fc;
}

.sheet-row.is-current .sheet-cell:first-child {
  color: #fff;
  font-weight: 900;
  background: var(--header);
}

.cell-empty {
  color: #8b7a3c;
  font-size: 0.8rem;
}

.fab {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 22;
  display: grid;
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 8px;
  place-items: center;
  color: #fff;
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
  background: var(--accent-dark);
  box-shadow: 0 16px 34px rgba(10, 102, 103, 0.28);
}

.floating-tools {
  position: fixed;
  right: calc(max(1rem, env(safe-area-inset-right)) + 74px);
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: max(1rem, env(safe-area-inset-left));
  z-index: 18;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, auto));
  align-items: center;
  gap: 0.35rem;
  width: fit-content;
  max-width: calc(100vw - 7.2rem);
  border: 1px solid rgba(227, 233, 239, 0.92);
  border-radius: 8px;
  padding: 0.38rem;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.tool-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0.42rem 0.68rem;
  color: var(--header);
  font-weight: 850;
  background: transparent;
}

.tool-button:hover,
.tool-button:focus-visible {
  background: #eef5f5;
  border-color: rgba(15, 138, 138, 0.16);
}

.admin-tool {
  display: none;
}

.admin-tool.is-visible {
  display: inline-flex;
  align-items: center;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid rgba(15, 138, 138, 0.16);
  border-radius: 7px;
  padding: 0.42rem 0.6rem;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 850;
  background: #eef7f6;
}

.sync-badge[data-status="offline"],
.sync-badge[data-status="pending"],
.sync-badge[data-status="error"] {
  border-color: rgba(245, 185, 66, 0.45);
  color: #674700;
  background: #fff5d8;
}

.zoom-tools {
  position: fixed;
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 76px);
  z-index: 19;
  display: grid;
  grid-template-columns: 42px 54px 42px;
  gap: 0.28rem;
  border: 1px solid rgba(227, 233, 239, 0.92);
  border-radius: 8px;
  padding: 0.32rem;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.zoom-button,
.edit-pill {
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--header);
  font-weight: 900;
  background: #f2f6f7;
}

.zoom-button {
  min-height: 38px;
  padding: 0;
  font-size: 1rem;
}

.zoom-button.is-wide {
  font-size: 0.78rem;
}

.edit-pill {
  position: fixed;
  left: 50%;
  bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 76px);
  z-index: 20;
  display: none;
  min-height: 42px;
  border-color: rgba(15, 138, 138, 0.16);
  padding: 0 1.05rem;
  color: #fff;
  font-size: 0.9rem;
  background: var(--accent-dark);
  box-shadow: 0 12px 26px rgba(10, 102, 103, 0.25);
  transform: translateX(-50%);
}

.edit-pill.is-visible {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sheet-wrap {
  width: 100vw;
  height: 100vh;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  cursor: grab;
  touch-action: pan-x pan-y;
  user-select: none;
}

.sheet-wrap.is-dragging,
.sheet-wrap.is-pinching {
  cursor: grabbing;
}

.sheet-stage {
  position: relative;
  width: var(--sheet-stage-width, max-content);
  height: var(--sheet-stage-height, auto);
  touch-action: pan-x pan-y;
}

.excel-sheet {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  width: max-content;
  min-height: auto;
  background: #fff;
  font-family: "Gill Sans MT", "Gill Sans", Calibri, Arial, sans-serif;
  box-shadow: 0 8px 28px rgba(15, 33, 46, 0.12);
  transform: scale(var(--sheet-scale, 1));
  transform-origin: top left;
}

.excel-row {
  display: grid;
  grid-template-columns:
    99px 233px 173px 212px 281px 192px 110px 198px 158px 109px 162px
    309px;
}

.excel-cell {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  border: 0;
  padding: 0 4px;
  color: #000;
  text-align: left;
  white-space: normal;
  background: #fff;
}

button.excel-cell {
  width: 100%;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(31, 78, 121, 0.12);
  touch-action: pan-x pan-y;
}

.merged {
  grid-column: 1 / -1;
  justify-content: center;
}

.row-1 .excel-cell,
.title-cell {
  height: 32px;
  color: #fff;
  font-size: 21.33px;
  font-weight: 900;
  text-align: center;
  background: #1f4e79;
}

.row-2 .excel-cell,
.instruction-cell {
  align-items: flex-start;
  justify-content: flex-start;
  height: 22px;
  color: #000;
  font-size: 21.33px;
  font-style: italic;
  line-height: 1.05;
  text-align: left;
  background: #ddebf7;
}

.row-3 .excel-cell,
.row-4 .excel-cell,
.row-5 .excel-cell,
.row-6 .excel-cell {
  height: 32px;
  background: #ddebf7;
}

.row-7 .excel-cell {
  height: 32px;
  border-right: 1px solid #d9d9d9;
  background: #fff;
}

.meta-label {
  position: relative;
  z-index: 1;
  overflow: visible;
  white-space: nowrap;
  font-size: 21.33px;
  font-style: italic;
  font-weight: 900;
}

.meta-value {
  justify-content: flex-start;
  font-size: 21.33px;
  font-style: italic;
  background: #ddebf7;
}

.row-6 .meta-value {
  padding-left: 46px;
}

.row-8 .excel-cell,
.column-head {
  justify-content: center;
  height: 64px;
  border: 1px solid #a6a6a6;
  color: #fff;
  font-size: 21.33px;
  font-weight: 900;
  line-height: 1.04;
  text-align: center;
  word-break: normal;
  overflow-wrap: normal;
  background: #00b0f0;
}

.data-row .excel-cell,
.data-cell {
  align-items: center;
  height: 58px;
  border: 1px solid #a6a6a6;
  font-size: 24px;
  line-height: 1;
  background: #fff2cc;
}

.data-cell.is-active {
  box-shadow: inset 0 0 0 3px #00b0f0;
}

.archives {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: none;
}

.archives.is-open {
  display: block;
}

.archives-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  max-height: min(72vh, 620px);
  overflow: auto;
  border: 1px solid var(--soft-line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  padding: 0.8rem 1rem calc(1rem + env(safe-area-inset-bottom));
  background: #fff;
  box-shadow: 0 -24px 64px rgba(10, 24, 36, 0.24);
}

.archives-list {
  display: grid;
  gap: 0.6rem;
}

.archive-item,
.archive-empty {
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 0.9rem;
  text-align: left;
  background: #fbfcfd;
}

.archive-item strong,
.archive-item span {
  display: block;
}

.archive-item span,
.archive-empty {
  color: var(--muted);
}

.admin {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
}

.admin.is-open {
  display: block;
}

.admin-panel {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: calc(0.9rem + env(safe-area-inset-top)) 1rem calc(1rem + env(safe-area-inset-bottom));
  background: var(--surface);
}

.admin-panel > .editor-heading,
.admin-toolbar,
.admin-workspace {
  max-width: 1420px;
  margin-right: auto;
  margin-left: auto;
}

.admin-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 360px) auto;
  align-items: end;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.admin-refresh-button {
  white-space: nowrap;
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.admin-metrics div {
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.admin-metrics strong,
.admin-metrics span {
  display: block;
}

.admin-metrics strong {
  font-size: 1.35rem;
  line-height: 1;
}

.admin-metrics span {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.admin-search {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.admin-search input {
  min-height: 42px;
}

.admin-workspace {
  display: grid;
  grid-template-columns: minmax(245px, 0.9fr) minmax(300px, 1.05fr) minmax(420px, 1.55fr);
  gap: 0.85rem;
  align-items: start;
}

.admin-column {
  display: grid;
  min-height: min(76dvh, 760px);
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 0.65rem;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 0.8rem;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.admin-column-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.admin-column-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.admin-column-heading span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
}

.admin-inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.55rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--soft-line);
}

.admin-inline-form label {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.admin-inline-form input {
  min-height: 38px;
  padding: 0.56rem 0.65rem;
}

.user-inline-form {
  grid-template-columns: minmax(110px, 0.9fr) minmax(130px, 1fr) auto;
}

.admin-list {
  display: grid;
  gap: 0.5rem;
  align-content: start;
  max-height: calc(76dvh - 148px);
  overflow: auto;
  padding-right: 0.15rem;
}

.admin-list-item {
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 0.7rem;
  background: #f8fafb;
}

.admin-manage-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
}

.admin-manage-item.is-muted {
  opacity: 0.68;
  background: #f2f4f5;
}

.admin-item-main {
  min-width: 0;
}

.admin-item-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.admin-item-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-item-main > span {
  display: block;
  margin-top: 0.22rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
}

.admin-item-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
}

.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.16rem 0.42rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  background: #e9eef2;
}

.status-pill.is-on,
.status-pill.is-live {
  color: #075657;
  background: rgba(15, 138, 138, 0.12);
}

.status-pill.is-off {
  color: #7f2517;
  background: rgba(159, 52, 31, 0.12);
}

.status-pill.is-archived {
  color: #364655;
  background: #e8edf0;
}

.editor {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
}

.editor.is-open {
  display: block;
}

.editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 24, 36, 0.52);
  backdrop-filter: blur(2px);
}

.editor-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  max-width: 760px;
  margin: 0 auto;
  border: 1px solid var(--soft-line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  padding: 0.8rem 1rem calc(1rem + env(safe-area-inset-bottom));
  background: #fff;
  box-shadow: 0 -24px 64px rgba(10, 24, 36, 0.24);
}

.editor-handle {
  width: 52px;
  height: 5px;
  margin: 0 auto 0.85rem;
  border-radius: 999px;
  background: #cfdae2;
}

.editor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.editor-heading h2 {
  font-size: 1.22rem;
  font-weight: 900;
}

.editor-control {
  display: grid;
  gap: 0.45rem;
}

.editor-control small {
  color: var(--muted);
}

.editor-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

@media (max-width: 780px) {
  .floating-tools {
    right: calc(0.55rem + env(safe-area-inset-right) + 68px);
    bottom: calc(0.55rem + env(safe-area-inset-bottom));
    left: calc(0.55rem + env(safe-area-inset-left));
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: auto;
    max-width: none;
    gap: 0.3rem;
    padding: 0.34rem;
  }

  .tool-button {
    justify-content: center;
    min-height: 34px;
    padding: 0.32rem 0.42rem;
    font-size: 0.72rem;
  }

  .sync-badge {
    justify-content: center;
    min-height: 34px;
    padding: 0.32rem 0.42rem;
    font-size: 0.68rem;
  }

  .fab {
    width: 58px;
    height: 58px;
    right: max(0.55rem, env(safe-area-inset-right));
    bottom: calc(0.55rem + env(safe-area-inset-bottom));
    font-size: 2rem;
  }

  .zoom-tools {
    right: 0.45rem;
    bottom: calc(8.2rem + env(safe-area-inset-bottom));
    grid-template-columns: 38px 46px 38px;
  }

  .zoom-button {
    min-height: 36px;
  }

  .edit-pill {
    bottom: calc(8.2rem + env(safe-area-inset-bottom));
    min-height: 38px;
  }

  .login-view {
    min-height: 100svh;
    align-items: center;
    justify-items: center;
    padding: calc(0.85rem + env(safe-area-inset-top)) 0.85rem calc(0.85rem + env(safe-area-inset-bottom));
  }

  .login-card {
    padding: 0.95rem;
  }

  .login-card h1 {
    font-size: 1.42rem;
  }

  .login-mark {
    width: 44px;
    height: 44px;
  }

  .editor-panel,
  .archives-panel {
    max-height: 82dvh;
    padding-right: 0.85rem;
    padding-left: 0.85rem;
  }

  .admin-toolbar,
  .admin-workspace,
  .admin-metrics,
  .admin-inline-form,
  .user-inline-form {
    grid-template-columns: 1fr;
  }

  .admin-panel {
    padding: calc(0.55rem + env(safe-area-inset-top)) 0.55rem calc(0.75rem + env(safe-area-inset-bottom));
    font-size: 0.9rem;
  }

  .admin-panel .editor-heading {
    position: sticky;
    top: 0;
    z-index: 1;
    align-items: center;
    margin: -0.55rem -0.55rem 0.65rem;
    padding: calc(0.55rem + env(safe-area-inset-top)) 0.55rem 0.55rem;
    background: #fff;
    box-shadow: 0 1px 0 var(--soft-line);
  }

  .admin-panel .editor-heading h2 {
    font-size: 1.05rem;
    line-height: 1.05;
  }

  .admin-toolbar {
    gap: 0.55rem;
    margin-bottom: 0.65rem;
  }

  .admin-metrics {
    gap: 0.4rem;
  }

  .admin-metrics div {
    padding: 0.55rem 0.62rem;
  }

  .admin-metrics strong {
    font-size: 1.12rem;
  }

  .admin-search input {
    min-height: 38px;
  }

  .admin-column {
    min-height: auto;
    gap: 0.48rem;
    padding: 0.62rem;
  }

  .admin-column-heading h3 {
    font-size: 0.92rem;
  }

  .admin-inline-form {
    align-items: stretch;
    padding-bottom: 0.52rem;
  }

  .admin input {
    min-height: 38px;
    padding: 0.52rem 0.62rem;
    font-size: 16px;
  }

  .admin .primary-button,
  .admin .danger-button,
  .admin .ghost-button {
    min-height: 38px;
    padding: 0.52rem 0.72rem;
  }

  .admin-list {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .admin-list-item {
    padding: 0.52rem;
  }

  .admin-manage-item {
    grid-template-columns: 1fr;
    gap: 0.52rem;
  }

  .admin-item-actions {
    justify-content: stretch;
  }

  .admin-item-actions button {
    flex: 1 1 auto;
  }

  .admin-item-main > span {
    font-size: 0.76rem;
  }

  .sheet-wrap {
    height: 100dvh;
    padding-bottom: 7.6rem;
  }

  .row-1 .excel-cell,
  .title-cell {
    font-size: 21.33px;
  }

  .instruction-cell {
    height: 22px;
    font-size: 21.33px;
  }

  .meta-label,
  .meta-value {
    font-size: 21.33px;
  }

  .row-8 .excel-cell,
  .column-head {
    font-size: 21.33px;
  }

  .data-row .excel-cell,
  .data-cell {
    font-size: 24px;
  }

  .sheet-view {
    padding-bottom: 0;
  }

  .sheet-title {
    min-height: 58px;
    padding-right: 3.7rem;
    padding-left: 3.7rem;
  }

  .sheet-title h1 {
    font-size: 1.02rem;
    line-height: 1.08;
  }

  .sheet-title .ghost-button,
  .sheet-title .icon-button {
    top: calc(0.65rem + env(safe-area-inset-top));
    min-height: 32px;
    padding: 0.3rem 0.46rem;
    font-size: 0.78rem;
  }

  .sheet-title .icon-button {
    left: 0.55rem;
    width: 42px;
  }

  .sheet-title .ghost-button {
    right: 0.55rem;
  }

  .sheet-note,
  .header-card,
  .status-strip,
  .entry-focus,
  .sheet-wrap {
    margin: 0;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .header-card-title {
    align-items: stretch;
    flex-direction: column;
  }

  .header-card-title button {
    width: auto;
    margin-left: auto;
  }

  .header-card.is-locked .header-card-title {
    margin-bottom: 0;
  }

  .header-card.is-locked .header-grid {
    grid-template-columns: 1fr;
  }

  .header-card.is-locked .header-grid label {
    grid-template-columns: 118px minmax(0, 1fr);
    align-items: center;
  }

  .header-card {
    min-height: 178px;
  }

  .header-grid {
    margin-top: 0.75rem;
  }

  .header-grid label {
    grid-template-columns: 118px minmax(0, 1fr);
    min-height: 46px;
    font-size: clamp(1.25rem, 3.6vw, 2.25rem);
  }

  .sheet-note {
    font-size: clamp(1.22rem, 4.2vw, 2rem);
  }

  .sheet-spacer .sheet-cell {
    min-height: 52px;
  }

  .sheet-grid {
    min-width: 1040px;
  }

  .sheet-row {
    grid-template-columns:
      74px 128px 148px 128px 185px 168px 92px 168px 152px 130px 132px
      190px;
  }

  .sheet-cell {
    min-height: 58px;
    padding: 0.5rem;
    font-size: 0.9rem;
  }

  .sheet-header .sheet-cell {
    min-height: 66px;
    font-size: 0.9rem;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 0.5cm;
  }

  *,
  *::before,
  *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body {
    background: #fff;
  }

  .login-view,
  .floating-tools,
  .zoom-tools,
  .edit-pill,
  .fab,
  .editor,
  .archives,
  .admin,
  .sync-badge {
    display: none !important;
  }

  .sheet-view,
  .sheet-wrap {
    display: block !important;
    width: auto;
    height: auto;
    overflow: visible;
    padding: 0;
  }

  .sheet-stage {
    width: auto !important;
    height: auto !important;
  }

  body.pdf-export-mode .data-row.is-empty {
    display: none !important;
  }

  .excel-sheet {
    position: static;
    min-height: auto;
    box-shadow: none;
    transform: none;
    transform-origin: top left;
    zoom: 0.44;
  }
}
