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

:root {
  --bg:        #0a0a14;
  --surface:   #111128;
  --surface2:  #1a1a36;
  --border:    #2a2a4a;
  --text:      #e2e8f0;
  --text-muted:#8892a4;
  --purple:    #7c3aed;
  --purple2:   #a78bfa;
  --teal:      #0d9488;
  --teal2:     #5eead4;
  --blue:      #1d4ed8;
  --blue2:     #93c5fd;
  --green:     #16a34a;
  --red:       #dc2626;
  --warn:      #d97706;
  --radius:    10px;
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--purple2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Navbar ─── */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-logo { font-size: 20px; font-weight: 700; text-decoration: none; }
.logo-kvn   { color: var(--purple2); }
.logo-cloud { color: var(--text); }
.nav-links  { display: flex; gap: 20px; align-items: center; }
.nav-link   { color: var(--text-muted); font-size: 14px; text-decoration: none; transition: color .2s; }
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-logout { color: var(--red) !important; opacity: .7; }
.nav-logout:hover { opacity: 1; }

/* ─── Page wrap ─── */
.page-wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }

/* ─── Alerts ─── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 14px;
}
.alert-success { background: rgba(22,163,74,.15); border: 1px solid rgba(22,163,74,.4); color: #86efac; }
.alert-error   { background: rgba(220,38,38,.15); border: 1px solid rgba(220,38,38,.4); color: #fca5a5; }
.alert-warning { background: rgba(217,119,6,.15);  border: 1px solid rgba(217,119,6,.4);  color: #fcd34d; }

/* ─── Auth pages ─── */
.auth-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 80px); padding: 24px 16px;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 36px 32px; width: 100%; max-width: 420px;
}
.auth-logo { font-size: 24px; font-weight: 700; margin-bottom: 20px; }
.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.auth-desc  { color: var(--text-muted); font-size: 14px; margin-bottom: 8px; line-height: 1.6; }
.auth-desc.muted { opacity: .6; }
.auth-form  { margin-top: 20px; }
.auth-links { margin-top: 20px; font-size: 14px; color: var(--text-muted); text-align: center; }
.auth-links a { color: var(--purple2); }
.auth-links span { margin: 0 6px; }
.icon-big   { font-size: 48px; margin-bottom: 12px; }

/* ─── Fields ─── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.field input,
.field select,
.field textarea {
  width: 100%; padding: 10px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 15px;
  outline: none; transition: border-color .2s;
}
.field input:focus,
.field select:focus { border-color: var(--purple); }
.field input::placeholder { color: var(--text-muted); opacity: .6; }

/* ─── Buttons ─── */
.btn-primary {
  background: var(--purple); color: #fff; border: none;
  padding: 11px 22px; border-radius: 8px; font-size: 15px;
  font-weight: 600; cursor: pointer; transition: background .2s;
}
.btn-primary:hover { background: #6d28d9; }
.btn-full { width: 100%; }
.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); padding: 10px 20px;
  border-radius: 8px; font-size: 14px; cursor: pointer;
  display: inline-block; text-align: center; text-decoration: none;
  transition: border-color .2s, color .2s;
}
.btn-ghost:hover { border-color: var(--purple2); color: var(--purple2); text-decoration: none; }
.btn-sm {
  padding: 6px 14px; font-size: 13px; border-radius: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; transition: all .2s;
  display: inline-block;
}
.btn-sm:hover { border-color: var(--purple2); color: var(--text); text-decoration: none; }
.btn-warn  { border-color: var(--warn) !important; color: var(--warn) !important; }
.btn-danger { border-color: var(--red) !important; color: var(--red) !important; }

