@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap');
@import url('./theme-tagras.css');

:root {
  --tg-surface-2: #eef3f7;
  --tg-surface-3: #e3e9f0;
  --tg-shadow-soft: 0 14px 38px rgba(15, 23, 42, 0.12);
  --tg-shadow-hard: 0 18px 48px rgba(12, 21, 37, 0.16);
  --tg-radius-sm: 8px;
  --tg-radius: 12px;
  --tg-radius-lg: 16px;
  --tg-sidebar-width: 248px;
  --tg-border-strong: #c1c9d6;
  --tg-card-border: rgba(15, 23, 42, 0.06);
  --tg-surface-border: rgba(15, 23, 42, 0.06);
  --tg-gradient: radial-gradient(circle at 8% 16%, rgba(52, 184, 192, 0.14), transparent 32%),
    radial-gradient(circle at 70% 0%, rgba(227, 65, 106, 0.10), transparent 26%),
    linear-gradient(135deg, #f6fbfc 0%, #f4f6fb 50%, #f7fafe 100%);
  --tg-glow: 0 0 0 8px rgba(52, 184, 192, 0.12);
  --tg-font-family: 'Manrope', 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont,
    'Helvetica Neue', Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--tg-gradient);
  color: var(--tg-text-main);
  font-family: var(--tg-font-family);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--tg-primary-dark);
  text-decoration: none;
}
a:hover { color: var(--tg-primary); }

img { max-width: 100%; display: block; }

.tg-page {
  display: flex;
  min-height: 100vh;
  background: var(--tg-gradient);
}

.tg-sidebar {
  width: var(--tg-sidebar-width);
  background: linear-gradient(180deg, #1f2a38 0%, #1a212d 100%);
  color: #e7edf6;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 16px 24px;
  box-sizing: border-box;
  position: sticky;
  top: 0;
  min-height: 100vh;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 6px 0 24px rgba(15,23,42,0.18);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.tg-sidebar.is-collapsed {
  position: fixed;
  transform: translateX(-100%);
  opacity: 0;
  min-height: 100vh;
  z-index: 1001;
}
.tg-sidebar.is-open {
  transform: translateX(0);
  opacity: 1;
}
.tg-mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(2px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-out;
}
.tg-mobile-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}
body.sidebar-open {
  overflow: hidden;
}

.tg-sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--tg-radius);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.tg-sidebar__logo img { height: 28px; }

.tg-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}
.tg-menu li { margin-bottom: 6px; }

.tg-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--tg-radius-sm);
  color: #d9e2ef;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  border: 1px solid transparent;
}
.tg-menu a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.tg-menu a.active {
  color: #fff;
  background: rgba(52, 184, 192, 0.20);
  border-color: rgba(52, 184, 192, 0.45);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.tg-menu__section > a {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
}
.tg-menu__caret {
  font-size: 10px;
  opacity: 0.9;
  transition: transform 0.15s ease;
}
.tg-menu__section > ul {
  list-style: none;
  padding: 4px 0 0 6px;
  margin: 0;
  display: none;
}
.tg-menu__section.open > ul { display: block; }
.tg-menu__section.open .tg-menu__caret { transform: rotate(90deg); }

.tg-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.82) 0%, rgba(245,247,250,0.92) 100%);
}

.tg-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--tg-line-soft);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 10px 24px rgba(15,23,42,0.06);
}
.tg-topbar__burger {
  display: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--tg-radius);
  background: transparent;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  position: relative;
}
.tg-topbar__burger span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: block;
  width: 20px;
  height: 2px;
  background: var(--tg-text-main);
  border-radius: 2px;
}
.tg-topbar__burger span::before,
.tg-topbar__burger span::after {
  content: '';
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: var(--tg-text-main);
  border-radius: 2px;
}
.tg-topbar__burger span::before { top: -6px; }
.tg-topbar__burger span::after { top: 6px; }
.tg-topbar__burger:hover { background: rgba(0,0,0,0.04); }
.tg-topbar__burger:focus { outline: none; box-shadow: 0 0 0 2px rgba(52,184,192,0.35); }
.tg-topbar__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--tg-text-main);
}
.tg-topbar__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.tg-topbar__search input { width: 220px; }

