:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #18222b;
  --muted: #5b6975;
  --line: #d9e1e8;
  --accent: #0f5f6f;
  --accent-strong: #0a4652;
  --warn: #9a5a00;
  --danger: #a53535;
  --ok: #1f7a4d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.portal-page {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(9, 16, 22, 0.18), rgba(9, 16, 22, 0.82)),
    url("/assets/owl-portal-bg.png") center / cover no-repeat fixed;
  color: #fff;
}

.portal-shell {
  min-height: 100vh;
  max-width: 1180px;
  display: grid;
  align-items: end;
  padding: 32px;
}

.portal-panel {
  width: min(820px, 100%);
  padding: 0 0 54px;
}

.portal-copy p {
  margin: 0 0 8px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.portal-copy h1 {
  margin: 0 0 24px;
  font-size: 46px;
  line-height: 1;
  letter-spacing: 0;
}

.portal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

.portal-logout {
  margin-top: 14px;
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(7, 18, 24, 0.72);
  color: #fff;
}

.portal-card {
  min-height: 138px;
  display: grid;
  align-content: end;
  gap: 8px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  background: rgba(7, 18, 24, 0.72);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}

.portal-card:hover,
.portal-card:focus {
  border-color: #9ce5ef;
  outline: 2px solid rgba(156, 229, 239, 0.38);
  background: rgba(9, 47, 57, 0.78);
}

.portal-card span {
  font-size: 28px;
  font-weight: 800;
}

.portal-card strong {
  color: rgba(255, 255, 255, 0.76);
  font-size: 15px;
}

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(9, 16, 22, 0.18), rgba(9, 16, 22, 0.82)),
    url("/assets/owl-portal-bg.png") center / cover no-repeat fixed;
  color: #fff;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  background: rgba(7, 18, 24, 0.82);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px);
}

.login-panel p {
  margin: 0 0 6px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.login-panel h1 {
  margin: 0 0 12px;
  font-size: 34px;
}

.login-panel input {
  background: rgba(255, 255, 255, 0.94);
}

.login-message {
  min-height: 20px;
  color: #ffd5d5;
  text-transform: none;
  letter-spacing: 0;
}

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

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px;
}

.afl-page main {
  max-width: 1760px;
}

.status-grid,
.content-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.content-grid {
  grid-template-columns: minmax(360px, 1.4fr) minmax(320px, 1fr);
  align-items: start;
}

.afl-workspace {
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.panel h3 {
  margin: 18px 0 10px;
  font-size: 15px;
}

.kv {
  display: grid;
  grid-template-columns: minmax(130px, 0.75fr) 1fr;
  gap: 8px;
  margin: 8px 0;
}

.kv span:first-child,
label span {
  color: var(--muted);
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin: -4px -4px 14px;
  gap: 4px;
  overflow-x: auto;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 6px 6px 0 0;
  min-width: max-content;
}

.tab.active {
  color: var(--accent-strong);
  background: #e7f3f5;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

form {
  display: grid;
  gap: 12px;
}

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

label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #bfccd7;
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  min-height: 44px;
}

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

.check-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.check-row input {
  width: 20px;
  min-height: 20px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.form-actions-top {
  margin-top: 0;
  margin-bottom: 12px;
  justify-content: flex-start;
}

button,
.button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 10px 13px;
  min-height: 44px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.secondary,
.button.secondary {
  background: #fff;
  color: var(--accent-strong);
}

button.warning {
  border-color: var(--warn);
  background: var(--warn);
}

.list {
  display: grid;
  gap: 10px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.record-button {
  width: 100%;
  text-align: left;
  color: var(--ink);
  align-items: stretch;
  justify-content: start;
  display: block;
  min-height: auto;
  border-color: var(--line);
  cursor: pointer;
}

.record-button:hover,
.record-button:focus {
  border-color: var(--accent);
  outline: 2px solid #c7edf3;
}

.open-details {
  display: block;
  margin-top: 8px;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 13px;
}

.item strong {
  display: block;
  margin-bottom: 5px;
}

.concept-list {
  margin-bottom: 14px;
}

.concept-item {
  display: grid;
  gap: 7px;
}

.concept-item button {
  justify-self: start;
}

.panel-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8eef3;
  color: #293843;
  font-size: 13px;
}

.badge.ok {
  background: #e4f4eb;
  color: var(--ok);
}

.badge.warn {
  background: #fff2d9;
  color: var(--warn);
}

.badge.danger {
  background: #f9e4e4;
  color: var(--danger);
}

.offline {
  border-left: 4px solid var(--warn);
}

.concept-banner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid #f3c66d;
  border-left: 4px solid var(--warn);
  background: #fff8e8;
  color: var(--ink);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.concept-banner strong,
.concept-banner span {
  display: block;
}

.concept-banner span {
  color: var(--muted);
  margin-top: 3px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  background: #18222b;
  color: #fff;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 28, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 20;
}

.modal.show {
  display: flex;
}

.modal-panel {
  width: min(920px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25);
}

.modal-close {
  float: right;
  min-height: 34px;
  padding: 5px 10px;
}

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

.record-kv {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  overflow-wrap: anywhere;
}

.record-kv span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: capitalize;
}

.record-kv strong {
  display: block;
  margin-top: 3px;
}

.signature-preview {
  width: 220px;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  background: #fff;
}

.export-page main {
  max-width: 1180px;
}

.export-report h1,
.export-report h2 {
  margin-top: 0;
}

.export-heading {
  border-bottom: 2px solid #111;
  margin-bottom: 16px;
  padding-bottom: 10px;
}

.export-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 18px;
  font-size: 12px;
}

