/* Admin panel layout: sidebar + content on desktop, drawer navigation on phones. */

/* Sign-in */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; position: relative; }
.auth::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(0,0,0,.55), rgba(0,0,0,.92)), url(../assets/img/mountains.jpg) center / cover;
  filter: saturate(.8);
}
.auth .card { width: min(400px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 18px; background: rgba(21,27,34,.82); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.otp { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.otp input { height: 54px; text-align: center; font: 22px var(--mono); padding: 0; }

/* Shell */
.admin { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 20px 12px; border-right: 1px solid var(--border); background: var(--bg-raised);
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; }
.side .brand small { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; }
.nav-item {
  appearance: none; border: 0; background: transparent; color: var(--muted); cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 10px;
  font: 500 14px Inter, system-ui, sans-serif; transition: background .15s, color .15s;
}
.nav-item:hover { color: var(--ink); background: rgba(255,255,255,.04); }
.nav-item[aria-current="page"] { color: var(--ink); background: var(--card); }
.nav-item[aria-current="page"] svg { color: var(--cyan); }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--muted); }
.side .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 10px 0; border-top: 1px solid var(--border); font-size: 13px; }

.main { min-width: 0; padding: 0 28px 48px; }
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; height: 68px; background: rgba(0,0,0,.78); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); margin: 0 -28px 8px; padding: 0 28px; }
.top .search { width: min(420px, 100%); }
.menu-btn { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 12px 0 20px; }
.page-head p { margin-top: 4px; }

@media (max-width: 900px) {
  .admin { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 60; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .3s var(--ease); box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .side-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.5); }
  .menu-btn { display: inline-grid; }
  .main { padding: 0 16px 40px; }
  .top { margin: 0 -16px 8px; padding: 0 16px; }
}

/* KPIs */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { padding: 18px; }
.kpi .value { font-size: 28px; font-weight: 600; letter-spacing: -.02em; margin: 6px 0 4px; white-space: nowrap; }
@media (max-width: 600px) {
  .kpi { padding: 14px; }
  .kpi .value { font-size: 21px; }
  .kpi .label { letter-spacing: .04em; font-size: 10px; }
  .top .chip { display: none; }
}
.kpi .delta { font-size: 12px; color: var(--good); }
.kpi .delta.down { color: var(--warn); }

.grid-dash { display: grid; gap: 16px; grid-template-columns: 1.6fr 1fr; align-items: start; margin-top: 16px; }
@media (max-width: 1100px) { .grid-dash { grid-template-columns: 1fr; } }

/* Revenue chart */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 180px; padding-top: 12px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.chart .col i {
  display: block; border-radius: 4px 4px 2px 2px; background: linear-gradient(180deg, var(--cyan), rgba(0,217,255,.35));
  min-height: 3px; transform-origin: bottom; animation: grow .7s var(--ease) both;
}
.chart .col:hover i { background: var(--cyan); }
.chart .col:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--card-2); border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; font-size: 12px; white-space: nowrap; z-index: 2;
}
@keyframes grow { from { transform: scaleY(0); } }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 8px; }

/* Servers */
.servers { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.server { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 rgba(61,220,132,.5); animation: pulse 2.4s infinite; }
.pulse.warn { background: var(--warn); animation: none; }
.pulse.idle { background: var(--faint); box-shadow: none; animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(61,220,132,0); } 100% { box-shadow: 0 0 0 0 rgba(61,220,132,0); } }

/* Filters */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .search { flex: 1; min-width: 220px; }

/* Drawer */
.drawer-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .25s; }
.drawer-scrim.open { opacity: 1; }
.drawer {
  position: fixed; z-index: 45; top: 0; right: 0; height: 100vh; width: min(520px, 100%); overflow-y: auto;
  background: var(--bg-raised); border-left: 1px solid var(--border); box-shadow: var(--shadow);
  transform: translateX(100%); transition: transform .32s var(--ease);
}
.drawer.open { transform: none; }
.drawer-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 16px 20px; background: rgba(8,11,15,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.drawer-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.facts .label { display: block; margin-bottom: 3px; text-transform: none; letter-spacing: 0; font-size: 12px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Plans editor */
.plan-edit { display: grid; gap: 12px; grid-template-columns: 1.3fr 1fr 1fr 1fr auto; align-items: end; }
@media (max-width: 760px) { .plan-edit { grid-template-columns: 1fr 1fr; } }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: rgba(255,255,255,.14); transition: background .2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease); }
.switch input:checked + span { background: var(--cyan); }
.switch input:checked + span::after { transform: translateX(18px); }

.log-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 12px 16px; font-size: 14px; }
.log-row + .log-row { border-top: 1px solid rgba(255,255,255,.06); }
@media (max-width: 600px) { .log-row { grid-template-columns: 1fr; gap: 2px; } }

/* Roles demo switch */
.demo-switch { display: flex; flex-direction: column; gap: 6px; padding: 12px 10px 0; font-size: 11px; color: var(--faint); }
.demo-switch select { min-height: 36px; font-size: 13px; padding: 0 10px; border-radius: 10px; }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: rgba(255,255,255,.03); }

