:root {
  color-scheme: light;
  --forest: #15352d;
  --forest-2: #21483d;
  --gold: #d5a646;
  --paper: #fffefa;
  --cream: #f5f2ea;
  --ink: #183029;
  --muted: #65746f;
  --line: rgba(21, 53, 45, 0.14);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; color: var(--ink); background: #dfe5e0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { color: inherit; }

.topbar { min-height: 76px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; padding: 11px 20px; color: white; background: var(--forest); border-bottom: 3px solid var(--gold); }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 42px; height: 42px; position: relative; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.28); border-radius: 12px; background: rgba(255,255,255,.08); }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; top: 7px; width: 4px; height: 10px; border-radius: 3px; background: white; }
.brand-mark::before { left: 10px; }
.brand-mark::after { right: 10px; }
.brand-mark span { position: absolute; inset: 14px 6px 6px; border-radius: 3px; background: var(--gold); }
.brand p { margin: 0 0 2px; color: #d6e2de; font-size: .68rem; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.brand h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; font-weight: 500; line-height: 1; }

.view-tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid rgba(255,255,255,.17); border-radius: 12px; background: rgba(0,0,0,.14); }
.view-tab { min-height: 38px; padding: 0 15px; border: 0; border-radius: 8px; color: #dbe7e3; background: transparent; font-size: .83rem; font-weight: 750; cursor: pointer; }
.view-tab.is-active { color: #172b25; background: var(--paper); box-shadow: 0 3px 10px rgba(0,0,0,.14); }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.live-status { display: inline-flex; align-items: center; gap: 7px; color: #dce7e3; font-size: .75rem; font-weight: 650; }
.live-status i { width: 8px; height: 8px; border-radius: 50%; background: #7ed69d; box-shadow: 0 0 0 4px rgba(126,214,157,.13); }
.refresh-button { min-height: 39px; padding: 0 13px; border: 1px solid rgba(255,255,255,.24); border-radius: 9px; color: white; background: rgba(255,255,255,.08); font-size: .8rem; font-weight: 750; cursor: pointer; }
.refresh-button:hover { background: rgba(255,255,255,.15); }

.pdf-toolbar { min-height: 58px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; background: rgba(250,249,245,.97); border-bottom: 1px solid var(--line); box-shadow: 0 7px 26px rgba(21,53,45,.07); }
.tool-group { display: flex; align-items: center; gap: 4px; }
.separator { width: 1px; height: 28px; margin: 0 3px; background: var(--line); }
.icon-button, .zoom-value, .text-button { height: 39px; border: 1px solid var(--line); border-radius: 9px; background: white; cursor: pointer; }
.icon-button:hover, .zoom-value:hover, .text-button:hover { border-color: rgba(185,133,42,.58); background: #faf7ee; }
.icon-button:disabled { opacity: .35; cursor: not-allowed; }
.icon-button { width: 39px; padding: 0; font-size: 1.3rem; }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.zoom-value { min-width: 72px; font-size: .8rem; font-weight: 750; }
.text-button { padding: 0 13px; font-size: .8rem; font-weight: 750; }
.page-control { height: 39px; display: flex; align-items: center; gap: 6px; padding: 0 9px; color: var(--muted); font-size: .8rem; }
.page-control input { width: 40px; padding: 4px 2px; text-align: center; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; background: white; appearance: textfield; }

.viewer-shell { position: relative; height: calc(100% - 137px); background-color: #dce2dd; background-image: radial-gradient(rgba(21,53,45,.09) 1px, transparent 1px); background-size: 18px 18px; }
.view-panel { position: absolute; inset: 0; }
.pan-area { width: 100%; height: 100%; overflow: auto; padding: 30px; text-align: center; cursor: grab; overscroll-behavior: contain; scrollbar-color: rgba(21,53,45,.35) transparent; }
.pan-area.is-dragging { cursor: grabbing; user-select: none; }
#pdfCanvas { display: block; margin: auto; background: white; box-shadow: 0 24px 70px rgba(8,31,24,.2); }

.status-card, .error-card { position: absolute; inset: 50% auto auto 50%; z-index: 4; transform: translate(-50%, -50%); width: min(460px, calc(100% - 36px)); padding: 26px; text-align: center; border: 1px solid rgba(255,255,255,.7); border-radius: 17px; background: rgba(252,251,247,.95); box-shadow: 0 20px 55px rgba(18,40,33,.14); backdrop-filter: blur(14px); }
.status-card p, .error-card p { margin: 12px 0 0; color: var(--muted); line-height: 1.5; }
.loader { display: block; width: 34px; height: 34px; margin: auto; border: 3px solid rgba(21,53,45,.15); border-top-color: var(--gold); border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-card button { min-height: 42px; margin-top: 16px; padding: 0 16px; border: 0; border-radius: 9px; background: var(--gold); font-weight: 800; cursor: pointer; }
.drag-hint { position: absolute; left: 50%; bottom: 15px; z-index: 5; transform: translateX(-50%); padding: 8px 12px; border-radius: 999px; color: white; background: rgba(21,53,45,.88); font-size: .74rem; pointer-events: none; }

#sheetView { display: grid; grid-template-rows: auto 1fr; overflow: hidden; background: #eef1ed; }
.sheet-note { padding: 9px 16px; color: #465750; border-bottom: 1px solid var(--line); background: #fff9e9; font-size: .78rem; text-align: center; }
#sheetFrame { width: 133.333%; height: 133.333%; border: 0; background: white; transform: scale(.75); transform-origin: top left; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 820px) {
  .topbar { min-height: 120px; grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 8px 12px; padding: 10px 12px; }
  .view-tabs { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; }
  .view-tab { flex: 1; }
  .live-status { display: none; }
  .pdf-toolbar { min-height: 56px; overflow-x: auto; justify-content: flex-start; }
  .viewer-shell { height: calc(100% - 176px); }
  .pan-area { padding: 18px; }
}

@media (max-width: 470px) {
  .brand-mark { width: 38px; height: 38px; }
  .text-button { display: none; }
  .separator { display: none; }
  .page-control { padding: 0 4px; }
  .drag-hint { max-width: calc(100% - 20px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
}
