:root {
      --bg: #f4f6f7;
      --panel: #ffffff;
      --ink: #182230;
      --muted: #667085;
      --line: #d9e0e6;
      --brand: #0f766e;
      --brand-dark: #0b4f4a;
      --red: #b42318;
      --amber: #b7791f;
      --green: #15803d;
      --blue: #2563eb;
      --violet: #6d28d9;
      --shadow: 0 12px 26px rgba(24, 34, 48, .08);
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      background: var(--bg);
      color: var(--ink);
      font-family: Arial, Helvetica, sans-serif;
      font-size: 14px;
      letter-spacing: 0;
    }

    button, input, select { font: inherit; }

    .app {
      min-height: 100vh;
      display: grid;
      grid-template-columns: 292px 1fr;
    }

    aside {
      background: #0d3432;
      color: #edf8f6;
      padding: 22px;
      display: flex;
      flex-direction: column;
      gap: 18px;
    }

    .brand h1 {
      margin: 0;
      font-size: 23px;
      line-height: 1.15;
      font-weight: 800;
    }

    .brand-mark {
      width: 72px;
      height: 72px;
      object-fit: contain;
      border-radius: 12px;
      background: white;
      padding: 6px;
      margin-bottom: 12px;
      display: block;
    }

    .brand p {
      margin: 9px 0 0;
      color: #bcd9d6;
      line-height: 1.35;
    }

    .side-group {
      border-top: 1px solid rgba(255,255,255,.14);
      padding-top: 15px;
    }

    .side-title {
      color: #a9cbc7;
      font-size: 12px;
      text-transform: uppercase;
      font-weight: 800;
      margin-bottom: 10px;
    }

    .importer-nav, .status-list {
      display: grid;
      gap: 8px;
    }

    .nav-btn, .status-row {
      border: 1px solid rgba(255,255,255,.15);
      color: #edf8f6;
      background: rgba(255,255,255,.06);
      border-radius: 8px;
      padding: 9px 10px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 8px;
    }

    .nav-btn {
      cursor: pointer;
      text-align: left;
    }

    .nav-btn.active {
      background: #edf8f6;
      color: #0d3432;
      border-color: #edf8f6;
      font-weight: 800;
    }

    .badge {
      display: inline-flex;
      align-items: center;
      min-height: 24px;
      border-radius: 999px;
      padding: 3px 8px;
      font-size: 12px;
      font-weight: 800;
      background: #eef2f6;
      color: #344054;
      white-space: nowrap;
    }

    .badge.red { background: #fee4e2; color: var(--red); }
    .badge.amber { background: #fef0c7; color: var(--amber); }
    .badge.green { background: #dcfce7; color: var(--green); }
    .badge.blue { background: #dbeafe; color: var(--blue); }
    .badge.violet { background: #ede9fe; color: var(--violet); }

    .status-editor {
      width: 100%;
      min-width: 190px;
      border: 1px solid #cbd5e1;
      border-radius: 8px;
      padding: 7px 28px 7px 9px;
      background: #eef2f6;
      color: #344054;
      font-size: 12px;
      font-weight: 800;
      cursor: pointer;
    }

    .status-editor.amber { background: #fef0c7; color: var(--amber); }
    .status-editor.green { background: #dcfce7; color: var(--green); }
    .status-editor.blue { background: #dbeafe; color: var(--blue); }
    .status-editor.violet { background: #ede9fe; color: var(--violet); }
    .status-editor:focus { outline: 2px solid var(--brand); outline-offset: 1px; }




    .attachment-label {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 190px;
      padding: 8px 10px;
      border-radius: 8px;
      background: var(--brand);
      color: white;
      font-size: 11px;
      font-weight: 800;
      cursor: pointer;
      text-align: center;
    }

    .attachment-input { display: none; }
    .attachment-list { display: grid; gap: 6px; margin-top: 8px; min-width: 210px; }
    .attachment-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 6px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
    .attachment-download { border: 0; padding: 0; background: none; color: var(--blue); text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .attachment-delete { grid-column: 2; grid-row: 1 / span 2; border: 0; background: #fee4e2; color: var(--red); border-radius: 6px; width: 26px; height: 26px; cursor: pointer; }
    .documents-cell > small { max-width: 220px; }

    .manual-field {
      width: 100%;
      min-width: 150px;
      border: 1px solid #cbd5e1;
      border-radius: 8px;
      padding: 7px 8px;
      background: #ffffff;
      color: var(--ink);
      font-size: 12px;
    }

    .manual-field.compact { min-width: 115px; }
    .manual-field.wide { min-width: 220px; }
    .manual-textarea { margin-top: 6px; resize: vertical; line-height: 1.35; }
    .manual-field:focus, .manual-date:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

    .inline-field {
      display: grid;
      gap: 3px;
      margin-top: 6px;
      color: var(--muted);
      font-size: 10px;
      font-weight: 700;
      text-transform: none;
    }

    .manual-date {
      width: 145px;
      min-width: 145px;
      border: 1px solid #cbd5e1;
      border-radius: 8px;
      padding: 7px 8px;
      background: #ffffff;
      color: var(--ink);
      font-size: 12px;
    }

    .shipping-dates { min-width: 170px; }
    .shipping-dates .inline-field:first-child { margin-top: 0; }

    .date-editor {
      width: 145px;
      min-width: 145px;
      border: 1px solid #cbd5e1;
      border-radius: 8px;
      padding: 7px 8px;
      background: #ffffff;
      color: var(--ink);
      font-size: 12px;
      cursor: pointer;
    }

    .date-editor:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
    .date-save-note { color: var(--green); font-size: 10px; white-space: nowrap; }

    .status-save-note {
      color: var(--green);
      font-size: 10px;
      line-height: 1.25;
    }

    main {
      padding: 24px;
      min-width: 0;
    }

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

    .topbar h2 {
      margin: 0;
      font-size: 25px;
      line-height: 1.15;
    }

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

    .actions {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 8px;
    }

    .btn {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      color: var(--ink);
      min-height: 38px;
      padding: 8px 11px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 7px;
      white-space: nowrap;
    }

    .btn.primary {
      background: var(--brand);
      color: white;
      border-color: var(--brand);
    }

    .btn.primary:hover { background: var(--brand-dark); }
    .btn.icon { width: 38px; justify-content: center; padding: 0; }

    .panel {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 8px;
      box-shadow: var(--shadow);
      min-width: 0;
    }

    .panel-head {
      padding: 14px;
      border-bottom: 1px solid var(--line);
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
    }

    .panel-head h3 {
      margin: 0;
      font-size: 16px;
    }

    .filters {
      padding: 14px;
      display: grid;
      grid-template-columns: repeat(6, minmax(130px, 1fr));
      gap: 10px;
      margin-bottom: 16px;
    }

    label {
      display: grid;
      gap: 5px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
      text-transform: uppercase;
    }

    input, select {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 9px 10px;
      background: white;
      color: var(--ink);
      min-width: 0;
    }

    .kpis {
      display: grid;
      grid-template-columns: repeat(2, minmax(180px, 1fr));
      gap: 12px;
      margin-bottom: 16px;
    }

    .kpi {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 14px;
      box-shadow: var(--shadow);
      min-height: 92px;
    }

    .kpi span {
      display: block;
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
      text-transform: uppercase;
      margin-bottom: 8px;
    }

    .kpi strong {
      font-size: 26px;
      line-height: 1;
    }

    .importer-cards {
      display: grid;
      grid-template-columns: repeat(4, minmax(180px, 1fr));
      gap: 12px;
      margin-bottom: 16px;
    }

    .importer-card {
      border: 1px solid var(--line);
      background: var(--panel);
      box-shadow: var(--shadow);
      border-radius: 8px;
      padding: 14px;
      display: grid;
      gap: 10px;
      cursor: pointer;
      text-align: left;
      color: var(--ink);
    }

    .importer-card.active {
      border-color: var(--brand);
      outline: 2px solid rgba(15, 118, 110, .16);
    }

    .importer-card h3 {
      margin: 0;
      font-size: 17px;
    }

    .card-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      color: var(--muted);
      font-size: 12px;
    }

    .card-grid strong {
      display: block;
      color: var(--ink);
      font-size: 15px;
      margin-top: 2px;
    }

    .layout {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 16px;
      align-items: start;
    }

    .stack {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 4fr);
      gap: 16px;
      align-items: start;
    }

    .stack > .panel { min-width: 0; }

    .table-wrap {
      overflow: auto;
      max-height: 620px;
    }

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

    th, td {
      padding: 10px;
      text-align: left;
      vertical-align: top;
      border-bottom: 1px solid #edf0f2;
    }

    th {
      position: sticky;
      top: 0;
      z-index: 1;
      background: #f8faf9;
      color: #475467;
      font-size: 12px;
      text-transform: uppercase;
    }

    tr:hover td { background: #f8fbfa; }

    small {
      display: block;
      color: var(--muted);
      line-height: 1.35;
      margin-top: 3px;
    }

    .list {
      padding: 12px;
      display: grid;
      gap: 9px;
      max-height: 360px;
      overflow: auto;
    }

    .item {
      border: 1px solid #e6ebef;
      border-radius: 8px;
      padding: 10px;
      background: #fbfcfc;
      display: grid;
      gap: 6px;
    }

    .item-head {
      display: flex;
      justify-content: space-between;
      gap: 8px;
      align-items: flex-start;
    }

    .item strong { line-height: 1.25; }

    .muted { color: var(--muted); }

    .checklist-btn {
      margin-top: 8px;
      min-height: 32px;
      padding: 6px 9px;
      font-size: 12px;
    }

    dialog {
      width: min(520px, calc(100% - 28px));
      max-height: calc(100vh - 28px);
      padding: 0;
      border: 1px solid var(--line);
      border-radius: 8px;
      box-shadow: 0 24px 60px rgba(24, 34, 48, .24);
      color: var(--ink);
    }

    dialog::backdrop { background: rgba(15, 35, 42, .58); }

    .dialog-head {
      padding: 16px;
      border-bottom: 1px solid var(--line);
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 12px;
    }

    .dialog-head h3 { margin: 0; font-size: 18px; }
    .dialog-head p { margin: 4px 0 0; color: var(--muted); }

    .manual-checklist {
      padding: 16px;
      display: grid;
      gap: 9px;
      overflow: auto;
    }

    .manual-check-item {
      display: flex;
      align-items: center;
      gap: 11px;
      padding: 11px 12px;
      border: 1px solid #e6ebef;
      border-radius: 8px;
      background: #fbfcfc;
      color: var(--ink);
      font-size: 14px;
      font-weight: 700;
      text-transform: none;
      cursor: pointer;
    }

    .manual-check-item input {
      width: 20px;
      height: 20px;
      margin: 0;
      accent-color: var(--brand);
      flex: 0 0 20px;
    }

    .manual-check-item:has(input:checked) {
      border-color: #99d5ce;
      background: #edf8f6;
      color: var(--brand-dark);
    }

    .checklist-progress {
      padding: 0 16px 14px;
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
    }

    .dialog-actions {
      padding: 12px 16px;
      border-top: 1px solid var(--line);
      display: flex;
      justify-content: flex-end;
    }

    .empty {
      color: var(--muted);
      text-align: center;
      padding: 20px;
    }

    .source-alert {
      display: none;
      margin-bottom: 16px;
      border: 1px solid #fecdca;
      background: #fff1f0;
      color: var(--red);
      border-radius: 8px;
      padding: 12px 14px;
      line-height: 1.4;
    }

    @media (max-width: 1180px) {
      .app { grid-template-columns: 1fr; }
      .layout { grid-template-columns: 1fr; }
      .stack { grid-template-columns: minmax(0, 1fr) minmax(0, 4fr); }
      .filters { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
      .kpis { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
      .importer-cards { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
      .topbar { flex-direction: column; }
      .actions { justify-content: flex-start; }
    }

    @media (max-width: 640px) {
      aside { padding: 16px; }
      main { padding: 14px; }
      .brand-mark { width: 58px; height: 58px; }
      .brand h1, .topbar h2 { font-size: 20px; }
      .filters, .kpis, .importer-cards, .stack { grid-template-columns: 1fr; }
      .actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr 42px; }
      .btn { justify-content: center; min-width: 0; }
      .panel-head { align-items: flex-start; flex-direction: column; }
      .table-wrap { max-height: 560px; }
      table { min-width: 980px; }
      th, td { padding: 9px; }
      .list { max-height: 300px; }
    }

    @media print {
      aside, .actions, .filters { display: none !important; }
      body { background: white; }
      .app, .layout { display: block; }
      main { padding: 0; }
      .panel, .kpi, .importer-card { box-shadow: none; }
      .table-wrap, .list { max-height: none; overflow: visible; }
    }
