/* RainTech Portal — one stylesheet, no framework, no web fonts.
   Self-hosted everything: the CSP forbids third-party origins, and a
   portal that fetches a font from a CDN tells that CDN who signs in and
   when. */

:root {
  --bg:              #f4f6f9;
  --surface:         #ffffff;
  --surface-2:       #f8fafc;
  --border:          #dde3ea;
  --border-strong:   #c3ccd8;
  --text:            #161b22;
  --text-dim:        #5b6672;
  --text-faint:      #8a95a3;
  --accent:          #1f5fd0;
  --accent-hover:    #1a4fb0;
  --accent-soft:     #e8f0fd;
  --danger:          #b3261e;
  --danger-soft:     #fdeceb;
  --warn:            #8a5a00;
  --warn-soft:       #fdf4e3;
  --ok:              #1a6b3c;
  --ok-soft:         #e7f5ec;

  --app-sp2sp:       #1f6f8b;
  --app-od2od:       #2563a8;
  --app-exch:        #0f6f4f;
  --app-teams:       #5b4bb5;
  --app-dbx2sp:      #1d6fb8;
  --app-sp2az:       #0f7b8a;
  --app-sp2blob:     #3d5fa8;
  --app-bots:        #b3261e;
  --app-onenote:     #8a3b91;
  --app-forms:       #9a5b1f;
  --app-fs2sp:       #3b6e8f;
  --app-fs2az:       #0b72b9;

  --radius:          10px;
  --radius-sm:       6px;
  --shadow:          0 1px 2px rgba(16,24,40,.05),
                     0 4px 16px rgba(16,24,40,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0f1216;
    --surface:       #171b21;
    --surface-2:     #1d222a;
    --border:        #2a313b;
    --border-strong: #3a434f;
    --text:          #e6eaf0;
    --text-dim:      #a3adba;
    --text-faint:    #76808d;
    --accent:        #4d8ef7;
    --accent-hover:  #6ba1f8;
    --accent-soft:   #16233a;
    --danger:        #f2837c;
    --danger-soft:   #2c1a19;
    --warn:          #e0b062;
    --warn-soft:     #2a2317;
    --ok:            #62c48d;
    --ok-soft:       #15271d;
    --shadow:        0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── layout ─────────────────────────────────────────────── */
.wrap { max-width: 1060px; margin: 0 auto; padding: 28px 20px 64px; }
.narrow { max-width: 460px; margin: 0 auto; padding: 48px 20px 64px; }
.centered {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}

/* ── top bar ────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; color: var(--text); font-weight: 500;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand b { font-weight: 650; }
/* The logo: RAIN/TECH over PORTAL on the RainTech navy, as the tools'
   headers show it. Fixed colours: it is the brand, not the theme. */
.rt-logo {
  display: inline-flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1px; line-height: 1; flex: none;
  padding: 4px 11px 5px; border-radius: 7px;
  background: #001647; border: 1px solid rgba(139, 219, 2, .35);
}
.brand:hover .rt-logo, .brand:focus-visible .rt-logo {
  border-color: #8BDB02;
}
.rt-logo-cloud { width: 46px; height: 8px; display: block; }
.rt-logo-name { font: 700 14px/1 var(--font); letter-spacing: .12em; }
.rt-logo-rain { color: #F7F7FF; }
.rt-logo-tech { color: #8BDB02; }
.rt-logo-sub {
  font: 600 9px/1 var(--font); color: #F7F7FF; opacity: .9;
  letter-spacing: .42em; padding-left: .42em;
}
.rt-logo-large { padding: 7px 15px 8px; border-radius: 9px; }
.rt-logo-large .rt-logo-cloud { width: 62px; height: 11px; }
.rt-logo-large .rt-logo-name { font-size: 19px; }
.rt-logo-large .rt-logo-sub { font-size: 11.5px; }
.topnav { display: flex; gap: 20px; flex: 1; font-size: 14px; }
.topnav a { color: var(--text-dim); }
.topnav a:hover { color: var(--text); text-decoration: none; }
.topuser { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.whoami { display: flex; align-items: center; gap: 8px; color: var(--text); }
.whoami-name { max-width: 200px; overflow: hidden;
               text-overflow: ellipsis; white-space: nowrap; }
.chip {
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  padding: 2px 7px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid transparent;
}

/* ── cards and panels ───────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.card + .card { margin-top: 20px; }
.card h2 { margin: 0 0 4px; font-size: 17px; font-weight: 640; }
.card h2 + .sub { margin-top: 0; }

.page-head { margin: 0 0 22px; }
.page-head h1 { margin: 0 0 4px; font-size: 22px; font-weight: 650;
                letter-spacing: -.01em; }
.sub { margin: 0 0 20px; color: var(--text-dim); font-size: 14px; }

/* ── forms ──────────────────────────────────────────────── */
label { display: block; font-size: 13px; font-weight: 560;
        margin: 0 0 6px; color: var(--text); }
.field { margin-bottom: 16px; }
.hint { font-size: 12.5px; color: var(--text-faint); margin: 5px 0 0; }

input[type=text], input[type=email], input[type=password],
input[type=url], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px;
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 84px; font-family: var(--mono); font-size: 13px;
           resize: vertical; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 9px 16px;
  font: inherit; font-weight: 560; line-height: 1.2;
  color: #fff; background: var(--accent);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .12s;
}
button:hover, .btn:hover { background: var(--accent-hover);
                           text-decoration: none; }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-secondary {
  background: var(--surface); color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #8f1e17; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.linkish {
  background: none; border: none; color: var(--text-dim);
  padding: 0; font: inherit; cursor: pointer;
}
.linkish:hover { background: none; color: var(--text);
                 text-decoration: underline; }
.inline { display: inline; }

/* ── flashes ────────────────────────────────────────────── */
.flashes { margin-bottom: 20px; display: grid; gap: 8px; }
.flash {
  padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 14px; border: 1px solid transparent;
}
.flash-error   { background: var(--danger-soft); color: var(--danger);
                 border-color: currentColor; }
.flash-success { background: var(--ok-soft); color: var(--ok);
                 border-color: currentColor; }
.flash-warning { background: var(--warn-soft); color: var(--warn);
                 border-color: currentColor; }
.flash-info    { background: var(--accent-soft); color: var(--accent);
                 border-color: currentColor; }

.notice {
  padding: 13px 15px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13.5px; color: var(--text-dim); margin: 0 0 18px;
}
.notice strong { color: var(--text); }
.notice-warn { background: var(--warn-soft); border-color: var(--warn);
               color: var(--warn); }
.notice-warn strong { color: var(--warn); }

/* ── the launcher grid ──────────────────────────────────── */
.app-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
}
.app-card {
  position: relative; display: flex; flex-direction: column;
  padding: 20px; min-height: 172px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
a.app-card:hover {
  text-decoration: none; transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 2px 4px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.10);
}
.app-card.locked { opacity: .62; }
.app-icon {
  width: 38px; height: 38px; border-radius: 9px;
  display: grid; place-items: center; margin-bottom: 13px;
  background: var(--tint, var(--accent-soft));
}
.app-icon svg { width: 21px; height: 21px; }
.app-card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 620; }
.app-card p { margin: 0; font-size: 13px; color: var(--text-dim);
              line-height: 1.5; }
.app-foot {
  margin-top: auto; padding-top: 14px; font-size: 12px;
  color: var(--text-faint); display: flex; align-items: center; gap: 8px;
}
/* A heading for a grid of its own below the launcher (the file server
   agents), set like a card's. */
.section-head h2 { margin: 0 0 4px; font-size: 17px; font-weight: 640; }
.section-head .sub { margin-bottom: 14px; }
.badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 99px; border: 1px solid var(--border-strong);
  color: var(--text-dim); background: var(--surface-2);
}
.badge-soon { }
.badge-locked { color: var(--warn); border-color: var(--warn);
                background: var(--warn-soft); }
.badge-ready { color: var(--ok); border-color: var(--ok);
               background: var(--ok-soft); }

/* ── tables ─────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 12px; font-weight: 620;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); padding: 0 12px 9px; white-space: nowrap;
}
td { padding: 11px 12px; border-top: 1px solid var(--border);
     vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ── misc ───────────────────────────────────────────────── */
.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 22px 0; color: var(--text-faint); font-size: 12.5px;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.codes {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin: 18px 0; padding: 18px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 14px; letter-spacing: .04em;
}
.secret-box {
  padding: 14px; margin: 14px 0; word-break: break-all;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 13px;
  /* One click selects the whole value. A secret holds - and _, and a
     double-click stops at the first -, so copying by hand lost part of
     it and the tool's credentials were then refused. */
  user-select: all; -webkit-user-select: all; cursor: text;
}
.qr { display: grid; place-items: center; padding: 18px;
      background: #fff; border-radius: var(--radius-sm);
      border: 1px solid var(--border); margin: 16px 0; }
.qr svg { display: block; max-width: 200px; height: auto; }
.checks { display: grid; gap: 9px; margin: 6px 0 16px; }
.checks label {
  display: flex; align-items: center; gap: 9px; margin: 0;
  font-weight: 450; font-size: 14px; cursor: pointer;
}
.checks input { width: auto; }
.stack { display: grid; gap: 11px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between;
          align-items: center; gap: 16px; flex-wrap: wrap; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); font-size: 13px; }
