/* Title Drift - design tokens */
:root {
  --bg:        #f7f8fa;
  --surface:   #ffffff;
  --surface-2: #fbfcfd;
  --ink:       #0f172a;
  --ink-2:     #475569;
  --ink-3:     #94a3b8;
  --line:      #e2e8f0;
  --line-2:    #cbd5e1;
  --accent:    #2563eb;
  --accent-d:  #1d4ed8;
  --accent-bg: #eff6ff;
  --ok:        #047857;
  --ok-bg:     #ecfdf5;
  --warn:      #b45309;
  --warn-bg:   #fffbeb;
  --err:       #b91c1c;
  --err-bg:    #fef2f2;
  --radius:    10px;
  --shadow:    0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
  --shadow-lg: 0 4px 6px -1px rgba(15,23,42,.07), 0 10px 24px -4px rgba(15,23,42,.10);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 Geist, ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-d); text-decoration: underline; }
h1, h2, h3 { letter-spacing: -.022em; }

/* ---------------------------------------------------------------- layout */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 0 28px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 9px; font-weight: 640; color: var(--ink);
        font-size: 15px; margin-right: 14px; }
.logo:hover { text-decoration: none; }
.logo .logomark { width: 25px; height: 25px; flex: none; }
.topnav { display: flex; gap: 2px; }
.topnav a {
  padding: 6px 11px; border-radius: 7px; color: var(--ink-2);
  font-size: 14px; font-weight: 500;
}
.topnav a:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.topnav a.on { background: var(--accent-bg); color: var(--accent-d); }
.grow { flex: 1; }

/* ------------------------------------------------- header: balance + user */
.creditpill {
  display: inline-flex; align-items: center; gap: 7px; margin-right: 10px;
  padding: 5px 11px 5px 9px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-2); font-size: 13px; line-height: 1; background: var(--surface);
}
.creditpill:hover { border-color: var(--accent); color: var(--accent-d);
                    background: var(--accent-bg); text-decoration: none; }
.creditpill svg { width: 15px; height: 15px; flex: none; opacity: .75; }
.creditpill b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.creditpill:hover b { color: var(--accent-d); }
.creditpill span { color: var(--ink-3); }
.creditpill.low { border-color: var(--warn); background: var(--warn-bg, transparent); }
.creditpill.low b, .creditpill.low svg { color: var(--warn); opacity: 1; }
.creditpill.low:hover { border-color: var(--warn); background: var(--warn-bg, transparent); }
.creditpill.low:hover b { color: var(--warn); }

.usermenu { position: relative; }
.usermenu > summary {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 4px;
  border-radius: 9px; cursor: pointer; list-style: none; user-select: none;
}
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu > summary:hover { background: var(--bg); }
.usermenu[open] > summary { background: var(--bg); }
.usermenu > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 640;
  letter-spacing: .01em; background: var(--accent-bg); color: var(--accent-d);
}
.who { display: grid; line-height: 1.25; text-align: left; min-width: 0; }
.who b { font-size: 13px; font-weight: 570; color: var(--ink); }
.who > span { font-size: 11.5px; color: var(--ink-3); overflow: hidden;
              text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }
.chev { width: 14px; height: 14px; flex: none; color: var(--ink-3);
        transition: transform .15s ease; }
.usermenu[open] .chev { transform: rotate(180deg); }

.usermenu .menu {
  position: absolute; right: 0; top: calc(100% + 7px); min-width: 244px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  box-shadow: 0 12px 34px -10px rgba(15, 23, 42, .28); padding: 5px; z-index: 40;
}
.menu-head { padding: 9px 10px 10px; border-bottom: 1px solid var(--line);
             margin-bottom: 5px; line-height: 1.3; }
.menu-head b { display: block; font-size: 12.5px; font-weight: 570;
               overflow: hidden; text-overflow: ellipsis; }
.menu-head span { font-size: 11.5px; color: var(--ink-3); }
.usermenu .menu a, .usermenu .menu button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: 7px; border: 0; background: none;
  font: inherit; font-size: 13.5px; color: var(--ink-2); text-align: left; cursor: pointer;
}
.usermenu .menu a:hover, .usermenu .menu button:hover {
  background: var(--bg); color: var(--ink); text-decoration: none; }
.usermenu .menu svg { width: 15px; height: 15px; flex: none; opacity: .7; }
.usermenu .menu em { margin-left: auto; font-style: normal; font-size: 12px;
                     color: var(--ink-3); font-variant-numeric: tabular-nums; }
