:root {
  --bg: #0f1412;
  --bg-elev: #18211c;
  --ink: #e8f0ea;
  --muted: #93a699;
  --line: #2a3a31;
  --accent: #3ecf8e;
  --accent-ink: #062416;
  --danger: #ff7b72;
  --warn: #e6b35a;
  --ok: #3ecf8e;
  --font: "Segoe UI", "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --mono: "Cascadia Code", "Consolas", "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1d3a2c 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #243048 0%, transparent 45%),
    var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.92em; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 20, 18, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-logo {
  display: block;
  height: 1.55rem;
  width: auto;
  max-width: 9rem;
  object-fit: contain;
}
.login-logo {
  display: block;
  height: 2.4rem;
  width: auto;
  max-width: 12rem;
  object-fit: contain;
  margin: 0 0 0.75rem;
}
.color-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  width: 100%;
}
.branding-form {
  max-width: none;
}
.branding-identity {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}
.branding-options-colours {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  max-width: none;
}
.branding-options-assets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}
.branding-asset-card {
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  max-width: none;
}
.branding-subhead {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  color: var(--ink);
}
.lede.compact {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
}
@media (max-width: 900px) {
  .branding-options-assets { grid-template-columns: 1fr; }
  .color-grid { grid-template-columns: 1fr; }
}
.color-field {
  display: grid;
  gap: 0.45rem;
  align-content: start;
  color: var(--muted);
  font-size: 0.9rem;
  min-width: 0;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  overflow: hidden;
}
.color-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
}
.color-input-row input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev);
  cursor: pointer;
  overflow: hidden;
  flex: 0 0 2.25rem;
}
.color-input-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-input-row input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 8px;
}
.color-input-row input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 8px;
}
.color-input-row .color-hex,
.card-form .color-input-row .color-hex {
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  max-width: 100%;
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
}
.branding-preview {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  background:
    radial-gradient(500px 180px at 0% 0%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
    var(--bg);
  color: var(--ink);
}
.branding-preview-bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
}
.branding-preview-bar strong { color: var(--ink); }
.branding-preview p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.branding-preview-accent {
  margin-left: auto;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.8rem;
  font-weight: 650;
}
.branding-asset {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}
.branding-asset-img {
  display: block;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  padding: 0.5rem;
}
.logo-preview { height: 3rem; width: auto; max-width: 14rem; }
.favicon-preview { height: 2rem; width: 2rem; }
.branding-page .panel,
.branding-page .branding-asset-img,
.branding-page .color-field,
.branding-page .color-input-row input[type="color"],
.branding-page .color-input-row .color-hex,
.branding-page .branding-preview,
.branding-page .card-form input,
.branding-page .btn.ghost,
.branding-page button.ghost {
  border-color: var(--line);
}
.topbar nav { display: flex; flex-wrap: wrap; gap: 0.9rem; align-items: center; }
.topbar nav a, .nav-dropdown summary { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.topbar nav a:hover, .nav-dropdown summary:hover { color: var(--ink); }
.topbar .muted { opacity: 0.75; }
.logout-form { display: inline; margin: 0; padding: 0; }
.nav-logout {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  opacity: 0.75;
}
.nav-logout:hover { color: var(--ink); opacity: 1; }
.nav-dropdown { position: relative; }
.nav-dropdown summary { cursor: pointer; list-style: none; }
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary::after { content: " ▾"; font-size: 0.75em; }
.nav-dropdown[open] summary::after { content: " ▴"; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.65rem);
  left: -0.75rem;
  min-width: 220px;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}
.topbar nav .dropdown-menu a {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: 7px;
}
.topbar nav .dropdown-menu a:hover { background: rgba(255, 255, 255, 0.05); }

.wrap { width: min(1100px, calc(100% - 2rem)); margin: 1.5rem auto 3rem; }
.page-head, .panel-head, .actions, .actions-row, .toolbar {
  display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap;
}
.page-head { justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1, .login-panel h1 { margin: 0.15rem 0 0.35rem; font-size: clamp(1.6rem, 3vw, 2.2rem); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); font-size: 0.75rem; margin: 0; }
.lede { color: var(--muted); margin: 0; max-width: 42rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.2rem;
}
.stat, .panel, .card-form, .login-panel .card-form {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem;
}
.stat .label { display: block; color: var(--muted); font-size: 0.85rem; }
.stat strong { display: block; font-size: 1.6rem; margin: 0.25rem 0; }
.stat .meta { color: var(--muted); font-size: 0.85rem; }
.service-status-list {
  list-style: none;
  margin: 0.45rem 0 0.35rem;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}
