:root {
  --ink: #03070c;
  --text: #424242;
  --muted: #6b7280;
  --red: #f00000;
  --red-dark: #c40000;
  --bg: #eff1f6;
  --surface: #ffffff;
  --line: #dde1ea;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(3 7 12 / 6%), 0 8px 24px rgb(3 7 12 / 6%);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 40px 24px 64px; }
h1, h2, legend, strong { color: var(--ink); }
h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: -0.01em; }
a { color: var(--red); }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 16px; padding: 14px 24px; background: var(--ink); color: #fff; }
.brand { display: flex; align-items: center; gap: 14px; color: #fff; text-decoration: none; }
.brand img { height: 36px; width: auto; display: block; }
.brand-name { font-size: 18px; font-weight: 600; padding-left: 14px; border-left: 1px solid rgb(255 255 255 / 25%); }
.user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-text { display: flex; flex-direction: column; line-height: 1.2; }
.user-text strong { color: #fff; font-size: 14px; }
.user-text small { color: rgb(255 255 255 / 65%); font-size: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--red); color: #fff; font-weight: 700; font-size: 14px; }

/* Buttons */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 18px; border-radius: 6px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; }
.button-primary { background: var(--red); color: #fff; }
.button-primary:hover { background: var(--red-dark); }
.button-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.button-secondary:hover { border-color: var(--ink); }
.button-ghost { color: #fff; border-color: rgb(255 255 255 / 30%); padding: 6px 12px; }
.button-ghost:hover { border-color: #fff; }
.button-microsoft { width: 100%; background: var(--surface); color: #5e5e5e; border-color: #8c8c8c; border-radius: 2px; padding: 12px; }
.button-microsoft:hover { background: #f3f3f3; }
.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .tile:focus-visible { outline: 3px solid rgb(240 0 0 / 35%); outline-offset: 2px; }

/* Sign-in */
.signin { display: grid; place-items: center; padding-top: 6vh; }
.signin-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px; display: flex; flex-direction: column; gap: 16px; }
.signin-card h1 { font-size: 24px; margin: 0; }
.signin-card p { margin: 0; line-height: 1.5; }
.signin-card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink); }
.ms-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: #5e5e5e; }
.error { background: #fdecec; color: #8a1010; border: 1px solid #f5c2c2; padding: 10px 14px; border-radius: 6px; font-size: 14px; }

/* Forms */
input, select, textarea { font: inherit; font-size: 14px; font-weight: 400; color: var(--ink); padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; background: #fff; width: 100%; }
::placeholder { color: #9aa1ad; }
textarea { resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #b8bfcc; }

/* Hub */
.hub h1 { margin-bottom: 24px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.tile { position: relative; display: flex; flex-direction: column; gap: 16px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: transform 0.15s, border-color 0.15s; }
.tile:hover { transform: translateY(-2px); border-color: var(--ink); }
.tile-body { display: flex; flex-direction: column; gap: 6px; line-height: 1.45; }
.tile-body strong { font-size: 18px; }
.tile-icon { width: 48px; height: 48px; border-radius: 10px; display: grid; place-items: center; background: #fdecec; color: var(--red); }
.tile-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tile-icon.large { width: 64px; height: 64px; }
.tile-icon.large svg { width: 36px; height: 36px; }
.tile-status { margin-top: auto; font-size: 13px; font-weight: 600; color: var(--red); }
.tile-coming-soon .tile-icon { background: var(--bg); color: var(--muted); }
.tile-coming-soon .tile-status { color: var(--muted); }

/* App pages */
.back { display: inline-block; margin-bottom: 20px; font-size: 14px; text-decoration: none; color: var(--muted); }
.back:hover { color: var(--ink); }
.narrow { max-width: 720px; }
.placeholder { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px; }
.placeholder h1 { margin: 16px 0 12px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: #fff4ce; color: #7a5b00; }

/* MSA generator */
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.app-header h1 { margin: 0; }
.template-name { margin: 0; font-size: 12px; color: var(--muted); }
.msa-layout { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: 28px; align-items: start; }
.msa-form { display: flex; flex-direction: column; gap: 18px; }
fieldset { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 18px 20px 20px; }
legend { font-weight: 700; font-size: 14px; padding: 0 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
.field em { color: var(--red); font-style: normal; margin-left: 2px; }
.field-wide { grid-column: 1 / -1; }
.field [aria-invalid="true"] { border-color: #d33; background: #fff8f8; }
.field-error { color: #a40000; font-weight: 600; font-size: 12px; }
.actions { position: sticky; bottom: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 0; background: var(--bg); }
.status { margin-right: auto; font-size: 13px; font-weight: 600; }
.status[data-state="pending"] { color: #7a5b00; }
.status[data-state="ready"] { color: #11703a; }
.status[data-state="error"] { color: #a40000; }
.button:disabled { opacity: 0.6; cursor: progress; }

.preview { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.preview h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 4px; }
.preview h3 { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 18px 0 6px; }
.excerpt { margin: 0 0 8px; font-family: Roboto, "Segoe UI", sans-serif; font-size: 13px; line-height: 1.55; color: #222; white-space: pre-line; }
.excerpt mark { background: #fff4ce; color: inherit; padding: 0 2px; border-radius: 2px; cursor: pointer; }
.excerpt mark.missing { background: #fdecec; color: #a40000; }

@media (max-width: 1000px) {
  .msa-layout { grid-template-columns: 1fr; }
  .preview { position: static; max-height: none; }
}

@media (max-width: 640px) {
  main { padding: 24px 16px 48px; }
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .brand img { height: 28px; }
  .user-text { display: none; }
  .fields { grid-template-columns: 1fr; }
}
