:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #d9dee7;
  --text: #17202a;
  --muted: #687386;
  --accent: #176b5f;
  --accent-weak: #e8f3f1;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
}

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

input,
select {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  min-height: 38px;
}

.hidden {
  display: none !important;
}

.shell {
  min-height: 100vh;
}

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

.login-box {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.login-box h1 {
  margin: 0 0 18px;
  font-size: 22px;
}

.login-box label,
.toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.login-box label + label {
  margin-top: 14px;
}

.login-box button {
  width: 100%;
  margin-top: 18px;
}

.error {
  min-height: 20px;
  color: var(--danger);
}

.app-panel {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 6px 10px;
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(140px, 180px) 100px max-content max-content max-content;
  gap: 12px;
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}

.checkline {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  min-height: 38px;
  color: var(--text) !important;
}

.checkline input {
  min-height: auto;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-grid div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
}

.summary-grid strong {
  font-size: 22px;
}

.table-wrap {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: var(--accent-weak);
  color: #20332f;
  font-weight: 700;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: #fafbfc;
}

.reason-cell {
  max-width: 520px;
  color: var(--muted);
}

.print-only {
  display: none;
}

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

.secure-panel {
  width: min(760px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.secure-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.secure-head p,
.secure-head h1 {
  margin: 0;
}

.secure-head p {
  color: var(--muted);
  margin-bottom: 4px;
}

.secure-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

.secure-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

#secureCanvas {
  width: 100%;
  max-height: 360px;
  margin-top: 18px;
  border: 1px solid var(--line);
  background: #0b1018;
}

@media (max-width: 840px) {
  .app-panel {
    padding: 12px;
  }

  .topbar,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

@media print {
  @page {
    margin: 12mm;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }

  .screen-only,
  .login-panel {
    display: none !important;
  }

  .app-panel {
    display: block !important;
    width: 100%;
    padding: 0;
  }

  .print-only {
    display: block !important;
  }

  .print-only h1 {
    margin: 0 0 10mm;
    font-size: 18pt;
  }

  #printTable th,
  #printTable td {
    border: 1px solid #000;
    padding: 5mm 4mm;
    font-size: 13pt;
  }

  #printTable th {
    background: #fff;
  }
}