/* ─── Dashboard ─── */
.dash-wrap  { max-width: 960px; margin: 0 auto; padding: 28px 16px 60px; }
.dash-header{ display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.dash-title { font-size: 26px; font-weight: 700; }
.dash-sub   { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.section-label {
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 12px;
}

/* ─── Stats row (admin) ─── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.stat-val { font-size: 28px; font-weight: 700; color: var(--purple2); }
.stat-lbl { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ─── Services grid ─── */
.services-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.svc-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px; transition: border-color .2s;
}
.svc-card.active  { border-color: var(--purple); }
.svc-card.inactive{ opacity: .8; }
.svc-top   { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.svc-icon  { font-size: 28px; width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.vpn-icon   { background: rgba(124,58,237,.15); }
.immich-icon{ background: rgba(13,148,136,.15); }
.cloud-icon { background: rgba(29,78,216,.15); }
.svc-name  { font-size: 16px; font-weight: 600; }
.svc-info  { border-top: 1px solid var(--border); padding-top: 12px; margin-bottom: 14px; }
.info-row  { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; }
.info-row span:first-child { color: var(--text-muted); }
.svc-empty { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.btn-svc {
  display: block; text-align: center; padding: 9px 14px;
  background: rgba(124,58,237,.2); border: 1px solid var(--purple);
  color: var(--purple2); border-radius: 8px; font-size: 14px;
  font-weight: 500; text-decoration: none; transition: background .2s;
}
.btn-svc:hover { background: rgba(124,58,237,.35); text-decoration: none; }
.btn-svc.teal  { background: rgba(13,148,136,.2); border-color: var(--teal); color: var(--teal2); }
.btn-svc.teal:hover { background: rgba(13,148,136,.35); }
.btn-svc.blue  { background: rgba(29,78,216,.2); border-color: var(--blue); color: var(--blue2); }
.btn-svc.blue:hover { background: rgba(29,78,216,.35); }

/* ─── Apps grid ─── */
.apps-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.app-btn {
  padding: 9px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; color: var(--text-muted);
  text-decoration: none; transition: all .2s;
}
.app-btn:hover { border-color: var(--purple2); color: var(--text); text-decoration: none; }
.app-btn.teal:hover { border-color: var(--teal2); }

/* ─── Badges ─── */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px; margin: 2px 2px 0 0;
}
.badge-active   { background: rgba(22,163,74,.2);   color: #86efac; }
.badge-inactive { background: rgba(100,100,100,.15); color: var(--text-muted); }
.badge-teal     { background: rgba(13,148,136,.2);   color: var(--teal2); }
.badge-blue     { background: rgba(29,78,216,.2);    color: var(--blue2); }

/* ─── Table ─── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left; padding: 10px 12px;
  color: var(--text-muted); font-size: 12px; font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td {
  padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.04);
  vertical-align: middle;
}
.data-table tr:hover td { background: rgba(255,255,255,.02); }

/* ─── User card (admin) ─── */
.user-card {
  display: flex; align-items: flex-start; gap: 20px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px; margin-bottom: 28px;
  flex-wrap: wrap;
}
.user-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--purple); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; flex-shrink: 0;
}
.user-name  { font-size: 18px; font-weight: 600; }
.user-email { color: var(--text-muted); font-size: 14px; margin-top: 2px; }
.user-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }

/* ─── Add sub form ─── */
.add-sub-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.add-sub-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.add-sub-form .field { margin: 0; min-width: 130px; }

/* ─── Support ─── */
.support-block {
  margin-top: 32px; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; font-size: 14px; color: var(--text-muted);
}

/* ─── Back link ─── */
.back-link {
  display: inline-block; color: var(--text-muted);
  font-size: 14px; margin-bottom: 20px;
}
.back-link:hover { color: var(--text); text-decoration: none; }

/* ─── Mobile ─── */
@media (max-width: 600px) {
  .auth-card { padding: 24px 18px; }
  .services-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .add-sub-form { flex-direction: column; }
  .add-sub-form .field { min-width: 100%; }
  .user-card { flex-direction: column; }
  .user-actions { margin-left: 0; }
  .navbar { padding: 0 14px; }
  .nav-links { gap: 12px; }
}

/* ─── Admin extras ─── */
.badge-red    { background: rgba(220,38,38,.2);   color: #fca5a5; }
.badge-orange { background: rgba(217,119,6,.2);   color: #fcd34d; }
.badge-green  { background: rgba(22,163,74,.2);   color: #86efac; }
.stat-val.purple { color: var(--purple2); }
.stat-val.green  { color: #86efac; }
.stat-val.teal   { color: var(--teal2); }
.stat-val.red    { color: #fca5a5; }
.stat-val.orange { color: #fcd34d; }

.search-form  { display:flex; gap:10px; flex-wrap:wrap; }
.search-input {
  flex:1; min-width:200px; padding:10px 14px;
  background:var(--surface); border:1px solid var(--border);
  border-radius:8px; color:var(--text); font-size:14px; outline:none;
}
.search-input:focus { border-color:var(--purple); }

.user-avatar.blocked { background: var(--red); }
.btn-success { border-color: var(--green) !important; color: #86efac !important; }

.msg-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-top: 20px;
}
.msg-form   { display:flex; flex-direction:column; gap:10px; margin-top:10px; }
.msg-input  {
  width:100%; padding:10px 12px; background:var(--surface2);
  border:1px solid var(--border); border-radius:8px;
  color:var(--text); font-size:14px; resize:vertical; outline:none;
}
.msg-input:focus { border-color:var(--purple); }
