:root {
  --bg: #0b1220;
  --bg-elev: #121a2b;
  --bg-input: #0a101c;
  --border: #243047;
  --text: #dbe4f3;
  --text-muted: #8fa1bf;
  --text-bright: #f4f7fc;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.12);
  --radius: 14px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

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

.is-hidden { display: none !important; }

html, body {
  min-height: 100%;
}

body {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(59, 130, 246, 0.22), transparent 55%),
    radial-gradient(700px 420px at 100% 0%, rgba(14, 165, 233, 0.12), transparent 45%),
    linear-gradient(180deg, #07101d 0%, var(--bg) 45%, #0a1322 100%);
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel {
  width: min(420px, 100%);
  background: color-mix(in srgb, var(--bg-elev) 92%, white 2%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.panel.dashboard {
  width: min(1100px, 100%);
}

.brand.row {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.brand.row .ghost {
  margin-top: 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.brand .left {
  display: flex;
  gap: 14px;
  align-items: center;
}

.ok {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid #22c55e;
  color: #22c55e;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.create-box {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
}

.create-box h2 {
  font-size: 14px;
  color: var(--text-bright);
  margin-bottom: 10px;
}

.row-inputs {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.row-inputs input { flex: 1; }
.row-inputs button {
  width: auto;
  padding: 0 18px;
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  word-break: break-word;
}

th { color: var(--text-muted); font-weight: 600; }

th:nth-child(1), td:nth-child(1) { width: 28%; }
th:nth-child(2), td:nth-child(2) { width: 24%; }
th:nth-child(3), td:nth-child(3) { width: 14%; }
th:nth-child(4), td:nth-child(4) { width: 12%; }
th:nth-child(5), td:nth-child(5) { width: 22%; }

tbody tr:last-child td { border-bottom: 0; }

code.lic-key {
  display: inline-block;
  font-size: 12px;
  color: var(--text-bright);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 4px 10px;
}

.badge-on {
  color: #86efac;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.badge-off {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.device-cell {
  color: var(--text-muted);
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.actions .btn-sm {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  line-height: 1.2;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
}

.actions .btn-sm:hover {
  background: rgba(255,255,255,0.04);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
}

.actions .btn-sm:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.actions .btn-danger:hover {
  border-color: rgba(239, 68, 68, 0.55);
  color: #fecaca;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: white;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
}

.brand h1 {
  font-size: 22px;
  color: var(--text-bright);
  line-height: 1.2;
}

.muted { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-bright);
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
}

input:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, white 10%);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 14px;
  cursor: pointer;
}

button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

button.ghost {
  margin-top: 18px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.error {
  background: var(--danger-dim);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.cards {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.card h2 {
  font-size: 14px;
  color: var(--text-bright);
  margin-bottom: 8px;
}

.card p { font-size: 13px; color: var(--text-muted); line-height: 1.45; }

/* ===== Admin app shell ===== */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elev) 96%, black 4%);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 40;
}

.sidebar-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 8px;
}

.sidebar-head strong {
  display: block;
  color: var(--text-bright);
  font-size: 14px;
}

.sidebar-head .muted {
  margin: 0;
  font-size: 12px;
}

.brand-mark.sm {
  width: 36px;
  height: 36px;
  font-size: 12px;
  border-radius: 10px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  padding: 11px 12px;
  border-radius: 10px;
}

.nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-bright);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.35);
  color: #93c5fd;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 8px;
}

.who-line {
  font-size: 13px;
  color: var(--text-muted);
}

.btn-side {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px;
}

.btn-side:hover {
  background: rgba(255,255,255,0.04);
}

.main {
  min-width: 0;
  padding: 18px 20px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.topbar h1 {
  flex: 1;
  font-size: 22px;
  color: var(--text-bright);
}

.btn-refresh {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
}

.burger {
  display: none;
  width: 42px;
  height: 42px;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}

.burger span {
  display: block;
  height: 2px;
  background: var(--text-bright);
  border-radius: 2px;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 30;
}

.view-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.feed {
  display: grid;
  gap: 12px;
}

.feed-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.025);
  padding: 14px 16px;
}

.feed-card.status-success {
  border-color: rgba(34, 197, 94, 0.35);
}

.feed-card.status-failed {
  border-color: rgba(239, 68, 68, 0.35);
}

.feed-card.status-processing {
  border-color: rgba(234, 179, 8, 0.35);
}

.feed-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.feed-top time {
  font-size: 12px;
  color: var(--text-muted);
}

.feed-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 10px;
}

.feed-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.feed-grid span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.feed-grid strong {
  font-size: 13px;
  color: var(--text-bright);
  word-break: break-word;
}

.feed-meta, .feed-msg {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.badge-wait {
  color: #fde68a;
  background: rgba(234, 179, 8, 0.14);
  border: 1px solid rgba(234, 179, 8, 0.35);
}

.empty-feed {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .burger { display: inline-flex; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(280px, 86vw);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .feed-grid { grid-template-columns: 1fr; }
}

