:root {
  --ink: #1b2a32;
  --muted: #5d6e78;
  --line: #d7e0e4;
  --paper: #f3f6f4;
  --card: #ffffff;
  --navy: #0e3a4d;
  --navy-2: #14536c;
  --green: #0f6e56;
  --green-2: #0c5a46;
  --warn: #8a3b12;
  --row: #f7faf8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 15px/1.5 "Segoe UI", "Be Vietnam Pro", sans-serif;
}

.topbar {
  background: var(--navy);
  color: #fff;
}

.topbar__inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 20px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "title source"
    "nav nav";
  gap: 8px 16px;
  align-items: end;
}
.topbar__inner > div:first-child { grid-area: title; }
.topbar__tools {
  grid-area: source;
  justify-self: end;
  align-self: start;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  margin-top: 6px;
}
.source { margin-top: 0; }

.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 12px;
  color: #b7d4c8;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.source {
  color: #d7efe6;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.source:hover { border-bottom-color: #d7efe6; }

.nav {
  grid-area: nav;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0 2px;
}
.nav-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  gap: 4px 6px;
  min-height: 72px;
  padding: 8px 10px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
}
.nav-label {
  flex: 1 0 100%;
  margin: 0 2px 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b7d4c8;
}
.nav a {
  color: #f4fbf8;
  text-decoration: none;
  font-weight: 650;
  font-size: 14px;
  line-height: 1.2;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.nav a:hover { background: rgba(255, 255, 255, 0.14); }
.nav a[aria-current="page"] {
  background: #fff;
  color: var(--navy);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #f7faf8;
}
.card span { display: block; color: var(--muted); font-size: 13px; }
.card strong {
  display: block;
  margin-top: 4px;
  color: var(--navy);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}
.card small { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }

.col-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 8px 0 12px;
}
.col-picks label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--navy);
}
.col-picks input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
}
.detail-table { min-width: 760px; }
.detail-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
}

.log {
  max-height: 220px;
  overflow: auto;
  background: #102833;
  color: #e7f3ee;
  border-radius: 8px;
  padding: 10px 12px;
  font: 12px/1.45 Consolas, "Cascadia Mono", monospace;
  white-space: pre-wrap;
}

.review-table input { width: 100%; min-width: 180px; }

@media (max-width: 1100px) {
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .filters--even { grid-template-columns: 1fr 1fr; }
}

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.fields {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 0.8fr) minmax(280px, 1.2fr);
  gap: 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field span {
  font-size: 13px;
  font-weight: 650;
  color: var(--navy);
}

