:root {
  --bg: #f6f4f8;
  --surface: #ffffff;
  --surface-alt: #fbf9fc;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-soft: #ede9fe;
  --tg-blue: #2481cc;
  --tg-bg: #e7ebf0;
  --tg-bubble: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #059669;
  --success-bg: #d1fae5;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(31, 41, 55, 0.06);
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header.top-bar {
  background: linear-gradient(135deg, #2e1065 0%, #5b21b6 60%, #7c3aed 100%);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 2px 12px rgba(46, 16, 101, 0.2);
}
.brand-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-title h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-meta {
  font-size: 0.84rem;
  opacity: 0.9;
}

.mode-switcher {
  display: flex;
  background: rgba(255, 255, 255, 0.14);
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
}
.mode-btn {
  border: none;
  background: transparent;
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.mode-btn.active {
  background: #fff;
  color: #4c1d95;
}

.container {
  max-width: 1280px;
  margin: 22px auto;
  padding: 0 18px 48px;
}

.hidden {
  display: none !important;
}

/* TG Dual Simulator Layout */
.tg-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 22px;
  align-items: start;
}
@media (max-width: 960px) {
  .tg-grid {
    grid-template-columns: 1fr;
  }
}

.tg-frame {
  background: var(--tg-bg);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid #d4dce4;
  box-shadow: var(--shadow);
}
.tg-header {
  background: #ffffff;
  padding: 12px 18px;
  border-bottom: 1px solid #dce3ea;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.tg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tg-header-info {
  flex: 1;
  min-width: 0;
}
.tg-header-title {
  font-weight: 700;
  font-size: 0.96rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tg-header-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.tg-body {
  padding: 18px;
  max-height: 700px;
  overflow-y: auto;
}
.tg-post {
  background: var(--tg-bubble);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  font-size: 0.92rem;
  white-space: pre-wrap;
}
.tg-inline-kb {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tg-inline-row {
  display: flex;
  gap: 5px;
}
.tg-inline-btn {
  flex: 1;
  background: rgba(36, 129, 204, 0.12);
  color: #1666a5;
  border: 1px solid rgba(36, 129, 204, 0.22);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}
.tg-inline-btn:hover {
  background: rgba(36, 129, 204, 0.22);
}

/* Cards & Admin UI */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card h2,
.card h3 {
  margin-top: 0;
  margin-bottom: 12px;
}
.sub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.sub-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 15px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.sub-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-outline {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover {
  background: #f9fafb;
}
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.btn-success {
  background: var(--success-bg);
  color: var(--success);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.field input,
.field select,
.field textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
}
th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--surface-alt);
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}
.badge-confirmed {
  background: var(--success-bg);
  color: var(--success);
}
.badge-cancelled {
  background: var(--danger-bg);
  color: var(--danger);
}
.badge-completed {
  background: var(--primary-soft);
  color: var(--primary);
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 7px;
  margin-top: 10px;
}
.slot-chip {
  padding: 8px 6px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  text-align: center;
}
.slot-chip.selected,
.slot-chip:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.alert {
  padding: 11px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 0.88rem;
}
.alert-info {
  background: var(--primary-soft);
  color: #4c1d95;
}
.alert-error {
  background: var(--danger-bg);
  color: #991b1b;
}
.alert-success {
  background: var(--success-bg);
  color: #065f46;
}

.notif-item {
  border-left: 4px solid var(--primary);
  background: var(--surface-alt);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 0.86rem;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal {
  background: #fff;
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
}
