:root {
  --bg: #0b0e14;
  --bg2: #121722;
  --card: #171d29;
  --border: #262e3d;
  --text: #e2e8f0;
  --muted: #7b8698;
  --accent: #f97316;
  --accent2: #fb923c;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --blue: #60a5fa;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border); background: var(--bg2);
}
.topbar h1 {
  font-size: 18px; margin: 0; font-weight: 800;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.topbar nav a { color: var(--muted); margin-left: 18px; font-size: 14px; }
.topbar nav a:hover { color: var(--text); }

.container { max-width: 1100px; margin: 0 auto; padding: 28px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; margin-bottom: 20px;
}

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-card { width: 100%; max-width: 340px; text-align: center; }
.login-card .logo { font-size: 40px; margin-bottom: 8px; }

input, select, textarea {
  background: #1b2330; border: 1px solid var(--border); color: var(--text);
  padding: 9px 12px; border-radius: 9px; font-size: 14px; width: 100%;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; margin-top: 12px; }

button, .btn {
  background: var(--accent); color: #0b0e14; border: none; padding: 9px 16px;
  border-radius: 9px; font-weight: 600; font-size: 14px; cursor: pointer;
  font-family: inherit; display: inline-block;
}
button:hover, .btn:hover { background: var(--accent2); text-decoration: none; }
button.secondary, .btn.secondary { background: #263042; color: var(--text); }
button.secondary:hover, .btn.secondary:hover { background: #303c52; }
button.danger, .btn.danger { background: var(--red); color: #1a0d0d; }
button.warn, .btn.warn { background: var(--yellow); color: #1a1400; }

.error { color: var(--red); font-size: 13px; margin-top: 10px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700;
}
.badge.active { background: rgba(52,211,153,0.15); color: var(--green); border: 1px solid rgba(52,211,153,0.3); }
.badge.blocked { background: rgba(248,113,113,0.15); color: var(--red); border: 1px solid rgba(248,113,113,0.3); }
.badge.expired { background: rgba(251,191,36,0.15); color: var(--yellow); border: 1px solid rgba(251,191,36,0.3); }
.badge.pending_activation { background: rgba(96,165,250,0.15); color: var(--blue); border: 1px solid rgba(96,165,250,0.3); }
.badge.archived { background: rgba(123,134,152,0.15); color: var(--muted); border: 1px solid var(--border); }
.badge.green { background: rgba(52,211,153,0.15); color: var(--green); border: 1px solid rgba(52,211,153,0.3); }
.badge.yellow { background: rgba(251,191,36,0.15); color: var(--yellow); border: 1px solid rgba(251,191,36,0.3); }
.badge.red { background: rgba(248,113,113,0.15); color: var(--red); border: 1px solid rgba(248,113,113,0.3); }
.badge.muted { background: rgba(123,134,152,0.15); color: var(--muted); border: 1px solid var(--border); }

.alert-banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px;
  font-size: 13px; margin-bottom: 16px;
}
.alert-banner.clone {
  background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.35); color: var(--red);
}
.alert-banner .title { font-weight: 700; margin-right: 4px; }

.filters { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-width: 160px; }

.stat-row { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; min-width: 110px; }
.stat .n { font-size: 22px; font-weight: 800; }
.stat .l { font-size: 12px; color: var(--muted); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }

.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; text-align: right; }

.license-key {
  font-family: ui-monospace, monospace; background: #1b2330; padding: 8px 12px;
  border-radius: 8px; border: 1px solid var(--border); font-size: 15px; letter-spacing: 0.02em;
  word-break: break-all;
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.back-link { display: inline-block; margin-bottom: 16px; color: var(--muted); font-size: 13px; }
h2 { font-size: 16px; margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 13px; }
form.inline { display: inline; }

.nav-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 20px; background: var(--red); color: #1a0d0d;
  font-size: 11px; font-weight: 800; margin-left: 5px; vertical-align: 2px;
}
tr.unread td { font-weight: 700; }
tr.unread td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.thread { display: flex; flex-direction: column; gap: 14px; margin: 18px 0; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); }
.msg.reseller { align-self: flex-start; background: #1b2330; }
.msg.admin { align-self: flex-end; background: rgba(249,115,22,0.12); border-color: rgba(249,115,22,0.3); }
.msg-meta { font-size: 11px; color: var(--muted); margin-bottom: 5px; display: flex; gap: 8px; }
.msg-body { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.attachment-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 4px 9px;
  border-radius: 8px; background: #1b2330; border: 1px solid var(--border); color: var(--text);
}
.attachment-chip:hover { border-color: var(--accent); text-decoration: none; }
