    :root {
      --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
      --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

      --bg-base: #0f1115;
      --bg-surface: #181b21;
      --bg-elevated: #22262f;

      --border: #2d333e;
      --border-focus: #526077;

      --text-main: #e2e8f0;
      --text-muted: #8b94a5;

      --accent: #3b82f6;
      --accent-hover: #2563eb;
      --danger: #ef4444;
      --success: #10b981;
      --warning: #fbbf24;

      --radius-sm: 4px;
      --radius-md: 6px;
      --radius-lg: 8px;
    }

    * { box-sizing: border-box; }

    html,
    body {
      height: 100%;
      margin: 0;
      padding: 0;
      background-color: var(--bg-base);
      color: var(--text-main);
      font-family: var(--font-main);
      font-size: 14px;
      line-height: 1.5;
    }

    body {
      overflow: hidden;
      display: flex;
    }

    h1,
    h2,
    p {
      margin: 0;
    }

    h1 {
      font-size: 18px;
      margin-bottom: 2px;
      color: #fff;
      font-weight: 600;
    }

    h2 {
      font-size: 16px;
      color: #fff;
      font-weight: 600;
    }

    p { color: var(--text-muted); }

    svg {
      fill: none;
      stroke: currentColor;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .kicker {
      font-size: 12px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      color: var(--text-muted);
    }

    .mono {
      font-family: var(--font-mono);
      font-size: 13px;
    }

    .text-muted {
      color: var(--text-muted) !important;
    }

.sidebar {
  width: 250px;
  flex: 0 0 250px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

    .brand {
      height: 60px;
      padding: 0 20px;
      display: flex;
      align-items: center;
      border-bottom: 1px solid var(--border);
      font-weight: 600;
      font-size: 16px;
      gap: 12px;
    }

    .brand-icon {
      background: var(--accent);
      color: white;
      width: 26px;
      height: 26px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: var(--radius-sm);
      font-size: 14px;
    }

.nav-menu {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

    .nav-item {
      width: 100%;
      border: 0;
      background: transparent;
      padding: 8px 12px;
      border-radius: var(--radius-sm);
      cursor: pointer;
      color: var(--text-muted);
      font: inherit;
      font-weight: 500;
      display: flex;
      align-items: center;
      gap: 10px;
      transition: 0.2s;
      text-align: left;
    }

    .nav-item svg {
      width: 18px;
      height: 18px;
      stroke-width: 1.5px;
    }

    .nav-item:hover {
      background-color: var(--bg-elevated);
      color: var(--text-main);
    }

.nav-item.active {
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--accent);
}

.logout-item {
  color: #fecaca;
}

.logout-item:hover {
  color: #fff;
  background: rgba(239, 68, 68, 0.14);
}

    .main-content {
      flex: 1;
      display: flex;
      flex-direction: column;
      min-width: 0;
    }

    .top-bar {
      height: 60px;
      background-color: var(--bg-surface);
      border-bottom: 1px solid var(--border);
      padding: 0 32px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .content-area {
      flex: 1;
      padding: 32px;
      overflow-y: auto;
    }

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

    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 8px 16px;
      border-radius: var(--radius-sm);
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      border: 1px solid transparent;
      font-family: inherit;
      line-height: 1.2;
      box-shadow: none !important;
    }

    .btn svg {
      width: 16px;
      height: 16px;
    }

    .btn-primary {
      background-color: var(--accent);
      border-color: transparent;
      color: white;
    }

    .btn-primary:hover,
    .btn-primary:focus {
      background-color: var(--accent-hover);
      border-color: transparent;
      color: white;
    }

    .btn-secondary {
      background-color: transparent;
      color: var(--text-main);
      border-color: var(--border);
    }

    .btn-secondary:hover,
    .btn-secondary:focus {
      background-color: var(--bg-elevated);
      border-color: var(--border-focus);
      color: var(--text-main);
    }

    .btn-danger {
      background-color: var(--danger);
      border-color: var(--danger);
      color: white;
    }

    .btn-danger:hover,
    .btn-danger:focus {
      background-color: #dc2626;
      border-color: #dc2626;
      color: white;
    }

    .btn-icon {
      background-color: transparent;
      border: 1px solid transparent;
      color: var(--text-muted);
      cursor: pointer;
      padding: 6px;
      border-radius: var(--radius-sm);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: 0.2s;
    }

    .btn-icon svg {
      width: 16px;
      height: 16px;
      stroke-width: 2px;
    }

    .btn-icon:hover,
    .btn-icon:focus {
      background-color: var(--bg-elevated);
      color: var(--text-main);
      border-color: var(--border);
    }

    .btn-icon.danger:hover,
    .btn-icon.danger:focus {
      background-color: rgba(239, 68, 68, 0.1);
      color: var(--danger);
      border-color: rgba(239, 68, 68, 0.3);
    }

    .status-text {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      font-weight: 500;
    }

    .dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background-color: var(--text-muted);
      flex-shrink: 0;
    }

    .dot.green { background-color: var(--success); }
    .dot.red { background-color: var(--danger); }

    .card {
      background-color: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      margin-bottom: 24px;
      overflow: hidden;
      color: var(--text-main);
    }

    .card-header {
      padding: 16px 24px;
      border-bottom: 1px solid var(--border);
      display: flex;
      justify-content: space-between;
      align-items: center;
      background-color: rgba(255,255,255,0.02);
    }

    table {
      width: 100%;
      border-collapse: collapse;
      text-align: left;
    }

    th {
      color: var(--text-muted);
      font-size: 12px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      padding: 12px 24px;
      border-bottom: 1px solid var(--border);
      background-color: rgba(255,255,255,0.01);
    }

    td {
      padding: 12px 24px;
      border-bottom: 1px solid var(--border);
      vertical-align: middle;
    }

    tr:last-child td { border-bottom: none; }
    tr:hover td { background-color: var(--bg-elevated); }

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

    .drag-handle {
      cursor: grab;
      color: var(--text-muted);
      display: inline-flex;
      align-items: center;
      padding: 4px;
      border-radius: 4px;
    }

    .drag-handle:hover {
      background-color: var(--bg-elevated);
      color: var(--text-main);
    }

    .drag-handle svg {
      width: 16px;
      height: 16px;
    }

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

    .sortable-ghost {
      opacity: 0.3;
      background-color: rgba(59, 130, 246, 0.1) !important;
    }

    .row-actions {
      display: flex;
      justify-content: flex-end;
      gap: 4px;
    }

    .form-group { margin-bottom: 20px; }

    .form-label {
      display: block;
      font-size: 13px;
      font-weight: 600;
      margin-bottom: 8px;
      color: var(--text-main);
    }

    .form-control,
    .form-select {
      width: 100%;
      padding: 8px 12px;
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      font-size: 13px;
      font-family: inherit;
      background-color: var(--bg-base);
      color: var(--text-main);
      transition: 0.2s;
      box-shadow: none !important;
    }

    .form-control:focus,
    .form-select:focus {
      outline: none;
      border-color: var(--accent);
      background-color: var(--bg-base);
      color: var(--text-main);
    }

    textarea.form-control {
      min-height: 80px;
      resize: vertical;
    }

    select.form-select {
      appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b94a5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 12px center;
      padding-right: 36px;
      cursor: pointer;
    }

    .toggle-switch {
      position: relative;
      display: inline-flex;
      align-items: center;
      gap: 12px;
      cursor: pointer;
    }

    .toggle-switch input {
      opacity: 0;
      width: 0;
      height: 0;
      position: absolute;
    }

    .toggle-slider {
      width: 40px;
      height: 22px;
      background-color: var(--border);
      border-radius: 12px;
      position: relative;
      transition: 0.3s;
    }

    .toggle-slider::before {
      content: "";
      position: absolute;
      height: 16px;
      width: 16px;
      left: 3px;
      bottom: 3px;
      background-color: var(--text-main);
      border-radius: 50%;
      transition: 0.3s;
    }

    .toggle-switch input:checked + .toggle-slider {
      background-color: var(--success);
    }

    .toggle-switch input:checked + .toggle-slider::before {
      transform: translateX(18px);
      background-color: #fff;
    }

    .toggle-label {
      font-size: 13px;
      font-weight: 500;
    }

    .form-grid {
      display: grid;
      grid-template-columns: repeat(12, 1fr);
      gap: 16px;
    }

    .form-col-12 { grid-column: span 12; }
    .form-col-8 { grid-column: span 8; }
    .form-col-6 { grid-column: span 6; }
    .form-col-4 { grid-column: span 4; }
    .form-col-3 { grid-column: span 3; }

    .form-grid > [class*="form-col-"] {
      min-width: 0;
      width: auto;
      max-width: none;
      flex: initial;
    }

    .modal-backdrop.show {
      opacity: 0.6;
      backdrop-filter: blur(2px);
    }

    .modal-dialog {
      max-width: 680px;
    }

    .modal-content {
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      color: var(--text-main);
      box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    }

    .modal-header {
      padding: 16px 24px;
      border-bottom: 1px solid var(--border);
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .modal-body {
      max-height: calc(90vh - 124px);
      overflow-y: auto;
      padding: 24px;
      background: var(--bg-base);
    }

    .modal-footer {
      padding: 16px 24px;
      border-top: 1px solid var(--border);
      display: flex;
      justify-content: flex-end;
      gap: 12px;
    }

    .confirm-modal .modal-dialog {
      max-width: 440px;
    }

    .confirm-modal .modal-body {
      background: var(--bg-surface);
      max-height: none;
    }

    .condition-box {
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 16px;
      margin-bottom: 16px;
    }

    .split-layout {
      display: grid;
      grid-template-columns: 350px 1fr;
      gap: 24px;
      height: calc(100vh - 160px);
    }

    .split-list {
      display: flex;
      flex-direction: column;
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      overflow: hidden;
    }

    .split-list-items {
      flex: 1;
      overflow-y: auto;
    }

    .split-item {
      width: 100%;
      border: 0;
      background: transparent;
      color: inherit;
      text-align: left;
      font: inherit;
      padding: 16px;
      border-bottom: 1px solid var(--border);
      cursor: pointer;
    }

    .split-item:hover { background-color: var(--bg-elevated); }

    .split-item.active {
      background-color: rgba(59, 130, 246, 0.1);
      border-left: 3px solid var(--accent);
    }

    .split-item-title {
      font-weight: 600;
      margin-bottom: 4px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .split-item-meta {
      font-size: 12px;
      color: var(--text-muted);
      display: flex;
      justify-content: space-between;
    }

    .split-detail {
      background: #000;
      color: #a1a1aa;
      border-radius: var(--radius-lg);
      padding: 20px;
      overflow: auto;
      border: 1px solid var(--border);
      font-size: 13px;
      margin: 0;
      white-space: pre-wrap;
    }

.raw-header-viewer {
  font-family: var(--font-mono);
  line-height: 1.55;
  tab-size: 2;
}

.header-line {
  display: block;
  min-height: 1.55em;
}

.header-line:hover {
  background: rgba(255, 255, 255, 0.035);
}

.header-name {
  color: #93c5fd;
  font-weight: 700;
}

.header-colon {
  color: #64748b;
}

.header-value {
  color: #cbd5e1;
}

.header-continuation {
  color: #94a3b8;
  padding-left: 18px;
  border-left: 2px solid rgba(148, 163, 184, 0.22);
}

.header-route .header-name {
  color: #38bdf8;
}

.header-identity .header-name {
  color: #fbbf24;
}

.header-auth .header-name {
  color: #34d399;
}

.header-spam .header-name {
  color: #fb7185;
}

.header-mime .header-name {
  color: #c084fc;
}

.header-email {
  color: #fcd34d;
}

.header-domain {
  color: #7dd3fc;
}

.header-ip {
  color: #fca5a5;
}

.header-empty,
.header-raw {
  color: var(--text-muted);
}

    .log-layout {
      height: calc(100vh - 124px);
      display: flex;
      flex-direction: column;
      min-height: 0;
    }

    .log-toolbar {
      margin-bottom: 16px;
      max-width: 360px;
      flex: 0 0 auto;
    }

    .log-textarea {
      flex: 1 1 auto;
      min-height: 0 !important;
      resize: none !important;
      overflow: auto;
      font-family: var(--font-mono);
      font-size: 13px;
      line-height: 1.5;
      white-space: pre;
    }

    .toast-container {
      position: fixed;
      top: 74px;
      right: 32px;
      z-index: 1080;
      display: flex;
      flex-direction: column;
      gap: 10px;
      pointer-events: none;
    }

    .toast-message {
      background: var(--text-main);
      color: var(--bg-base);
      padding: 10px 16px;
      border-radius: var(--radius-sm);
      font-weight: 600;
      font-size: 13px;
      transform: translateY(-10px);
      opacity: 0;
      transition: 0.2s;
      box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
    }

    .toast-message.show {
      transform: translateY(0);
      opacity: 1;
    }
.inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.empty-state {
  padding: 32px 24px;
  color: var(--text-muted);
  text-align: center;
}

.error-banner {
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
  color: #fecaca;
  border-radius: var(--radius-sm);
}

.condition-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

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

.worker-result {
  margin-top: 16px;
}

.worker-result pre {
  margin: 0;
}

.col-order {
  width: 100px;
}

.col-status,
.col-conditions {
  width: 120px;
}

.col-actions {
  width: 100px;
  text-align: right;
}

.card.flush {
  margin: 0;
}

.card.flex-column-card {
  display: flex;
  flex-direction: column;
}

.compact-heading {
  font-size: 14px;
  margin-bottom: 16px;
}

.filter-meta-grid {
  margin-bottom: 24px;
}

.toggle-offset {
  margin-top: 6px;
}

.full-width-dashed {
  width: 100%;
  border-style: dashed;
}

.full-width {
  width: 100%;
}

.login-page {
  display: grid;
  min-height: 100%;
  place-items: center;
  overflow: auto;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.login-brand {
  height: auto;
  padding: 0 0 18px;
  border-bottom: 0;
}

.login-copy {
  margin-bottom: 20px;
}

.login-copy h1 {
  font-size: 20px;
  margin-bottom: 6px;
}

.no-bottom-margin {
  margin-bottom: 0;
}

.padded-panel {
  padding: 24px;
}

.account-security-card {
  margin-top: 18px;
}

.security-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.security-panel {
  min-width: 0;
}

.security-panel h3 {
  font-size: 15px;
  margin: 0 0 18px;
}

.security-panel-heading {
  display: flex;
  min-height: 32px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.security-panel-heading h3 {
  margin-bottom: 0;
}

.input-action-row,
.button-row {
  display: flex;
  gap: 10px;
}

.input-action-row .form-control {
  min-width: 0;
}

.compact-textarea {
  min-height: 76px;
  resize: vertical;
}

.otp-setup-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.otp-qr-link {
  display: grid;
  width: 240px;
  min-height: 240px;
  place-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.otp-qr-link:focus {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.otp-qr-link img {
  display: block;
  width: 216px;
  height: 216px;
}

.otp-setup-fields {
  min-width: 0;
}

#filterTableBody tr.decision-spam td:first-child {
  box-shadow: inset 5px 0 0 var(--danger);
}

#filterTableBody tr.decision-keep td:first-child {
  box-shadow: inset 5px 0 0 var(--success);
}

@media (max-width: 900px) {
  body {
    overflow: auto;
    display: block;
  }

  .sidebar {
    width: 100%;
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .nav-menu {
    flex-direction: row;
    overflow-x: auto;
  }

  .nav-item {
    width: auto;
    flex: 0 0 auto;
  }

  .logout-item .nav-label {
    display: none;
  }

  .top-bar {
    padding: 0 16px;
  }

  .content-area {
    padding: 16px;
  }

  .split-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .split-list {
    min-height: 240px;
  }

  .form-col-8,
  .form-col-6,
  .form-col-4,
  .form-col-3 {
    grid-column: span 12;
  }

  .security-layout {
    grid-template-columns: 1fr;
  }

  .otp-setup-layout {
    grid-template-columns: 1fr;
  }

  .input-action-row,
  .button-row {
    flex-direction: column;
  }
}
