*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0b0d14;
  --surface:    #13161f;
  --surface2:   #1c2030;
  --border:     #252a3d;
  --accent:     #4f8ef7;
  --accent-h:   #3a7ae0;
  --text:       #dde4f0;
  --muted:      #7a859a;
  --danger:     #e05252;
  --success:    #4caf7d;
  --warning:    #e0a53a;
  --sidebar-w:  220px;
  --radius:     8px;
}

body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; font-size: 15px; line-height: 1.6; min-height: 100vh; }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1rem; border-bottom: 1px solid var(--border); }
.brand-anchor { font-size: 1.6rem; }
.brand-name { font-size: .95rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.brand-sub { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.nav-section { padding: .75rem 1rem .25rem; font-size: .65rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: .6rem; padding: .5rem 1rem; color: var(--muted); text-decoration: none; font-size: .875rem; transition: color .15s, background .15s; border-radius: 0; }
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--accent); background: rgba(79,142,247,.1); border-right: 2px solid var(--accent); }
.nav-icon { font-size: .5rem; flex-shrink: 0; }
.sidebar-footer { padding: .75rem 1rem; border-top: 1px solid var(--border); display: flex; align-items: center; gap: .5rem; }
.user-avatar { width: 30px; height: 30px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .7rem; color: var(--muted); }
.btn-logout { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: .25rem; border-radius: 4px; transition: color .15s; }
.btn-logout:hover { color: var(--danger); }

/* ── Main content ── */
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 2rem; max-width: 1200px; }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem; }

/* ── Page header ── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.page-sub { color: var(--muted); font-size: .875rem; margin-top: .3rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.section-header h2 { font-size: 1rem; font-weight: 600; }
.link-all { font-size: .85rem; color: var(--accent); text-decoration: none; }
.link-all:hover { text-decoration: underline; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border-radius: var(--radius); font-size: .875rem; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: background .15s; white-space: nowrap; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-full { width: 100%; justify-content: center; }

/* ── Auth ── */
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2.5rem; width: 100%; max-width: 400px; }
.auth-card-wide { max-width: 480px; }
.auth-logo { font-size: 2.5rem; text-align: center; margin-bottom: .5rem; }
.auth-title { font-size: 1.4rem; font-weight: 700; text-align: center; margin-bottom: .2rem; }
.auth-sub { color: var(--muted); text-align: center; font-size: .875rem; margin-bottom: 1.5rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }

/* ── Forms ── */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .875rem; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=tel], select, textarea {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: .5rem .75rem; font-size: .9rem; width: 100%;
  transition: border-color .15s; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
small { color: var(--muted); font-size: .78rem; font-weight: 400; }
.req { color: var(--danger); }
.input-code { font-size: 1.4rem; letter-spacing: .3em; text-align: center; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
legend { padding: 0 .5rem; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; max-width: 720px; display: flex; flex-direction: column; gap: 1.5rem; }
.form-card form { display: flex; flex-direction: column; gap: 1.5rem; }
.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; padding-top: .5rem; }
.radio-group { display: flex; flex-direction: column; gap: .6rem; }
.radio-option { display: flex; align-items: flex-start; gap: .75rem; cursor: pointer; padding: .75rem; border-radius: var(--radius); border: 1px solid var(--border); transition: border-color .15s; }
.radio-option:hover { border-color: var(--accent); }
.radio-option input[type=radio] { width: auto; margin-top: .25rem; accent-color: var(--accent); }
.radio-option span { display: flex; flex-direction: column; gap: .1rem; }
.radio-option strong { font-size: .9rem; }
.info-box { background: rgba(79,142,247,.08); border: 1px solid rgba(79,142,247,.3); border-radius: var(--radius); padding: .75rem 1rem; font-size: .875rem; }

/* ── Stat grid ── */
.stat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: .75rem; margin-bottom: 2rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1rem; text-align: center; text-decoration: none; color: var(--text); transition: border-color .15s, transform .1s; }
.stat-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.stat-num { font-size: 1.8rem; font-weight: 700; }
.stat-label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-active      .stat-num { color: var(--success); }
.stat-onboarding  .stat-num { color: var(--accent); }
.stat-provisioning .stat-num { color: var(--warning); }
.stat-suspended   .stat-num { color: var(--danger); }
.stat-canceled    .stat-num { color: var(--muted); }
.stat-total       .stat-num { color: var(--text); }

