  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; }
  body { font-family: var(--font); background: var(--bg); color: var(--text); display: flex; flex-direction: column; }

  /* ── Layout ── */
  .page { display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .tabs-bar { background: var(--surface); border-bottom: 1px solid var(--border); display: flex; gap: 2px; padding: 0 32px; flex-shrink: 0; justify-content: center; }
  .tab-btn { padding: 12px 18px; border: none; background: none; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s; }
  .tab-btn:hover { color: var(--text); }
  .tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
  .tab-panel { display: none; flex: 1; overflow-y: auto; padding: 28px 32px; }
  .tab-panel.active { display: block; }
  .tab-panel > * { max-width: 1200px; margin-left: auto; margin-right: auto; }

  /* ── Cards ── */
  .card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
  .card-title { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .8px; text-transform: uppercase; margin-bottom: 14px; }

  /* ── Forms ── */
  .form-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .form-row:last-child { border-bottom: none; }
  .form-label { flex: 0 0 180px; font-size: 13px; color: var(--text); font-weight: 500; }
  .form-label small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
  .form-active-cell   { flex: 0 0 250px; }
  .form-backfill-cell { flex: 0 0 240px; }
  .model-warn { font-size: 14px; }
  :root { --amber: #f59e0b; }
  select, input[type="text"], input[type="email"] {
    background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
    color: var(--text); font-size: 13px; padding: 7px 10px; outline: none;
    transition: border-color .15s;
  }
  select:focus, input:focus { border-color: var(--accent); }
  select { min-width: 180px; cursor: pointer; }

  /* ── Buttons ── */
  .btn { border: none; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; padding: 8px 16px; transition: opacity .15s; }
  .btn:hover { opacity: .85; }
  .btn-primary { background: var(--accent); color: #fff; }
  .btn-danger { background: var(--red); color: #fff; }
  .btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
  .btn-sm { padding: 5px 11px; font-size: 12px; }
  .btn:disabled { opacity: .4; cursor: not-allowed; }

  /* ── Table ── */
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  th { text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .6px; text-transform: uppercase; padding: 8px 12px; border-bottom: 1px solid var(--border); }
  td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
  tr:last-child td { border-bottom: none; }
  tr:hover td { background: var(--surface2); }
  .badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
  .badge-active { background: rgba(52,211,153,.15); color: var(--green); }
  .badge-inactive { background: rgba(248,113,113,.15); color: var(--red); }
  .badge-ok { background: rgba(52,211,153,.15); color: var(--green); }
  .badge-missing { background: rgba(248,113,113,.15); color: var(--red); }
  .badge-disabled { background: rgba(251,191,36,.15); color: var(--yellow); }

  /* ── Status card ── */
  .status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
  .status-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
  .status-card-name { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
  .status-card-value { font-size: 14px; color: var(--text); font-weight: 500; }
  .status-card-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }

  /* ── Prompt viewer ── */
  .prompt-select-row { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
  .prompt-content { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 16px; font-family: 'Cascadia Code', 'Fira Code', monospace; font-size: 12px; color: var(--code); white-space: pre-wrap; word-break: break-word; max-height: 520px; overflow-y: auto; }

  /* ── Toast ── */
  #toast { position: fixed; top: 20px; right: 20px; padding: 12px 20px; border-radius: 8px; font-size: 13px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 1000; }
  #toast.show { opacity: 1; }
  #toast.success { background: rgba(52,211,153,.9); color: #0a1a12; }
  #toast.error { background: rgba(248,113,113,.9); color: #1a0a0a; }

  /* ── Loading spinner ── */
  .spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
  @keyframes spin { to { transform: rotate(360deg); } }
  .loading-row { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }

  /* ── Modal ── */
  .modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 500; align-items: center; justify-content: center; }
  .modal-backdrop.open { display: flex; }
  .modal { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 24px; width: 420px; max-width: 95vw; }
  .modal-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
  .modal-field { margin-bottom: 12px; }
  .modal-field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
  .modal-field input { width: 100%; }
  .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

  /* ── Autocomplete ── */
  .ac-wrap { position: relative; display: inline-block; }
  .ac-list { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface2); border: 1px solid var(--accent); border-radius: 6px; z-index: 200; max-height: 180px; overflow-y: auto; margin-top: 2px; min-width: 180px; }
  .ac-item { padding: 7px 11px; font-size: 13px; cursor: pointer; color: var(--text); white-space: nowrap; }
  .ac-item:hover, .ac-item.active { background: rgba(79,126,248,.2); color: var(--accent); }

  /* ── Agent models save row ── */
  .models-save-row { display: flex; justify-content: flex-end; padding-top: 14px; }

  /* ── Owner autocomplete (Lägg till säljare) ── */
  .oa-wrap { position: relative; width: 220px; }
  .oa-input { width: 100%; box-sizing: border-box; padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-size: 12px; outline: none; transition: border-color .15s; }
  .oa-input:focus { border-color: var(--accent); }
  .oa-dropdown { position: absolute; left: 0; right: 0; top: calc(100% + 3px); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 300; max-height: 220px; overflow-y: auto; }
  .oa-item { padding: 8px 12px; cursor: pointer; font-size: 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
  .oa-item:last-child { border-bottom: none; }
  .oa-item:hover, .oa-item.selected { background: var(--surface2); }
  .oa-meta { font-size: 11px; color: var(--muted); }
  .oa-empty { padding: 9px 12px; font-size: 12px; color: var(--muted); }
  .oa-chip { display: flex; align-items: center; gap: 6px; padding: 4px 10px; background: rgba(79,126,248,.12); border: 1px solid rgba(79,126,248,.3); border-radius: 6px; font-size: 12px; max-width: 220px; }
  .oa-chip-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; min-width: 0; }
  .oa-chip-meta { font-size: 10px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
  .oa-chip-clear { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; flex-shrink: 0; }
  .oa-chip-clear:hover { color: var(--red); }
