:root {
  /* Kosmos — deep space navy + electric blue (matches the brand graphics) */
  --bg: #070c1a;          /* deep space navy, near-black */
  --panel: #0f1730;       /* navy panel */
  --panel-2: #17233f;     /* raised / input navy */
  --border: #263659;      /* subtle navy border */
  --text: #e9eefc;        /* cool near-white */
  --muted: #93a3c9;       /* blue-grey */
  --accent: #2f6bff;      /* Kosmos electric blue — CTAs, highlights */
  --accent-2: #5b9bf5;    /* periwinkle (the logo star) — focus, links, pills */
  --green: #2ea043;
  --red: #da3633;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .2px; display: inline-flex; align-items: center; gap: 8px; }
.logo { color: var(--accent); margin-right: 6px; }
.logo-img { height: 24px; width: 24px; border-radius: 6px; display: block; }
.who { color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 4px; padding: 12px 24px 0; border-bottom: 1px solid var(--border); background: var(--panel); }
.tab {
  background: none; border: none; color: var(--muted); padding: 10px 16px; cursor: pointer;
  font-size: 14px; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

main { max-width: 900px; margin: 0 auto; padding: 28px 24px 80px; }
.panel { display: none; }
.panel.active { display: block; animation: fade .18s ease; }
/* Stacked widgets inside a panel (a toggle .row above a form .card, or two
   cards in a row) shouldn't touch. Applies as a top-margin so it composes
   naturally with .panel-head's own bottom margin. */
.panel > .row + .card,
.panel > .row + .row,
.panel > .card + .card,
.panel > .card + .row { margin-top: 14px; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel-head h2 { margin: 0 0 4px; font-size: 20px; }
.panel-head .sub { margin: 0 0 18px; color: var(--muted); }
/* Secondary heading within a panel (e.g. "Custom ASIN monitors" under Tasks). */
.panel-head.subhead { margin-top: 28px; }
.panel-head.subhead h2 { font-size: 16px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.field-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.card > .sub { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
/* labelled numeric inputs in a wrapping row (deal-feed filters) */
.filter-grid { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); flex: 1 1 130px; }
.filter-grid button { flex: 0 0 auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid button { grid-column: 1 / -1; }
.form-inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
/* Type dropdown stays compact; the value input fills the rest of the row.
   (Without this the select's width:100% starves the input to a tiny box.) */
.form-inline select { flex: 0 0 150px; width: auto; }
.form-inline input { flex: 1 1 160px; min-width: 0; }
.form-inline input[type="number"] { flex: 0 0 150px; }

input, select {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: 8px; font-size: 14px; width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent-2); }

.btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 10px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: rgba(218,54,51,.1); border-color: var(--red); }

.list { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
}
.row .main { flex: 1; min-width: 0; }
.row .email { font-weight: 600; }
.row .meta { color: var(--muted); font-size: 12px; margin-top: 2px; display: flex; gap: 12px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 20px; font-size: 11px; border: 1px solid var(--border); }
.pill.on { color: var(--green); border-color: rgba(46,160,67,.4); }
.pill.off { color: var(--muted); }
.pill.key { color: var(--accent-2); border-color: rgba(47,129,247,.35); }
.pill.type { color: var(--accent); border-color: rgba(255,153,0,.35); text-transform: uppercase; letter-spacing: .5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--panel-2); border: 1px solid var(--border); border-radius: 20px; cursor: pointer; transition: .15s; }
.slider::before { content: ""; position: absolute; height: 16px; width: 16px; left: 2px; top: 2px; background: var(--muted); border-radius: 50%; transition: .15s; }
.switch input:checked + .slider { background: rgba(46,160,67,.25); border-color: var(--green); }
.switch input:checked + .slider::before { transform: translateX(16px); background: var(--green); }

.empty { color: var(--muted); text-align: center; padding: 28px; border: 1px dashed var(--border); border-radius: var(--radius); }

/* activity tab */
.activity-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.activity-row .reason,
.row .main > .reason { color: var(--muted); font-size: 12px; margin-top: 6px; line-height: 1.4; }
.activity-row a { color: var(--text); text-decoration: none; }
.activity-row a:hover { color: var(--accent-2); }

#datastream-result { margin-top: 16px; }
.result { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: var(--panel); }
.result.skip { border-color: rgba(218,54,51,.4); }
.result.run { border-color: rgba(46,160,67,.4); }
.result .verdict { font-weight: 600; font-size: 15px; }
.result.skip .verdict { color: var(--red); }
.result.run .verdict { color: var(--green); }
.result .detail { color: var(--muted); margin-top: 6px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--red); }

/* modal popup (blocking alert) */
.modal-overlay { position: fixed; inset: 0; background: rgba(3, 6, 15, .66); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px; }
.modal-overlay[hidden] { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 26px; max-width: 400px; width: 100%; box-shadow: 0 24px 70px rgba(0, 0, 0, .55); }
.modal-card h3 { margin: 0 0 8px; font-size: 18px; }
.modal-card p { margin: 0 0 22px; color: var(--muted); line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; }

/* login page */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 36px 32px; width: 100%; max-width: 360px; text-align: center; }
.login-brand { font-size: 20px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.login-brand .logo-img { height: 44px; width: 44px; border-radius: 10px; }
.login-sub { color: var(--muted); margin: 8px 0 24px; }
.login-btn { display: block; width: 100%; text-decoration: none; padding: 12px; }
.login-error { background: rgba(218,54,51,.12); border: 1px solid var(--red); color: #ff9b98; border-radius: 8px; padding: 10px 12px; margin-bottom: 16px; font-size: 13px; }
.who { position: relative; }
/* Avatar + name button that opens the sign-out dropdown. */
.user-btn { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 4px 10px 4px 4px; border-radius: 999px; cursor: pointer; font-size: 13px; }
.user-btn:hover { border-color: var(--muted); }
.user-avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; background: var(--panel); flex: 0 0 auto; }
.user-btn .chev { color: var(--muted); flex: 0 0 auto; }
.user-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.user-dropdown { position: absolute; right: 0; top: calc(100% + 6px); min-width: 168px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 6px; box-shadow: 0 12px 30px rgba(0,0,0,.45); z-index: 50; }
.user-dropdown[hidden] { display: none; }
.user-dropdown-item { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 6px; color: var(--text); text-decoration: none; font: inherit; font-size: 14px; background: none; border: none; cursor: pointer; }
.user-dropdown-item:hover { background: var(--panel); }

/* landing page */
.lp-nav { display: flex; align-items: center; justify-content: space-between; padding: 18px 32px; max-width: 1060px; margin: 0 auto; }
.lp-nav .brand { font-weight: 700; font-size: 16px; }
.lp-nav .btn { text-decoration: none; }
.lp-hero { max-width: 720px; margin: 0 auto; padding: 72px 24px 48px; text-align: center; }
.lp-hero h1 { font-size: 44px; line-height: 1.08; letter-spacing: -0.5px; margin: 0 0 18px; }
.lp-hero h1 .accent { color: var(--accent); }
.lp-hero p { font-size: 18px; color: var(--muted); margin: 0 auto 28px; max-width: 560px; line-height: 1.6; }
.lp-hero .btn { text-decoration: none; display: inline-block; padding: 13px 28px; font-size: 15px; }
.lp-hero-note { margin-top: 14px; color: var(--muted); font-size: 13px; }
.lp-features { max-width: 1000px; margin: 0 auto; padding: 24px; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.feature { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 22px; }
.feature-icon { width: 38px; height: 38px; border-radius: 9px; background: var(--panel-2); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; color: var(--accent); }
.feature h3 { margin: 0 0 6px; font-size: 16px; }
.feature p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.lp-steps { max-width: 820px; margin: 44px auto; padding: 0 24px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; text-align: center; }
.lp-step .num { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.lp-step h4 { margin: 0 0 6px; font-size: 15px; }
.lp-step p { margin: 0; color: var(--muted); font-size: 13px; }
.lp-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 46px 24px 40px; border-top: 1px solid var(--border); margin-top: 36px; }
@media (max-width: 640px) { .lp-hero h1 { font-size: 32px; } .lp-steps { grid-template-columns: 1fr; } }