.export-table th,
.export-table td {
  border: 1px solid #222;
  padding: 5px;
  vertical-align: top;
}

.export-table th {
  background: #eee;
  text-align: left;
}

.archive-index {
  margin-bottom: 22px;
}

.archive-overview {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 18px;
  font-size: 12px;
}

.archive-overview th,
.archive-overview td {
  border: 1px solid #222;
  padding: 6px;
  text-align: left;
  vertical-align: top;
}

.archive-overview th {
  background: #eee;
}

.archive-form-block > h2 {
  margin: 18px 0 8px;
}

.export-form-page {
  background: #fff;
  color: #111;
  border: 2px solid #111;
  padding: 10px;
  margin-bottom: 22px;
  page-break-after: always;
  overflow-x: auto;
}

.export-form-header {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1fr 0.8fr;
  border: 1px solid #111;
  border-bottom: 0;
}

.export-form-header > div {
  min-height: 46px;
  padding: 7px;
  border-right: 1px solid #111;
  display: grid;
  align-content: center;
}

.export-form-header > div:last-child {
  border-right: 0;
}

.export-form-header span {
  display: block;
  margin-top: 2px;
}

.export-form-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
}

.export-form-table th,
.export-form-table td {
  border: 1px solid #111;
  padding: 4px;
  min-height: 24px;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.export-form-table th {
  background: #eee;
}

.export-sector-table td {
  height: 38px;
}

.export-lower-grid {
  display: grid;
  grid-template-columns: 0.95fr 1fr 1.2fr 0.9fr;
}

.export-signature {
  width: 120px;
  max-width: 100%;
  height: auto;
  background: #fff;
}

.export-footer-grid {
  display: grid;
  grid-template-columns: 1fr 0.9fr 1fr;
  border: 1px solid #111;
  border-top: 0;
}

.export-footer-grid > div {
  padding: 7px;
  border-right: 1px solid #111;
}

.export-footer-grid > div:last-child {
  border-right: 0;
}

.export-footer-grid h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.export-box {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 1px solid #111;
  text-align: center;
  line-height: 14px;
  margin-right: 4px;
}

.export-seat-map {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  max-width: 210px;
}

.export-seat {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border: 1px solid #111;
  font-size: 10px;
  min-height: 18px;
  text-align: center;
}

.export-seat > * {
  border-right: 1px solid #111;
  font-style: normal;
}

.export-seat > *:last-child {
  border-right: 0;
}

.export-hash {
  border: 1px solid #111;
  border-top: 0;
  padding: 5px;
  font-size: 10px;
  overflow-wrap: anywhere;
}

@media print {
  body {
    background: #fff;
  }

  .export-toolbar,
  .toast {
    display: none !important;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .panel,
  .export-report {
    border: 0;
    border-radius: 0;
    padding: 0;
  }

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

  .archive-index {
    page-break-after: always;
  }

  .export-form-page {
    border: 0;
    margin: 0;
    padding: 0;
    overflow: visible;
  }
}

@media (max-width: 900px) {
  .portal-shell {
    padding: 18px;
    align-items: end;
  }

  .portal-panel {
    padding-bottom: 28px;
  }

  .portal-copy h1 {
    font-size: 36px;
  }

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

  .topbar,
  .status-grid,
  .content-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  main {
    padding: 12px;
  }
}

.paper-log {
  background: #fff;
  color: #111;
  border: 2px solid #111;
  padding: 10px;
  overflow-x: auto;
  font-size: 12px;
}

.paper-header {
  display: grid;
  grid-template-columns: 1.6fr 1fr 0.8fr;
  align-items: center;
  border: 1px solid #111;
  border-bottom: 0;
}

.paper-header > div {
  min-height: 54px;
  padding: 8px;
  border-right: 1px solid #111;
  display: grid;
  align-content: center;
  gap: 4px;
}

.paper-header > div:last-child {
  border-right: 0;
}

.paper-header strong,
.paper-header span {
  display: block;
}

.paper-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

.paper-table th,
.paper-table td {
  border: 1px solid #111;
  padding: 4px;
  vertical-align: middle;
}

.paper-table th {
  font-weight: 700;
  background: #f1f1f1;
}

.paper-table input,
.paper-table textarea {
  border: 0;
  border-radius: 0;
  padding: 4px;
  min-height: 28px;
  background: transparent;
}

.paper-table input:focus,
.paper-table textarea:focus {
  outline: 2px solid var(--accent);
  background: #eef8fa;
}

.paper-table textarea {
  min-height: 62px;
}

.paper-table input[type="checkbox"] {
  width: 20px;
  min-height: 20px;
  display: block;
  margin: 0 auto;
  accent-color: #111;
}

.sector-table {
  min-width: 1260px;
}

.afl-page .sector-table {
  min-width: 0;
}

.sector-table tbody tr {
  height: 42px;
}

.sector-table .narrow {
  width: 52px;
}

.afl-page .sector-table th,
.afl-page .sector-table td {
  padding: 3px;
}

.afl-page .sector-table th:nth-child(1) {
  width: 46px;
}

.afl-page .sector-table th:nth-child(2) {
  width: 118px;
}

.afl-page .sector-table th:nth-child(3) {
  width: 132px;
}

.afl-page .sector-table th:nth-child(4) {
  width: 160px;
}

.afl-page .sector-table th:nth-child(5),
.afl-page .sector-table th:nth-child(6) {
  width: 86px;
}

.afl-page .sector-table th:nth-child(7) {
  width: 92px;
}

.afl-page .sector-table th:nth-child(8),
.afl-page .sector-table th:nth-child(9) {
  width: 152px;
}

.afl-page .sector-table th:nth-child(10),
.afl-page .sector-table th:nth-child(11) {
  width: 78px;
}

.afl-page .sector-table input,
.afl-page .sector-table textarea {
  min-height: 24px;
  padding: 3px;
}

.paper-lower {
  display: grid;
  grid-template-columns: 0.95fr 1fr 1.2fr 0.9fr;
  align-items: stretch;
  min-width: 1460px;
}

.afl-page .paper-lower {
  min-width: 0;
}

.paper-lower .paper-table {
  height: 100%;
}

.paper-footer {
  display: grid;
  grid-template-columns: 1fr 0.8fr 1fr;
  min-width: 1460px;
  border: 1px solid #111;
  border-top: 0;
}

.afl-page .paper-footer {
  min-width: 0;
}

.paper-footer > div {
  padding: 8px;
  border-right: 1px solid #111;
}

.paper-footer > div:last-child {
  border-right: 0;
}

.paper-footer label {
  margin-top: 8px;
}

.paper-footer input {
  min-height: 32px;
}

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

.paper-check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #111;
}

.paper-check input {
  width: 18px;
  min-height: 18px;
  accent-color: #111;
}

.seat-map {
  width: 220px;
  max-width: 100%;
  margin: 10px auto 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  border: 2px solid #111;
  border-radius: 18px 18px 6px 6px;
  padding: 10px 8px 8px;
}

.seat-hint {
  margin-top: 6px;
  font-size: 11px;
  color: #333;
}

.seat-control {
  display: grid;
  grid-template-columns: 15px 1fr 34px;
  gap: 3px;
  align-items: center;
  border: 2px solid #111;
  border-radius: 3px;
  padding: 2px;
  min-height: 27px;
  color: #111;
}

.seat-control input {
  width: 14px;
  min-height: 14px;
  accent-color: #111;
}

.seat-control span {
  font-size: 10px;
  text-align: center;
}

.seat-control select {
  width: 100%;
  min-height: 20px;
  padding: 0;
  border: 1px solid #111;
  border-radius: 2px;
  background: #fff;
  font-size: 10px;
}

.time-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
}

.time-pair label {
  display: grid;
  gap: 1px;
}

.time-pair span {
  color: #333;
  font-size: 9px;
  line-height: 1;
  text-align: center;
}

.time-pair input {
  text-align: center;
  min-height: 24px;
}

.muted-cell {
  color: #555;
  font-size: 11px;
  text-align: center;
}

.signature-pad {
  display: grid;
  gap: 4px;
}

.signature-pad canvas {
  width: 100%;
  min-width: 130px;
  height: 54px;
  border: 1px solid #111;
  background: #fff;
  touch-action: none;
}

.signature-pad .signature-clear {
  min-height: 24px;
  padding: 2px 6px;
  border-radius: 2px;
  border-color: #333;
  background: #fff;
  color: #111;
  font-size: 10px;
}

@media (max-width: 900px) {
  .paper-log {
    margin: 0 -8px;
  }

  .paper-header,
  .paper-lower,
  .paper-footer {
    min-width: 1460px;
  }

  .afl-page .paper-header,
  .afl-page .paper-lower,
  .afl-page .paper-footer {
    min-width: 0;
  }

  .afl-page .paper-log {
    margin: 0;
  }
}
