:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #66736b;
  --paper: #f4f6f2;
  --panel: #ffffff;
  --line: #dce2dc;
  --brand: #165b3d;
  --brand-dark: #0e422c;
  --lime: #d9f260;
  --danger: #a83b38;
  --warning: #9a6813;
  --shadow: 0 16px 45px rgba(25, 50, 36, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-size: 15px; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; }
code { padding: 2px 6px; border-radius: 5px; background: #eef1ed; font-size: .88em; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px; background: #102b20; color: white; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; color: white; padding: 4px 8px 28px; }
.brand span { width: 34px; height: 34px; border-radius: 10px; background: var(--lime); color: #102b20; display: grid; place-items: center; font-weight: 900; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { color: #bfd0c7; padding: 11px 12px; border-radius: 9px; font-weight: 650; }
.sidebar nav a:hover, .sidebar nav a.active { color: white; background: rgba(255,255,255,.1); }
.sidebar > form { margin-top: auto; }
.nav-logout { border: 0; background: none; color: #bfd0c7; padding: 11px 12px; cursor: pointer; }

.main { width: 100%; max-width: 1500px; margin: 0 auto; padding: 42px clamp(22px, 4vw, 64px) 70px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 28px; }
.page-head h1 { margin: 3px 0 5px; font-size: clamp(30px, 4vw, 48px); line-height: 1.04; letter-spacing: -.035em; }
.page-head p:not(.eyebrow) { margin: 0; color: var(--muted); max-width: 760px; }
.eyebrow { margin: 0; color: var(--brand); font-size: 12px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.muted { color: var(--muted); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 18px; font-size: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: start; gap: 18px; margin-bottom: 14px; }
.panel-head h2 { margin-bottom: 3px; }
.grid { display: grid; gap: 22px; margin-top: 22px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mapping-layout { grid-template-columns: minmax(300px, .7fr) minmax(520px, 1.3fr); align-items: start; }
.narrow { max-width: 650px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.stat { min-height: 120px; padding: 18px; border-radius: 15px; background: #fff; border: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; }
.stat span { color: var(--muted); font-weight: 650; }
.stat strong { font-size: 38px; letter-spacing: -.04em; }
.stat.positive { background: #e9f7ef; }.stat.warning { background: #fff8df; }.stat.danger { background: #fff0ef; }

.button { appearance: none; display: inline-flex; justify-content: center; align-items: center; min-height: 40px; padding: 8px 14px; border: 1px solid #cbd4cc; border-radius: 9px; background: white; color: var(--ink); font-weight: 750; cursor: pointer; }
.button:hover { border-color: var(--brand); color: var(--brand); }
.button.primary { background: var(--brand); border-color: var(--brand); color: white; }
.button.primary:hover { background: var(--brand-dark); }
.button.danger { color: var(--danger); border-color: #e6c1bf; }.button.small { min-height: 32px; padding: 5px 9px; font-size: 13px; }

.stack { display: grid; gap: 20px; }.stack > .panel { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
label { display: grid; gap: 7px; color: #314038; font-weight: 700; }
label small { color: var(--muted); font-weight: 450; }
input, select, textarea { width: 100%; border: 1px solid #cbd4cc; border-radius: 9px; background: white; color: var(--ink); padding: 10px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22,91,61,.12); }
select[multiple] { min-height: 120px; }.check { display: flex; align-items: center; gap: 9px; min-height: 42px; }.check input { width: 18px; height: 18px; }
.form-actions { display: flex; justify-content: flex-end; }.inline-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; margin-top: 18px; }

.notice { padding: 12px 14px; margin: 0 0 18px; border-radius: 10px; border: 1px solid; }
.notice.success { color: #174f34; background: #e7f6ed; border-color: #b6dec5; }.notice.error { color: #7c2926; background: #fff0ef; border-color: #ebc1bf; }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; background: #eef1ed; }
.badge.ok { color: #155234; background: #dff3e7; }.badge.info { color: #28516f; background: #e4f1f9; }.badge.warning { color: #79500b; background: #fff0c6; }.badge.danger { color: #862e2a; background: #fbe2e1; }.badge.muted { color: #59665e; }

.table-wrap { overflow-x: auto; }.panel.table-wrap { padding: 0; }.panel.table-wrap > h2 { padding: 24px 24px 0; }
table { width: 100%; border-collapse: collapse; min-width: 680px; } th, td { padding: 14px 16px; border-bottom: 1px solid #e8ece8; text-align: left; vertical-align: top; } th { color: var(--muted); font-size: 12px; letter-spacing: .05em; text-transform: uppercase; } tr:last-child td { border-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; }.actions form { display: flex; flex-wrap: wrap; gap: 7px; }
.error-text { max-width: 330px; color: var(--danger); font-size: 13px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

.target-stack { display: grid; gap: 9px; }.target-mini { display: flex; justify-content: space-between; align-items: center; padding: 13px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); }.target-mini small { display: block; color: var(--muted); margin-top: 3px; }.target-mini b { font-size: 22px; }
.source-panel { margin-top: 22px; }.source-list { display: grid; gap: 10px; }.source-row { display: grid; grid-template-columns: 180px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; background: #f8faf7; border-radius: 11px; }.source-row small { display: block; color: var(--muted); }.copy-field { display: flex; gap: 7px; }.copy-field input { font-family: ui-monospace, monospace; font-size: 12px; color: #506158; }
.details { margin: 0; }.details > div { display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding: 10px 0; border-bottom: 1px solid #edf0ed; }.details dt { color: var(--muted); }.details dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }.details.fields > div { grid-template-columns: minmax(120px, .35fr) 1fr; }
.filters form { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)) auto; gap: 10px; align-items: end; }
.meta-list { display: flex; gap: 10px; margin: 18px 0; }.meta-list div { flex: 1; padding: 12px; border-radius: 10px; background: #f2f5f1; }.meta-list dt { color: var(--muted); font-size: 12px; }.meta-list dd { margin: 3px 0 0; font-size: 24px; font-weight: 850; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 15% 20%, #e4f3d0, transparent 30%), #102b20; }
.auth-card { width: min(100%, 460px); padding: 34px; background: white; border-radius: 20px; box-shadow: 0 25px 80px rgba(0,0,0,.25); }.auth-card h1 { margin: 6px 0 10px; font-size: 34px; letter-spacing: -.035em; }.auth-card form { display: grid; gap: 17px; margin: 24px 0; }.subtle-link { display: inline-block; font-size: 13px; color: var(--muted); }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 1fr; }.sidebar { position: static; height: auto; padding: 12px 18px; flex-direction: row; align-items: center; overflow-x: auto; }.brand { padding: 0 12px 0 0; white-space: nowrap; }.sidebar nav { display: flex; }.sidebar > form { margin: 0 0 0 auto; }.nav-logout { white-space: nowrap; }.main { padding-top: 30px; }.stats { grid-template-columns: repeat(2, 1fr); }.grid.two, .mapping-layout { grid-template-columns: 1fr; }.filters form { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 680px) {
  .main { padding: 24px 14px 50px; }.sidebar { align-items: start; }.brand strong, .sidebar > form { display: none; }.page-head { align-items: start; flex-direction: column; }.stats { grid-template-columns: 1fr 1fr; }.stat { min-height: 100px; }.form-grid, .inline-form { grid-template-columns: 1fr; }.span-2 { grid-column: span 1; }.source-row { grid-template-columns: 1fr; }.copy-field { align-items: stretch; }.filters form { grid-template-columns: 1fr 1fr; }.auth-card { padding: 25px; }
}