.usermenu .menu form { margin: 5px -5px -5px; padding: 5px;
                       border-top: 1px solid var(--line); }

.page { max-width: 1760px; margin: 22px auto 48px; padding: 0 28px; }
.page.narrow { max-width: 400px; margin-top: 10vh; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.page-head h1 { font-size: 21px; margin: 0 0 3px; }
.page-head p { margin: 0; color: var(--ink-2); font-size: 14px; }
.split { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: start; }
/* mapping screen: settings + preview side by side on wide displays */
/* Mapping screen: columns | settings | preview.
   Under 1400px the preview drops to a full-width row of its own. */
.split.wide { grid-template-columns: 300px minmax(0, 1fr); }
.split.wide > :nth-child(3) { grid-column: 1 / -1; }
@media (min-width: 1400px) {
  .split.wide { grid-template-columns: 290px 430px minmax(0, 1fr); }
  .split.wide > :nth-child(3) { grid-column: auto; }
}
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- surfaces */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px;
}
.card > .hd {
  padding: 12px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.card > .hd h2 { font-size: 14px; margin: 0; font-weight: 600; }
.card > .hd .sub { font-size: 13px; color: var(--ink-3); }
.card > .bd { padding: 17px 18px; }
.card > .bd.tight { padding: 0; }
.card.accent { border-color: #fcd34d; background: var(--warn-bg); }

/* ---------------------------------------------------------------- forms */
label.field, .field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 550; color: var(--ink-2);
                     margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=file], select, textarea {
  width: 100%; padding: 8px 11px; font: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.13);
}
input[type=file] { padding: 7px 10px; background: var(--surface-2); cursor: pointer; }
input.mini { width: 76px; padding: 5px 8px; font-size: 13px; }
.hint { font-size: 12.5px; color: var(--ink-3); margin: -7px 0 12px; line-height: 1.4; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label.checkbox { display: flex; gap: 8px; align-items: center; font-size: 14px;
                 color: var(--ink-2); margin-bottom: 16px; cursor: pointer; }
label.checkbox input { width: auto; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 14px; font-weight: 550; line-height: 1;
  padding: 9px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  transition: background .12s, border-color .12s;
}
button:hover, .btn:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.btn.primary, button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn.primary:hover, button.primary:hover { background: var(--accent-d); color: #fff; }
.btn.danger, button.danger { color: var(--err); border-color: #fecaca; }
.btn.danger:hover, button.danger:hover { background: var(--err-bg); }
.btn.sm, button.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
button.linkish { border: none; background: none; color: var(--ink-2); padding: 6px 10px;
                 font-weight: 500; font-size: 14px; }
button.linkish:hover { background: var(--bg); color: var(--ink); }
form.inline { display: inline-flex; }
.btnrow { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }

/* ---------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .045em; color: var(--ink-3); padding: 9px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px;
           vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.dim { opacity: .55; }
td.tight { width: 1%; white-space: nowrap; }
.filecell { display: flex; flex-direction: column; gap: 3px; min-width: 210px; }
.filecell a, .filecell > b {
  font-weight: 550; color: var(--ink); display: block; max-width: 300px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.filecell a:hover { color: var(--accent); text-decoration: none; }
.filecell .meta { font-size: 12.5px; color: var(--ink-3); white-space: nowrap;
                  display: flex; align-items: center; gap: 7px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11.5px;
       font-weight: 550; background: #eef2ff; color: #4338ca; white-space: nowrap; }
.tablewrap { overflow-x: auto; }

/* ---------------------------------------------------------------- status */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 7px; border-radius: 20px; font-size: 12.5px; font-weight: 550;
  background: #f1f5f9; color: var(--ink-2); white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.running   { background: var(--accent-bg); color: var(--accent-d); }
.pill.running::before { animation: pulse 1.4s ease-in-out infinite; }
.pill.done      { background: var(--ok-bg);   color: var(--ok); }
.pill.queued    { background: var(--warn-bg); color: var(--warn); }
.pill.failed    { background: var(--err-bg);  color: var(--err); }
.pill.cancelled { background: #f1f5f9;        color: var(--ink-2); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.track { background: #e8edf3; border-radius: 20px; height: 6px; overflow: hidden; min-width: 96px; }
.track.tall { height: 9px; }
.track i { display: block; height: 100%; border-radius: 20px; background: var(--accent);
           transition: width .5s ease; }
.track.is-done i { background: var(--ok); }
.progresscell { display: flex; flex-direction: column; gap: 5px; min-width: 130px; }
.progresscell .num { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 12px; }
.stat { border: 1px solid var(--line); border-radius: 9px; padding: 13px 15px; background: var(--surface-2); }
.stat .n { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums;
           letter-spacing: -.02em; line-height: 1.15; }
.stat .k { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.stat.good .n { color: var(--ok); }
.stat.bad  .n { color: var(--err); }
.stat.warn .n { color: var(--warn); }

.meter { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.meter b { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.meter span { font-size: 13px; color: var(--ink-3); }

/* ---------------------------------------------------------------- misc */
.notice { padding: 11px 15px; border-radius: 9px; margin-bottom: 16px; font-size: 14px;
          border: 1px solid transparent; }
.notice.ok  { background: var(--ok-bg);  color: var(--ok);  border-color: #a7f3d0; }
.notice.err { background: var(--err-bg); color: var(--err); border-color: #fecaca; }
.notice.info { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.notice.warn { background: var(--warn-bg); color: var(--warn); border-color: #fed7aa; }
.empty { padding: 44px 20px; text-align: center; color: var(--ink-3); }
.empty p { margin: 0 0 4px; }
.empty .big { font-size: 15px; color: var(--ink-2); font-weight: 550; }
.muted { color: var(--ink-2); }
.dim3 { color: var(--ink-3); }
.sm { font-size: 13px; }
.xs { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.mono { font-family: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
        font-feature-settings: "tnum" 1; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
          font-size: 16px; letter-spacing: .05em; background: var(--surface);
          border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 12px;
          display: inline-block; user-select: all; }
.back { display: inline-block; font-size: 13.5px; color: var(--ink-2); margin-bottom: 14px; }
.back:hover { color: var(--accent); text-decoration: none; }
.kv { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 13px; color: var(--ink-2); }
.kv div { display: flex; gap: 6px; }
.kv .k { color: var(--ink-3); }
.divider { height: 1px; background: var(--line); margin: 18px 0; }

.mkgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 5px;
  max-height: 340px; overflow-y: auto; padding: 3px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2);
}
.mkgrid::-webkit-scrollbar { width: 9px; }
.mkgrid::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 9px;
                                   border: 3px solid var(--surface-2); }
.mk {
  display: flex; align-items: center; gap: 6px; padding: 4px 7px; cursor: pointer;
  border: 1px solid transparent; border-radius: 7px; background: var(--surface);
  min-width: 0;
}
.mk:hover { border-color: var(--line-2); }
.mk input { margin: 0; width: auto; flex: none; }
.mk .amz { width: 17px; height: 9px; flex: none; fill: #FF9900; }
.mk .mkname { min-width: 0; line-height: 1.1; }
.mk .mkname b { display: block; font-size: 12.5px; font-weight: 600;
                overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk .mkname b::before { content: "amazon"; color: var(--ink-3); font-weight: 500; }
.mk .mkname small { display: block; font-size: 10.5px; color: var(--ink-3);
                    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk:has(input:checked) { border-color: var(--accent); background: var(--accent-bg); }
.mk:has(input:checked) .mkname b { color: var(--accent-d); }

.fieldlabel { display: flex; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 550;
              color: var(--ink-2); margin-bottom: 7px; }
.fieldlabel em { font-style: normal; font-size: 12px; font-weight: 500; color: var(--accent-d);
                 background: var(--accent-bg); padding: 1px 7px; border-radius: 20px; }

.pill.waiting { background: var(--warn-bg); color: var(--warn); }
.pill.waiting::before { animation: pulse 2s ease-in-out infinite; }
.estimate { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2);
            padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
            background: var(--surface-2); margin-top: 2px; }
.estimate b { font-size: 15px; font-weight: 650; color: var(--ink); white-space: nowrap; }
.estimate .sep { color: var(--ink-3); }

textarea { width: 100%; padding: 8px 11px; font: inherit; font-size: 13px;
           font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
           border: 1px solid var(--line-2); border-radius: 8px; resize: vertical; }
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.13); }

td .btnrow { flex-wrap: nowrap; gap: 6px; }

/* credit balance */
.balance { display: flex; align-items: baseline; gap: 7px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  white-space: nowrap; }
.balance b { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.balance span { font-size: 13px; color: var(--ink-3); }
.balance a { font-size: 13px; margin-left: 4px; }
.balance.low { border-color: #fcd34d; background: var(--warn-bg); }
.balance.low b { color: var(--warn); }


a.balance { text-decoration: none; color: inherit; transition: border-color .12s, background .12s; }
a.balance:hover { border-color: var(--line-2); background: var(--surface-2); text-decoration: none; }
.balance .chev { color: var(--ink-3); font-size: 17px; line-height: 1; margin-left: 2px; }

/* ---------------------------------------------------------------- credits */
.packs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.pack { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
        background: var(--surface); position: relative; display: flex; flex-direction: column; }
.pack.featured { border-color: var(--accent); box-shadow: 0 8px 26px -12px rgba(37,99,235,.32); }
.pack .tag:empty { display: none; }
.pack .tag { position: absolute; top: -10px; left: 20px; background: var(--accent); color: #fff;
             font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px;
             white-space: nowrap; }
.pack header { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.pack h3 { font-size: 14.5px; margin: 0; }
.pack .save { font-size: 11.5px; font-weight: 600; color: var(--ok); background: var(--ok-bg);
              padding: 2px 8px; border-radius: 20px; }
.pack .qty { margin: 14px 0 0; font-size: 13.5px; color: var(--ink-3); }
.pack .qty b { display: block; font-size: 30px; font-weight: 650; color: var(--ink);
               letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.pack .rate { margin: 10px 0 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em;
              font-variant-numeric: tabular-nums; }
.pack .rate span { font-size: 12.5px; font-weight: 400; color: var(--ink-3); }
.packline { height: 1px; background: var(--line); margin: 16px 0 14px; }
.pack .blurb { margin: 0 0 16px; font-size: 13.5px; color: var(--ink-2); flex: 1; }
.pack .btn.block { display: block; width: 100%; text-align: center; font-size: 15px;
                   padding: 11px 16px; font-weight: 600; }
@media (max-width: 780px) { .packs { grid-template-columns: 1fr; } }

.reassure { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px 28px;
            margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.reassure div { font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.reassure b { display: block; color: var(--ink); font-size: 13.5px; font-weight: 600;
              margin-bottom: 3px; }
@media (max-width: 900px) { .reassure { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .reassure { grid-template-columns: 1fr; } }

.est { display: block; margin: 0 0 20px; padding: 14px 18px;
       border: 1px solid var(--line); border-radius: var(--radius);
       background: var(--surface); }
.est-row { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.est-row label { font-size: 12px; color: var(--ink-3); display: grid; gap: 5px; }
.est-row input { width: 116px; padding: 7px 10px; font: inherit; font-size: 15px;
                 font-variant-numeric: tabular-nums; border: 1px solid var(--line);
                 border-radius: 8px; background: var(--surface); color: var(--ink); }
.est-row input:focus { outline: 2px solid var(--accent); outline-offset: -1px;
                       border-color: transparent; }
.est-row .op { font-size: 15px; color: var(--ink-3); padding-bottom: 9px; }
.est-out { margin: 0 0 7px; font-size: 12.5px; color: var(--ink-3); }
.est-out b { font-size: 21px; color: var(--ink); font-weight: 650; letter-spacing: -.02em;
             font-variant-numeric: tabular-nums; margin-right: 5px; }
.est-hint { margin: 0 0 9px auto; font-size: 13px; color: var(--ink-2); text-align: right; }
.est-hint.ok { color: var(--ok); }
@media (max-width: 640px) {
  .est-row input { width: 100%; }
  .est-row label { flex: 1 1 40%; }
  .est-row .op { display: none; }
  .est-hint { margin: 0; text-align: left; flex: 1 1 100%; }
  .est-out { flex: 1 1 100%; }
}

/* --------------------------------------------------------------- mobile ---
   the topbar packs logo + nav + email + sign-out; on a phone the email is what
   overflows, and it is the one item the reader already knows. */
@media (max-width: 820px) {
  .topbar { padding: 0 14px; gap: 6px; }
  .logo { margin-right: 6px; font-size: 14.5px; }
  .topnav { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav a { padding: 6px 9px; white-space: nowrap; }
  .logo { white-space: nowrap; }
  .who { display: none; }
  .creditpill { margin-right: 6px; padding: 5px 9px; }
  .creditpill span { display: none; }
  .page { padding: 0 14px; }
}
/* below this the wordmark costs more room than the nav can spare */
@media (max-width: 560px) {
  .logo { font-size: 0; margin-right: 2px; }
  .logo .logomark { width: 26px; height: 26px; }
  .chev { display: none; }
}
