:root {
  --bg: #080d1a;
  --bg-accent: #0f172a;
  --card: #111a2e;
  --card-2: #16223b;
  --border: #253455;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #38bdf8;
  --primary-2: #6366f1;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', 'Noto Sans Bengali', system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top right, #172554 0%, var(--bg) 52%);
  color: var(--text);
  min-height: 100vh;
}

.wrap {
  max-width: 1220px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 14px 20px;
  background: rgba(17, 26, 46, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
}

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

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: grid;
  place-items: center;
  font-size: 22px;
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.28);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.lang-switch {
  display: inline-flex;
  background: #091020;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}

.lang-switch button {
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 13px;
}

.lang-switch button.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
}

.pill {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #0b1324;
  color: var(--primary);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.card h2, .card h3 {
  margin: 0 0 12px;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}

.grid-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 8px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

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

input, select, textarea {
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #091020;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

button {
  padding: 9px 14px;
  border-radius: 9px;
  border: none;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}

button:hover { filter: brightness(1.12); }
button:active { transform: scale(0.98); }

.btn-alt {
  background: #1e293b;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-chip {
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 10px;
}

.btn-chip.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.45);
}

.btn-danger {
  background: #7f1d1d;
  color: #fecaca;
}

.btn-success {
  background: #15803d;
  color: #dcfce7;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.on { background: rgba(34, 197, 94, 0.18); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.35); }
.badge.off { background: rgba(239, 68, 68, 0.16); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.35); }
.badge.phase2 { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.35); }

.meta {
  font-size: 12.5px;
  color: var(--muted);
}

.oled-frame {
  background: #020617;
  border: 3px solid #334155;
  border-radius: 12px;
  padding: 10px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  box-shadow: inset 0 0 24px rgba(56, 189, 248, 0.12);
}

canvas#oledSimCanvas {
  width: 256px;
  height: 128px;
  image-rendering: pixelated;
  background: #000;
  border-radius: 4px;
}

canvas#oledTextPreview {
  width: 256px;
  height: auto;
  max-height: 96px;
  image-rendering: pixelated;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.stat-box {
  background: #091020;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.stat-box .k { font-size: 11px; color: var(--muted); }
.stat-box .v { font-size: 15px; font-weight: 700; margin-top: 3px; }

.meter-bar {
  width: 100%;
  height: 12px;
  background: #091020;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8, #a855f7);
  transition: width 0.2s ease;
}

.table-scroll {
  overflow-x: auto;
}

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

th, td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.event-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #091020;
  border: 1px solid #1d2b47;
  font-size: 12.5px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: #091020;
  border: 1px solid var(--border);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 11px 16px;
  border-radius: 10px;
  background: #0f172a;
  border: 1px solid var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  z-index: 9999;
}

.touch-sim-box {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px;
  border-radius: 12px;
  background: #091020;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.virtual-touch-pad {
  width: 148px;
  height: 148px;
  border-radius: 16px;
  background: linear-gradient(145deg, #0b3b75, #062147);
  border: 2px solid #2563eb;
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.25), inset 0 0 16px rgba(56, 189, 248, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  position: relative;
  transition: transform 0.08s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.virtual-touch-pad:hover {
  border-color: var(--primary);
}

.virtual-touch-pad.active {
  transform: scale(0.96);
  border-color: #67e8f9;
  box-shadow: 0 0 28px rgba(56, 189, 248, 0.65), inset 0 0 24px rgba(103, 232, 249, 0.45);
}

.touch-rings {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 2px solid rgba(186, 230, 253, 0.7);
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 8px rgba(186, 230, 253, 0.18), 0 0 0 16px rgba(186, 230, 253, 0.08);
}

.touch-rings-inner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle, #bae6fd 0%, #38bdf8 70%, transparent 100%);
}

.virtual-touch-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #bae6fd;
  text-align: center;
}

.hidden { display: none !important; }
