:root {
  --ink: #0b1220;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --surface: #f8fafc;
  --card: #ffffff;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #eff4ff;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --bad: #b91c1c;
  --bad-soft: #fef2f2;
  --header: #0b1220;
  --header-ink: #e2e8f0;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e5e7eb;
    --ink-2: #cbd5e1;
    --muted: #94a3b8;
    --line: #1f2937;
    --line-2: #334155;
    --surface: #0b1020;
    --card: #111827;
    --accent: #6d94ff;
    --accent-ink: #0b1220;
    --accent-soft: #172447;
    --ok: #34d399;
    --ok-soft: #062b20;
    --warn: #fbbf24;
    --warn-soft: #2b2006;
    --bad: #f87171;
    --bad-soft: #2b0b0b;
    --header: #05080f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--surface); }
h2 { font-size: 16px; margin: 0 0 8px; }
h3 { font-size: 13px; margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
p { margin: 0 0 10px; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--accent-soft); padding: 1px 4px; border-radius: 4px; }
.muted, .hint { color: var(--muted); }
.hint { margin: 0; font-size: 13px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 0 20px;
  height: 52px; background: var(--header); color: var(--header-ink); }
.brand { font-weight: 700; letter-spacing: .02em; }
.brand span { font-weight: 400; opacity: .7; }
.tabs { display: flex; gap: 4px; }
.tabs button { background: none; border: 0; color: var(--header-ink); opacity: .7; padding: 8px 12px; border-radius: 6px;
  font: inherit; cursor: pointer; }
.tabs button:hover { opacity: 1; background: rgba(255, 255, 255, .06); }
.tabs button.active { opacity: 1; background: rgba(255, 255, 255, .12); }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: rgba(255, 255, 255, .16);
  font-size: 11px; text-align: center; }
.badge:empty { display: none; }


main { padding: 16px 20px 40px; }
.tab { display: none; }
.tab.active { display: block; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.spacer { flex: 1; }
input[type=search], input[type=text], input[type=email], input[type=number], select, textarea {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line-2); border-radius: 6px;
  padding: 7px 10px; }
input[type=search] { min-width: 280px; }
input[type=number] { width: 64px; }
textarea { width: 100%; resize: vertical; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button, .button { font: inherit; font-weight: 600; border-radius: 6px; padding: 7px 12px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; }
button:disabled { opacity: .5; cursor: default; }
button.secondary, .button.secondary { background: var(--card); color: var(--ink); border-color: var(--line-2); }
button.link { background: none; border-color: transparent; color: var(--accent); padding: 7px 6px; font-weight: 500; }
button.small, .button.small { padding: 4px 8px; font-size: 12px; }
button.danger { background: var(--card); color: var(--bad); border-color: var(--line-2); }

.bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 12px;
  background: var(--accent-soft); border: 1px solid var(--line-2); border-radius: var(--radius); }
.bulk[hidden] { display: none; }
.divider { width: 1px; height: 22px; background: var(--line-2); }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.table-wrap.small { max-height: 220px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); position: sticky; top: 0; }
td.check, th.check { width: 36px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--accent-soft); }
tbody tr.selected { background: var(--accent-soft); }
td .sub { display: block; color: var(--muted); font-size: 12px; }
#sample td, #sample th { white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; cursor: default; }
#sample tbody tr:hover { background: none; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

