* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #060816;
  --panel: rgba(11, 17, 37, 0.84);
  --panel-strong: rgba(16, 24, 52, 0.9);
  --line: rgba(120, 151, 255, 0.1);
  --text: #eef3ff;
  --muted: #93a5d3;
  --primary: #71a7ff;
  --accent: #7b5cff;
  --success: #43d59f;
  --error: #ff7f9f;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  --sidebar-width: 260px;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050711;
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

.bg-orb {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.2;
  pointer-events: none;
  z-index: 0;
}
.orb-a { top: -150px; left: -150px; background: #3d7cff; }
.orb-b { bottom: -150px; right: -100px; background: #7a5bff; }

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at center, black, transparent 80%);
  pointer-events: none;
  z-index: 0;
}

/* Login Wrapper */
.login-wrapper {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 100;
  background: #050711;
  padding: 20px;
}

.login-wrapper.hidden { display: none !important; }

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 48px 40px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.brand-centered {
  text-align: center;
  margin-bottom: 32px;
}

.brand-centered h2 { margin: 16px 0 8px; font-size: 24px; }
.brand-centered p { color: var(--muted); font-size: 14px; }

/* Admin Layout */
.admin-layout {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: var(--sidebar-width);
  background: rgba(8, 12, 28, 0.6);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
}

.sidebar-header {
  padding: 32px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: white;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  font-weight: 800;
  box-shadow: 0 8px 16px rgba(113, 167, 255, 0.2);
}

.brand-copy strong { display: block; font-size: 16px; }
.brand-copy small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  width: 100%;
  box-shadow: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.nav-item.active {
  background: rgba(113, 167, 255, 0.1);
  color: var(--primary);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info { font-size: 13px; font-weight: 600; }

.footer-actions { display: flex; gap: 8px; }

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  box-shadow: none;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.1); }

/* Main Content */
.main-content {
  flex: 1;
  padding: 40px;
  overflow-y: auto;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}

.content-header h2 { margin: 0 0 8px; font-size: 28px; }
.content-header p { margin: 0; color: var(--muted); }

.tab-panel.hidden { display: none; }

/* Components */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-header h3 { margin: 0; font-size: 16px; color: var(--primary); }

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

.stat {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}

.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.stat strong { display: block; font-size: 24px; margin-top: 8px; }

