@font-face { font-family: Inter; src: url(/assets/inter.woff2) format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
:root { --navy: #1E293B; --navy-line: #334155; --red: #DC2626; --red-dark: #B91C1C; --bg: #F8FAFC; --line: #D5DAE1; --zebra: #EEF1F4; --muted: #64748B; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; font-size: 14px; color: var(--navy); background: var(--bg); overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }

.btn { background: var(--red); color: #fff; border: 0; border-radius: 6px; padding: 8px 16px; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--red-dark); }
.btn:focus-visible, .link-btn:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.btn-ghost { background: transparent; color: var(--navy); border: 1px solid var(--navy); padding: 6px 12px; }
.btn-ghost:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { display: block; width: 100%; margin-top: 16px; padding: 12px; }
.link-btn { background: none; border: 0; padding: 2px 0; color: var(--red); font-size: 12px; cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: var(--red-dark); }
.link-btn.armed { font-weight: 700; }

/* Login */
body.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 16px; }
.card .logo { display: block; width: 72px; height: 72px; margin: 0 auto 12px; }
.card h1, .card .sub { text-align: center; }
.built { color: var(--muted); font-size: 12px; margin-left: auto; }
.built-login { margin: 0; }
.card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 28px 24px; }
.card h1 { margin: 0; font-size: 22px; letter-spacing: 0.04em; }
.card .sub { margin: 4px 0 20px; color: var(--muted); }
.card label { display: block; font-weight: 600; margin-bottom: 6px; }
.card input { width: 100%; padding: 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.msg { background: #FEF2F2; border: 1px solid #FECACA; color: var(--red-dark); padding: 10px 12px; border-radius: 6px; margin: 0 0 16px; }

/* App layout: title, bar and footer stay put; only the table box scrolls */
body.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; }
.brand { flex: none; display: flex; align-items: center; gap: 8px; }
.brand-name { font-weight: 700; font-size: 13px; line-height: 1.15; max-width: 80px; color: var(--navy); }
.brand img { width: 44px; height: 44px; display: block; }
.top h1 { flex: 1; min-width: 0; margin: 0; font-size: clamp(13px, 3.6vw, 18px); line-height: 1.25; letter-spacing: 0.02em; }
.top-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.top-actions form { margin: 0; }
.status { font-size: 13px; color: var(--muted); min-width: 0; }
.status.ok { color: #15803D; }
.status.err { color: var(--red-dark); font-weight: 600; }
.bar { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0 12px 8px; font-size: 13px; }
.storage { font-weight: 600; }
.note { color: var(--muted); }
.foot { display: flex; align-items: center; gap: 12px; padding: 8px 12px; }
.count { color: var(--muted); font-size: 13px; }

.sheet { flex: 1; min-height: 0; overflow: auto; margin: 0 12px; background: #fff; border-top: 1px solid var(--line); border-left: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
table { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: 2580px; }
th, td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; vertical-align: top; }
th { position: sticky; top: 0; z-index: 3; background: var(--navy); color: #fff; font-weight: 700; text-align: center; vertical-align: middle; height: 35px; padding: 2px 6px; font-size: 13px; line-height: 1.2; border-color: var(--navy-line); }
tbody tr:nth-child(even) td { background: var(--zebra); }
tbody tr:nth-child(odd) td { background: #fff; }
th:first-child, td:first-child { position: sticky; left: 0; }
th:first-child { z-index: 4; }
td:first-child { z-index: 2; }
th:nth-child(1) { width: 60px; }  th:nth-child(2) { width: 170px; } th:nth-child(3) { width: 260px; }
th:nth-child(4) { width: 210px; } th:nth-child(5) { width: 180px; } th:nth-child(6) { width: 190px; }
th:nth-child(7) { width: 140px; } th:nth-child(8) { width: 150px; } th:nth-child(9) { width: 260px; }
th:nth-child(10) { width: 220px; } th:nth-child(11) { width: 200px; } th:nth-child(12) { width: 260px; }
th:nth-child(13) { width: 280px; }

td.sr { text-align: center; padding: 6px 2px; }
td.sr .n { display: block; font-weight: 700; margin-bottom: 4px; }
td select, td input[type=text], td textarea { display: block; width: 100%; border: 0; border-radius: 0; background: transparent; padding: 8px; }
td select { height: 56px; text-overflow: ellipsis; }
td input[type=text] { height: 56px; }
td textarea { height: 56px; resize: vertical; line-height: 1.35; }
td select:focus, td input:focus, td textarea:focus { outline: 0; background: #fff; box-shadow: inset 0 0 0 2px var(--navy); }
td .bad { box-shadow: inset 0 0 0 2px var(--red); }
td.files { padding: 6px 8px; }
.files ul { list-style: none; margin: 6px 0 0; padding: 0; }
.files li { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: 13px; }
.files a { color: var(--navy); font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .sz { color: var(--muted); font-size: 12px; flex: none; }
.files .fcount { color: var(--muted); font-size: 12px; margin-left: 8px; }
.files input[type=file] { display: none; }

@media (max-width: 600px) {
  .top { flex-wrap: wrap; gap: 8px; }
  .brand img { width: 36px; height: 36px; }
  .top h1 { flex: 1 1 60%; order: 2; }
  .top-actions { order: 1; margin-left: auto; }
  .top h1 { flex-basis: 100%; }
  .foot { flex-wrap: wrap; }
  td select, td input[type=text], td textarea { font-size: 16px; }
}