.chip { display: inline-block; margin: 0 4px 3px 0; padding: 1px 8px; border-radius: 10px; font-size: 12px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.chip.izuran_beta { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip.server_trial { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.status { font-weight: 600; font-size: 12px; }
.status.new { color: var(--accent); }
.status.invited, .status.in_beta, .status.customer { color: var(--ok); }
.status.do_not_contact, .status.not_now { color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.wide { grid-column: 1 / -1; }
.card label { display: block; margin: 0 0 10px; font-weight: 500; }
.card label > input, .card label > select, .card label > textarea { display: block; width: 100%; margin-top: 4px; font-weight: 400; }
.card label > input[type=number] { display: inline-block; width: 72px; margin: 0 4px; }
.card label > input[type=radio], .card label > input[type=checkbox] { display: inline; width: auto; margin: 0 6px 0 0; }
.nowrap { white-space: nowrap; }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.result { margin-top: 12px; padding: 10px 12px; border-radius: 6px; background: var(--ok-soft); color: var(--ok); }
.result.error { background: var(--bad-soft); color: var(--bad); }
.file input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file span { display: inline-block; padding: 9px 14px; border: 1px dashed var(--line-2); border-radius: 6px; cursor: pointer; }
.file:focus-within span { outline: 2px solid var(--accent); }
.options { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 12px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; margin: 0; }
fieldset label { display: block; font-weight: 400; margin: 2px 0; }
legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.mapping { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.mapping label { margin: 0; font-size: 13px; }
.state { display: flex; gap: 8px; align-items: baseline; margin-bottom: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--warn); }
pre.cmd { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 12px; overflow: auto; }
.about { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
.about dt { color: var(--muted); }
.about dd { margin: 0; word-break: break-all; }

.segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; background: var(--card); color: var(--ink); font-weight: 500; }
.segmented button.active { background: var(--accent); color: var(--accent-ink); }
.cards-list { display: grid; gap: 10px; }
.invite { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.invite-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; }
.invite-head strong { font-size: 15px; }
.invite .meta { color: var(--muted); font-size: 12px; }
.invite .buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.invite details { margin-top: 8px; }
.invite details pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface); padding: 10px; border-radius: 6px; border: 1px solid var(--line); margin: 6px 0 0; }
.tag-expired { color: var(--warn); font-weight: 600; }
.tag-sent { color: var(--ok); font-weight: 600; }

.drawer { position: fixed; top: 52px; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--card);
  border-left: 1px solid var(--line-2); box-shadow: -12px 0 32px rgba(15, 23, 42, .12); display: flex; flex-direction: column; z-index: 4; }
.drawer[hidden] { display: none; }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-head p { margin: 2px 0 0; }
.drawer-body { padding: 12px 18px 32px; overflow: auto; }
.drawer-body section { margin-bottom: 18px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.fields label { font-size: 12px; color: var(--muted); }
.fields input, .fields select { display: block; width: 100%; margin-top: 2px; color: var(--ink); }
.fields .full { grid-column: 1 / -1; }
.checks label { display: inline-flex; align-items: center; gap: 4px; margin-right: 12px; font-size: 13px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .kind { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-left: 6px; }
.timeline details { margin-top: 4px; font-size: 12px; }
.timeline pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0 0; font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.note-form { display: flex; gap: 6px; margin-top: 6px; }
.note-form input { flex: 1; }

dialog { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 18px; width: min(420px, 92vw);
  background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(15, 23, 42, .4); }
dialog label { display: block; margin-bottom: 10px; font-weight: 500; }
dialog label input { display: block; width: 100%; margin-top: 4px; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--surface);
  padding: 9px 14px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; max-width: 80vw; }
#toast.show { opacity: 1; }
#toast.error { background: var(--bad); color: #fff; }

@media (max-width: 760px) {
  .top { gap: 10px; padding: 0 12px; overflow-x: auto; }
  .who span { display: none; }
  main { padding: 12px; }
  input[type=search] { min-width: 0; width: 100%; }
  .options { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
}

/* Hosted: who is signed in, and the screen shown while signing in or when an account isn't allowed. */
.who { margin: 0 0 0 auto; display: flex; align-items: center; gap: 10px; font-size: 12px; opacity: .8; }
.who button.link { color: var(--header-ink); font-size: 12px; padding: 4px 6px; }
.gate { max-width: 440px; margin: 15vh auto 0; text-align: center; }
.gate p { color: var(--muted); }
body.signed-out main, body.signed-out .tabs, body.signed-out .who { display: none; }
body:not(.signed-out) .gate { display: none; }
.progress { color: var(--muted); font-size: 13px; }
