* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --accent: #14b8a6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --sidebar: #0b1220;
  --sidebar-2: #111b2e;
  --sidebar-text: #94a3b8;
  --sidebar-active: #2563eb;

  --background: #f6f8fc;
  --card: #ffffff;
  --text: #172033;
  --muted: #718096;
  --border: #e5eaf1;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, .04);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, .07);
  --radius: 14px;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: "Inter", sans-serif;
  background: var(--background);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
}


/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
  width: 260px;
  background:
    radial-gradient(circle at 20% 10%, rgba(37, 99, 235, .16), transparent 28%),
    var(--sidebar);
  color: #fff;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  border-right: 1px solid rgba(255,255,255,.05);
}

.brand {
  height: 82px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #14b8a6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 8px 25px rgba(37,99,235,.28);
}

.brand-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .6px;
}

.brand-subtitle {
  font-size: 10px;
  color: #718096;
  margin-top: 3px;
}

.navigation {
  padding: 25px 14px;
  flex: 1;
}

.nav-section-title {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #526078;
  padding: 0 13px 10px;
}

.settings-title {
  margin-top: 28px;
}

.nav-item {
  width: 100%;
  height: 46px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sidebar-text);
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 14px;
  border-radius: 10px;
  margin-bottom: 5px;
  text-align: left;
  transition: all .2s ease;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,.055);
}

.nav-item.active {
  color: #fff;
  background: linear-gradient(
    90deg,
    rgba(37,99,235,.24),
    rgba(37,99,235,.08)
  );
  border-color: rgba(37,99,235,.18);
}

.nav-icon {
  width: 22px;
  text-align: center;
  font-size: 16px;
}

.nav-item.active .nav-icon {
  color: #60a5fa;
}

.sidebar-footer {
  padding: 18px 20px 22px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.server-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.server-status strong {
  display: block;
  font-size: 11px;
}

.server-status small {
  display: block;
  color: #64748b;
  font-size: 9px;
  margin-top: 3px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 4px rgba(16,185,129,.10);
  flex-shrink: 0;
}

.sidebar-version {
  color: #475569;
  font-size: 9px;
}


/* =========================================================
   MAIN
========================================================= */

.main {
  margin-left: 260px;
  width: calc(100% - 260px);
  min-height: 100vh;
}

.topbar {
  height: 82px;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.breadcrumb {
  font-size: 10px;
  color: #a0aabd;
  margin-bottom: 5px;
}

.breadcrumb span {
  color: var(--primary);
  font-weight: 600;
}

.topbar h1 {
  font-size: 19px;
  font-weight: 750;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.system-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #64748b;
  font-size: 11px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #dbeafe, #ccfbf1);
  color: #1d4ed8;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  border: 2px solid white;
  box-shadow: var(--shadow-sm);
}

.mobile-menu,
.mobile-brand {
  display: none;
}


/* =========================================================
   CONTENT
========================================================= */

.content {
  padding: 34px;
  max-width: 1700px;
}

.page-section {
  display: none;
  animation: fadeUp .22s ease;
}

.page-section.active {
  display: block;
}

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

.welcome,
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 28px;
}

.eyebrow {
  font-size: 9px;
  color: var(--primary);
  font-weight: 800;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}

.welcome h2,
.section-heading h2 {
  font-size: 28px;
  letter-spacing: -.6px;
  margin-bottom: 6px;
}

.welcome p,
.section-heading p {
  color: var(--muted);
  font-size: 12px;
}


/* =========================================================
   BUTTONS
========================================================= */

.primary-btn,
.secondary-btn {
  border: 0;
  min-height: 42px;
  padding: 0 17px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all .2s ease;
}

.primary-btn {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  box-shadow: 0 8px 20px rgba(37,99,235,.18);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(37,99,235,.24);
}

.primary-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

.secondary-btn {
  background: #f1f5f9;
  color: #475569;
}

.secondary-btn:hover {
  background: #e2e8f0;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
}


/* =========================================================
   STAT CARDS
========================================================= */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 17px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 112px;
  padding: 21px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}

.stat-icon.purple {
  background: #eef2ff;
  color: #6366f1;
}

.stat-icon.green {
  background: #ecfdf5;
  color: #10b981;
}

.stat-icon.blue {
  background: #eff6ff;
  color: #2563eb;
}

.stat-icon.orange {
  background: #fff7ed;
  color: #f59e0b;
}

.stat-info span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 7px;
}

