:root {
  --bg: #07080f;
  --panel: #10131d;
  --line: rgba(255,255,255,.08);
  --text: #f4f5f8;
  --muted: #9aa3b5;
  --purple: #3b2cff;
  --cyan: #00c2ff;
  --lime: #b6f000;
  --danger: #ff5c7a;
  --ok: #3dd68c;
  --warn: #ffbf3c;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --display: "Manrope", system-ui, sans-serif;
  --sidebar: 268px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 800;
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--purple), var(--cyan));
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 10px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: .2s transform, .2s opacity, .2s background;
}
.btn:hover { transform: translateY(-1px); }
.btn.solid {
  background: linear-gradient(135deg, var(--purple), #6a5cff);
  color: white;
}
.btn.ghost {
  background: rgba(255,255,255,.03);
  border-color: var(--line);
  color: var(--text);
}
.btn.danger { border-color: rgba(255,92,122,.4); color: #ffc0cb; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(59,44,255,.25), transparent 30%),
    radial-gradient(circle at 80% 0%, rgba(0,194,255,.18), transparent 28%),
    var(--bg);
}
.login-card {
  width: min(440px, 100%);
  background: rgba(16,19,29,.92);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,.4);
}
.login-card h1 {
  font-family: var(--display);
  margin: 18px 0 8px;
  letter-spacing: -.03em;
}
.stack { display: grid; gap: 14px; }
.stack label, .panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.28);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(0,194,255,.55);
  box-shadow: 0 0 0 3px rgba(0,194,255,.12);
}
input[type="color"] { padding: 4px; height: 44px; }
input[type="checkbox"] { width: auto; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #0b0d16;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sidebar-top { display: flex; justify-content: space-between; align-items: center; }
.company-chip {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255,255,255,.03);
}
.company-chip strong { display: block; margin-bottom: 4px; }
.company-chip span { color: var(--muted); font-size: 12px; }
.side-nav { display: grid; gap: 4px; flex: 1; overflow: auto; }
.side-nav button {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 11px 12px;
  border-radius: 12px;
  cursor: pointer;
}
.side-nav button.active, .side-nav button:hover {
  background: rgba(59,44,255,.16);
  color: var(--text);
}
.logout { margin-top: auto; }

.main { min-width: 0; }
.main-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(7,8,15,.88);
  backdrop-filter: blur(14px);
  z-index: 5;
}
.main-top h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.45rem;
  letter-spacing: -.03em;
}
.main-top p { margin: 4px 0 0; }
.top-actions { margin-left: auto; }
#views { padding: 22px 24px 48px; display: grid; gap: 18px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px;
}
.stat, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
}
.stat { padding: 18px; min-height: 110px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value {
  font-family: var(--display);
  font-size: 1.8rem;
  font-weight: 800;
  margin-top: 10px;
  letter-spacing: -.04em;
}
.stat .hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.panel { padding: 18px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.05rem;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
}
.row, .row-2 {
  display: grid;
  gap: 12px;
}
.row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.row-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }

.chart {
  display: flex;
  align-items: end;
  gap: 6px;
  height: 180px;
  padding-top: 10px;
}
.chart-bar {
  flex: 1;
  min-width: 0;
  background: linear-gradient(180deg, var(--cyan), var(--purple));
  border-radius: 8px 8px 4px 4px;
  position: relative;
  opacity: .85;
  transition: .2s opacity;
}
.chart-bar:hover { opacity: 1; }
.chart-bar span {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}
.status-bars { display: grid; gap: 10px; }
.status-row { display: grid; grid-template-columns: 120px 1fr 40px; gap: 10px; align-items: center; font-size: 13px; }
.status-track {
  height: 8px;
  background: rgba(255,255,255,.06);
  border-radius: 999px;
  overflow: hidden;
}
.status-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--cyan));
  border-radius: inherit;
}
.list { display: grid; gap: 8px; }
.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid transparent;
}
.list-item:hover { border-color: var(--line); }
.list-item strong { display: block; }
.list-item span { color: var(--muted); font-size: 12px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.toolbar input, .toolbar select { max-width: 280px; }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
}
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge.free, .badge.active, .badge.confirmed, .badge.paid { background: rgba(61,214,140,.15); color: var(--ok); }
.badge.busy, .badge.pending_payment, .badge.pending { background: rgba(255,191,60,.15); color: var(--warn); }
.badge.soon, .badge.trial { background: rgba(0,194,255,.15); color: var(--cyan); }
.badge.cancelled, .badge.suspended { background: rgba(255,92,122,.15); color: var(--danger); }
.badge.completed { background: rgba(255,255,255,.08); color: var(--muted); }

.checks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 10px;
}
.checks label, .check-inline {
  display: flex !important;
  align-items: center;
  gap: 8px;
  color: var(--text);
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.slide-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 10px;
  background: rgba(255,255,255,.02);
}
.brand-preview {
  border-radius: 24px;
  padding: 18px;
  min-height: 280px;
  border: 1px solid var(--line);
  background: #f5f6fa;
  color: #111;
}
.brand-preview .phone {
  background: white;
  border-radius: 22px;
  padding: 16px;
  box-shadow: 0 18px 40px rgba(0,0,0,.12);
}
.brand-preview .chip {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  color: white;
  font-size: 12px;
  margin-bottom: 12px;
}
.sub-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: rgba(255,255,255,.03);
  display: grid;
  gap: 8px;
}
.key-box, .env-box {
  display: block;
  white-space: pre-wrap;
  word-break: break-all;
  background: rgba(0,0,0,.35);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}
.modal-card {
  width: min(640px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  background: #10131d;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
}
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  background: #171b28;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0,0,0,.35);
  animation: rise .25s ease;
}
.toast.ok { border-color: rgba(61,214,140,.4); }
.toast.err { border-color: rgba(255,92,122,.4); }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.skel-block {
  position: relative;
  overflow: hidden;
  background: rgba(255,255,255,.05);
  border-radius: 16px;
  min-height: 88px;
}
.skel-block::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

.mobile-only { display: none; }

@media (max-width: 1100px) {
  .stat-grid, .grid-2, .checks, .row-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    width: min(86vw, 300px);
    transform: translateX(-105%);
    transition: transform .25s;
    z-index: 30;
  }
  .sidebar.open { transform: none; }
  .mobile-only { display: inline-flex; }
  #views { padding: 16px; }
  .main-top { padding: 14px 16px; }
}