input, select {
  height: 42px;
  border: 1px solid #c5d2d8;
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input:focus, select:focus {
  outline: 2px solid #b7ddd1;
  border-color: var(--green);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid #c5d2d8;
  background: #fff;
  color: var(--navy);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.btn--primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.btn--primary:hover { background: var(--green-2); }
.btn:hover { border-color: var(--navy-2); }
.btn[aria-disabled="true"],
.btn:disabled { opacity: 0.55; pointer-events: none; }

.hint, .results__bar p, .empty td {
  color: var(--muted);
  font-size: 13px;
}

.hint { margin: 10px 0 0; }

.results__bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.results__bar p { margin: 0; }

.error { color: var(--warn); }

.pager { display: flex; gap: 6px; align-items: center; }

.pager button {
  height: 34px;
  min-width: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font: inherit;
}

.pager button[aria-current="page"] {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

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

th {
  font-size: 13px;
  color: var(--navy);
  background: #eef4f1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

th.no-sort { cursor: default; }
th .mark { color: var(--green); margin-left: 4px; }

tbody tr:nth-child(even) { background: var(--row); }

td a {
  color: var(--green);
  font-weight: 650;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.btn--small {
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

h2 {
  margin: 0;
  font-size: 20px;
  color: var(--navy);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tabs button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
}

.tabs button[aria-current="true"] {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.catalog-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) 180px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  color: var(--navy);
  font-weight: 650;
}

.section-title {
  margin: 14px 0 6px;
  font-size: 15px;
  color: var(--navy);
}

.catalog table { min-width: 1400px; }
.catalog .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.catalog .group td { color: var(--muted); font-style: italic; }

.package { font-weight: 650; }
.muted { color: var(--muted); }

.run-state {
  margin: 8px 0 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.run-state[data-status="running"] { color: var(--green); }
.run-state[data-status="stopped"] { color: var(--warn); }
.run-state[data-status="completed"] { color: var(--navy); }
.run-state[data-status="error"] { color: var(--warn); }
.run-state[data-status="idle"] { color: var(--muted); }

.fetch-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  margin-top: 12px;
}
.fetch-options .check { height: auto; font-weight: 650; }
.fetch-options input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
}
.fetch-options .field { min-width: 180px; }

.fetch-log { max-height: 320px; }

.checkpoint-table { min-width: 760px; }
.checkpoint-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2f4;
}
.tag--running { background: #d9f3ea; color: var(--green); }
.tag--done { background: #e5f0e8; color: var(--green-2); }
.tag--error { background: #fde8df; color: var(--warn); }

.warn-box {
  margin-top: 10px;
  border: 1px solid #e7c3b2;
  background: #fff6f1;
  color: var(--warn);
  border-radius: 8px;
  padding: 10px 12px;
}

.btn--stop {
  border-color: #e7c3b2;
  color: var(--warn);
}

.pick { position: relative; overflow: visible; }
.pick:focus-within { z-index: 30; }
.pick__box {
  min-height: 42px;
  display: flex;
  align-items: center;
  border: 1px solid #c5d2d8;
  border-radius: 8px;
  background: #fff;
}
.pick__box input {
  height: 40px;
  border: 0;
  flex: 1;
  min-width: 0;
  outline: none;
  background: transparent;
}
.pick__clear {
  border: 0;
  background: transparent;
  color: var(--navy);
  font: inherit;
  cursor: pointer;
  padding: 0 10px;
}
.pick__menu {
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 240px;
  overflow: auto;
  background: #fff;
  border: 1px solid #c5d2d8;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 40, 51, 0.12);
}
.pick__menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: #fff;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}
.pick__menu button[aria-selected="true"],
.pick__menu button:hover { background: #eef4f1; }
.pick__empty { margin: 0; padding: 8px 12px; color: var(--muted); font-size: 13px; }
.filters.is-collapsed { display: none; }
.review-table .dose-input { margin-top: 6px; }

.multi__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.multi.is-collapsed .multi__box,
.multi.is-collapsed .multi__menu { display: none; }
.multi { position: relative; overflow: visible; }
.multi:focus-within { z-index: 30; }
.multi__box {
  min-height: 42px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  border: 1px solid #c5d2d8;
  border-radius: 8px;
  padding: 4px 8px;
  background: #fff;
}
.multi__box:focus-within {
  outline: 2px solid #b7ddd1;
  border-color: var(--green);
}
.multi__chips { display: flex; flex-wrap: wrap; gap: 4px; }
.multi__box input {
  height: 32px;
  border: 0;
  padding: 0 4px;
  flex: 1 1 120px;
  min-width: 90px;
  outline: none;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 6px;
  border-radius: 999px;
  background: #e5f0e8;
  color: var(--navy);
  font-size: 13px;
}
.chip button {
  border: 0;
  background: transparent;
  color: var(--navy);
  cursor: pointer;
  font: inherit;
  line-height: 1;
  padding: 0 2px;
}
.multi__menu {
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 240px;
  overflow: auto;
  background: #fff;
  border: 1px solid #c5d2d8;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 40, 51, 0.12);
}
.multi__menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: #fff;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}
.multi__menu button[aria-selected="true"],
.multi__menu button:hover { background: #eef4f1; }
.multi__empty {
  margin: 0;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.detail-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-top: 8px;
}
.detail-tools .hint { margin: 0; }
.col-panel {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border: 1px solid #d5e0e4;
  border-radius: 10px;
  background: #f7faf8;
}
.col-panel.is-collapsed { display: none; }
.col-picks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}
.col-group {
  min-width: 0;
  padding: 8px;
  border: 1px solid #e1ebe6;
  border-radius: 8px;
  background: #fff;
}
.col-group h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--navy);
}
.col-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow: auto;
}
.col-row {
  display: grid;
  grid-template-columns: 28px 52px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-height: 28px;
}
.col-handle {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #c5d2d8;
  border-radius: 8px;
  background: #fff;
  cursor: grab;
}
.col-order {
  width: 52px;
  height: 28px;
  padding: 0 6px;
}
.col-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 13px;
}
.tag--saved {
  margin-left: 8px;
  background: #e5f0e8;
  color: var(--green-2);
  vertical-align: middle;
}

.rank-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.rank-grid h3 { margin: 0 0 8px; font-size: 15px; color: var(--navy); }

.checks-field { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checks label { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 650;
  border: 1px solid var(--line);
}
.pill--pending { background: #fff4e8; color: var(--warn); border-color: #f0c9a8; }
.pill--approved { background: #eef2f4; color: #6b7c86; }
.pill--auto { background: #e7f6f1; color: var(--green-2); border-color: #b7e0d2; }
.pill--wait { background: #eef1f3; color: #5c6b73; border-color: #c5ced4; }
.slot.is-wait { border-color: #c5ced4; background: #f4f6f8; }
.file-box { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.duyet-list { display: flex; flex-direction: column; gap: 12px; }
.duyet-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
}
.duyet-card h3 { margin: 0; font-size: 18px; }
.duyet-card .meta { margin: 4px 0 10px; color: var(--muted); }
.duyet-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.slot {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}
.slot.is-pending {
  border-color: #e3b48a;
  background: #fff8f1;
  font-weight: 650;
}
.slot.is-approved { opacity: 0.55; background: #f4f7f8; }
.slot.is-auto { background: #fff; }
.slot header { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.slot h4 { margin: 0; font-size: 13px; }
.pair { margin: 6px 0; font-size: 13px; font-weight: 500; }
.pair b { font-weight: 700; }
.slot .hint { margin: 4px 0; font-size: 12px; }
.slot input, .slot select { width: 100%; margin-top: 4px; }
.slot .btn { margin-top: 6px; }
@media (max-width: 1100px) {
  .duyet-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .duyet-grid { grid-template-columns: 1fr; }
}
.rank-table, .notice-table { min-width: 0; }
.notice-table { min-width: 720px; }
.field--grow { flex: 1 1 240px; }

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.subnav a {
  text-decoration: none;
  color: var(--navy);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  margin: 0;
  padding: 7px 14px;
  font-weight: 650;
}
.subnav a:hover { background: #eef4f1; }
.subnav a[aria-current="page"] {
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}
.filters--even { grid-template-columns: repeat(4, minmax(140px, 1fr)); }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.admin-card h2 { margin: 0 0 6px; font-size: 20px; }
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 650;
}
.badge--ok { background: #e7f6f1; color: var(--green-2); }
.badge--bad { background: #fff4e8; color: var(--warn); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.stat-grid div { background: var(--row); border-radius: 8px; padding: 8px 10px; }
.stat-grid b { display: block; font-size: 18px; }
.meter { height: 8px; background: #e4ece8; border-radius: 99px; overflow: hidden; margin: 8px 0; }
.meter span { display: block; height: 100%; width: 0; background: var(--green); }
fieldset.group {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  margin: 0 0 12px;
  padding: 12px 14px 14px;
}
fieldset.group legend { font-weight: 650; color: var(--navy); padding: 0 6px; }
input.is-invalid, select.is-invalid { border-color: var(--warn); background: #fff8f1; }
.log-table { min-width: 880px; }
.log-table tbody tr { cursor: pointer; }
.log-table tbody tr:hover { background: var(--row); }
dialog.log-dialog { border: 0; border-radius: 12px; padding: 16px 18px; max-width: 760px; width: calc(100% - 32px); }
dialog.log-dialog::backdrop { background: rgba(14, 58, 77, 0.4); }
dialog.log-dialog pre { white-space: pre-wrap; background: var(--row); border-radius: 8px; padding: 10px; }
@media (max-width: 800px) {
  .admin-grid, .stat-grid { grid-template-columns: 1fr; }
}
.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 72px;
  gap: 8px;
  align-items: center;
  margin: 5px 0;
}
.bar { height: 10px; background: #e4ece8; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--navy-2); border-radius: 99px; }
.bar > span.is-done { background: var(--green); }
.bar > span.is-run { background: #c47b12; }
.bar > span.is-error { background: #a33b24; }
.bar > span.is-wait { background: #7d8e96; }
.dash-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
}
.insight { margin: 0 0 8px; }
.insight.warn { color: var(--warn); }
.insight.good { color: var(--green); }
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(14, 42, 55, 0.45);
  justify-content: center;
  align-items: flex-start;
  padding: 32px 16px;
  z-index: 30;
  overflow: auto;
}
.modal-back[hidden] { display: none !important; }
body:not([data-role]) [data-roles],
[data-roles][hidden],
.nav-group[hidden],
.session-chip[hidden] { display: none !important; }
.session-chip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
  color: #d7efe6;
  font-size: 13px;
}
.session-chip a,
.session-chip button {
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 2px 10px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.login-panel { max-width: 460px; margin: 28px auto; }
.login-panel h2 { margin-top: 0; }
.modal-back:not([hidden]) { display: flex; }
.modal {
  width: min(780px, 100%);
  background: #fff;
  border-radius: 12px;
  padding: 16px 18px 18px;
}
.modal h2 { margin: 0 0 8px; font-size: 20px; }
.modal-grid { display: grid; gap: 12px; }
.modal .faded input, .modal .faded select { color: #6d7c84; }
.detail-table .col-fix { width: 1%; white-space: nowrap; }
.banner {
  background: #fff4e8;
  color: var(--warn);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 0 0 10px;
}
.version-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 99px;
  background: #e7f2ec;
  color: var(--navy);
  font-size: 12px;
}
.results .table-wrap th:last-child,
.results .table-wrap td:last-child {
  position: sticky;
  right: 0;
  background: #fff;
  box-shadow: -8px 0 10px rgba(14, 42, 55, 0.05);
}
.results .table-wrap thead th:last-child { background: #f7faf8; z-index: 1; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .nav { grid-template-columns: 1fr; }
  .topbar__inner {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "source"
      "nav";
  }
  .topbar__tools { justify-self: start; align-items: flex-start; }
  .fields { grid-template-columns: 1fr 1fr; }
  .field--grow { grid-column: 1 / -1; }
  h1 { font-size: 22px; }
  .topbar__inner { align-items: stretch; }
  .results__bar { flex-direction: column; align-items: flex-start; }
  .catalog-tools { grid-template-columns: 1fr; }
  .rank-grid { grid-template-columns: 1fr; }
  .col-picks { grid-template-columns: 1fr; }
}

:root {
  --head: #eef4f1;
  --chart-ink: #1b2a32;
  --chart-grid: #d7e0e4;
  --chart-1: #0f6e56;
  --chart-2: #14536c;
  --chart-3: #c47b12;
  --chart-4: #a33b24;
  --chart-5: #7d8e96;
  --tip: #102833;
  --tip-ink: #f4fbf8;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e6f1ec;
  --muted: #a9bdc6;
  --line: #314851;
  --paper: #10181d;
  --card: #18262e;
  --row: #20313a;
  --head: #1b3038;
  --warn: #f0b08a;
  --chart-ink: #d7efe6;
  --chart-grid: #314851;
  --chart-1: #3dbe9a;
  --chart-2: #7eb6d4;
  --chart-3: #e0a45a;
  --chart-4: #e08b7a;
  --chart-5: #9aadb6;
  --tip: #f4fbf8;
  --tip-ink: #102833;
}

html[data-theme="dark"] body { background: var(--paper); color: var(--ink); }
html[data-theme="dark"] .panel,
html[data-theme="dark"] .card,
html[data-theme="dark"] .duyet-card,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .subnav,
html[data-theme="dark"] fieldset.group,
html[data-theme="dark"] .slot.is-auto { background: var(--card); color: var(--ink); }
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] .field span,
html[data-theme="dark"] th,
html[data-theme="dark"] .card strong { color: #d7efe6; }
html[data-theme="dark"] .topbar { background: #0a242f; }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] .btn,
html[data-theme="dark"] .pager button {
  background: #122027;
  color: var(--ink);
  border-color: var(--line);
}
html[data-theme="dark"] .btn--primary { background: var(--green); color: #fff; border-color: var(--green); }
html[data-theme="dark"] th { background: var(--head); }
html[data-theme="dark"] .results .table-wrap th:last-child,
html[data-theme="dark"] .results .table-wrap td:last-child { background: var(--card); }
html[data-theme="dark"] .log { background: #0c1418; }

.theme-toggle {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  margin-top: 8px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: transparent;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 19;
  border: 0;
  background: rgba(8, 20, 28, 0.48);
  cursor: pointer;
}
.sidebar-backdrop[hidden] { display: none !important; }

body.has-sidebar { padding-left: 248px; }
body.has-sidebar.sidebar-collapsed { padding-left: 76px; }
body.has-sidebar main,
body.has-sidebar .topbar__inner { max-width: none; }
body.has-sidebar .topbar__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 16px;
}
body.has-sidebar .topbar__inner > div:first-of-type { flex: 1 1 220px; }
body.has-sidebar .topbar__tools { margin-left: auto; }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
  width: 248px;
  display: flex;
  flex-direction: column;
  background: #0e3a4d;
  color: #f4fbf8;
  overflow: auto;
}
.sidebar__head {
  display: flex;
  justify-content: flex-end;
  padding: 10px 10px 0;
}
.sidebar__collapse {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  background: transparent;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
body.has-sidebar .nav {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
  padding: 8px 10px 24px;
  background: transparent;
}
body.has-sidebar .nav-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  min-height: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}
body.has-sidebar .nav-label {
  flex: none;
  margin: 0 8px 4px;
}
body.has-sidebar .nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  padding: 8px 10px;
}
body.has-sidebar .nav a[aria-current="page"] {
  background: #fff;
  color: #0e3a4d;
}
.nav-ico { display: inline-flex; width: 18px; height: 18px; flex: 0 0 18px; }
.nav-ico svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-text { min-width: 0; }

body.sidebar-collapsed .sidebar { width: 76px; }
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
body.sidebar-collapsed .nav a { justify-content: center; }
body.sidebar-collapsed .sidebar__head { justify-content: center; }

.fields,
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px 14px;
  align-items: end;
}
.field-pair {
  grid-column: span 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  align-items: end;
  min-width: 0;
}
.checks-field { grid-column: 1 / -1; }
.field input,
.field select,
.pick__box,
.multi__box { width: 100%; }
form.panel > .actions,
.file-box > .actions { justify-content: flex-end; }

main, .panel { min-width: 0; }
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}
.table-wrap table { border-collapse: separate; border-spacing: 0; }
.col-idx {
  width: 3.2rem;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
th.sticky-name,
td.sticky-name {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--card);
}
thead th.sticky-name { z-index: 3; background: var(--head); }
tbody tr:nth-child(odd) td.sticky-name { background: var(--card); }
tbody tr:nth-child(even) td.sticky-name { background: var(--row); }
.col-filters th {
  cursor: default;
  background: var(--card);
  font-weight: 500;
}
.col-filter {
  height: 32px;
  min-width: 72px;
  width: 100%;
  font-size: 13px;
  font-weight: 450;
}
.summary-table { min-width: 520px; }
.summary-table caption {
  caption-side: bottom;
  padding-top: 8px;
  text-align: left;
  color: var(--muted);
  font-size: 13px;
}

.card--metric { background: var(--card); }
.metric__label { display: block; color: var(--muted); font-size: 13px; font-weight: 650; }
.metric__value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 4px 0 0;
}
.card--metric strong {
  font-size: 32px;
  line-height: 1.1;
  font-weight: 720;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
html[data-theme="dark"] .card--metric strong { color: #d7efe6; }
.card--metric .unit { font-size: 13px; font-weight: 650; color: var(--muted); }
.metric__note { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
.chart-card {
  margin: 0;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px 12px;
  background: var(--card);
}
.chart-card--wide { grid-column: 1 / -1; }
.chart-card figcaption { font-weight: 700; color: var(--navy); margin-bottom: 6px; }
html[data-theme="dark"] .chart-card figcaption { color: #d7efe6; }
.chart-box { position: relative; height: 280px; overflow: visible; }
.chart-tip {
  position: fixed;
  z-index: 50;
  max-width: min(320px, calc(100vw - 16px));
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--tip);
  color: var(--tip-ink);
  font-size: 13px;
  line-height: 1.35;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(8, 20, 28, 0.24);
}
.chart-tip[hidden] { display: none !important; }
.chart-tip strong { font-weight: 700; }

@media (max-width: 1023px) {
  body.has-sidebar,
  body.has-sidebar.sidebar-collapsed { padding-left: 0; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    width: min(288px, 86vw);
    transform: translateX(-105%);
    transition: transform 0.18s ease;
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-collapsed .sidebar { width: min(288px, 86vw); }
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .nav-text {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
  }
  body.sidebar-collapsed .nav a { justify-content: flex-start; }
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .fields,
  .filters,
  .field-pair { grid-template-columns: 1fr; }
  .field-pair,
  .checks-field,
  .field--grow { grid-column: 1 / -1; }
  form.panel > .actions,
  .file-box > .actions { flex-direction: column; align-items: stretch; }
  form.panel > .actions .btn,
  .file-box > .actions .btn,
  #notice-form .btn { min-height: 44px; width: 100%; }
  #notice-form { flex-direction: column; align-items: stretch; }
  .btn { min-height: 44px; }
  .topbar__tools .btn,
  .theme-toggle,
  .session-chip button,
  .session-chip a { width: auto; min-height: 32px; }
  .field input,
  .field select,
  .col-filter { min-height: 44px; }
  h1 { font-size: 22px; }
  .card--metric strong { font-size: 28px; }
  .chart-box { height: 240px; }
  .results__bar { align-items: stretch; }
}

@media (min-width: 1440px) {
  .chart-box { height: 300px; }
}

.today-head__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.today-head h2 { margin: 0 0 4px; }
.today-banner {
  background: #fff4e8;
  color: var(--warn);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 10px 0 0;
}
html[data-theme="dark"] .today-banner { background: #3a2a22; }
.today-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
button.tile {
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 12px;
}
.today-modal .fields { grid-template-columns: 1fr 1fr; }
.today-modal fieldset.field { border: 0; margin: 0; padding: 0; }
button.tile:hover,
button.tile.is-on { border-color: var(--green); }
button.tile.is-on { box-shadow: inset 0 0 0 1px var(--green); }
.today-filter { margin: 10px 0 0; }
.today-filter .btn { min-height: 36px; }
.task-list { margin: 8px 0 0; padding-left: 18px; }
.task-list a { color: var(--navy-2); font-weight: 650; }
html[data-theme="dark"] .task-list a { color: #9fd7c4; }
.tender-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.tender-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 14px;
  min-width: 0;
}
.tender-card h3 { margin: 0; font-size: 16px; line-height: 1.35; }
.tender-card__top,
.tender-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
.tender-card__code {
  margin: 0;
  font-weight: 720;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
html[data-theme="dark"] .tender-card__code,
html[data-theme="dark"] .tender-card h3 { color: #d7efe6; }
.tender-card__badges { display: flex; flex-wrap: wrap; gap: 6px; }
.tender-card__drug,
.tender-card__alert { margin: 0; }
.tender-card__alert { color: var(--warn); font-weight: 650; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
  background: #e5f5ef;
  color: var(--green);
}
.badge--warn { background: #fff4e8; color: var(--warn); }
html[data-theme="dark"] .badge { background: #14352c; color: #8ee0c4; }
html[data-theme="dark"] .badge--warn { background: #3a2a22; color: #f0b08a; }
.deadline { margin: 0; font-weight: 700; }
.deadline--red { color: #a33b24; }
.deadline--yellow { color: #8a5a00; }
.deadline--gray { color: var(--muted); font-weight: 600; }
.deadline--het-han { color: var(--muted); font-weight: 700; }
.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--green);
  vertical-align: middle;
}
.match-lines { margin: 0; padding-left: 18px; font-size: 13px; }
.qt-settings {
  margin: 12px 0 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--row);
}
.qt-settings > summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 720;
}
.qt-settings > summary .hint { font-weight: 550; text-align: right; }
.qt-settings__body { display: grid; gap: 12px; padding: 0 14px 14px; }
.qt-grid {
  display: grid;
  grid-template-columns: 7.5rem minmax(18rem, 1.25fr) minmax(14rem, 1fr);
  gap: 10px 18px;
  align-items: end;
}
.qt-provinces { grid-column: 1 / -1; }
.qt-ids input { height: 36px; }
.detail-investor { margin: 0; font-weight: 720; }
.qt-board { margin-top: 12px; }
.qt-board h2 { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.qt-board .qt-note { margin: 0 0 8px; }
.qt-board .table-wrap { max-height: 520px; }
.qt-table { width: 100%; font-size: 13px; }
.qt-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.qt-table td {
  vertical-align: top;
  padding: 8px;
  border-top: 1px solid var(--line);
}
.qt-table tbody tr:hover td { background: var(--row); }
.qt-name { font-weight: 650; min-width: 14rem; }
.qt-code { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 720; }
.qt-muted { color: var(--muted); }
.qt-actions { white-space: nowrap; text-align: right; }
.qt-actions .btn { min-height: 32px; padding: 0 8px; }
.qt-detail { min-width: 1680px; }
.qt-labelrow {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.qt-labelrow > span:first-child { font-size: 13px; font-weight: 650; color: var(--navy); }
.qt-textbtn {
  border: 0;
  background: transparent;
  color: var(--green);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  padding: 0;
  height: auto;
}
.qt-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.qt-chips:empty { display: none; }
.qt-settings .qt-provinces input[type="search"] {
  height: 34px;
  padding: 0 10px;
}
.qt-list {
  max-height: 148px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  align-content: start;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}
.qt-list .hint { grid-column: 1 / -1; margin: 6px 8px; }
.qt-check {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 1px 8px;
  font-size: 13px;
  line-height: 1.2;
}
.qt-settings .qt-all input[type="checkbox"],
.qt-settings .qt-list input[type="checkbox"] {
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
  max-height: 14px;
  margin: 0;
  padding: 0;
  flex: 0 0 14px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  box-shadow: none;
  accent-color: var(--green);
}
.qt-settings input[type="time"] { width: 7.4rem; flex: 0 0 auto; }
.qt-days input[type="number"] { width: 100%; max-width: 6rem; }
.qt-catalog {
  display: grid;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.qt-import { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.qt-import input[type="file"] { max-width: 100%; }
.clock-row { display: flex; flex-wrap: wrap; gap: 8px; }
.clock-row select { flex: 1; min-width: 0; }
.rollup-row { cursor: pointer; }
.rollup-row.is-on { outline: 2px solid var(--green); }
html[data-theme="dark"] .deadline--red { color: #e08b7a; }
html[data-theme="dark"] .deadline--yellow { color: #e0a45a; }
.tender-card__prices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}
.tender-card__prices div { min-width: 0; }
.tender-card__prices dt { color: var(--muted); font-size: 12px; }
.tender-card__prices dd {
  margin: 2px 0 0;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.tender-card__prices small { font-weight: 550; color: var(--muted); }
.note-line { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.tender-card__actions .btn { min-height: 36px; }
.today-modal { width: min(1120px, 100%); }
.catalog-box {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--row);
}
.catalog-box h3 { margin: 0; font-size: 15px; }
.catalog-box .actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.catalog-box .actions .btn,
.catalog-box .chip-add .btn { min-height: 36px; }
.catalog-box input[type="file"] { font: inherit; min-width: 0; }
#pref-import-note[hidden],
#fill-gap[hidden] { display: none !important; }
.today-modal .check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}
.today-modal .check input { width: 16px; height: 16px; padding: 0; }
select.multi { height: auto; min-height: 168px; padding: 8px; }
.chip-add { display: flex; gap: 8px; }
.chip-add input { flex: 1; min-width: 0; }
.chip-list, .suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.chip, .suggest__item {
  border: 1px solid var(--line);
  background: var(--row);
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit;
  cursor: pointer;
}
.suggest { flex-direction: column; align-items: stretch; }
.suggest__item { border-radius: 8px; text-align: left; }
.snackbar {
  position: fixed;
  z-index: 45;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  align-items: center;
  max-width: min(520px, calc(100% - 24px));
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 10px 28px rgba(8, 20, 28, 0.28);
}
.snackbar[hidden] { display: none !important; }
.snackbar .btn { background: #fff; color: var(--navy); min-height: 36px; }
#lists > .panel,
#viec { scroll-margin-top: 12px; }

@media (max-width: 1023px) {
  .qt-grid { grid-template-columns: 1fr 1fr; }
  .qt-days { grid-column: 1 / -1; }
}
@media (max-width: 768px) {
  .today-head__row,
  .today-tiles,
  .tender-card__prices,
  .qt-grid,
  .chip-add { grid-template-columns: 1fr; display: grid; }
  .today-head__row { display: flex; flex-direction: column; }
  .chip-add { display: flex; }
  .qt-settings > summary { flex-direction: column; align-items: flex-start; }
  .qt-settings > summary .hint { text-align: left; }
  .tender-card__actions .btn,
  .today-head__row .btn { width: 100%; min-height: 44px; }
}

[hidden] { display: none !important; }
