:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --success: #067647;
  --danger: #b42318;
  --warning: #b54708;
  --secondary-bg: #eef2ff;
  --nav-active-bg: #e9e8ff;
  --badge-bg: #f2f4f7;
  --success-bg: #ecfdf3;
  --danger-bg: #fef3f2;
  --warning-bg: #fffaeb;
  --info-bg: #eef4ff;
  --info: #175cd3;
  --input-bg: #ffffff;
  --upload-bg: #fafafa;
  --focus-ring: #e0e7ff;
  --shadow: rgba(16, 24, 40, 0.04);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--bg);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #111c2f;
  --ink: #e5e7eb;
  --muted: #9ca3af;
  --line: #2b3a52;
  --primary: #a5b4fc;
  --primary-dark: #818cf8;
  --success: #6ee7b7;
  --danger: #fca5a5;
  --warning: #fcd34d;
  --secondary-bg: #24314a;
  --nav-active-bg: #29365a;
  --badge-bg: #253248;
  --success-bg: #123b35;
  --danger-bg: #44252c;
  --warning-bg: #44351e;
  --info-bg: #1c3151;
  --info: #93c5fd;
  --input-bg: #0f1a2c;
  --upload-bg: #172338;
  --focus-ring: #3730a3;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
}
a {
  color: var(--primary);
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 9px;
  padding: 11px 16px;
  cursor: pointer;
  background: var(--primary);
  color: white;
  font-weight: 700;
  text-decoration: none;
}
button:hover,
.button:hover {
  background: var(--primary-dark);
}
button.secondary,
.button.secondary {
  background: var(--secondary-bg);
  color: var(--primary-dark);
}
button.danger {
  background: var(--danger-bg);
  color: var(--danger);
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 22px 60px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
}
.brand {
  color: var(--ink);
  text-decoration: none;
  font-size: 22px;
  font-weight: 800;
}
.brand span {
  color: var(--primary);
}
nav {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
nav a {
  color: var(--muted);
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 650;
}
nav a:hover,
nav a.active {
  color: var(--primary-dark);
  background: var(--nav-active-bg);
}
h1,
h2,
h3 {
  line-height: 1.15;
  margin-top: 0;
}
h1 {
  font-size: clamp(28px, 4vw, 42px);
  margin-bottom: 8px;
}
h2 {
  font-size: 22px;
  margin-bottom: 6px;
}
h3 {
  font-size: 17px;
}
.subtitle,
.hint {
  color: var(--muted);
}
.subtitle {
  margin: 0 0 28px;
}
.hint {
  font-size: 13px;
  line-height: 1.5;
}
.grid {
  display: grid;
  gap: 18px;
}
.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 22px;
  box-shadow: 0 8px 25px var(--shadow);
}
.card + .card {
  margin-top: 18px;
}
.login-layout {
  display: grid;
  grid-template-columns: 8fr 8fr;
  gap: 24px;
  align-items: start;
  width: 100%;
  max-width: 1000px;
  margin: 30px auto;
}

.login-layout .card {
  width: 100%;
  box-sizing: border-box;
  padding: 28px;
}

.login-layout .card + .card {
  margin-top: 0;
}

.login-layout .card:nth-child(2),
.login-layout .card:nth-child(3) {
  grid-column: 2;
}

.login-layout .card:nth-child(3) {
  margin-top: 0;
}

.login-layout .card:first-child {
  grid-column: 1;
  grid-row: 1 / span 2;
}