.tg-content {
  padding: 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  margin: 0 auto;
  max-width: 98%;
}

h1, h2, h3, h4 {
  margin: 0 0 8px;
  color: var(--tg-text-main);
  font-weight: 700;
}
.tg-page-title {
  font-size: 22px;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.tg-section-title {
  font-size: 16px;
  margin: 14px 0 8px;
  color: var(--tg-text-main);
}
.tg-text-muted {
  color: var(--tg-text-soft);
  font-size: 13px;
}
p { margin: 0 0 12px; color: var(--tg-text-main); }

.tg-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tg-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--tg-radius-sm);
  background: var(--tg-surface-2);
  border: 1px solid var(--tg-border);
  font-weight: 700;
  color: var(--tg-text-main);
}
.tg-user-chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tg-success);
  box-shadow: 0 0 0 4px rgba(31,169,122,0.12);
  display: inline-block;
}

/* Page header */
.tg-page-header {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 12px;
}
.tg-page-header__main { grid-column: 1 / span 1; }
.tg-page-header__title { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.tg-page-header__subtitle { margin: 4px 0 0; color: var(--tg-text-soft); }
.tg-page-header__meta { display: flex; gap: 8px; justify-content: flex-end; }
.tg-page-header__actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.tg-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--tg-border);
  background: var(--tg-surface);
  color: var(--tg-text-main);
  font-weight: 600;
  font-size: 12px;
}
.tg-chip--muted { background: var(--tg-surface-2); color: var(--tg-text-soft); }
.tg-chip--info { border-color: var(--tg-info); color: var(--tg-info); }
.tg-chip--danger { border-color: var(--tg-danger); color: var(--tg-danger); background: var(--tg-danger-soft); }

/* Layout */
.tg-layout {
  display: grid;
  gap: 12px;
  grid-template-columns: 100%;
  align-items: start;
  overflow: visible;
}
.tg-layout__filters { display: flex; flex-direction: column; gap: 10px; overflow: visible; }
.tg-layout__content { display: flex; flex-direction: column; gap: 12px; overflow: visible; }
@media (max-width: 1100px) {
  .tg-layout { grid-template-columns: 1fr; }
}

body.no-sidebar .tg-page {
  display: flex;
  flex-direction: column;
}
body.no-sidebar .tg-main {
  min-height: 100vh;
}
body.no-sidebar .tg-topbar {
  box-shadow: none;
}

/* Empty state */
.tg-empty {
  padding: 20px;
  text-align: center;
  color: var(--tg-text-soft);
  background: var(--tg-surface);
  border: 1px dashed var(--tg-border);
  border-radius: var(--tg-radius);
}
.tg-empty__title { font-weight: 700; margin-bottom: 6px; color: var(--tg-text-main); }
.tg-empty__subtitle { margin-bottom: 10px; }