/* Providers and servers */
.providers { padding: 16px 18px; }
.provider { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.provider i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.provider.on { color: var(--ink); }
.provider.on i { background: var(--good); }
.provider small { color: var(--faint); font-size: 12px; }
.server-actions { gap: 8px; }
.choice-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.role-list { display: grid; gap: 8px; }
.choice {
  appearance: none; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 3px;
  padding: 12px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--border); color: var(--ink); font: inherit; font-size: 14px;
  transition: border-color .2s, box-shadow .2s;
}
.choice b { font-weight: 500; }
.choice small { color: var(--muted); font-size: 12px; }
.choice[aria-pressed="true"] { border-color: var(--cyan-line); box-shadow: 0 0 0 3px var(--cyan-soft); }
.check { gap: 10px; font-size: 14px; min-height: 40px; }
.check small { margin-left: auto; }
.summary-box { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: 14px; background: rgba(255,255,255,.03); border: 1px solid var(--border); font-size: 14px; }
.summary-box b { font-weight: 500; }

/* Provisioning steps */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.steps li { display: flex; align-items: center; gap: 12px; padding: 8px 4px; font-size: 14px; color: var(--faint); transition: color .3s; }
.steps li .state { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex: none; position: relative; transition: all .3s; }
.steps li.active { color: var(--ink); }
.steps li.active .state { border-color: var(--cyan); border-top-color: transparent; animation: spin .8s linear infinite; }
.steps li.done { color: var(--muted); }
.steps li.done .state { background: var(--cyan); border-color: var(--cyan); }
.steps li.done .state::after { content: ""; position: absolute; left: 6px; top: 2.5px; width: 5px; height: 9px; border: solid #001018; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.spinner { width: 20px; height: 20px; border: 2px solid rgba(0,0,0,.25); border-top-color: #001018; border-radius: 50%; animation: spin .8s linear infinite; }
.success-mark { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin: 8px auto 0; background: var(--cyan-soft); color: var(--cyan); animation: pop .5s var(--ease); }
.success-mark svg { width: 34px; height: 34px; stroke-width: 2; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

/* Permissions matrix */
table.perms td.c, table.perms th.c { text-align: center; }
table.perms td.c svg { width: 16px; height: 16px; }

/* Support inbox */
.inbox { display: grid; grid-template-columns: 340px 1fr; gap: 16px; height: calc(100dvh - 190px); min-height: 480px; }
.thread-list { overflow-y: auto; }
.thread {
  appearance: none; width: 100%; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
  padding: 14px 16px; border: 0; border-bottom: 1px solid rgba(255,255,255,.06); background: transparent; color: var(--ink); font: inherit; font-size: 14px;
}
.thread b { font-weight: 500; }
.thread:hover { background: rgba(255,255,255,.03); }
.thread.active { background: rgba(0,217,255,.06); box-shadow: inset 3px 0 0 var(--cyan); }
.thread .preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.conversation { display: flex; flex-direction: column; min-height: 0; }
.conv-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.conv-head b { font-weight: 600; }
.conv-head .back { display: none; transform: rotate(180deg); }
.conv-context { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 13px; background: rgba(255,255,255,.02); }
.conv-context .btn { margin-left: auto; }
.empty { flex: 1; display: grid; place-items: center; align-content: center; gap: 10px; color: var(--faint); }
.empty svg { width: 36px; height: 36px; }
@media (max-width: 900px) {
  .inbox { grid-template-columns: 1fr; height: calc(100dvh - 170px); }
  .inbox.has-thread .thread-list { display: none; }
  .inbox:not(.has-thread) .conversation { display: none; }
  .conv-head .back { display: inline-grid; }
}

/* Responsive fixes from the layout audit */
.filters .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.filters .segmented::-webkit-scrollbar { display: none; }
.filters .segmented button { flex: none; }
.actions .btn { white-space: normal; text-align: center; line-height: 1.2; padding: 8px 10px; min-width: 0; }
.head-title { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.id-copy {
  appearance: none; border: 0; background: none; padding: 2px 0; cursor: pointer; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; max-width: 100%; text-align: left; overflow-wrap: anywhere;
  min-height: 32px;
}
.id-copy svg { width: 14px; height: 14px; flex: none; }
.id-copy:hover { color: var(--ink); }
.conv-head .grow { min-width: 0; overflow-wrap: anywhere; }
.conv-head .btn { flex: none; }
.drawer-head .grow, .thread .row > b { min-width: 0; }
@media (max-width: 420px) {
  .conv-head { flex-wrap: wrap; }
  .conv-head .grow { flex-basis: calc(100% - 56px); }
  .facts { grid-template-columns: 1fr; }
}
@media (max-width: 380px) { .actions { grid-template-columns: 1fr; } }
@media (max-height: 600px) {
  .inbox { height: calc(100dvh - 84px); min-height: 220px; }
  .support-head, .conv-context, .conversation .quick { display: none; }
  .conv-head { padding: 8px 12px; }
  .main { padding-bottom: 8px; }
  .page-head { margin: 4px 0 10px; }
  .page-head h1 { font-size: 22px; }
}

/* Loading states and toggles used by the API-backed pages */
.spinner.light { border-color: rgba(255,255,255,.15); border-top-color: var(--cyan); }
.row.check { gap: 10px; font-size: 14px; cursor: pointer; }
