:root {
  --bg-void: #050508;
  --bg-surface: #0c0c12;
  --bg-card: #12121b;
  --bg-card-hover: #171724;
  --border-subtle: #24171c;
  --border-red: rgba(255, 26, 43, 0.42);
  --red-neon: #ff1e32;
  --red-bright: #ff4454;
  --red-deep: #b80014;
  --red-glow: 0 0 24px rgba(255, 26, 43, 0.25);
  --text-main: #f4f5f8;
  --text-muted: #989bad;
  --text-dim: #686b7d;
  --green: #18d47b;
  --amber: #f5a623;
  --radius: 12px;
}

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

body {
  background-color: var(--bg-void);
  background-image:
    radial-gradient(circle at 12% 10%, rgba(255, 22, 42, 0.10), transparent 36%),
    radial-gradient(circle at 88% 85%, rgba(180, 0, 20, 0.08), transparent 38%);
  color: var(--text-main);
  font-family: "Segoe UI", Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--red-bright); text-decoration: none; }
a:hover { color: #ff6b78; }

.layout {
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-box {
  padding: 6px 4px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-box img {
  width: 100%;
  height: auto;
  display: block;
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.93rem;
  border: 1px solid transparent;
  transition: all 0.18s ease;
}

.nav-link:hover {
  background: rgba(255, 30, 50, 0.08);
  color: var(--text-main);
  border-color: rgba(255, 30, 50, 0.22);
}

.nav-link.active {
  background: linear-gradient(90deg, rgba(255, 30, 50, 0.20), rgba(255, 30, 50, 0.05));
  color: #fff;
  border-color: var(--border-red);
  box-shadow: var(--red-glow);
}

.bot-status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px;
  font-size: 0.82rem;
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
}

.status-dot.offline {
  background: var(--red-neon);
  box-shadow: 0 0 10px var(--red-neon);
}

.main-content {
  padding: 28px 34px 48px;
  max-width: 1420px;
  width: 100%;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.page-header .subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-top: 2px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--red-neon), transparent);
}

.kpi-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  margin-top: 6px;
  color: var(--text-main);
}

.kpi-sub {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 4px;
}

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

.card-title {
  font-size: 1.08rem;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-group label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
  background: #08080d;
  border: 1px solid #2a1d22;
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--red-neon);
  box-shadow: 0 0 0 3px rgba(255, 30, 50, 0.16);
}

textarea.mono {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.86rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.16s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--red-neon), var(--red-deep));
  color: #fff;
  box-shadow: 0 4px 16px rgba(255, 24, 46, 0.28);
}

.btn-primary:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #1a1a26;
  color: var(--text-main);
  border-color: #31252a;
}

.btn-secondary:hover {
  background: #232333;
  border-color: var(--border-red);
}

.btn-success {
  background: rgba(24, 212, 123, 0.16);
  color: #4bf3a2;
  border-color: rgba(24, 212, 123, 0.45);
}

.btn-success:hover {
  background: rgba(24, 212, 123, 0.28);
}

.btn-danger {
  background: rgba(255, 30, 50, 0.14);
  color: #ff6b78;
  border-color: rgba(255, 30, 50, 0.35);
}

.btn-danger:hover {
  background: rgba(255, 30, 50, 0.26);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.78rem;
}

.alert {
  padding: 13px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.alert-success {
  background: rgba(24, 212, 123, 0.12);
  border-color: rgba(24, 212, 123, 0.35);
  color: #6df5b4;
}

.alert-error {
  background: rgba(255, 30, 50, 0.14);
  border-color: rgba(255, 30, 50, 0.45);
  color: #ff7c88;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th, td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid #1e181d;
  vertical-align: middle;
}

th {
  color: var(--text-muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  background: #0d0d14;
}

tr:hover td {
  background: rgba(255, 30, 50, 0.03);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.badge-available { background: rgba(24, 212, 123, 0.14); color: #4ff4a4; border: 1px solid rgba(24, 212, 123, 0.35); }
.badge-reserved  { background: rgba(245, 166, 35, 0.15); color: #ffc55c; border: 1px solid rgba(245, 166, 35, 0.35); }
.badge-delivered { background: rgba(255, 30, 50, 0.16); color: #ff6e7b; border: 1px solid rgba(255, 30, 50, 0.42); }
.badge-muted     { background: rgba(152, 155, 173, 0.12); color: #a7abbd; border: 1px solid rgba(152, 155, 173, 0.25); }

code.cell-code {
  font-family: Consolas, monospace;
  background: #08080d;
  border: 1px solid #241920;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.8rem;
  color: #e6e7ef;
  word-break: break-all;
}

/* Field Toggle Cards (Permanent Delivery Rule) */
.field-selector-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-toggle-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  background: #0a0a10;
  border: 1px solid #26191f;
  padding: 12px 14px;
  border-radius: 10px;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.field-toggle-row.enabled {
  border-color: var(--border-red);
  background: rgba(255, 30, 50, 0.06);
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #232331;
  border-radius: 999px;
  transition: 0.2s;
  border: 1px solid #392930;
}

.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #c8cbd8;
  border-radius: 50%;
  transition: 0.2s;
}

.switch input:checked + .slider {
  background: var(--red-neon);
  border-color: #ff6573;
  box-shadow: 0 0 12px rgba(255, 30, 50, 0.5);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
  background: #fff;
}

/* Live Telegram Preview Box */
.tg-preview {
  background: #0e1621;
  border: 1px solid #223044;
  border-radius: 14px;
  padding: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.88rem;
  color: #e9eff7;
  line-height: 1.55;
}

.tg-preview .tg-bubble {
  background: #182533;
  border-radius: 12px;
  padding: 14px 16px;
  border-left: 3px solid var(--red-neon);
}

.tg-preview .tg-quote {
  border-left: 3px solid #ff4454;
  background: rgba(255, 30, 50, 0.10);
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 8px;
  font-size: 0.83rem;
}

.tg-preview code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: Consolas, monospace;
  color: #9cdcfe;
}

/* Login Page */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-red);
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.65), var(--red-glow);
  text-align: center;
}

.login-emblem {
  width: 136px;
  height: 136px;
  border-radius: 50%;
  margin: 0 auto 14px;
  border: 2px solid var(--red-neon);
  box-shadow: 0 0 28px rgba(255, 24, 46, 0.45);
  object-fit: cover;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main-content { padding: 18px; }
  .grid-2 { grid-template-columns: 1fr; }
}