/* Buttons */
.tg-btn,
button,
input[type=submit] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--tg-radius-sm);
  font-family: var(--tg-font-family);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
  text-decoration: none;
  background: #fff;
  color: var(--tg-text-main);
}
.tg-btn:hover,
button:hover,
input[type=submit]:hover { transform: translateY(-1px); }
.tg-btn:active,
button:active,
input[type=submit]:active { transform: translateY(0); }
.tg-btn:disabled,
button:disabled,
input[type=submit]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
.tg-btn-primary {
  background: linear-gradient(135deg, var(--tg-primary) 0%, var(--tg-primary-dark) 100%);
  color: #fff;
  border-color: var(--tg-primary);
  box-shadow: 0 8px 18px rgba(52,184,192,0.22);
}
.tg-btn-primary:hover { box-shadow: 0 10px 24px rgba(52,184,192,0.32); }
.tg-btn-secondary {
  background: #fff;
  color: var(--tg-primary-dark);
  border-color: var(--tg-border);
}
.tg-btn-secondary:hover { border-color: var(--tg-primary); color: var(--tg-primary); }
.tg-btn-danger {
  background: linear-gradient(135deg, var(--tg-danger) 0%, #b81f33 100%);
  color: #fff;
  border-color: var(--tg-danger);
  box-shadow: 0 8px 16px rgba(215,38,61,0.25);
}
.tg-btn-ghost {
  background: transparent;
  color: var(--tg-text-main);
  border-color: transparent;
}
.tg-btn--compact { padding: 6px 10px; font-size: 13px; }
.tg-btn--xs { padding: 5px 8px; font-size: 12px; }

/* Cards */
.tg-card {
  background: var(--tg-surface);
  border: 1px solid var(--tg-card-border, rgba(15,23,42,0.06));
  border-radius: var(--tg-radius-lg);
  box-shadow: var(--tg-shadow-soft);
  padding: 16px 18px;
  overflow: visible;
}
.tg-card + .tg-card { margin-top: 10px; }
.tg-card--ok { border-left: 4px solid var(--tg-success); }
.tg-card--warning { border-left: 4px solid var(--tg-warning); }
.tg-card--danger { border-left: 4px solid var(--tg-danger); }
.tg-card--soft { box-shadow: none; border-color: var(--tg-border); }
.tg-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.tg-card__title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px 0;
}
.tg-card__subtitle {
  font-size: 13px;
  color: var(--tg-text-soft);
  margin: 0;
}
.tg-card__actions { display: flex; gap: 8px; align-items: center; }
.tg-card__body { display: flex; flex-direction: column; gap: 12px; overflow: visible; }
.tg-card__footer { margin-top: 8px; color: var(--tg-text-soft); font-size: 13px; }

/* Alerts */
.tg-alert {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--tg-radius-sm);
  font-size: 13px;
  border: 1px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
}
.tg-alert--info { background: var(--tg-info-soft); color: var(--tg-text-main); border-color: rgba(47,128,237,0.25); }
.tg-alert--warning { background: var(--tg-warning-soft); color: var(--tg-text-main); border-color: rgba(244,161,0,0.35); }
.tg-alert--danger { background: var(--tg-danger-soft); color: var(--tg-text-main); border-color: rgba(215,38,61,0.3); }

/* Badges */
.tg-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.tg-badge--success { background: var(--tg-success-soft); color: var(--tg-success); }
.tg-badge--warning { background: var(--tg-warning-soft); color: var(--tg-warning); }
.tg-badge--danger { background: var(--tg-danger-soft); color: var(--tg-danger); }
.tg-badge--info { background: var(--tg-info-soft); color: var(--tg-info); }
.tg-badge--maintenance { background: var(--tg-accent-soft); color: var(--tg-accent); }
.tg-badge--neutral { background: var(--tg-surface-2); color: var(--tg-text-soft); border: 1px solid var(--tg-border); }

/* Inputs */
input[type=text],
input[type=password],
input[type=number],
input[type=date],
input[type=email],
select,
textarea,
.tg-input {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--tg-radius-sm);
  border: 1px solid var(--tg-border);
  background: #fff;
  font-family: var(--tg-font-family);
  font-size: 13px;
  color: var(--tg-text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { resize: vertical; min-height: 80px; }
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--tg-primary);
  box-shadow: var(--tg-glow);
}
.tg-input--error { border-color: var(--tg-danger); }
.tg-input__error-text {
  font-size: 11px;
  color: var(--tg-danger);
  margin-top: 4px;
}
label { display: block; font-weight: 600; color: var(--tg-text-main); margin-bottom: 6px; }
label > input,
label > select,
label > textarea { margin-top: 4px; }

.tg-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
}

.tg-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.tg-field { display: flex; flex-direction: column; gap: 4px; }
.tg-field__label { font-weight: 600; color: var(--tg-text-main); font-size: 13px; }