/* ── Dashboard grid ── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.tenant-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tenant-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--border); transition: background .12s; }
.tenant-row:last-child { border-bottom: none; }
.tenant-row:hover { background: var(--surface2); }
.tenant-row-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.tenant-name { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tenant-meta { font-size: .75rem; color: var(--muted); }
.tenant-row-badges { display: flex; gap: .4rem; flex-shrink: 0; }
.audit-list { display: flex; flex-direction: column; gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.audit-row { padding: .6rem 1rem; border-bottom: 1px solid var(--border); }
.audit-row:last-child { border-bottom: none; }
.audit-action { font-size: .8rem; font-weight: 600; color: var(--accent); font-family: monospace; }
.audit-meta { font-size: .75rem; color: var(--muted); display: flex; gap: .75rem; }
.audit-details { font-size: .75rem; margin-top: .15rem; }

/* ── Table ── */
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.data-table th { background: var(--surface2); padding: .65rem 1rem; text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: .7rem 1rem; border-bottom: 1px solid var(--border); font-size: .875rem; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table .clickable-row { cursor: pointer; transition: background .1s; }
.data-table .clickable-row:hover td { background: var(--surface2); }
.data-table a { color: var(--accent); text-decoration: none; }
.data-table a:hover { text-decoration: underline; }
code { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: .1em .4em; font-size: .82em; font-family: 'Consolas', monospace; }

/* ── Badges ── */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.badge-product      { background: rgba(79,142,247,.15);  color: #7aabff; }
.badge-plan         { background: rgba(136,146,164,.15); color: var(--muted); }
.badge-active       { background: rgba(76,175,125,.15);  color: #80d4a8; }
.badge-onboarding   { background: rgba(79,142,247,.15);  color: #7aabff; }
.badge-provisioning { background: rgba(224,165,58,.15);  color: #f0c070; }
.badge-suspended    { background: rgba(224,82,82,.15);   color: #f08080; }
.badge-canceled     { background: rgba(136,146,164,.15); color: var(--muted); }
.badge-archived     { background: rgba(136,146,164,.1);  color: var(--muted); }
.action-badge { font-family: monospace; font-size: .78rem; background: rgba(79,142,247,.1); color: var(--accent); padding: .1rem .4rem; border-radius: 4px; }

/* ── Filter bar ── */
.filter-bar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-btn { padding: .3rem .7rem; border-radius: 999px; font-size: .8rem; text-decoration: none; color: var(--muted); background: var(--surface); border: 1px solid var(--border); transition: all .15s; cursor: pointer; }
.filter-btn:hover, .filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-sep { color: var(--border); }
.filter-bar select { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: .3rem .6rem; font-size: .85rem; width: auto; cursor: pointer; }

/* ── Detail layout ── */
.detail-layout { display: grid; grid-template-columns: 280px 1fr; gap: 1.5rem; align-items: start; }
.detail-col { display: flex; flex-direction: column; gap: 1.5rem; }
.detail-col-wide { }
.detail-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.detail-section h2 { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 0; }
.detail-section form { display: flex; flex-direction: column; gap: 1rem; }
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; font-size: .875rem; }
.detail-list dt { color: var(--muted); white-space: nowrap; }
.detail-list dd { word-break: break-all; }

/* ── Settings ── */
.settings-grid { display: grid; grid-template-columns: 280px 1fr; gap: 1.5rem; align-items: start; }
.settings-grid .detail-section { display: flex; flex-direction: column; gap: 1rem; }
.settings-grid .detail-section form { display: flex; flex-direction: column; gap: 1rem; }

/* ── Audit ── */
.nowrap { white-space: nowrap; }
.small { font-size: .8rem; }

/* ── Pagination ── */
.pagination { display: flex; gap: .4rem; margin-top: 1rem; flex-wrap: wrap; }
.page-btn { padding: .3rem .65rem; border-radius: 4px; font-size: .85rem; text-decoration: none; color: var(--muted); background: var(--surface); border: 1px solid var(--border); transition: all .15s; }
.page-btn:hover, .page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Alerts ── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); font-size: .875rem; margin-bottom: 1rem; }
.alert-error   { background: rgba(224,82,82,.12);  border: 1px solid rgba(224,82,82,.35);  color: #f08080; }
.alert-success { background: rgba(76,175,125,.12); border: 1px solid rgba(76,175,125,.35); color: #80d4a8; }

/* ── QR ── */
.qr-wrapper { display: flex; justify-content: center; margin: 1rem 0; }
.qr-code { border-radius: var(--radius); border: 3px solid #fff; }
.secret-reveal { margin: .5rem 0 1rem; }
.secret-reveal summary { cursor: pointer; font-size: .85rem; color: var(--muted); }
.secret-key { display: block; margin-top: .5rem; background: var(--bg); padding: .5rem .75rem; border-radius: var(--radius); font-size: .82rem; word-break: break-all; border: 1px solid var(--border); font-family: monospace; }

/* ── Misc ── */
.muted { color: var(--muted); }
.empty-state { color: var(--muted); padding: 2rem; text-align: center; }
.empty-state a { color: var(--accent); }
.filter-tag { background: rgba(79,142,247,.15); color: var(--accent); padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; text-transform: uppercase; }
.page-footer { background: var(--surface); border-top: 1px solid var(--border); padding: .6rem 1.5rem .6rem calc(var(--sidebar-w) + 1.5rem); text-align: left; font-size: .75rem; color: var(--muted); }

@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar .brand-name, .sidebar .brand-sub, .sidebar .nav-section,
  .sidebar .user-info, .nav-item span:not(.nav-icon) { display: none; }
  .main-content { margin-left: 60px; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid, .detail-layout, .settings-grid { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .page-footer { padding-left: 80px; }
}

/* ── Admin management ── */
.badge-primary { background: rgba(224,165,58,.15); color: #f0c070; }
.badge-you { background: rgba(79,142,247,.15); color: var(--accent); font-size: .65rem; font-weight: 700; padding: .1rem .4rem; border-radius: 999px; text-transform: uppercase; letter-spacing: .05em; margin-left: .4rem; vertical-align: middle; }
.status-dot { font-size: .8rem; font-weight: 600; }
.dot-green { color: var(--success); }
.dot-gray  { color: var(--muted); }
.action-group { display: flex; gap: .4rem; flex-wrap: wrap; }
.btn-sm { padding: .25rem .6rem; font-size: .78rem; }
.btn-danger { background: rgba(224,82,82,.15); color: #f08080; border: 1px solid rgba(224,82,82,.3); }
.btn-danger:hover { background: rgba(224,82,82,.3); }
