:root {
      --brand:       #0a205c;
      --brand-light: #e6f4ef;
      --brand-mid:   #1a8c6a;
      --accent:      #d4a017;
      --accent-light:#fdf3d7;
      --bg:          #f5f6f3;
      --surface:     #ffffff;
      --border:      #dde0da;
      --text:        #1a1c19;
      --muted:       #6b7068;
      --ok:          #1a8c6a;
      --ok-bg:       #e6f4ef;
      --warn:        #b87514;
      --warn-bg:     #fdf3d7;
      --err:         #c0392b;
      --err-bg:      #fdecea;
      --radius:      10px;
      --radius-lg:   16px;
      --shadow:      0 1px 4px rgba(0,0,0,0.07);
      --shadow-md:   0 4px 16px rgba(0,0,0,0.10);
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }

    body {
      font-family: 'DM Sans', sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
      font-size: 15px;
      line-height: 1.6;
    }

    /* ── HEADER ── */
    header {
      background: var(--brand);
      color: #fff;
      padding: 0 1.5rem;
      height: 58px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: sticky;
      top: 0;
      z-index: 100;
      box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }
    .logo {
      display: flex;
      align-items: center;
      gap: 10px;
      font-weight: 600;
      font-size: 17px;
      letter-spacing: -0.3px;
    }
    .logo-icon {
      width: 30px; height: 30px;
      background: rgba(255,255,255,0.15);
      border-radius: 7px;
      display: flex; align-items: center; justify-content: center;
      font-size: 16px;
    }
    .header-badge {
      font-size: 11px;
      background: rgba(255,255,255,0.18);
      padding: 3px 10px;
      border-radius: 20px;
      font-weight: 500;
      letter-spacing: 0.3px;
    }

    /* ── LAYOUT ── */
    .page {
      max-width: 700px;
      margin: 0 auto;
      padding: 2rem 1.25rem 4rem;
    }

    .section-title {
      font-size: 13px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      color: var(--muted);
      margin-bottom: 0.75rem;
    }

    /* ── CARD ── */
    .card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 1.5rem;
      box-shadow: var(--shadow);
      margin-bottom: 1.25rem;
    }

    /* ── UPLOAD ── */
    .upload-zone {
      border: 2px dashed var(--border);
      border-radius: var(--radius-lg);
      padding: 2.5rem 1.5rem;
      text-align: center;
      cursor: pointer;
      background: var(--surface);
      transition: border-color 0.2s, background 0.2s;
      margin-bottom: 1.25rem;
      position: relative;
    }
    .upload-zone:hover,
    .upload-zone.dragging {
      border-color: var(--brand-mid);
      background: var(--brand-light);
    }
    .upload-zone input[type=file] { display: none; }
    .upload-emoji { font-size: 36px; margin-bottom: 10px; }
    .upload-zone h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
    .upload-zone p  { font-size: 13px; color: var(--muted); }

    /* ── FILE TAG ── */
    .file-tag {
      display: none;
      align-items: center;
      gap: 8px;
      background: var(--brand-light);
      border: 1px solid #b2d9cc;
      border-radius: var(--radius);
      padding: 8px 14px;
      font-size: 13px;
      color: var(--brand);
      font-weight: 500;
      margin-bottom: 1rem;
    }
    .file-tag.visible { display: flex; }
    .file-tag-remove {
      margin-left: auto;
      cursor: pointer;
      color: var(--muted);
      font-size: 16px;
      line-height: 1;
      background: none;
      border: none;
      padding: 0 2px;
    }
    .file-tag-remove:hover { color: var(--err); }

    /* ── FORM ── */
    .form-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
      margin-bottom: 1rem;
    }
    @media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

    label { font-size: 13px; font-weight: 500; color: var(--muted); display: block; margin-bottom: 5px; }
    input[type=text], select, textarea {
      width: 100%;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 9px 12px;
      font-size: 14px;
      font-family: 'DM Sans', sans-serif;
      color: var(--text);
      outline: none;
      transition: border-color 0.2s;
    }
    input[type=text]:focus, select:focus, textarea:focus {
      border-color: var(--brand-mid);
    }
    textarea { resize: vertical; min-height: 70px; }

    /* ── BUTTON ── */
    .btn-analyze {
      width: 100%;
      padding: 13px;
      background: var(--brand);
      color: #fff;
      border: none;
      border-radius: var(--radius);
      font-size: 15px;
      font-weight: 600;
      font-family: 'DM Sans', sans-serif;
      cursor: pointer;
      transition: background 0.2s, transform 0.1s;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
    }
    .btn-analyze:hover:not(:disabled) { background: #084d38; }
    .btn-analyze:active:not(:disabled) { transform: scale(0.99); }
    .btn-analyze:disabled {
      background: var(--border);
      color: var(--muted);
      cursor: not-allowed;
    }

    .btn-secondary {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 8px 16px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      font-size: 13px;
      font-weight: 500;
      font-family: 'DM Sans', sans-serif;
      color: var(--text);
      cursor: pointer;
      transition: background 0.15s;
    }
    .btn-secondary:hover { background: var(--bg); }

    /* ── LOADING ── */
    .progress-wrap {
      display: none;
      margin-bottom: 1.25rem;
    }
    .progress-wrap.visible { display: block; }
    .progress-label {
      font-size: 13px;
      color: var(--muted);
      margin-bottom: 6px;
      display: flex;
      justify-content: space-between;
    }
    .progress-bar {
      height: 4px;
      background: var(--border);
      border-radius: 4px;
      overflow: hidden;
    }
    .progress-fill {
      height: 100%;
      width: 0;
      background: linear-gradient(90deg, var(--brand), var(--brand-mid));
      border-radius: 4px;
      transition: width 0.5s ease;
    }

    /* ── SUMMARY METRICS ── */
    .metrics {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 10px;
      margin-bottom: 1.25rem;
    }
    .metric {
      border-radius: var(--radius);
      padding: 14px 12px;
      text-align: center;
      border: 1px solid transparent;
    }
    .metric.ok   { background: var(--ok-bg);   border-color: #b2d9cc; }
    .metric.warn { background: var(--warn-bg);  border-color: #f0d08a; }
    .metric.err  { background: var(--err-bg);   border-color: #f0b8b2; }
    .metric-num  { font-size: 26px; font-weight: 600; line-height: 1; }
    .metric.ok   .metric-num { color: var(--ok); }
    .metric.warn .metric-num { color: var(--warn); }
    .metric.err  .metric-num { color: var(--err); }
    .metric-lbl  { font-size: 12px; color: var(--muted); margin-top: 4px; }

    /* ── ALERT ── */
    .alert {
      border-radius: var(--radius);
      padding: 12px 16px;
      font-size: 14px;
      font-weight: 500;
      margin-bottom: 1.25rem;
      display: flex;
      align-items: flex-start;
      gap: 10px;
    }
    .alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
    .alert.ok   { background: var(--ok-bg);   color: #0a4a30; border: 1px solid #b2d9cc; }
    .alert.warn { background: var(--warn-bg);  color: #7a4e00; border: 1px solid #f0d08a; }
    .alert.err  { background: var(--err-bg);   color: #7a1a10; border: 1px solid #f0b8b2; }

    /* ── CHECK LIST ── */
    .check-item {
      display: flex;
      align-items: flex-start;
      gap: 12px;
      padding: 12px 0;
      border-bottom: 1px solid var(--border);
    }
    .check-item:last-child { border-bottom: none; padding-bottom: 0; }
    .badge {
      font-size: 11px;
      font-weight: 600;
      padding: 3px 9px;
      border-radius: 20px;
      white-space: nowrap;
      flex-shrink: 0;
      margin-top: 2px;
    }
    .badge-ok   { background: var(--ok-bg);   color: var(--ok); }
    .badge-warn { background: var(--warn-bg);  color: var(--warn); }
    .badge-err  { background: var(--err-bg);   color: var(--err); }
    .check-name   { font-size: 14px; font-weight: 500; color: var(--text); }
    .check-detail { font-size: 13px; color: var(--muted); margin-top: 2px; }

    /* ── EMAIL ── */
    .email-body {
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 14px 16px;
      font-family: 'DM Mono', monospace;
      font-size: 12.5px;
      color: var(--text);
      white-space: pre-wrap;
      line-height: 1.7;
      margin-bottom: 1rem;
      max-height: 280px;
      overflow-y: auto;
    }

    /* ── HISTORY ── */
    .history-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 0;
      border-bottom: 1px solid var(--border);
      font-size: 13px;
      cursor: pointer;
      transition: background 0.15s;
    }
    .history-item:last-child { border-bottom: none; }
    .history-item:hover { background: var(--bg); border-radius: var(--radius); padding-left: 8px; }
    .history-dot {
      width: 8px; height: 8px;
      border-radius: 50%;
      flex-shrink: 0;
    }
    .history-dot.ok   { background: var(--ok); }
    .history-dot.warn { background: var(--warn); }
    .history-dot.err  { background: var(--err); }
    .history-name { font-weight: 500; flex: 1; }
    .history-date { color: var(--muted); }
    .history-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 1.5rem 0; }

    /* ── TABS ── */
    .tabs {
      display: flex;
      gap: 4px;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 4px;
      margin-bottom: 1.5rem;
    }
    .tab {
      flex: 1;
      padding: 8px;
      text-align: center;
      font-size: 13px;
      font-weight: 500;
      border-radius: 7px;
      cursor: pointer;
      color: var(--muted);
      border: none;
      background: none;
      font-family: 'DM Sans', sans-serif;
      transition: background 0.15s, color 0.15s;
    }
    .tab.active {
      background: var(--surface);
      color: var(--brand);
      box-shadow: var(--shadow);
    }

    /* ── PANELS ── */
    .panel { display: none; }
    .panel.active { display: block; }

    /* ── TOAST ── */
    .toast {
      position: fixed;
      bottom: 1.5rem;
      left: 50%;
      transform: translateX(-50%) translateY(80px);
      background: var(--text);
      color: #fff;
      padding: 10px 20px;
      border-radius: 30px;
      font-size: 13px;
      font-weight: 500;
      z-index: 999;
      transition: transform 0.3s ease;
      white-space: nowrap;
    }
    .toast.show { transform: translateX(-50%) translateY(0); }

    /* ── WORKER CONFIG ── */
    .config-note {
      background: var(--accent-light);
      border: 1px solid #f0d08a;
      border-radius: var(--radius);
      padding: 12px 14px;
      font-size: 13px;
      color: #7a4e00;
      margin-bottom: 1.25rem;
      display: flex;
      gap: 8px;
      align-items: flex-start;
    }

    /* ── RESPONSIVE ── */
    @media (max-width: 480px) {
      .page { padding: 1.25rem 1rem 3rem; }
      .card { padding: 1.25rem; }
      .metrics { gap: 8px; }
      .metric-num { font-size: 22px; }
    }