:root {
  --panel-bg: #0f1620;
  --tab-bg: #121b27;
  --tab-active-bg: #1a2140;
  --tab-active-border: #2a3570;
}

[data-theme="light"] {
  --panel-bg: #ffffff;
  --tab-bg: #f0f3f8;
  --tab-active-bg: #e1e7f1;
  --tab-active-border: #c3cfde;
}

.layout{
  display: grid;
  grid-template-columns: 220px 1fr;
  margin-top: 10px;
}

/* TABS */
.tabs{
  border-right: 1px solid var(--border);
  background: var(--bg-elev-2);
  padding: 10px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* buttons (без изменений по сути) */
.tab{
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--tab-bg);
  color: var(--text);
  cursor: pointer;
}

.tab.active{
  background: var(--tab-active-bg);
  border-color: var(--tab-active-border);
}

/* footer always at bottom */
.tabs-footer{
  margin-top: 12px;
  padding: 10px 0 10px 0;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 8px;
  background: var(--bg-elev-2);
}

.tabs-footer .btn{
  width: 100%;
}

.panel {
  padding: 14px;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h2, h3 {
  margin: 8px 0 12px 0;
}

.card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin: 12px 0;
}

.db-table-row {
  cursor: pointer;
}

.db-table-row:hover {
  background: var(--table-stripe);
}

.about-card {
  margin-top: 0;
}

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

.about-logo {
  width: 42px;
  height: 42px;
  display: block;
}

.about-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 700;
}

.about-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 12px;
  opacity: 0.85;
  margin-top: 4px;
}

.about-link {
  color: var(--text);
  text-decoration: none;
}

.about-link.muted {
  color: var(--muted);
}

.card.warn {
  border-color: #4e3b00;
}

.card.danger {
  border-color: #5a1d1d;
}

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

.grid:not(table) .full {
  grid-column: 1 / -1;
}

.conditions .table {
  width: 100%;
}

.conditions-builder {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(120px, 160px) minmax(200px, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.cond-value select[multiple] {
  min-height: 72px;
}

.lbl {
  font-size: 12px;
  opacity: 0.85;
  margin-bottom: 6px;
}

input, select {
  width: 100%;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--control-bg);
  color: var(--text);
  outline: none;
}

.input-error {
  border-color: #b02a2a;
  box-shadow: 0 0 0 1px #b02a2a;
}

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

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
  display: none;
  min-width: 200px;
  max-height: 60vh;
  overflow-y: auto;
  margin-top: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.dropdown-menu button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.dropdown-menu button:hover {
  background: var(--bg-elev-2);
}

.dropdown.open .dropdown-menu {
  display: block;
}

.rule-sort {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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


.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  font-size: 12px;
  vertical-align: middle;
}

.table th {
  text-align: left;
  opacity: 0.85;
  font-size: 13px;
}

.plugin-row.is-off td {
  background: var(--bg-elev);
  color: var(--muted);
}

.hint {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 6px;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.plugin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.plugin-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--bg-elev-2);
  display: grid;
  gap: 10px;
}

.plugin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.plugin-title {
  font-weight: 700;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  opacity: 0.9;
}

.pre {
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  overflow: auto;
  max-height: 300px;
  white-space: pre-wrap;
  word-break: break-word;
}

.tabpane { display: none; }
.tabpane.active { display: block; }

.logs-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-direction: row;
  border-right: none;
  padding: 0;
  background: transparent;
}

.logs-tabs .tab {
  width: auto;
}

.logs-row {
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  width: 100%;
}

.logs-filters {
  flex-wrap: nowrap;
  overflow-x: auto;
}

.logs-row label {
  max-width: 220px;
}

.logs-filters label {
  max-width: none;
  width: 160px;
  min-width: 140px;
}

#logsControlsShared label {
  width: 150px;
}

.logs-filters label select,
.logs-filters label input[type="date"] {
  width: 100%;
}

#logsControlsShared,
#logsControlsLevel,
#logsControlsEvent {
  flex: 0 1 auto;
  max-width: 100%;
}

.logs-row .hint {
  margin-left: auto;
}

.logs-actions {
  align-items: center;
  flex-basis: 100%;
  justify-content: flex-start;
  margin-top: 6px;
}

#logsControlsShared,
#logsControlsLevel,
#logsControlsEvent {
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 10px;
}

#logsControlsShared label,
#logsControlsLevel label,
#logsControlsEvent label {
  max-width: none;
}

.logs-actions .btn {
  min-width: 140px;
}

.logs-actions .hint {
  margin-left: 0;
}

.logs-pane { display: none; }
.logs-pane.active { display: block; }

.drag-handle {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--control-bg);
  color: var(--text);
  border-radius: 8px;
  cursor: grab;
}

.drag-handle:active {
  cursor: grabbing;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: 860px;
  max-width: 100%;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-head, .modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-foot {
  border-bottom: none;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.modal-title {
  font-weight: 700;
}

.modal-body {
  padding: 12px;
  overflow: auto;
  overflow-x: hidden;
}

.root-row {
  display: grid;
  grid-template-columns: 140px minmax(240px, 1fr) 140px;
  gap: 10px;
  align-items: end;
}

.root-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .tabs { display: flex; gap: 8px; border-right: none; border-bottom: 1px solid var(--border); }
  .tab { width: auto; }
  .grid { grid-template-columns: 1fr; }
  .plugin-grid { grid-template-columns: 1fr; }
}