.stat-info strong {
  font-size: 23px;
  letter-spacing: -.5px;
}


/* =========================================================
   PANELS
========================================================= */

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.panel-header h3 {
  font-size: 13px;
  margin-bottom: 4px;
}

.panel-header p {
  font-size: 10px;
  color: var(--muted);
}


/* =========================================================
   DASHBOARD
========================================================= */

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, .8fr);
  gap: 20px;
  margin-bottom: 20px;
}


/* =========================================================
   TABLES
========================================================= */

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

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

th {
  background: #f8fafc;
  color: #7c899e;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .45px;
  text-align: left;
  padding: 13px 20px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 14px 20px;
  border-bottom: 1px solid #eef1f5;
  font-size: 10px;
  white-space: nowrap;
}

tbody tr {
  transition: background .15s ease;
}

tbody tr:hover {
  background: #fafcff;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.email-cell {
  font-weight: 700;
  color: #273449;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 20px;
  font-size: 9px;
  font-weight: 700;
}

.status-badge.active {
  background: #ecfdf5;
  color: #059669;
}

.status-badge.disabled {
  background: #f1f5f9;
  color: #64748b;
}

.status-badge .status-dot {
  width: 5px;
  height: 5px;
  box-shadow: none;
}

.row-action {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
}

.row-action:hover {
  color: var(--primary-dark);
}

.empty-state {
  text-align: center;
  color: #94a3b8;
  padding: 34px;
}


/* =========================================================
   QUICK SETTINGS
========================================================= */

.quick-panel {
  padding-bottom: 5px;
}

.quick-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 17px 22px;
  border-top: 1px solid #eef1f5;
}

.quick-setting strong {
  display: block;
  font-size: 10px;
  margin-bottom: 4px;
}

.quick-setting small {
  display: block;
  max-width: 210px;
  line-height: 1.55;
  color: var(--muted);
  font-size: 9px;
}

.quick-setting select {
  width: auto;
  min-width: 105px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 10px;
  color: #475569;
}


/* =========================================================
   SWITCH
========================================================= */

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  display: none;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: #cbd5e1;
  transition: .2s;
}

.switch span:before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}

.switch input:checked + span {
  background: var(--primary);
}

.switch input:checked + span:before {
  transform: translateX(18px);
}


/* =========================================================
   INFO
========================================================= */

.quick-info {
  display: flex;
  gap: 10px;
  margin: 13px 22px 18px;
  padding: 13px;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: 9px;
}

.info-icon {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  flex-shrink: 0;
}

.quick-info p {
  color: #52647c;
  font-size: 9px;
  line-height: 1.55;
}


/* =========================================================
   ACTIVITY
========================================================= */

.activity-panel {
  min-height: 170px;
}

.activity-empty {
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  gap: 5px;
}

.activity-empty strong {
  font-size: 11px;
  color: #64748b;
}

.activity-empty span {
  font-size: 9px;
}

.empty-icon {
  font-size: 25px;
  margin-bottom: 5px;
  color: #cbd5e1;
}


/* =========================================================
   FORMS
========================================================= */

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