.mt-24 { margin-top: 24px; }
.mt-16 { margin-top: 16px; }
.mt-12 { margin-top: 12px; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid-span-4 { grid-column: 1 / -1; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.stack { display: grid; gap: 16px; }

.field { display: grid; gap: 8px; }
.field span { font-size: 13px; color: var(--muted); font-weight: 600; }

input, select, textarea {
  background: rgba(7, 12, 27, 0.6);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: white;
  font: inherit;
  outline: none;
  transition: all 0.2s;
}

input:focus, select:focus, textarea:focus { border-color: var(--primary); }

.primary-btn {
  background: var(--primary);
  color: #050711;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: none;
}

.primary-btn.small { padding: 8px 16px; font-size: 13px; }
.primary-btn:hover { opacity: 0.9; transform: translateY(-1px); }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: white;
  border-radius: 12px;
  padding: 12px 20px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
}

.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.status-message {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 13px;
  line-height: 1.5;
}

.status-message-info {
  color: #cfe0ff;
  background: rgba(113, 167, 255, 0.1);
  border-color: rgba(113, 167, 255, 0.18);
}

.status-message-success {
  color: #9ef3cf;
  background: rgba(67, 213, 159, 0.12);
  border-color: rgba(67, 213, 159, 0.2);
}

.status-message-error {
  color: #ffc1d2;
  background: rgba(255, 127, 159, 0.12);
  border-color: rgba(255, 127, 159, 0.2);
}

.ghost-btn.is-busy,
.primary-btn.is-busy {
  opacity: 0.75;
  cursor: progress;
}
.centered { text-align: center; }

/* Tables */
.table-wrapper {
  overflow-x: auto;
}

.quota-sub-card-table {
  max-height: min(560px, 65vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.quota-sub-card-table table {
  min-width: 880px;
}

.quota-sub-card-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(11, 17, 37, 0.98);
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pagination-summary,
.pagination-page {
  color: var(--muted);
  font-size: 12px;
}

.table-pagination .ghost-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
  border-bottom: 2px solid var(--line);
}

td {
  padding: 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
}

tr:hover td { background: rgba(255,255,255,0.01); }

.table-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-active, .status-succeeded { color: #9ef3cf; background: rgba(67, 213, 159, 0.1); }
.status-pending, .status-processing { color: #ffd58a; background: rgba(255, 213, 138, 0.1); }
.status-disabled, .status-failed, .status-void { color: #ffc1d2; background: rgba(255, 127, 159, 0.1); }
.status-approved { color: #9ef3cf; background: rgba(67, 213, 159, 0.1); }
.status-rejected { color: #ffc1d2; background: rgba(255, 127, 159, 0.1); }

.stability-stable { color: #9ef3cf; background: rgba(67, 213, 159, 0.1); }
.stability-bumpy { color: #ffd58a; background: rgba(255, 213, 138, 0.1); }
.stability-danger { color: #ffc1d2; background: rgba(255, 127, 159, 0.1); }

code { background: rgba(255,255,255,0.05); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; }

.log-viewer {
  background: #02040a;
  border-radius: 12px;
  padding: 16px;
  font-size: 13px;
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--line);
}

.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.small-select { padding: 6px 12px; font-size: 13px; width: auto; }
.small-input {
  width: 160px;
  padding: 6px 12px;
  font-size: 13px;
}
.actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.health-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}
.health-ok { background: var(--success); box-shadow: 0 0 8px var(--success); }
.health-fail { background: var(--error); box-shadow: 0 0 8px var(--error); }
.health-unknown { background: #555; }

.health-group { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }

.hidden { display: none !important; }

/* Notification monitor editor */
.notify-rules-block {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  display: grid;
  gap: 16px;
  margin: 8px 0;
}

.notify-rules-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.notify-rules-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.notify-rules-title::before {
  content: "⚡";
  font-size: 14px;
}

.notify-rules-actions {
  display: flex;
  gap: 16px;
  align-items: center;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.inline-field select {
  padding: 6px 12px;
  font-size: 13px;
  background: var(--panel-strong);
}

.notify-rules-list {
  display: grid;
  gap: 10px;
}

.notify-rule-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.5fr auto;
  gap: 10px;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.notify-rule-row:hover {
  border-color: var(--line);
  background: rgba(0, 0, 0, 0.3);
}

.notify-rule-row input,
.notify-rule-row select {
  padding: 8px 12px;
  font-size: 13px;
  background: var(--panel-strong);
  border-radius: 8px;
}

.notify-rule-row .ghost-btn {
  padding: 8px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--error);
  border-color: rgba(255, 127, 159, 0.2);
}

.notify-rule-row .ghost-btn:hover {
  background: rgba(255, 127, 159, 0.1);
}

.notify-empty-rule {
  font-size: 13px;
  color: var(--muted);
  padding: 20px 0;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.01);
}

/* Form refinement */
.form-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.compact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
}

/* Event list specific */
#notify-event-list td {
  vertical-align: top;
}

.event-summary {
  font-family: monospace;
  font-size: 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.2);
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .grid-4 { grid-template-columns: 1fr; }
  .grid-span-4 { grid-column: auto; }
  .notify-rule-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .notify-rules-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 1024px) {
  .sidebar { width: 70px; }
  .brand-copy, .nav-item span:not(.icon), .user-info { display: none; }
  .sidebar-header { padding: 20px 0; display: grid; place-items: center; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .nav-item .icon { font-size: 20px; }
  .sidebar-footer { padding: 16px 0; flex-direction: column; gap: 12px; }
}
