:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #566174;
  --line: #d8dee8;
  --accent: #136f63;
  --accent-dark: #0d5148;
  --danger: #b42318;
  --warn-bg: #fff8e6;
  --warn-line: #efd083;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #75d5c8;
  outline-offset: 2px;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 232px;
  background: #17202b;
  color: #fff;
  padding: 18px 14px;
}
.brand {
  font-size: 21px;
  font-weight: 700;
  margin: 6px 8px 24px;
}
.brand span { color: #75d5c8; }
.nav-link {
  display: block;
  color: #c8d1dc;
  padding: 11px 12px;
  border-radius: 6px;
  margin-bottom: 4px;
}
.nav-link.active,
.nav-link:hover {
  background: #263344;
  color: #fff;
  text-decoration: none;
}
.main { margin-left: 232px; padding: 22px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
h1 { margin: 0; font-size: 24px; }
h2 { margin: 0 0 14px; font-size: 18px; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}
.company-select {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.company-select label {
  color: var(--muted);
  font-size: 12px;
}
.company-select select {
  min-width: 230px;
  background: white;
}
.apply-company {
  min-width: 72px;
  height: 34px;
  padding: 0 9px;
  background: #fff;
  color: var(--accent-dark);
  border-color: #9fcac3;
}
.apply-company:hover { background: #edf8f6; }
.userbox { white-space: nowrap; color: var(--muted); }
.userbox a { margin-left: 10px; }
.cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metric, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.metric { padding: 16px; }
.metric span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 7px; }
.metric strong { font-size: 23px; }
.panel { padding: 16px; margin-bottom: 16px; }
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
input, select, button {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  font: inherit;
}
input { min-width: 280px; flex: 1; }
button {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  cursor: pointer;
  min-width: 96px;
}
button:hover { background: var(--accent-dark); }
button:disabled {
  background: #9ca3af;
  border-color: #9ca3af;
  cursor: not-allowed;
}
button.secondary {
  background: white;
  color: var(--accent-dark);
  border-color: #9fcac3;
}
button.secondary:hover { background: #edf8f6; }
.button-link {
  display: inline-block;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  margin: 2px 4px 2px 0;
}
.button-link:hover {
  background: #f8fafc;
  text-decoration: none;
}
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; background: white; }
th, td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  background: #f8fafc;
  color: #465266;
  font-size: 12px;
  text-transform: uppercase;
}
tr:last-child td { border-bottom: 0; }
.empty { color: var(--muted); padding: 20px; border: 1px dashed var(--line); border-radius: 6px; }
.strong-empty {
  color: #794100;
  background: var(--warn-bg);
  border-color: var(--warn-line);
  margin: 12px 0;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
}
.pager a {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}
.pager a.disabled { color: #7a8493; pointer-events: none; }
.summary-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--muted);
  margin: 2px 0 12px;
}
.summary-row strong { color: var(--ink); font-size: 18px; }
.report-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.report-intro p {
  margin: -8px 0 0;
  color: var(--muted);
}
.report-scope,
.notice {
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
  color: #5e4200;
}
.report-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}
.report-steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}
.report-steps strong {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
}
.report-section { margin-top: 18px; }
.report-section > h2 { margin-bottom: 10px; }
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}
.report-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}
.report-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.report-card h2 { margin: 0; }
.report-card p {
  margin: 0;
  color: var(--muted);
}
.report-help { font-size: 13px; }
.report-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: auto;
}
.report-form input,
.report-form select {
  min-width: 0;
  width: 100%;
}
.field { display: block; }
.field.full { grid-column: 1 / -1; }
.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.field small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 4px;
}
.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.admin-form h2,
.admin-form .full,
.admin-form .report-actions {
  grid-column: 1 / -1;
}
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}
.check input {
  width: auto;
  min-width: 0;
  height: auto;
  flex: 0 0 auto;
}
.report-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.report-actions form { margin: 0; }
.preview-actions { margin: 14px 0; }
.report-filter-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.report-filter-summary div { min-height: 58px; }
.legacy-link {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.legacy-link span {
  display: inline-block;
  margin-left: 6px;
}
.badge {
  display: inline-block;
  border: 1px solid #b9d9d3;
  background: #edf8f6;
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  white-space: nowrap;
}
.muted { color: var(--muted); margin-top: 0; }
.report-preview {
  max-height: 620px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1720;
  color: #e7edf5;
  font: 12px/1.45 Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.json-editor {
  width: 100%;
  min-height: 520px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #0f1720;
  color: #e7edf5;
  font: 12px/1.45 Consolas, "Liberation Mono", monospace;
  tab-size: 2;
}
.text-block {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
}
.text-block strong { display: block; margin-bottom: 6px; }
.text-block p {
  margin: 0;
  color: #344054;
  white-space: pre-wrap;
  word-break: break-word;
}
.detail .grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}
.detail .grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  min-height: 64px;
}
.detail span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.detail strong { font-weight: 600; }
.alert {
  background: #fff0ee;
  color: var(--danger);
  border: 1px solid #ffd0ca;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
}
.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: #17202b;
}
.login-card {
  width: min(380px, calc(100vw - 28px));
  background: white;
  border-radius: 8px;
  padding: 24px;
}
.login-card h1 { margin-bottom: 4px; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.login-card label { display: block; margin: 12px 0; color: #465266; }
.login-card input { width: 100%; min-width: 0; margin-top: 6px; }
.login-card button { width: 100%; margin-top: 8px; }
.attachment-modal {
  width: min(1100px, calc(100vw - 32px));
  height: min(780px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.28);
}
.attachment-modal::backdrop {
  background: rgba(16, 24, 40, 0.54);
}
.attachment-modal-head {
  height: 52px;
  padding: 0 14px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.attachment-modal-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.attachment-modal-actions a,
.attachment-modal-actions button {
  height: 34px;
  border-radius: 6px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}
.attachment-modal iframe {
  display: block;
  width: 100%;
  height: calc(100% - 52px);
  border: 0;
  background: #f8fafc;
}

@media (max-width: 920px) {
  .sidebar { position: static; width: auto; }
  .sidebar nav { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; }
  .nav-link { white-space: nowrap; }
  .main { margin-left: 0; padding: 14px; }
  .cards { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .topbar, .filters { flex-direction: column; }
  .report-intro { flex-direction: column; }
  .report-steps { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: 1fr; }
  .report-form { grid-template-columns: 1fr; }
  .admin-form { grid-template-columns: 1fr; }
  .report-actions button,
  .report-actions .button-link,
  .report-actions form { width: 100%; }
  .top-actions { align-items: stretch; width: 100%; }
  .company-select { align-items: stretch; flex-direction: column; }
  .company-select select { min-width: 0; width: 100%; }
  .apply-company { width: 100%; height: 42px; }
  input { min-width: 0; width: 100%; }
  .detail .grid { grid-template-columns: 1fr; }
  .attachment-modal {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
  }
  .attachment-modal-head { padding: 0 8px 0 12px; }
  .attachment-modal-actions a,
  .attachment-modal-actions button { padding: 0 10px; }
}