.form-group label {
  display: block;
  color: #475569;
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 8px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field-hint {
  color: #94a3b8;
  font-size: 9px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  color: #334155;
  border-radius: 8px;
  outline: none;
  transition: .2s;
}

input,
select {
  height: 42px;
  padding: 0 12px;
  font-size: 10px;
}

textarea {
  padding: 13px;
  resize: vertical;
  font-size: 10px;
  line-height: 1.7;
}

input::placeholder,
textarea::placeholder {
  color: #b0b8c6;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}


/* =========================================================
   TEMPLATES
========================================================= */

.template-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(350px, .85fr);
  gap: 20px;
}

.template-editor {
  padding: 0 22px 22px;
}

.template-editor .panel-header {
  padding-left: 0;
  padding-right: 0;
}

.variables {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 9px;
}

.variables button {
  border: 1px solid #dbeafe;
  background: #eff6ff;
  color: var(--primary);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 9px;
  font-weight: 600;
  transition: .2s;
}

.variables button:hover {
  background: #dbeafe;
  transform: translateY(-1px);
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.preview-panel {
  min-height: 560px;
}

.email-preview {
  margin: 0 20px 20px;
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.email-header {
  padding: 17px;
  display: flex;
  gap: 10px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.preview-avatar {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dbeafe, #ccfbf1);
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}

.preview-sender strong {
  display: block;
  font-size: 10px;
  margin-bottom: 4px;
}

.preview-sender span {
  display: block;
  font-size: 9px;
  color: #94a3b8;
}

.preview-subject {
  padding: 18px 18px 8px;
  font-size: 12px;
  font-weight: 750;
}

.preview-body {
  padding: 8px 18px 25px;
  white-space: pre-wrap;
  font-size: 10px;
  color: #526174;
  line-height: 1.8;
}


/* =========================================================
   SETTINGS
========================================================= */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.settings-status {
  padding: 0 22px 22px;
}

.large-status {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  margin-bottom: 14px;
}

.settings-status p {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
}

.info-list {
  padding: 0 22px 20px;
}

.info-list div {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #eef1f5;
}

.info-list div:last-child {
  border-bottom: 0;
}

.info-list span {
  color: var(--muted);
  font-size: 10px;
}

.info-list strong {
  font-size: 10px;
}


/* =========================================================
   LOGIN
========================================================= */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 20%, rgba(37,99,235,.15), transparent 30%),
    radial-gradient(circle at 85% 80%, rgba(20,184,166,.12), transparent 30%),
    #f5f8fc;
}

.login-container {
  width: 100%;
  max-width: 430px;
}

.login-card {
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(226,232,240,.9);
  border-radius: 20px;
  padding: 38px;
  box-shadow:
    0 25px 70px rgba(15,23,42,.10),
    0 5px 20px rgba(15,23,42,.04);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.login-heading {
  margin-bottom: 25px;
}

.login-heading h1 {
  font-size: 26px;
  letter-spacing: -.7px;
  margin-bottom: 7px;
}

.login-heading p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.login-card .form-group {
  margin-bottom: 17px;
}

.login-card .form-group label {
  font-size: 10px;
}

.login-card input {
  height: 47px;
  font-size: 11px;
  background: #fbfcfe;
}

.login-button {
  width: 100%;
  height: 47px;
  margin-top: 5px;
}

.login-error {
  display: none;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 10px;
  margin-bottom: 13px;
}

.login-error:not(:empty) {
  display: block;
}

.login-footer {
  text-align: center;
  color: #a0aabd;
  font-size: 9px;
  margin-top: 27px;
}


/* =========================================================
   MODAL
========================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.58);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 2000;
  backdrop-filter: blur(5px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 520px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 30px 90px rgba(0,0,0,.22);
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-header {
  padding: 22px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 15px;
  margin-bottom: 4px;
}

.modal-header p {
  color: var(--muted);
  font-size: 10px;
}

.modal-close {
  border: 0;
  background: #f1f5f9;
  color: #64748b;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 18px;
}

.modal form {
  padding: 22px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 10px;
  color: #64748b;
  margin-bottom: 22px;
}

.checkbox-row input {
  width: 15px;
  height: 15px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}


/* =========================================================
   TOAST
========================================================= */

.toast {
  position: fixed;
  right: 25px;
  bottom: 25px;
  background: #172033;
  color: white;
  padding: 12px 16px;
  border-radius: 9px;
  font-size: 10px;
  box-shadow: 0 15px 40px rgba(15,23,42,.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: .25s;
  z-index: 3000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

@media (max-width: 800px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 20px 0 50px rgba(0,0,0,.15);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
    width: 100%;
  }

  .topbar {
    padding: 0 18px;
  }

  .mobile-menu {
    display: block;
    border: 0;
    background: transparent;
    font-size: 20px;
    color: #475569;
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
  }

  .mobile-brand .brand-logo {
    width: 29px;
    height: 29px;
    font-size: 14px;
    border-radius: 8px;
  }

  .topbar-left > div {
    display: none;
  }

  .system-indicator {
    display: none;
  }

  .content {
    padding: 22px 16px;
  }

  .welcome,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 500px) {
  .login-card {
    padding: 28px 22px;
    border-radius: 16px;
  }

  .login-heading h1 {
    font-size: 23px;
  }

  .welcome h2,
  .section-heading h2 {
    font-size: 23px;
  }

  .primary-btn {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    min-height: 95px;
  }

  .panel-header {
    padding: 17px;
  }

  th,
  td {
    padding-left: 14px;
    padding-right: 14px;
  }

  .template-editor {
    padding-left: 17px;
    padding-right: 17px;
  }

  .preview-panel {
    min-height: auto;
  }

  .editor-actions {
    flex-direction: column;
  }

  .editor-actions button {
    width: 100%;
  }
}