/* Table */
.tg-table,
.tg-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--tg-surface);
  font-size: 13px;
  border: 1px solid var(--tg-surface-border, rgba(15,23,42,0.06));
  border-radius: var(--tg-radius);
  box-shadow: var(--tg-shadow-soft);
  overflow: visible;
  position: relative;
}
.tg-table thead,
.tg-content table thead {
  background: linear-gradient(180deg, #f5f7fb 0%, #eef2f6 100%);
  color: var(--tg-text-soft);
}
.tg-table th,
.tg-table td,
.tg-content table th,
.tg-content table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--tg-line-soft);
  text-align: left;
  overflow: visible;
  vertical-align: middle;
}
.tg-table tbody tr:nth-child(even),
.tg-content table tbody tr:nth-child(even) { background: #f9fbfd; }
.tg-table tbody tr:hover,
.tg-content table tbody tr:hover { background: var(--tg-primary-soft); }
.tg-table__row--active { border-left: 4px solid var(--tg-primary); background: #e6f6f7; }
.tg-table--compact th,
.tg-table--compact td { padding: 8px 10px; }
.tg-table--hover tbody tr:hover { background: var(--tg-primary-soft); }
.tg-table__col-actions { width: 1%; white-space: nowrap; }
.tg-table__empty { text-align: center; color: var(--tg-text-soft); font-size: 13px; }
.tg-table tr.is-expired { background: #fff1f3; }
.tg-table tr.is-expiring { background: #fff7e3; }
.tg-table tr.is-fresh { background: #eef7ff; }

.tg-table-wrapper {
  width: 100%;
  position: relative;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 780px) {
  .tg-table--compact {
    font-size: 12px;
  }
  .tg-table-wrapper .tg-table,
  .tg-table-wrapper table {
    min-width: 600px;
  }
}

@media (max-width: 600px) {
  .tg-table--responsive {
    border: none;
    box-shadow: none;
  }
  .tg-table--responsive thead {
    display: none;
  }
  .tg-table--responsive tbody tr {
    display: block;
    margin-bottom: 10px;
    border-radius: var(--tg-radius);
    border: 1px solid var(--tg-line-soft);
    background: var(--tg-surface);
    box-shadow: var(--tg-shadow-soft);
    overflow: hidden;
  }
  .tg-table--responsive td {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid var(--tg-line-soft);
  }
  .tg-table--responsive td:last-child {
    border-bottom: none;
  }
  .tg-table--responsive td::before {
    content: attr(data-label);
    font-weight: 600;
    margin-right: 8px;
    color: var(--tg-text-soft);
  }
}

/* Колонка с действиями: ведём как обычную ячейку, без flex,
   чтобы не ломать высоту строк при переносах текста */
.tg-table__col-actions {
  width: 1%;
  white-space: nowrap;
  vertical-align: middle;
}

/* Ячейка "Действия": тянем на высоту строки и центрируем содержимое */
.tg-table__actions {
  position: relative;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 100%;
}
.tg-actions-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tg-actions-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 140px;
  margin-top: 4px;
  background: var(--tg-surface);
  border: 1px solid var(--tg-line-soft);
  border-radius: var(--tg-radius);
  box-shadow: var(--tg-shadow-soft);
  padding: 6px;
  display: none;
  z-index: 5;
}
.tg-actions-menu.open { display: block; }
.tg-actions-menu .tg-btn {
  display: block;
  width: 100%;
  margin-bottom: 6px;
}
.tg-actions-menu .tg-btn:last-child { margin-bottom: 0; }

/* Имитация gap между кнопками/формами */
.tg-table__actions > * {
  margin-right: 6px;
}

.tg-table__actions > *:last-child {
  margin-right: 0;
}

.agent-cell .agent-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.tg-table th.agent-col,
.tg-table td.agent-col {
  white-space: nowrap;
}

/* Pills / statuses */
.db-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid transparent;
  background: #eef1f4;
  color: #2c3e50;
}
.db-status-online { background: var(--tg-success-soft); color: var(--tg-success); }
.db-status-offline { background: var(--tg-danger-soft); color: var(--tg-danger); }
.db-status-pill.is-clickable { cursor: pointer; border-color: #9aa6b5; }
.db-status-pill.is-clickable:hover { box-shadow: 0 0 0 1px #6b7280; }
.db-status-pill.is-disabled { opacity: 0.6; cursor: not-allowed; }

/* Lists / filters */
.tg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.tg-grid--auto-fit {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.health-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.health-status--danger {
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(215, 38, 61, 0.12);
  box-shadow: 0 0 0 1px rgba(215, 38, 61, 0.28), 0 10px 26px rgba(215, 38, 61, 0.18);
}
.health-status--danger .badge--danger {
  background: rgba(215, 38, 61, 0.18);
  color: var(--color-danger);
}
.health-status__hint {
  font-size: 13px;
  color: var(--color-danger);
  font-weight: 600;
}
.tg-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  align-items: flex-start;
}
.tg-grid-2--narrow {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.tg-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.tg-filters__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.tg-filters__actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.filters { display: table-row; }
.filter-input { width: 100%; box-sizing: border-box; }

.sortable { cursor: pointer; user-select: none; position: relative; }
.sortable .sort-icon {
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.75;
}

/* Alerts for errors/success */
.error { color: var(--tg-danger); margin-bottom: 10px; }
.success { color: var(--tg-success); margin-bottom: 10px; }

/* Inline form */
.inline-form {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  display: inline;
}
.tg-table__actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--tg-surface);
  padding: 18px 18px 16px;
  border: 1px solid var(--tg-border);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--tg-shadow-hard);
  border-radius: var(--tg-radius-lg);
}
.modal h3 { margin-top: 0; }
.modal-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}
.modal--wide { max-width: 900px; }
.modal--fullscreen {
  width: 100%;
  max-width: 1200px;
  height: auto;
}
.modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

@media (max-width: 600px) {
  .modal {
    max-width: 100%;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 14px 14px 12px;
  }
}

.tg-admin-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.tg-admin-modal {
  max-width: 360px;
  width: 90%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.tg-admin-modal__error {
  display: none;
  margin-bottom: 12px;
}

.modal-backdrop.modal-backdrop--full {
  align-items: flex-start;
  padding: 18px;
}

/* Actions dropdown */
.actions-menu { position: relative; display: inline-block; }
.actions-menu-trigger { background: #f7f8fa; border: 1px solid var(--tg-border); border-radius: var(--tg-radius-sm); }
.actions-menu .menu-content {
  display: none;
  position: absolute;
  right: 0;
  background: #fff;
  border: 1px solid var(--tg-border);
  box-shadow: 0 10px 24px rgba(15,23,42,0.18);
  z-index: 5;
  min-width: 190px;
  border-radius: var(--tg-radius-sm);
  overflow: hidden;
}
.actions-menu.open .menu-content { display: block; }
.actions-menu .menu-content form { margin: 0; padding: 0; border: 0; background: transparent; }
.actions-menu .menu-content button,
.actions-menu .menu-content input[type=submit] {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: #fff;
  padding: 10px 12px;
  color: #1f2933;
  cursor: pointer;
}
.actions-menu .menu-content button:hover,
.actions-menu .menu-content input[type=submit]:hover { background: #f1f5f9; }

.tg-actions { position: relative; display: inline-block; }
.tg-actions summary { list-style: none; }
.tg-actions summary::-webkit-details-marker { display: none; }
.tg-actions__trigger { display: inline-flex; align-items: center; gap: 6px; }
.tg-actions__menu {
  position: fixed;
  left: 0;
  top: 0;
  min-width: 180px;
  background: var(--tg-surface);
  border: 1px solid var(--tg-border);
  border-radius: var(--tg-radius);
  box-shadow: var(--tg-shadow-hard);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  max-height: 60vh;
  overflow: auto;
}
.tg-actions--dropup .tg-actions__menu { top: auto; bottom: calc(100% + 6px); }
.tg-actions[open] .tg-actions__menu { display: flex; }
.tg-actions__menu form { width: 100%; }
.tg-actions__menu .tg-btn { width: 100%; }

.tg-setup {
  max-width: 960px;
  margin: 32px auto 60px;
}
.tg-setup__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
}
.tg-setup__title {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 6px 0;
}
.tg-setup__subtitle { margin: 0; color: var(--tg-text-soft); }
.tg-setup__step-counter { font-size: 14px; color: var(--tg-text-soft); }
.tg-setup-steps {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}
.tg-setup-step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--tg-text-soft);
}
.tg-setup-step__index {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--tg-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
.tg-setup-step--active .tg-setup-step__index,
.tg-setup-step--done .tg-setup-step__index {
  background: var(--tg-primary);
  border-color: var(--tg-primary);
  color: #fff;
}
.tg-setup-step--done { color: var(--tg-text-main); }
.tg-card--setup { padding: 0; overflow: hidden; }
.tg-setup__body {
  display: flex;
  gap: 32px;
  padding: 28px;
}
.tg-setup__form-col {
  flex: 3;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.tg-setup__hint {
  flex: 1;
  background: #f5f8ff;
  border-radius: var(--tg-radius-lg);
  padding: 18px;
  font-size: 13px;
  color: var(--tg-text-soft);
}
.tg-setup__hint-title {
  font-weight: 600;
  color: var(--tg-text-main);
  margin-bottom: 4px;
}
.tg-setup__hint-text { margin: 0 0 8px 0; }
.tg-subgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}
.tg-subcard {
  border: 1px solid var(--tg-border);
  border-radius: var(--tg-radius-lg);
  padding: 16px;
  background: var(--tg-surface-2);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tg-subcard__title {
  font-weight: 600;
  margin-bottom: 4px;
}
.tg-setup__footer {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tg-setup__footer-actions { display: flex; gap: 10px; }
.tg-setup__done {
  text-align: center;
  padding: 40px 10px;
}
.tg-setup__done-icon {
  width: 60px;
  height: 60px;
  border-radius: 999px;
  background: var(--tg-success-soft);
  color: var(--tg-success);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 16px;
}
.tg-setup__checklist {
  margin: 18px auto 0;
  padding-left: 18px;
  max-width: 480px;
  text-align: left;
  color: var(--tg-text-soft);
}

/* Auth */
.tg-auth {
  max-width: 420px;
  margin: 40px auto;
  width: 100%;
}
.tg-auth__panel {
  background: var(--tg-surface);
  border: 1px solid var(--tg-border);
  border-radius: var(--tg-radius-lg);
  padding: 22px;
  box-shadow: var(--tg-shadow-soft);
}
.tg-auth__title { margin-bottom: 6px; font-size: 20px; }
.tg-auth__subtitle { margin-bottom: 14px; }
.tg-auth__panel form { display: flex; flex-direction: column; gap: 12px; margin: 0; }

/* Misc */
.top-right { margin-left: auto; }
.admin-only { display: inline-block; }

/* Switch */
.tg-switch { position: relative; display: inline-block; width: 46px; height: 24px; vertical-align: middle; }
.tg-switch input { display: none; }
.tg-switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #dcdfe6;
  transition: .2s;
  border-radius: 24px;
  border: 1px solid #c1c7d0;
  box-sizing: border-box;
}
.tg-switch-slider:before {
  position: absolute;
  content: '';
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 2px;
  background: #fff;
  transition: .2s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.tg-switch input:checked + .tg-switch-slider { background: var(--tg-primary); border-color: var(--tg-primary); }
.tg-switch input:checked + .tg-switch-slider:before { transform: translateX(20px); }
.tg-switch input:focus + .tg-switch-slider { box-shadow: var(--tg-glow); }

@media (max-width: 1024px) {
  .tg-page { flex-direction: column; }
  .tg-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    min-height: 100vh;
    transform: translateX(-100%);
    opacity: 0;
    z-index: 1001;
    width: 240px;
  }
  .tg-sidebar.is-open {
    transform: translateX(0);
    opacity: 1;
  }
  .tg-main { min-height: calc(100vh - 20px); }
  .tg-content { padding: 16px; max-width: 100%; }
  .tg-topbar { position: sticky; top: 0; }
  .tg-topbar__burger { display: inline-flex; }
  .tg-topbar__title { font-size: 16px; }
}

@media (max-width: 780px) {
  .tg-page { flex-direction: column; }
  .tg-topbar { flex-wrap: wrap; }
  .tg-topbar__right { width: 100%; justify-content: flex-start; }
  .tg-content { padding: 16px; }
  .tg-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