.section-gap { margin-top: 30px; }
.err-page { text-align: center; padding: 72px 20px; }
.err-code { font-size: 46px; font-weight: 700; color: var(--text-faint);
            margin: 0 0 8px; letter-spacing: -.02em; }

/* ── customers and their tenants ────────────────────────── */
.crumb { margin: 0 0 8px; font-size: 13px; }
.sides {
  display: grid; gap: 20px; align-items: start;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.sides > .card + .card { margin-top: 0; }
.sides-form { gap: 16px; }
.side-card h2 { margin: 0; }
.side-card .sub { margin: 4px 0 14px; }
.kv {
  display: grid; grid-template-columns: max-content minmax(0, 1fr);
  gap: 7px 16px; margin: 0 0 16px; font-size: 14px;
}
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.stages {
  display: flex; gap: 6px; list-style: none; padding: 0;
  margin: 0 0 18px; counter-reset: stage; font-size: 12.5px;
}
.stages li {
  flex: 1; counter-increment: stage; color: var(--text-faint);
  padding-top: 8px; border-top: 3px solid var(--border);
}
.stages li::before { content: counter(stage) ". "; }
.stages li.past { color: var(--ok); border-top-color: var(--ok); }
.stages li.now {
  color: var(--accent); border-top-color: var(--accent); font-weight: 600;
}
.steps-list {
  list-style: none; padding: 0; margin: 0 0 16px;
  display: grid; gap: 9px; font-size: 14px;
}
.step { display: grid; grid-template-columns: 20px minmax(0, 1fr);
        gap: 9px; align-items: start; }
/* Each tool taking part in a run, with room for "go on without it". */
.tool-list {
  list-style: none; padding: 0; margin: 0 0 16px;
  display: grid; gap: 9px; font-size: 14px;
}
.tool-list .step { grid-template-columns: 20px minmax(0, 1fr) auto; }
.step-mark {
  width: 16px; height: 16px; margin-top: 2px; border-radius: 50%;
  border: 2px solid var(--border-strong);
}
.step-done .step-mark { background: var(--ok); border-color: var(--ok); }
.step-running .step-mark {
  border-color: var(--accent); border-right-color: transparent;
  animation: spin .9s linear infinite;
}
.step-failed .step-mark { background: var(--danger);
                          border-color: var(--danger); }
.step-warning .step-mark { background: var(--warn);
                           border-color: var(--warn); }
.step-pending { color: var(--text-faint); }
.step-detail { display: block; color: var(--text-faint); font-size: 12.5px;
               overflow-wrap: anywhere; }
.waiting { display: flex; gap: 10px; align-items: flex-start;
           color: var(--text-dim); font-size: 14px; }
.spinner {
  flex: none; width: 16px; height: 16px; margin-top: 2px;
  border-radius: 50%; border: 2px solid var(--accent);
  border-right-color: transparent; animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner, .step-running .step-mark { animation: none; }
}
.badge-bad { color: var(--danger); border-color: var(--danger);
             background: var(--danger-soft); }
.hint-list { margin: 0 0 16px; padding-left: 18px; font-size: 13.5px;
             color: var(--text-dim); display: grid; gap: 5px; }
.plain-steps { margin: 12px 0 0; padding-left: 20px; display: grid;
               gap: 9px; font-size: 14px; }
details.quiet { margin: 0 0 14px; font-size: 14px; }
details.quiet summary { cursor: pointer; color: var(--accent); }
details.quiet[open] summary { margin-bottom: 10px; }
details.explainer summary { cursor: pointer; }
.sides + .explainer { margin-top: 20px; }
table.compact td { padding: 7px 10px; }
.cmd {
  margin: 12px 0; padding: 14px; overflow-x: auto;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 13px; line-height: 1.5;
}
.card h3 { margin: 18px 0 6px; font-size: 14.5px; font-weight: 640; }

@media (max-width: 720px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .topnav { display: none; }
  .card { padding: 20px; }
  .codes { grid-template-columns: 1fr; }
  .sides { grid-template-columns: 1fr; }
}

/* ── a customer's deletion ──────────────────────────────── */
.hidden { display: none !important; }
.notice-ok { background: var(--ok-soft); border-color: var(--ok);
             color: var(--ok); }
.notice-ok strong { color: var(--ok); }
.tick { color: var(--ok); font-weight: 700; }
.cross { color: var(--danger); font-weight: 700; }
.deletion-tools { list-style: none; padding: 0; margin: 0; display: grid;
                  gap: 14px; }
.deletion-tools [data-state] { display: flex; align-items: center; gap: 7px;
                               margin-top: 4px; }
.deletion-tools .spinner { margin-top: 0; }

/* ── a domain swap (the customer page's Domain swapped card) ── */
#domain-swap h3 { margin: 0; }
#domain-swap > .spread { margin: 0 0 10px; }
.swap-tools { margin: 0 0 16px; }
.swap-tools details.quiet { margin: 6px 0 0; font-size: 13px; }
.swap-addresses { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px;
                  overflow-wrap: anywhere; }
table.swap-domains { width: auto; min-width: 320px; margin: 0 0 4px; }
.swap-domains td { vertical-align: middle; }
.swap-domains input { width: auto; margin: 0; }
.swap-domains label { margin: 0; font-weight: 450; }

/* ── the File server card (fileserver_web) ─────────────── */
.fs-job { border-top: 1px solid var(--border); padding: 12px 0; }
.fs-job-head { display: flex; gap: 10px; align-items: baseline;
               flex-wrap: wrap; }
.fs-route { margin: 4px 0 6px; word-break: break-all; }
.fs-run { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
          font-size: 13px; }
.fs-access { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
             margin: 0 0 8px; font-size: 13px; }
.fs-access .hint { flex-basis: 100%; margin: 0; }
.fs-bar { display: inline-block; width: 160px; height: 8px;
          border-radius: 4px; background: var(--surface-2);
          border: 1px solid var(--border); overflow: hidden; }
.fs-bar span { display: block; height: 100%; background: var(--accent); }
.fs-bar span.fs-bar-moving { width: 30% !important;
  animation: fs-slide 1.4s ease-in-out infinite; }
@keyframes fs-slide { from { margin-left: -30%; } to { margin-left: 100%; } }
@media (prefers-reduced-motion: reduce) {
  .fs-bar span.fs-bar-moving { animation: none; } }
.fs-pct { font-weight: 600; font-size: 13px; }
.fs-actions { display: flex; gap: 8px; align-items: flex-start;
              flex-wrap: wrap; margin-top: 8px; }
.fs-edit { flex-basis: 100%; }
.fs-grid { display: grid; gap: 0 16px;
           grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.fs-grid .fs-wide { grid-column: 1 / -1; }
.fs-checks { display: grid; gap: 6px; margin: 4px 0 14px; font-size: 14px; }
.fs-history { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.fs-code { font-size: 30px; letter-spacing: .12em; font-weight: 650;
           margin: 4px 0 16px; }
/* A panel per kind of agent, inside #fileserver, with what it copied. */
#fileserver { margin-top: 20px; }
.fs-usage { display: grid; gap: 10px; margin: 0 0 16px;
            grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.fs-usage-cell { display: flex; flex-direction: column; gap: 2px;
                 padding: 10px 12px; border: 1px solid var(--border);
                 border-radius: 8px; background: var(--surface-2);
                 font-size: 13px; }
.fs-usage-cell strong { font-size: 18px; }

/* The usage pages (usage_web): figures right-aligned. */
.usage-table td.num, .usage-table th.num { text-align: right;
                                           white-space: nowrap; }
.usage-table tfoot td { font-weight: 650; border-top: 2px solid var(--border); }
.usage-filters { display: flex; gap: 10px; flex-wrap: wrap;
                 align-items: flex-end; margin: 0 0 16px; }
.usage-filters label { display: flex; flex-direction: column; gap: 4px;
                       font-size: 13px; }