.service-status-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}
.service-status-list span { color: var(--ink); font-size: 0.95rem; }
.service-status-list strong {
  display: inline;
  font-size: 0.95rem;
  margin: 0;
}
a.tool-card { text-decoration: none; color: inherit; transition: border-color 0.15s ease, transform 0.15s ease; }
a.tool-card:hover { border-color: rgba(62, 207, 142, 0.55); transform: translateY(-1px); text-decoration: none; }
.tool-grid { margin-bottom: 0; }
.tool-card-title { font-size: 1.15rem; }
.detail-list {
  display: grid;
  gap: 0.85rem;
  margin: 0;
}
.detail-list > div {
  display: grid;
  grid-template-columns: minmax(8rem, 11rem) 1fr;
  gap: 0.5rem 1rem;
  align-items: baseline;
}
.detail-list dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.detail-list dd {
  margin: 0;
  color: var(--ink);
}
.detail-list .meta { color: var(--muted); font-size: 0.9rem; }
.ok { color: var(--ok); }
.bad { color: var(--danger); }

.panel { margin-top: 1rem; }
.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.panel-grid > .panel { margin-top: 0; }
.panel + .card-form { margin-top: 1.5rem; }
.panel-head { justify-content: space-between; margin-bottom: 0.6rem; }
.panel-head h2 { margin: 0; font-size: 1.05rem; }

.logbox {
  margin: 0;
  max-height: 280px;
  overflow: auto;
  padding: 0.85rem;
  border-radius: 10px;
  background: #0a0e0c;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.logbox.tall { max-height: 70vh; }

.config-edit { display: grid; gap: 0.85rem; }
.config-editor {
  width: 100%;
  min-height: 60vh;
  resize: vertical;
  padding: 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0a0e0c;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
  tab-size: 4;
}
.config-editor:focus {
  outline: 1px solid rgba(62, 207, 142, 0.45);
}

.toolbar { margin-bottom: 0.9rem; }
.toolbar input, .toolbar select, .card-form input, .card-form select, .card-form button, .btn, button {
  font: inherit;
}
.toolbar input, .card-form input, .card-form select, .toolbar select {
  background: #0c1210;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
}
.toolbar input { flex: 1; min-width: 180px; }

.btn, button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn:hover, button:hover { filter: brightness(1.05); text-decoration: none; }
.btn.ghost, button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.danger, button.danger { background: #8a2f2a; color: #fff; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-elev);
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.8rem 0.9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
tr:last-child td { border-bottom: 0; }
.secret { word-break: break-all; }
.secret-reveal {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  max-width: 100%;
}
.secret-mask {
  letter-spacing: 0.08em;
  color: var(--muted);
}
.secret-toggle {
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}
.tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}
.entra-setup-status {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.55rem;
}
.entra-code-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.entra-code-row[hidden] {
  display: none !important;
}
.entra-user-code {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.45rem;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.entra-code-row .btn {
  flex: 0 0 auto;
}

.card-form { display: grid; gap: 0.85rem; max-width: 420px; }
.card-form.wide { max-width: 560px; }
.card-form.branding-form,
.card-form.branding-options-colours {
  width: 100%;
  max-width: none;
}
.branding-identity,
.color-grid,
.branding-preview {
  width: 100%;
}
.card-form label { display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.9rem; }
.card-form label.check {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
}
.page-center {
  width: min(640px, 100%);
  margin-inline: auto;
  text-align: center;
}
.page-center .page-head { justify-content: center; }
.page-center .panel-head { justify-content: center; }
.page-center .card-form { margin-inline: auto; text-align: left; }
.page-center .actions { justify-content: center; }
.panel-center {
  text-align: center;
}
.panel-center .panel-head { justify-content: center; }
.panel-center .card-form { margin-inline: auto; text-align: left; }
.panel-center .actions { justify-content: center; }
.actions-row { margin: 1rem 0; }

.flash-stack { display: grid; gap: 0.5rem; margin-bottom: 1rem; }
.flash {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  white-space: pre-wrap;
}
.flash-success { background: rgba(62, 207, 142, 0.12); border-color: rgba(62, 207, 142, 0.35); }
.flash-error { background: rgba(255, 123, 114, 0.12); border-color: rgba(255, 123, 114, 0.35); }
.flash-warn { background: rgba(230, 179, 90, 0.12); border-color: rgba(230, 179, 90, 0.4); }
.invite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.lede.compact { margin-top: 0.25rem; font-size: 0.9rem; }

.login-panel {
  min-height: calc(100vh - 3rem);
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 2rem;
  align-items: center;
}
.login-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem 1.15rem;
}
.login-card form { display: grid; gap: 0.85rem; }
.sso-btn {
  width: 100%;
  justify-content: center;
  gap: 0.65rem;
  background: #fff;
  color: #1b1b1b;
}
.sso-btn .ms-logo {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
}
.sso-btn:hover { filter: none; background: #f3f3f3; }
.login-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.65rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.35rem 0 0.15rem;
}
.login-divider::before,
.login-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}
.nav-user {
  color: var(--ink);
  font-size: 0.85rem;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inline-form {
  display: inline;
  margin: 0;
  padding: 0;
}
.clipboard-helper {
  position: fixed;
  left: -9999px;
  top: 0;
}
@media (max-width: 800px) {
  .login-panel { grid-template-columns: 1fr; min-height: auto; padding-top: 2rem; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .dropdown-menu { position: static; margin-top: 0.5rem; }
  .panel-grid { grid-template-columns: 1fr; }
  .detail-list > div { grid-template-columns: 1fr; gap: 0.15rem; }
}
