:root {
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eaf2ff;
  --text: #18212f;
  --muted: #667085;
  --border: #d8dee8;
  --border-soft: #e8ecf2;
  --surface: #ffffff;
  --surface-muted: #f5f7fa;
  --surface-strong: #eef2f7;
  --success: #16794b;
  --success-soft: #e9f7f0;
  --warning: #9a6700;
  --warning-soft: #fff6d8;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: 0 8px 24px rgba(15, 23, 42, .08);
  --radius: 12px;
  --radius-lg: 18px;
  --sidebar-width: 250px;
  color-scheme: light;
  font-family: "Segoe UI", "Yu Gothic UI", Meiryo, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--surface-muted); }
body { min-height: 100%; margin: 0; color: var(--text); background: var(--surface-muted); font-size: 15px; line-height: 1.65; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; color: var(--text); background: var(--surface);
  border: 1px solid #b9c2cf; border-radius: 8px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .14); }
input[type="checkbox"] { width: 20px; min-height: 20px; accent-color: var(--accent); }
input[type="color"] { min-height: 44px; padding: 5px; }
button:disabled, input:disabled { opacity: .52; cursor: not-allowed; }
h1, h2, h3 { margin-top: 0; line-height: 1.25; letter-spacing: -.02em; }
h1 { font-size: clamp(1.75rem, 3vw, 2.35rem); }
h2 { font-size: clamp(1.25rem, 2vw, 1.6rem); }
p { margin-top: 0; }
code { padding: 2px 6px; background: var(--surface-strong); border-radius: 5px; font-family: Consolas, monospace; }

.container, .content-container { width: min(1160px, calc(100% - 40px)); margin-inline: auto; }
.content-container { padding: 28px 0 56px; }
.content-container.wide { width: min(1380px, calc(100% - 40px)); }
.narrow { max-width: 760px; margin-inline: auto; }
.block { display: block; }
.muted { color: var(--muted); }
.centered { justify-content: center; text-align: center; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: -.01em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: #fff; background: var(--accent); border-radius: 9px; font-size: 18px; }
.simple-header { min-height: 70px; display: flex; align-items: center; padding: 0 28px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--border-soft); }

.button {
  display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 9px 17px;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-weight: 600; line-height: 1.2; transition: background .15s, border-color .15s, transform .05s;
}
.button:active { transform: translateY(1px); }
.button.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.secondary { color: var(--text); background: #fff; border-color: #b9c2cf; }
.button.secondary:hover { background: var(--surface-muted); border-color: #8e9aaa; }
.button.light { color: var(--accent-hover); background: #fff; }
.button.small { min-height: 36px; padding: 7px 13px; }
.button.large { min-height: 48px; padding: 12px 22px; }
.button.full { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.form-actions { display: flex; justify-content: flex-end; padding-top: 8px; }
.link-button { padding: 0; color: var(--accent); background: transparent; border: 0; cursor: pointer; }
.icon-button { display: none; width: 40px; height: 40px; padding: 0; background: transparent; border: 0; border-radius: 8px; cursor: pointer; font-size: 20px; }
.icon-button:hover { background: var(--surface-strong); }

.panel { padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(15, 23, 42, .03); }
.panel.narrow { max-width: 620px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.panel-heading h2 { margin-bottom: 4px; }
.panel-heading p { margin: 0; color: var(--muted); }

.alert { margin-bottom: 18px; padding: 12px 15px; border: 1px solid; border-radius: 9px; }
.alert-success { color: var(--success); background: var(--success-soft); border-color: #a7d9c0; }
.alert-warning { color: var(--warning); background: var(--warning-soft); border-color: #ead48d; }
.alert-danger { color: var(--danger); background: var(--danger-soft); border-color: #efb4ad; }
.compact-list { margin: 7px 0 0; padding-left: 20px; }
.flash-wrap { padding-top: 18px; }
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.success { color: var(--success); background: var(--success-soft); }
.badge.warning { color: var(--warning); background: var(--warning-soft); }
.badge.neutral { color: #475467; background: #eef2f6; }

.form-stack { display: grid; gap: 18px; }
.form-stack label { display: grid; gap: 7px; font-weight: 600; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-note { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.danger-text { color: var(--danger); }
.short-input { display: inline-block; width: 110px; }
.switch-list { display: grid; border-top: 1px solid var(--border-soft); }
.switch-row { display: flex !important; grid-template-columns: none !important; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 0; border-bottom: 1px solid var(--border-soft); }
.switch-row span { display: grid; gap: 2px; }
.switch-row small { color: var(--muted); font-weight: 400; }

.auth-body { min-height: 100vh; background: linear-gradient(135deg, #f6f8fb, #eaf1fb); }
.auth-main { min-height: calc(100vh - 70px); display: grid; place-items: center; padding: 36px 20px 60px; }
.auth-card { width: min(460px, 100%); padding: 32px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.auth-heading { margin-bottom: 24px; text-align: center; }
.auth-heading h1 { margin-bottom: 8px; }
.auth-heading p { margin: 0; color: var(--muted); }
.auth-links { margin-top: 20px; text-align: center; }

.shell-body { overflow-x: hidden; background: var(--surface-muted); }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar { overflow-y: auto; position: sticky; top: 0; height: 100vh; padding: 20px 14px; background: #fff; border-right: 1px solid var(--border); z-index: 20; }
.owner-sidebar { background: #f9fafc; }
.sidebar-brand { padding: 2px 10px 20px; }
.side-nav { display: grid; gap: 4px; }
.side-nav a { padding: 10px 12px; color: #3d4858; border-radius: 8px; font-weight: 550; }
.side-nav a:hover { background: var(--surface-strong); }
.side-nav a.active { color: var(--accent-hover); background: var(--accent-soft); }
.shell-content { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 15; min-height: 64px; display: flex; align-items: center; gap: 14px; padding: 0 24px; background: rgba(255,255,255,.93); border-bottom: 1px solid var(--border); backdrop-filter: blur(12px); }
.topbar-title { font-size: 17px; font-weight: 700; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); }
.topbar-user form { display: inline-flex; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { margin-bottom: 6px; }
.page-heading p { margin: 0; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stats-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card { min-height: 142px; display: grid; align-content: center; padding: 22px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.stat-card span { color: var(--muted); font-weight: 600; }
.stat-card strong { margin: 3px 0; font-size: 30px; line-height: 1.25; }
.stat-card small { color: var(--muted); }
.content-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; }
.task-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.task-list li { display: flex; gap: 14px; padding: 15px 0; border-top: 1px solid var(--border-soft); }
.task-list li:first-child { border-top: 0; }
.task-list li > span { flex: 0 0 30px; height: 30px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); border-radius: 50%; font-weight: 700; }
.task-list strong { display: block; margin-bottom: 3px; }
.task-list p { margin: 0; color: var(--muted); }
.empty-state { min-height: 360px; display: grid; place-content: center; justify-items: center; padding: 50px 24px; text-align: center; background: #fff; border: 1px dashed #b9c2cf; border-radius: var(--radius); }
.empty-icon { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 16px; color: var(--accent); background: var(--accent-soft); border-radius: 16px; font-size: 28px; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { max-width: 620px; margin: 0; color: var(--muted); }
.status-list { display: grid; margin: 0; }
.status-list div { display: grid; grid-template-columns: 150px 1fr; gap: 20px; padding: 13px 0; border-top: 1px solid var(--border-soft); }
.status-list div:first-child { border-top: 0; }
.status-list dt { color: var(--muted); }
.status-list dd { margin: 0; }

.table-panel { padding: 0; overflow: hidden; }
.table-toolbar { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.search-box { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.search-box input { width: min(360px, 58vw); min-height: 39px; }
.record-count { color: var(--muted); }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: #fff; }
.data-table th, .data-table td { padding: 13px 16px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
.data-table th { color: #475467; background: #f8fafc; font-size: 13px; font-weight: 700; }
.data-table tbody tr:hover { background: #fafcff; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.table-panel .form-actions { padding: 18px; border-top: 1px solid var(--border); }
.subnav { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 18px; }
.subnav a { padding: 7px 11px; color: #475467; background: #fff; border: 1px solid var(--border); border-radius: 7px; }

.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

@media (max-width: 980px) {
  .stats-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .container, .content-container, .content-container.wide { width: min(100% - 28px, 1160px); }
  .form-grid.two, .stats-grid, .stats-grid.four { grid-template-columns: 1fr; }
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-102%); width: min(290px, 86vw); box-shadow: var(--shadow); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .icon-button { display: inline-grid; place-items: center; }
  .topbar { padding: 0 14px; }
  .topbar-user > span:first-child { display: none; }
  .page-heading { display: grid; }
  .auth-card { padding: 25px 20px; }
  .simple-header { padding: 0 18px; }
  .switch-row { align-items: flex-start; }
}

/* Phase 2: device registration and monitoring */
.button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button.danger:hover { background: #912018; border-color: #912018; }
.badge.danger { color: var(--danger); background: var(--danger-soft); }
.badge .status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.section-gap { margin-top: 22px; }
.device-grid { margin-bottom: 22px; }
.registration-code-panel { display: flex; gap: 18px; margin-bottom: 22px; border-color: #a6d8bd; background: linear-gradient(135deg, #f6fff9, #fff); }
.code-panel-icon { flex: 0 0 44px; height: 44px; display: grid; place-items: center; color: #fff; background: var(--success); border-radius: 50%; font-size: 22px; font-weight: 700; }
.code-panel-main { min-width: 0; flex: 1; }
.code-panel-main h2 { margin-bottom: 5px; }
.registration-code-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 16px 0 8px; }
.registration-code { padding: 10px 14px; color: #0b4d31; background: #e5f7ed; border: 1px solid #9ad0b3; border-radius: 9px; font-size: clamp(1.25rem, 3vw, 1.75rem); font-weight: 800; letter-spacing: .08em; }
.inline-notice { display: grid; gap: 3px; padding: 15px 16px; border: 1px solid var(--border); border-radius: 9px; }
.inline-notice.warning { color: #694c00; background: var(--warning-soft); border-color: #ecd88e; }
.numbered-steps { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.numbered-steps li { display: flex; gap: 14px; padding: 14px 0; border-top: 1px solid var(--border-soft); }
.numbered-steps li:first-child { border-top: 0; }
.numbered-steps li > span { flex: 0 0 30px; height: 30px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); border-radius: 50%; font-weight: 800; }
.numbered-steps p { margin: 2px 0 0; color: var(--muted); }
.compact-empty { min-height: 280px; border: 0; border-radius: 0; }
.table-action-cell form { display: inline-flex; }
.back-link { display: inline-block; margin-bottom: 8px; color: var(--muted); }
.panel-divider { margin: 28px 0; border: 0; border-top: 1px solid var(--border-soft); }
.wrap-code { white-space: normal; overflow-wrap: anywhere; }
.empty-inline { padding: 32px 20px; color: var(--muted); text-align: center; }
.license-table select { min-width: 125px; min-height: 36px; padding: 6px 9px; }
.license-count-input { width: 84px; min-height: 36px; padding: 6px 9px; }
.license-table td:nth-child(4) { display: flex; gap: 8px; align-items: center; }

@media (max-width: 760px) {
  .registration-code-panel { display: grid; }
  .registration-code { width: 100%; text-align: center; font-size: 1.2rem; }
  .registration-code-row .button { width: 100%; }
}

/* Phase 3: Windows local user management */
.stats-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.status-strong { font-size: 24px !important; }
.security-explanation { border-color: #b7cdf7; background: linear-gradient(135deg, #f6f9ff, #fff); }
.security-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 14px 0; }
.security-flow span { padding: 9px 12px; color: #174ea6; background: #e9f1ff; border: 1px solid #c7d9fa; border-radius: 9px; font-weight: 700; }
.security-flow b { color: var(--muted); }
.profile-layout { grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); }
.password-entry { display: grid; gap: 13px; padding: 16px; background: #f8fafc; border: 1px solid var(--border-soft); border-radius: 10px; }
.checkbox-row { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 9px; font-weight: 600; }
.checkbox-row input { width: 18px; height: 18px; }
.inline-notice.danger { color: #7a271a; background: var(--danger-soft); border-color: #f1b5ad; }
.form-error { padding: 11px 13px; color: var(--danger); background: var(--danger-soft); border: 1px solid #f1b5ad; border-radius: 8px; font-weight: 700; }
.profile-card-list { display: grid; gap: 0; }
.profile-card { padding: 20px; border-bottom: 1px solid var(--border-soft); }
.profile-card:last-child { border-bottom: 0; }
.profile-card-header { display: flex; align-items: center; gap: 13px; }
.profile-avatar { flex: 0 0 42px; height: 42px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: 50%; font-weight: 800; }
.profile-title { min-width: 0; flex: 1; }
.profile-title h3 { margin: 0 0 2px; }
.profile-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 17px 0; padding: 13px 0; border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); }
.profile-facts div { padding: 0 13px; border-left: 1px solid var(--border-soft); }
.profile-facts div:first-child { border-left: 0; padding-left: 0; }
.profile-facts dt { color: var(--muted); font-size: 12px; }
.profile-facts dd { margin: 3px 0 0; font-weight: 700; }
.profile-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 9px; margin-top: 15px; }
.profile-actions > form { display: inline-flex; }
.profile-actions details { min-width: min(100%, 480px); }
.profile-actions summary { width: fit-content; padding: 7px 12px; color: var(--accent); background: #fff; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-weight: 700; }
.compact-form { margin-top: 12px; padding: 15px; background: #fff; border: 1px solid var(--border); border-radius: 10px; }
.button:disabled, input:disabled { opacity: .55; cursor: not-allowed; }

@media (max-width: 900px) {
  .stats-grid.three, .profile-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-facts div:nth-child(3) { border-left: 0; padding-left: 0; margin-top: 12px; }
  .profile-layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .stats-grid.three, .profile-facts { grid-template-columns: 1fr; }
  .profile-facts div { padding: 9px 0; border-left: 0; border-top: 1px solid var(--border-soft); }
  .profile-facts div:first-child { border-top: 0; }
  .profile-card-header { align-items: flex-start; flex-wrap: wrap; }
}


.policy-card-grid{grid-template-columns:repeat(auto-fit,minmax(300px,1fr))}.policy-card{display:flex;flex-direction:column;gap:18px}.summary-list{display:grid;gap:10px;margin:0}.summary-list>div{display:flex;justify-content:space-between;gap:20px;padding:10px 0;border-bottom:1px solid var(--border,#e5e7eb)}.summary-list dt{color:#64748b}.summary-list dd{margin:0;font-weight:700}.form-grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}.field-group{border:1px solid #dbe3ef;border-radius:12px;padding:16px}.field-group legend{padding:0 8px;font-weight:700}.time-range{display:flex;align-items:center;gap:10px}.time-range input{width:100%}.switch-row{display:flex;align-items:flex-start;gap:12px;padding:14px 16px;border:1px solid #dbe3ef;border-radius:12px}.switch-row input{margin-top:4px}.switch-row span{display:grid;gap:3px}.switch-row small{color:#64748b}.danger-switch{border-color:#fecaca;background:#fff7f7}.sticky-actions{position:sticky;bottom:0;display:flex;justify-content:flex-end;gap:12px;padding:14px;background:rgba(248,250,252,.96);border-top:1px solid #dbe3ef;backdrop-filter:blur(8px);z-index:5}.compact-filter{max-width:520px;margin-bottom:18px}.notice.danger{background:#fff1f2;border:1px solid #fecdd3;color:#9f1239;padding:12px;border-radius:10px}.button.full{width:100%;justify-content:center}.stack-lg{display:grid;gap:20px}@media(max-width:800px){.form-grid.three{grid-template-columns:1fr}.sticky-actions{position:static}}

/* Phase 5: resilience, system history and emergency unlocks */
.stat-card .stat-text { font-size: 1rem; line-height: 1.35; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form select { min-width: 92px; }
.inline-form input[type="text"] { min-width: 150px; flex: 1 1 180px; }
@media (max-width: 760px) {
  .inline-form { display: grid; grid-template-columns: 1fr; }
  .inline-form select, .inline-form input[type="text"], .inline-form .button { width: 100%; }
}

/* Phase 6: policy templates, overrides and application limits */
.stack-lg { display: grid; gap: 20px; }
.compact-panel { margin-bottom: 20px; }
.inline-copy-form { display: grid; grid-template-columns: minmax(260px, 1fr) auto; gap: 14px; align-items: end; }
.template-label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 16px; padding: 10px 12px; background: var(--surface-muted); border-radius: 8px; }
.template-label > span:first-child { color: var(--muted); font-size: 13px; }
.badge-stack { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.policy-card.is-archived { opacity: .78; }
.policy-field-section { display: grid; gap: 18px; }
.policy-field-section .panel-heading { margin-bottom: 0; }
.subsection-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 8px; border-top: 1px solid var(--border-soft); }
.subsection-heading h3 { margin-bottom: 3px; }
.subsection-heading p { margin: 0; color: var(--muted); }
.choice-row { display: flex; flex-wrap: wrap; gap: 9px; }
.choice-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 12px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
.choice-chip input { width: 18px; min-height: 18px; margin: 0; }
.app-limit-list { display: grid; gap: 10px; }
.app-limit-row { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px) auto; gap: 12px; align-items: end; padding: 14px; background: var(--surface-muted); border: 1px solid var(--border-soft); border-radius: 10px; }
.icon-action { min-height: 44px; padding: 9px 12px; background: #fff; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.icon-action.danger { color: var(--danger); }
.icon-action:hover { background: var(--surface-strong); }
.button.danger-outline { color: var(--danger); background: #fff; border-color: #e3a39d; }
.button.danger-outline:hover { background: var(--danger-soft); }
.override-switch { height: 100%; }
.danger-zone-soft { border-color: #efc3be; background: #fffafa; }
.inheritance-notice { display: none; margin-bottom: 14px; padding: 12px 14px; color: #315a8d; background: #eef6ff; border: 1px solid #bdd6f2; border-radius: 9px; }
.policy-override-fields.is-inherited .inheritance-notice { display: block; }
.policy-override-fields.is-inherited .policy-field-section { opacity: .72; }
.read-only-policy { pointer-events: none; opacity: .72; }
.action-panel { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 20px; }
.action-panel h2 { margin-bottom: 4px; }
.action-panel p { margin: 0; color: var(--muted); }
.notice.info { color: #175b9c; background: #eef6ff; border-color: #b8d5f2; }
@media (max-width: 760px) {
  .inline-copy-form, .app-limit-row { grid-template-columns: 1fr; }
  .subsection-heading, .action-panel { align-items: stretch; flex-direction: column; }
  .badge-stack { justify-content: flex-start; }
}

.template-editor-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.template-editor-fieldset:disabled { opacity: .78; }

/* Phase 8: plans, subscriptions, billing and account management */
.billing-summary-grid .stat-card strong { font-size: clamp(1.25rem, 2.5vw, 1.8rem); }
.billing-plan-grid, .public-pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.billing-plan-card { display: flex; flex-direction: column; gap: 14px; }
.billing-plan-card.current { border-color: color-mix(in srgb, var(--accent) 45%, white); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 13%, transparent); }
.billing-plan-header { display: flex; justify-content: space-between; gap: 14px; }
.billing-plan-header h3 { margin: 8px 0 0; font-size: 1.25rem; }
.billing-price { display: flex; align-items: baseline; gap: 7px; }
.billing-price strong { color: var(--text); font-size: clamp(1.55rem, 3vw, 2.2rem); }
.billing-price span { color: var(--muted); }
.compact-form { margin-top: auto; }
.compact-form label { gap: 6px; }
.trial-action { margin-top: -5px; }
.account-grid { align-items: start; }
.billing-review-actions { display: flex; align-items: center; gap: 8px; }
.billing-review-actions form { display: inline-flex; }
.form-grid .span-two { grid-column: 1 / -1; }
.section-heading.compact { margin-bottom: 16px; }
.public-pricing-grid .pricing-card { height: 100%; }
.button:disabled { cursor: not-allowed; opacity: .55; }

@media (max-width: 760px) {
  .billing-plan-grid, .public-pricing-grid { grid-template-columns: 1fr; }
  .billing-review-actions { align-items: stretch; flex-direction: column; }
  .billing-review-actions .button { width: 100%; }
  .form-grid .span-two { grid-column: auto; }
}

/* Phase 9 authentication and notification components */
.auth-heading { margin-bottom: 1.25rem; }
.auth-heading h1 { margin: 0 0 .4rem; font-size: 1.65rem; }
.auth-heading p { margin: 0; color: var(--muted, #64748b); }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; margin-top: 1rem; font-size: .92rem; }
.auth-secondary-form { margin-top: .75rem; text-align: center; }
.otp-input { font-size: 1.7rem; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.notification-list { display: grid; gap: .75rem; }
.notification-item { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem; border: 1px solid var(--border, #dbe3ee); border-radius: 12px; background: #fff; }
.notification-item.unread { border-left: 4px solid var(--accent); background: #f8fbff; }
.notification-item h2 { margin: .45rem 0 .3rem; font-size: 1rem; }
.notification-item p { margin: 0 0 .5rem; color: var(--text-secondary, #475569); }
.wrap-cell { min-width: 220px; max-width: 480px; white-space: normal; overflow-wrap: anywhere; }

/* Phase 10 household, permissions, notification preferences and security operations */
.permission-guide{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:18px}.permission-guide article{display:flex;flex-direction:column;gap:5px;padding:14px;border:1px solid var(--border);border-radius:12px;background:var(--surface-subtle)}.permission-guide span,.invite-summary span{color:var(--text-muted);font-size:.88rem}.table-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.table-actions form{display:flex;align-items:center;gap:6px;margin:0}.table-actions input,.table-actions select{min-width:120px}.wide-auth-card{max-width:620px}.invite-summary{display:grid;grid-template-columns:110px 1fr;gap:8px 14px;padding:16px;margin:18px 0;border:1px solid var(--border);border-radius:12px;background:var(--surface-subtle)}.notification-settings-grid{align-items:start}.toggle-list{display:flex;flex-direction:column;gap:4px}.toggle-row{display:flex!important;align-items:center;justify-content:space-between;gap:18px;padding:13px 0;border-bottom:1px solid var(--border);cursor:pointer}.toggle-row:last-child{border-bottom:0}.toggle-row span{display:flex;flex-direction:column;gap:3px}.toggle-row small{color:var(--text-muted);font-weight:400}.toggle-row input[type=checkbox]{width:20px;height:20px;flex:none}.toggle-row.compact{padding:8px 0}.security-filter{display:flex;gap:10px;align-items:end;flex-wrap:wrap;padding:0 18px 16px}.security-filter label{min-width:220px}.data-table code{white-space:nowrap;font-size:.83rem}.field-note{margin-top:4px;color:var(--text-muted);font-size:.8rem;max-width:420px;overflow-wrap:anywhere}
@media(max-width:760px){.permission-guide{grid-template-columns:1fr}.invite-summary{grid-template-columns:1fr}.table-actions form{width:100%}.table-actions input,.table-actions select{flex:1;min-width:0}.security-filter label{width:100%;min-width:0}}

/* Phase 11: platform operations, customer management, audit and CSV exports */
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px; align-items: end; }
.filter-grid label { display: grid; gap: 6px; font-weight: 600; }
.filter-grid .filter-wide { grid-column: span 2; }
.filter-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; padding-top: 20px; }
.pagination a { min-width: 38px; min-height: 38px; display: grid; place-items: center; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.pagination a.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.table-empty { padding: 28px; color: var(--muted); text-align: center; }
.mono-small { font-family: Consolas, monospace; font-size: 11px; }
.breadcrumb-line { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.stat-card .stat-text { font-size: clamp(1.25rem, 2.4vw, 1.8rem); }
.customer-detail-grid { align-items: start; }
.timeline-list { display: grid; gap: 12px; }
.timeline-list article { padding: 14px; background: var(--surface-muted); border: 1px solid var(--border-soft); border-radius: 9px; }
.timeline-list article p { margin: 9px 0 0; white-space: normal; }
.timeline-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.compact-log-list { display: grid; }
.compact-log-list article { display: grid; gap: 5px; padding: 12px 0; border-top: 1px solid var(--border-soft); }
.compact-log-list article:first-child { border-top: 0; }
.compact-log-list article > div { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.compact-log-list small { color: var(--muted); }
.inline-admin-name { display: grid; grid-template-columns: minmax(150px, 1fr) auto; gap: 8px; align-items: center; }
.inline-lock-form { display: grid; grid-template-columns: minmax(150px, 1fr) auto; gap: 8px; }
.table-actions.vertical { align-items: stretch; flex-direction: column; }
.metadata-details { margin-top: 6px; }
.metadata-details summary { color: var(--accent); cursor: pointer; font-size: 12px; }
.metadata-details pre { max-width: 560px; max-height: 220px; overflow: auto; padding: 10px; background: var(--surface-muted); border-radius: 7px; white-space: pre-wrap; word-break: break-word; font-size: 12px; }
.hash-code { display: inline-block; max-width: 230px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.dashboard-main-grid { align-items: start; }
.healthy-state { display: flex; align-items: center; gap: 14px; min-height: 120px; padding: 18px; color: var(--success); background: var(--success-soft); border: 1px solid #a7d9c0; border-radius: 10px; }
.healthy-state > span { width: 42px; height: 42px; display: grid; place-items: center; color: #fff; background: var(--success); border-radius: 50%; font-size: 22px; }
.healthy-state p { margin: 3px 0 0; color: #356b55; }
.attention-list { display: grid; }
.attention-list a { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 13px 0; color: var(--text); border-top: 1px solid var(--border-soft); }
.attention-list a:first-child { border-top: 0; }
.attention-list a > span:last-child { color: var(--accent); }
.metric-history { min-width: 720px; overflow-x: auto; }
.metric-history > div { display: grid; grid-template-columns: 90px repeat(6, minmax(90px, 1fr)); gap: 8px; padding: 10px 8px; border-top: 1px solid var(--border-soft); text-align: right; }
.metric-history > div span:first-child { text-align: left; }
.metric-history .metric-history-head { color: var(--muted); background: var(--surface-muted); border-top: 0; font-weight: 700; }
.audit-table td { vertical-align: top; }

@media (max-width: 980px) {
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid .filter-wide { grid-column: span 2; }
}
@media (max-width: 620px) {
  .filter-grid { grid-template-columns: 1fr; }
  .filter-grid .filter-wide { grid-column: auto; }
  .inline-admin-name, .inline-lock-form { grid-template-columns: 1fr; }
}

/* Phase 12: shared-hosting diagnostics, backup, restore and deployment preflight */
.maintenance-grid { align-items: start; }
.maintenance-stats .stat-card strong { min-height: 36px; display: flex; align-items: center; }
.diagnostic-list { display: grid; }
.diagnostic-list > div { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 11px 0; border-top: 1px solid var(--border-soft); }
.diagnostic-list > div:first-child { border-top: 0; }
.diagnostic-list small { display: block; margin-top: 3px; color: var(--muted); overflow-wrap: anywhere; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status-dot.ok { background: var(--success); }
.status-dot.warn { background: #d99a16; }
.status-dot.fail { background: var(--danger); }
.wrap-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.wrap-actions form { margin: 0; }
.restore-form { display: grid!important; grid-template-columns: minmax(100px, 1fr) auto; gap: 6px; }
.restore-form input { min-width: 0; }
.maintenance-grid hr { width: 100%; margin: 20px 0; border: 0; border-top: 1px solid var(--border); }
@media (max-width: 720px) {
  .diagnostic-list > div { grid-template-columns: 12px minmax(0, 1fr); }
  .diagnostic-list > div > .badge { grid-column: 2; justify-self: start; }
  .restore-form { grid-template-columns: 1fr; }
}

/* Phase 13: onboarding, installer distribution, support packages and feature inventory */
.onboarding-progress{display:grid;gap:12px}.progress-heading{display:flex;justify-content:space-between;gap:12px}.progress-track{height:10px;overflow:hidden;background:var(--surface-muted);border-radius:999px}.progress-track span{display:block;height:100%;background:var(--accent);border-radius:inherit}.onboarding-steps{display:grid;gap:12px}.onboarding-step{display:grid;grid-template-columns:44px minmax(0,1fr) auto;gap:15px;align-items:center;padding:18px;background:var(--surface);border:1px solid var(--border);border-radius:12px}.onboarding-step.completed{background:var(--success-soft);border-color:#afd9c2}.onboarding-step h2{margin:0 0 4px;font-size:1.05rem}.onboarding-step p{margin:0;color:var(--muted)}.step-number{width:38px;height:38px;display:grid;place-items:center;color:#fff;background:var(--accent);border-radius:50%;font-weight:800}.completed .step-number{background:var(--success)}.download-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}.download-card{display:flex;flex-direction:column;gap:12px}.download-card .button{align-self:flex-start}.quick-action-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.quick-action-grid a{display:grid;gap:5px;padding:16px;color:var(--text);background:var(--surface-muted);border:1px solid var(--border);border-radius:10px}.quick-action-grid a:hover{border-color:var(--accent);text-decoration:none}.quick-action-grid span{color:var(--muted);font-size:.85rem}.onboarding-summary .progress-track{margin-top:8px}.centered{justify-content:center}.support-package-panel .table-actions{min-width:140px}
@media(max-width:820px){.quick-action-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.download-grid{grid-template-columns:1fr}}
@media(max-width:620px){.onboarding-step{grid-template-columns:40px 1fr}.onboarding-step .button{grid-column:2;justify-self:start}.quick-action-grid{grid-template-columns:1fr}}

/* Phase 15: usage reports, compatibility and installer workflow */
.report-filter{display:flex;align-items:end;gap:16px;flex-wrap:wrap}.report-filter .field{min-width:210px}.usage-chart{min-height:280px;overflow-x:auto}.usage-chart.compact{min-height:190px}.usage-chart svg{display:block;width:100%;min-width:620px;height:auto}.chart-grid-line{stroke:#dbe3ef;stroke-width:1}.chart-axis-label{fill:#64748b;font:12px "Yu Gothic UI",sans-serif}.chart-bar{fill:var(--accent);opacity:.82}.chart-bar:hover{opacity:1}.report-ranking{display:grid;gap:14px}.ranking-row>div:first-child{display:flex;justify-content:space-between;gap:12px}.ranking-row span{color:#64748b}.ranking-bar{height:9px;background:#e8eef7;border-radius:999px;overflow:hidden;margin-top:6px}.ranking-bar span{display:block;height:100%;background:var(--accent);border-radius:999px}.compatibility-table td:nth-child(2),.compatibility-table td:nth-child(3){white-space:nowrap}.compact-stats{grid-template-columns:repeat(3,minmax(0,1fr))}.auto-logon-panel .profile-card-list{grid-template-columns:repeat(auto-fit,minmax(280px,1fr))}@media(max-width:760px){.compact-stats{grid-template-columns:1fr}.report-filter{align-items:stretch}.report-filter .field{min-width:100%}}
