:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #5d6576;
  --border: #d9dde5;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --error-bg: #fdecec;
  --error-text: #8a1c1c;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d;
    --card: #1d2129;
    --text: #e6e8ec;
    --muted: #9aa2b1;
    --border: #333a47;
    --accent: #6d8ff0;
    --accent-text: #0e1220;
    --error-bg: #3a1d1d;
    --error-text: #f4b4b4;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}

.card {
  width: 100%;
  max-width: 30rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  align-self: flex-start;
}

.brand {
  margin: 0 0 1rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted);
  text-transform: uppercase;
  font-size: .8rem;
}

h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
.lead { color: var(--muted); margin-top: 0; }

fieldset { border: 0; padding: 0; margin: 1.5rem 0; }
legend { font-weight: 600; margin-bottom: .5rem; }

label { display: block; margin: .75rem 0 .25rem; font-size: .9rem; }

input {
  width: 100%;
  padding: .6rem .7rem;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
}

input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

input + button { margin-top: 1rem; }

.hint { color: var(--muted); font-size: .85rem; margin: .4rem 0 0; }

.qr {
  display: flex;
  justify-content: center;
  margin: 1rem 0;
  padding: .5rem;
  background: #ffffff;
  border-radius: 8px;
}

.qr svg { width: 200px; height: 200px; }

details { margin: .5rem 0 1rem; font-size: .9rem; }
summary { cursor: pointer; color: var(--accent); }

.secret {
  display: block;
  margin-top: .5rem;
  padding: .5rem;
  font-size: .95rem;
  letter-spacing: .08em;
  word-break: break-all;
  border: 1px dashed var(--border);
  border-radius: 6px;
}

button {
  width: 100%;
  padding: .75rem;
  font: inherit;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.error {
  padding: .6rem .8rem;
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: 8px;
}

a { color: var(--accent); }

a.button {
  display: block;
  padding: .75rem;
  text-align: center;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent-text);
  background: var(--accent);
  border-radius: 8px;
}

button.secondary {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
}

/* console */

body.console { display: block; padding: 0; }

.bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: .75rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.bar .org { font-weight: 600; color: var(--text); text-decoration: none; }
.bar nav { display: flex; gap: 1rem; flex: 1; }
.bar nav a { color: var(--muted); text-decoration: none; padding: .25rem 0; }
.bar nav a.active { color: var(--text); border-bottom: 2px solid var(--accent); }

/* the app menu and the account menu, as in the webmail: details elements,
   since the pages run no script. */
.header-menus { display: flex; align-items: center; gap: .4rem; }
.menu-anchor { position: relative; }
.menu-anchor > summary { list-style: none; cursor: pointer; }
.menu-anchor > summary::-webkit-details-marker { display: none; }

.icon-button,
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--muted);
}

.icon-button:hover,
.menu-anchor[open] > .icon-button { background: var(--bg); color: var(--text); }

.avatar {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.avatar.large { width: 44px; height: 44px; font-size: 18px; flex-shrink: 0; }

.popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 14%);
  padding: 8px;
  font-size: .9rem;
}

.popover.apps { display: grid; grid-template-columns: repeat(3, 88px); gap: 4px; }

.popover .app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 4px;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
}

.popover .app-tile:hover,
.popover .app-tile.current { background: var(--bg); }

.popover .app-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

.popover.user { min-width: 260px; }

.user-card {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.user-card > div { min-width: 0; }
.user-email, .user-org { color: var(--muted); overflow-wrap: anywhere; }
.user-email { color: var(--text); }

.popover .menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  color: var(--text);
  background: none;
  font-weight: normal;
  text-align: left;
}

.popover .menu-item:hover { background: var(--bg); }
.popover a.menu-item { text-decoration: none; font-size: .9rem; }

button.link {
  width: auto;
  padding: 0;
  color: var(--accent);
  background: none;
  font-weight: normal;
}

main.wide { max-width: 60rem; margin: 2rem auto; padding: 0 1.5rem; }

form.inline {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1rem 0 1.5rem;
}

form.inline label { margin: 0; white-space: nowrap; }
form.inline input { max-width: 22rem; }
form.inline button { width: auto; padding: .6rem 1.2rem; margin-top: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); }
th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
td.actions { text-align: right; }
td.actions form { display: inline; }

button.small { width: auto; padding: .3rem .7rem; font-size: .85rem; }

.status {
  display: inline-block;
  padding: .1rem .5rem;
  font-size: .8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.status.active { color: #1d7a3a; border-color: #1d7a3a; }
.status.suspended { color: var(--error-text); border-color: var(--error-text); }
.status.problem { color: var(--error-text); border-color: var(--error-text); }

.check { margin: .75rem 0 1rem; }
.check-line { display: flex; align-items: center; gap: .6rem; margin: 0 0 .4rem; }
.check details { margin: 0; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
}

.panel h2 { font-size: 1.1rem; margin: 0 0 .5rem; display: flex; align-items: center; gap: .75rem; }
.panel form button { width: auto; padding: .5rem 1rem; }

.notice {
  padding: .6rem .8rem;
  border: 1px solid #1d7a3a;
  color: #1d7a3a;
  border-radius: 8px;
}

select {
  padding: .6rem .7rem;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.columns { display: flex; flex-wrap: wrap; gap: 0 2rem; }

form.danger {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

form.danger button { width: auto; padding: .5rem 1rem; color: var(--error-text); border-color: var(--error-text); }

form.inline input.narrow { max-width: 6rem; }

/* signing in with a passkey */
.passkey { margin-top: 1rem; }
.or { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

td.actions .button-link { margin-right: .5rem; font-size: .85rem; }
