:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --text: #1f252b;
  --muted: #68727d;
  --line: #dfe3e7;
  --accent: #e76419;
  --accent-dark: #c94e09;
  --green: #1d7a4c;
  --green-soft: #e9f6ef;
  --red: #b42318;
  --red-soft: #fff0ee;
  --amber: #8a5a00;
  --amber-soft: #fff7df;
  --header: #243441;
  --radius: 6px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; }
a { color: inherit; }
button, input, select { font: inherit; }

.app-header {
  min-height: 64px;
  display: grid;
  grid-template-columns: minmax(340px, 1fr) auto minmax(210px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 8px 28px;
  background: var(--header);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; width: fit-content; }
.brand span:last-child { display: grid; }
.brand small { color: #bec9d1; margin-top: 2px; white-space: nowrap; font-size: 12px; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; background: var(--accent); color: white; border-radius: 6px; font-weight: 800; font-size: 20px; }
.top-nav { display: flex; height: 48px; align-items: stretch; gap: 4px; }
.top-nav a { display: grid; place-items: center; padding: 0 16px; color: #d8e0e6; text-decoration: none; border-bottom: 3px solid transparent; }
.top-nav a:hover, .top-nav a.is-active { color: white; border-color: var(--accent); }
.logout-form { justify-self: end; }

.page-shell { width: min(1500px, calc(100% - 40px)); margin: 28px auto 60px; }
.page-heading, .section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.page-heading { margin-bottom: 22px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 28px; line-height: 1.2; margin-bottom: 5px; }
h2 { font-size: 20px; margin-bottom: 5px; }
h3 { font-size: 17px; margin-bottom: 5px; }
.page-heading p, .section-heading p { color: var(--muted); margin-bottom: 0; }

.button { min-height: 40px; border: 1px solid transparent; border-radius: 5px; padding: 8px 16px; cursor: pointer; font-weight: 700; background: #fff; color: var(--text); white-space: nowrap; }
.button:hover { filter: brightness(.96); }
.button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(231, 100, 25, .28); outline-offset: 2px; }
.button:disabled { opacity: .48; cursor: not-allowed; }
.button-primary { background: var(--accent); color: #fff; }
.button-confirm { background: var(--green); color: #fff; }
.button-quiet { border-color: #c9d0d6; background: transparent; color: inherit; }
.app-header .button-quiet { border-color: #687987; color: #fff; }
.button-small { min-height: 34px; padding: 5px 11px; font-size: 13px; }
.button-full { width: 100%; }

.flash, .notice { width: min(1500px, calc(100% - 40px)); margin: 16px auto; padding: 13px 16px; border: 1px solid; border-radius: var(--radius); }
.flash-success, .notice-safe { background: var(--green-soft); border-color: #b8dec8; color: #155d3a; }
.flash-error { background: var(--red-soft); border-color: #efbbb5; color: var(--red); }
.flash-info { background: #eef4f8; border-color: #c3d4df; color: #294b61; }
.notice-warning { background: var(--amber-soft); border-color: #ead49a; color: var(--amber); }
.page-shell > .notice { width: auto; margin: 0 0 14px; }

.metric-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 20px; overflow: hidden; }
.metric-strip > div { min-height: 86px; padding: 15px 18px; display: grid; gap: 5px; border-right: 1px solid var(--line); }
.metric-strip > div:last-child { border-right: 0; }
.metric-strip span { color: var(--muted); }
.metric-strip strong { font-size: 25px; }

.section-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
.section-attention { border-color: #e2c879; }
.section-heading { min-height: 65px; padding: 14px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.section-heading h2 { margin: 0; }
.text-link { color: var(--accent-dark); font-weight: 700; }
.count-badge { display: inline-grid; place-items: center; min-width: 28px; height: 28px; background: #edf0f2; border-radius: 50%; font-weight: 700; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 13px 15px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { background: #f8f9fa; color: #4f5a64; font-size: 12px; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { color: var(--muted); margin-top: 3px; }
td a { color: #285b7a; }
.price-target { color: var(--green); font-size: 17px; }
.actions-cell { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; min-width: 190px; }
.apply-form { display: flex; align-items: center; gap: 6px; }
.confirm-input { width: 108px; height: 34px; border: 1px solid #cbd2d8; border-radius: 4px; padding: 5px 8px; font-size: 12px; }
.status { display: inline-block; border-radius: 4px; padding: 4px 8px; font-size: 12px; font-weight: 700; background: #edf0f2; color: #4e5963; }
.status-approved, .status-verified, .status-completed { background: var(--green-soft); color: var(--green); }
.status-failed { background: var(--red-soft); color: var(--red); }
.status-running { background: var(--amber-soft); color: var(--amber); }
.empty-state { padding: 42px 20px; text-align: center; color: var(--muted); }

.mapping-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; padding: 18px; }
label { display: grid; gap: 7px; font-weight: 700; }
input, select { width: 100%; min-height: 42px; border: 1px solid #c8d0d6; border-radius: 5px; background: #fff; padding: 8px 10px; color: var(--text); }
.split-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.plain-list { list-style: none; padding: 0; margin: 0; max-height: 470px; overflow: auto; }
.plain-list li { padding: 12px 18px; border-bottom: 1px solid var(--line); display: grid; gap: 3px; }
.plain-list li:last-child { border-bottom: 0; }
.plain-list span { color: var(--muted); }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #eef1f3; }
.login-panel { width: min(420px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 32px; box-shadow: 0 12px 34px rgba(24, 35, 44, .08); }
.login-panel .brand-mark { margin-bottom: 20px; }
.login-panel h1 { margin-bottom: 7px; }
.login-panel > p { color: var(--muted); margin-bottom: 24px; }
.login-panel form { display: grid; gap: 15px; }
.login-panel .flash { width: auto; margin: 0 0 18px; }

@media (max-width: 900px) {
  .app-header { grid-template-columns: 1fr auto; padding: 8px 16px; gap: 8px; }
  .top-nav { order: 3; grid-column: 1 / -1; overflow-x: auto; width: calc(100% + 32px); margin: 0 -16px -8px; padding: 0 8px; background: #1e2b35; }
  .top-nav a { min-width: max-content; }
  .brand small { display: none; }
  .logout-form { grid-column: 2; grid-row: 1; }
  .page-shell { width: min(100% - 24px, 1500px); margin-top: 20px; }
  .flash, .notice { width: calc(100% - 24px); }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric-strip > div { border-bottom: 1px solid var(--line); }
  .metric-strip > div:nth-child(2n) { border-right: 0; }
  .metric-strip > div:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .mapping-form { grid-template-columns: 1fr; }
  .split-sections { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading .button { width: 100%; }
  h1 { font-size: 23px; }
  .metric-strip strong { font-size: 22px; }
  .section-heading { align-items: flex-start; }
  .table-wrap { overflow: visible; }
  table, thead, tbody, tr, th, td { display: block; min-width: 0; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tr { border-bottom: 8px solid var(--bg); padding: 6px 0; }
  tbody tr:last-child { border-bottom: 0; }
  td { display: grid; grid-template-columns: minmax(108px, 34%) 1fr; gap: 10px; border-bottom: 1px solid #edf0f2; padding: 10px 14px; overflow-wrap: anywhere; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 700; }
  td.actions-cell { display: flex; padding-left: 14px; min-width: 0; }
  td.actions-cell::before { width: 98px; flex: 0 0 98px; }
  .apply-form { flex-wrap: wrap; }
  .login-panel { padding: 24px; }
}
