:root {
  --ink: #0f1014;
  --paper: #f7f6f3;
  --panel: #ffffff;
  --line: #e6e4de;
  --muted: #6b6e79;
  --accent: #2b2d8f;
  --accent-soft: #eeeeff;
  --radius: 12px;
  font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1c1e2b, #0c0d13 65%);
}
.login-card {
  background: var(--panel);
  padding: 48px 40px;
  border-radius: 16px;
  width: 380px;
  text-align: center;
  box-shadow: 0 30px 60px rgba(0,0,0,0.35);
}
.login-logo { font-size: 22px; font-weight: 700; margin-bottom: 10px; }
.login-sub { color: var(--muted); font-size: 14px; line-height: 1.5; margin-bottom: 28px; }
.ms-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid #d0d0d0; border-radius: 6px; padding: 12px 16px;
  text-decoration: none; color: var(--ink); font-weight: 600; font-size: 14px;
  transition: background .15s;
}
.ms-btn:hover { background: #f2f2f2; }
.login-fine { color: #9a9ca5; font-size: 12px; margin-top: 18px; }

/* ---------- App shell ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 26px; background: var(--ink); color: #fff;
}
.topbar .brand { font-weight: 700; font-size: 15.5px; display: flex; align-items: center; gap: 8px; letter-spacing: -.2px; }
.topbar nav a { color: #a7a9bd; text-decoration: none; margin-left: 22px; font-size: 13.5px; font-weight: 500; transition: color .15s; }
.topbar nav a.active, .topbar nav a:hover { color: #fff; }
.topbar .who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #a7a9bd; }
.topbar .who img { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid #3a3c4e; }
.topbar .who a { color: #a7a9bd; font-size: 12px; text-decoration: none; }
.topbar .who a:hover { color: #fff; }

.layout { display: grid; grid-template-columns: 380px 1fr; gap: 0; min-height: calc(100vh - 60px); }
.panel-scroll { padding: 26px; overflow-y: auto; }
.controls { border-right: 1px solid var(--line); background: var(--panel); }
.preview-pane { background: linear-gradient(180deg, #eeedf6 0%, #e9e8f2 100%); display: flex; flex-direction: column; }

h2.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin: 26px 0 12px; }
h2.section-title:first-child { margin-top: 0; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input[type=text], .field input[type=url], .field input[type=tel], .field input[type=email] {
  width: 100%; padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; transition: border-color .15s;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.template-card {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 13px; cursor: pointer; background: #fff;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.template-card:hover { border-color: #c7c6ff; box-shadow: 0 4px 14px rgba(43,45,143,0.08); transform: translateY(-1px); }
.template-card.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 4px 14px rgba(43,45,143,0.12); }
.template-card .tpl-name { font-size: 13px; font-weight: 700; color: var(--ink); }
.template-card .tpl-blurb { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.template-card .tpl-tag { display: inline-block; background: var(--accent); color: #fff; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 6px; border-radius: 20px; margin-left: 5px; vertical-align: middle; }

.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type=color] { width: 40px; height: 32px; border: none; background: none; padding: 0; cursor: pointer; }

.upload-row { display: flex; align-items: center; gap: 10px; }
.upload-row img.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1.5px solid var(--line); background: #f2f1ec; }
.btn { display: inline-block; border: 1.5px solid var(--line); background: #fff; padding: 9px 15px; border-radius: 8px; font-size: 13px; cursor: pointer; font-weight: 600; color: var(--ink); transition: all .15s; }
.btn:hover { background: #f7f6f3; border-color: #d3d1c9; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #24252e; }
.btn.small { padding: 6px 11px; font-size: 12px; }

.preview-toolbar { padding: 18px 26px; border-bottom: 1px solid #d9d8e4; display: flex; align-items: center; justify-content: space-between; }
.preview-toolbar strong { font-size: 13.5px; font-weight: 700; }
.preview-toolbar .status { font-size: 12px; color: var(--muted); }
.preview-surface { flex: 1; padding: 44px; display: flex; align-items: flex-start; justify-content: center; }
.preview-card { background: #fff; border-radius: 14px; box-shadow: 0 20px 50px rgba(15,16,20,0.12), 0 2px 8px rgba(15,16,20,0.05); padding: 36px; min-width: 460px; }
.preview-actions { display: flex; gap: 10px; padding: 0 26px 26px; }
.html-box { width: 100%; height: 160px; font-family: 'SF Mono', Consolas, monospace; font-size: 11px; padding: 12px; border: 1.5px solid var(--line); border-radius: 8px; }

/* ---------- Team page ---------- */
.team-wrap { padding: 24px 32px; max-width: 1100px; margin: 0 auto; }
table.roster { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 16px rgba(20,22,28,0.05); }
table.roster th, table.roster td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
table.roster th { background: #f0f0ee; color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.yes { background: #e5f6ea; color: #1d7a3c; }
.badge.no { background: #f2f2f2; color: #888; }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 8px; font-size: 13px; opacity: 0; transform: translateY(10px); transition: all .2s; }
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Admin console ---------- */
.admin-wrap { padding: 24px 32px; max-width: 1100px; margin: 0 auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; flex-wrap: wrap; }
.tab-btn { border: none; background: none; padding: 10px 14px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab-btn.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.card h3 { margin: 0 0 14px; font-size: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form-row input[type=text], .form-row input[type=url], .form-row input[type=date], .form-row select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px;
}
.form-row input[type=checkbox] { margin-right: 6px; }
.item-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.item-row:last-child { border-bottom: none; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; margin-left: 6px; }
.pill.active { background: #e5f6ea; color: #1d7a3c; }
.pill.inactive { background: #f2f2f2; color: #888; }
.status-badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.status-badge.draft { background: #f2f2f2; color: #777; }
.status-badge.pending { background: #fff4e0; color: #a15c00; }
.status-badge.approved { background: #e5f6ea; color: #1d7a3c; }
.status-badge.rejected { background: #fde8e8; color: #b42318; }
.status-badge.none { background: #f2f2f2; color: #aaa; }
.result-box { background: #f6f5f2; border-radius: 8px; padding: 12px; font-size: 12px; margin-top: 12px; white-space: pre-wrap; }
.approval-preview { border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin: 10px 0; background: #fafafa; }

/* ---------- Install toolkit ---------- */
.health-banner { margin: 0 26px; padding: 10px 14px; background: #fff4e0; border: 1px solid #f0c674; border-radius: 8px; font-size: 12.5px; color: #7a4d00; }
.install-panel { padding: 0 26px 28px; }
.install-primary { text-align: center; margin-bottom: 6px; }
.install-primary .btn { width: 100%; padding: 13px; font-size: 14px; }
.install-hint { text-align: center; font-size: 11.5px; color: var(--muted); margin: 0 0 18px; }
.install-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.install-tile {
  display: block; text-align: left; background: #fff; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 12px 14px; text-decoration: none; cursor: pointer; font-family: inherit; transition: all .15s;
}
.install-tile:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(43,45,143,0.08); }
.install-tile-title { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.install-tile-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.install-secondary { display: flex; gap: 8px; justify-content: center; }

.modal-overlay { position: fixed; inset: 0; background: rgba(15,16,20,0.55); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-box { background: #fff; border-radius: 14px; padding: 26px 28px; max-width: 420px; box-shadow: 0 30px 60px rgba(0,0,0,0.3); }
.modal-box h3 { margin: 0 0 12px; font-size: 16px; }
.modal-box ol { margin: 0 0 12px; padding-left: 20px; font-size: 13px; line-height: 1.7; }
.modal-box code { background: #f2f1ec; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