@media (max-width: 768px) {
  .login-layout {
    grid-template-columns: 1fr;
  }

  .login-layout .card {
    grid-column: 1 !important;
    grid-row: auto !important;
  }
}
.metric {
  min-height: 124px;
}
.metric .value {
  display: block;
  font-size: 32px;
  font-weight: 850;
  margin: 10px 0 2px;
}
.metric .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 750;
  background: var(--badge-bg);
  color: var(--muted);
}
.badge.success {
  background: var(--success-bg);
  color: var(--success);
}
.badge.warning {
  background: var(--warning-bg);
  color: var(--warning);
}
.badge.danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.badge.info {
  background: var(--info-bg);
  color: var(--info);
}
form {
  display: grid;
  gap: 8px;
}
label {
  display: block;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 750;
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: var(--input-bg);
  color: var(--ink);
  outline: none;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
textarea {
  min-height: 130px;
  resize: vertical;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.notice {
  padding: 12px 14px;
  border-radius: 9px;
  margin-top: 14px;
  display: none;
}
.notice.show {
  display: block;
}
.notice.success {
  display: block;
  background: var(--success-bg);
  color: var(--success);
}
.notice.error {
  display: block;
  background: var(--danger-bg);
  color: var(--danger);
}
.notice.info {
  display: block;
  background: var(--info-bg);
  color: var(--info);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  text-align: left;
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table-wrap {
  overflow-x: auto;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.empty {
  color: var(--muted);
  padding: 28px 8px;
  text-align: center;
}
.recipient-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 250px;
  overflow: auto;
}
.recipient-option {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.recipient-option input {
  width: auto;
}
.upload {
  border: 1px dashed var(--muted);
  border-radius: 10px;
  padding: 18px;
  background: var(--upload-bg);
}
.stack {
  display: grid;
  gap: 16px;
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.import-list {
  display: grid;
  gap: 8px;
}
.import-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.import-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
@media (max-width: 800px) {
  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: 1fr;
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .shell {
    padding: 20px 14px 44px;
  }
}

/* ==========================================================================
   Modern UI/UX Overhaul & Hero Glassmorphism (MadOS Mail Sender)
   ========================================================================== */

.hero {
  position: relative;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 15%, rgba(56, 189, 248, 0.12), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(99, 102, 241, 0.15), transparent 50%),
    linear-gradient(135deg, rgba(2, 6, 23, 0.88), rgba(15, 23, 42, 0.94)),
    url("img/background.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: #f8fafc;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(circle at center, rgba(0, 0, 0, 0.15), rgba(2, 8, 23, 0.75));
  pointer-events: none;
}

.hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 220px;
  z-index: 0;
  background: linear-gradient(to bottom, transparent, #020817);
  pointer-events: none;
}

.hero > .shell {
  position: relative;
  z-index: 1;
}

/* Brand & SVG Logo */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  line-height: 1;
  transition: opacity 0.2s ease;
}

.brand:hover {
  opacity: 0.92;
}

.brand-logo {
  height: 38px;
  width: auto;
  border-radius: 9px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  display: block;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.brand:hover .brand-logo {
  transform: scale(1.03);
}

.brand-title {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 21px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.brand-title span {
  color: #38bdf8;
  font-weight: 700;
}

.hero h1,
.hero h2,
.hero h3 {
  color: #ffffff;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero .subtitle {
  color: rgba(226, 232, 240, 0.85);
  font-size: 15px;
}

/* Glassmorphic sticky topbar */
.hero .topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-radius: 18px;
  background: rgba(11, 20, 38, 0.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  margin-bottom: 28px;
  position: sticky;
  top: 14px;
  z-index: 50;
  transition: all 0.25s ease;
}

.hero .topbar.scrolled {
  background: rgba(8, 15, 30, 0.94);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 255, 255, 0.18);
}

.hero nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.hero nav a {
  color: rgba(241, 245, 249, 0.82);
  padding: 8px 13px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
}

.hero nav a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.1);
}

.hero nav a.active {
  color: #ffffff;
  background: rgba(56, 189, 248, 0.22);
  border: 1px solid rgba(56, 189, 248, 0.5);
  box-shadow: 0 2px 14px rgba(56, 189, 248, 0.25);
}

.hero .topbar button.secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 600;
  transition: all 0.18s ease;
}

.hero .topbar button.secondary:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

/* Glassmorphic cards on hero background */
.hero .card {
  background: rgba(13, 23, 44, 0.8);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
  color: #f1f5f9;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hero .card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.48);
}

.hero .metric {
  background: rgba(15, 27, 52, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.hero .metric:hover {
  transform: translateY(-3px);
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.hero .metric .value {
  color: #ffffff;
  font-size: 34px;
  font-weight: 850;
  letter-spacing: -0.02em;
}

.hero .metric .label {
  color: rgba(148, 163, 184, 0.92);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.hero label {
  color: #e2e8f0;
  font-weight: 700;
}

.hero input,
.hero select,
.hero textarea {
  background: rgba(8, 16, 32, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border-radius: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hero input:focus,
.hero select:focus,
.hero textarea:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.28);
}

.hero table th {
  color: #94a3b8;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 12px 14px;
}

.hero table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  padding: 12px 14px;
}

.hero table tr:hover td {
  background: rgba(255, 255, 255, 0.04);
}

.hero code {
  background: rgba(255, 255, 255, 0.12);
  color: #38bdf8;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.9em;
}

.hero .hint {
  color: rgba(148, 163, 184, 0.88);
}

@media (max-width: 900px) {
  .hero .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 16px;
    top: 6px;
  }
  .hero nav {
    width: 100%;
    margin-top: 8px;
  }
  .grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .grid.four,
  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }
}

.hero .topbar button.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.18s ease;
}

.hero .topbar button.icon-btn:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

.hero .topbar button.icon-btn svg {
  display: block;
}
