/* ==========================================================================
   MailOps V2 — Modern SaaS Design System (PC + Mobile 360px First-Class)
   ========================================================================== */

:root {
  --bg-canvas: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --bg-hover: #F8FAFC;

  --border-default: #E2E8F0;
  --border-strong: #CBD5E1;
  --border-subtle: #F1F5F9;

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --text-faint: #94A3B8;

  --brand-600: #2563EB;
  --brand-700: #1D4ED8;
  --brand-50: #EFF6FF;
  --brand-100: #DBEAFE;

  --green-700: #047857;
  --green-600: #059669;
  --green-50: #ECFDF5;
  --green-200: #A7F3D0;

  --amber-700: #B45309;
  --amber-600: #D97706;
  --amber-50: #FFFBEB;
  --amber-200: #FDE68A;

  --red-700: #B91C1C;
  --red-600: #DC2626;
  --red-50: #FEF2F2;
  --red-200: #FECACA;

  --purple-700: #6D28D9;
  --purple-50: #F5F3FF;
  --purple-200: #DDD6FE;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -4px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 44px -8px rgba(15, 23, 42, 0.16), 0 4px 12px rgba(15, 23, 42, 0.06);

  --sidebar-w: 244px;
  --topbar-h: 60px;
  --bottom-nav-h: 64px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--brand-600);
  text-decoration: none;
}

svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

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

.num {
  font-variant-numeric: tabular-nums;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* ---------- Layout Shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.sidebar-brand {
  height: var(--topbar-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2563EB 0%, #4F46E5 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.02em;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
  flex-shrink: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13.5px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

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

.nav-item.active {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 600;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.nav-item.active .nav-badge {
  background: var(--brand-100);
  color: var(--brand-700);
}

.nav-badge-warn {
  background: var(--amber-50);
  color: var(--amber-700);
  border: 1px solid var(--amber-200);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.provider-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-green { background: var(--green-600); }
.dot-amber { background: var(--amber-600); }
.dot-red { background: var(--red-600); }
.dot-blue { background: var(--brand-600); }
.dot-purple { background: var(--purple-700); }
.dot-gray { background: #94A3B8; }

.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-default);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
}

.topbar-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.content-area {
  padding: 22px 24px 40px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

/* Mobile Bottom Nav */
.mobile-bottom-nav {
  display: none;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s ease;
  user-select: none;
}

.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: var(--radius-xs);
}

.btn-xs {
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: var(--radius-xs);
}

.btn-lg {
  height: 42px;
  padding: 0 18px;
  font-size: 14px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
}

.btn-icon.btn-sm {
  width: 30px;
  height: 30px;
}

.btn-primary {
  background: var(--brand-600);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-700);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-soft {
  background: var(--brand-50);
  color: var(--brand-700);
}

.btn-soft:hover:not(:disabled) {
  background: var(--brand-100);
}

.btn-success {
  background: var(--green-600);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  background: var(--green-700);
}

.btn-danger-soft {
  background: var(--red-50);
  color: var(--red-700);
  border-color: var(--red-200);
}

.btn-danger-soft:hover:not(:disabled) {
  background: #FEE2E2;
}

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

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

/* ---------- Cards & Grids ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.card-body {
  padding: 18px 20px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s;
}

.kpi-card.clickable {
  cursor: pointer;
}

.kpi-card.clickable:hover {
  border-color: var(--brand-600);
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.kpi-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon svg {
  width: 16px;
  height: 16px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kpi-foot {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

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

.grid-main-side {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 16px;
}

/* ---------- Pills / Badges / Tags ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.5;
}

.pill-green { background: var(--green-50); color: var(--green-700); }
.pill-amber { background: var(--amber-50); color: var(--amber-700); }
.pill-red { background: var(--red-50); color: var(--red-700); }
.pill-blue { background: var(--brand-50); color: var(--brand-700); }
.pill-purple { background: var(--purple-50); color: var(--purple-700); }
.pill-gray { background: var(--bg-subtle); color: var(--text-secondary); }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

/* ---------- Tabs ---------- */
/* Subtle modern scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

.tabs-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  max-width: 100%;
  flex-shrink: 0;
  overflow-x: auto;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.tab-count {
  font-size: 11px;
  font-weight: 600;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.tab-btn.active .tab-count {
  background: var(--brand-50);
  color: var(--brand-700);
}

/* ---------- Form Controls ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.form-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 400;
}

.input, .select, .textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13.5px;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
  outline: none;
}

.select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  padding-right: 34px;
  cursor: pointer;
}

/* Sleek Custom Dropdown Component (Replaces ugly native OS select & popup) */
.cselect {
  position: relative;
  width: 100%;
  min-width: 0;
}

.cselect-inline {
  width: auto;
  display: inline-block;
}

.cselect-trigger {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.cselect-sm .cselect-trigger {
  height: 32px;
  font-size: 13px;
  padding: 0 9px;
}

.cselect-trigger:hover {
  border-color: var(--border-strong);
  background: #FCFDFE;
}

.cselect.open .cselect-trigger {
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.cselect-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.cselect-chevron {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  transition: transform 0.16s ease;
  flex-shrink: 0;
}

.cselect.open .cselect-chevron {
  transform: rotate(180deg);
  color: var(--brand-600);
}

.cselect-menu {
  position: absolute;
  left: 0;
  right: 0;
  min-width: 168px;
  top: calc(100% + 5px);
  background: #FFFFFF;
  border: 1px solid var(--border-default);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 140;
  max-height: 240px;
  overflow-y: auto;
  display: none;
  animation: fadeIn 0.12s ease;
}

.cselect.open .cselect-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cselect-option {
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}

.cselect-option:hover {
  background: var(--bg-subtle);
}

.cselect-option.selected {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 600;
}

.cselect-option svg {
  width: 14px;
  height: 14px;
  color: var(--brand-600);
}

.textarea {
  height: auto;
  padding: 9px 11px;
  resize: vertical;
  min-height: 76px;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input-sm {
  height: 32px;
  font-size: 13px;
  padding: 0 9px;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
}

.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}

.search-wrap .input {
  padding-left: 33px;
}

.checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-600);
  cursor: pointer;
  flex-shrink: 0;
}

/* TLD Chip Selector */
.tld-tier-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tld-tier-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.tld-tier-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  width: 68px;
  padding-top: 5px;
  flex-shrink: 0;
}

.tld-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.tld-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  transition: all 0.12s;
}

.tld-chip:hover {
  border-color: var(--border-strong);
}

.tld-chip.selected {
  background: var(--brand-50);
  border-color: var(--brand-600);
  color: var(--brand-700);
}

.tld-chip .tld-price {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  opacity: 0.75;
}

/* ---------- Tables ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}

.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s, background 0.15s;
}

.sortable-th:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.sortable-th.sorted {
  color: var(--brand-700);
}

.sort-arrow {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  opacity: 0.75;
}

.expand-caret {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg-subtle);
  transition: transform 0.16s ease, background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.expand-caret svg {
  width: 14px;
  height: 14px;
}

.expand-caret.open {
  transform: rotate(180deg);
  background: var(--brand-50);
  color: var(--brand-700);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #FAFCFF;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* ---------- Assets Domain Hierarchy ---------- */
.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.batch-action-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: linear-gradient(90deg, #EFF6FF 0%, #F5F3FF 100%);
  border: 1px solid #BFDBFE;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.domain-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.domain-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  overflow: visible;
  transition: border-color 0.15s;
}

.domain-card.selected {
  border-color: var(--brand-600);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.domain-parent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  flex-wrap: wrap;
}

.domain-parent-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.domain-name {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.domain-meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-muted);
}

.domain-parent-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.mailbox-children {
  border-top: 1px solid var(--border-subtle);
  background: #FAFBFD;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.mailbox-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 10px 38px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.mailbox-row:last-child {
  border-bottom: none;
}

.mailbox-row::before {
  content: '';
  position: absolute;
  left: 22px;
  top: 0;
  bottom: 50%;
  width: 10px;
  border-left: 1.5px solid #CBD5E1;
  border-bottom: 1.5px solid #CBD5E1;
  border-bottom-left-radius: 5px;
}

.mailbox-info {
  min-width: 0;
  flex: 1;
}

.mailbox-addr {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mailbox-sub {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.mailbox-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  position: relative;
}

.empty-children {
  padding: 10px 16px 10px 38px;
  font-size: 12.5px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ---------- Dropdown Menu ---------- */
.dropdown-wrap {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 196px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--bg-subtle);
}

.dropdown-item svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.dropdown-item.danger {
  color: var(--red-700);
}

.dropdown-item.danger svg {
  color: var(--red-600);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

/* ---------- Pipeline Stepper ---------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.step-dot-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--text-faint);
}

.step-dot-item.done {
  background: var(--green-50);
  color: var(--green-700);
}

.step-dot-item.current {
  background: var(--brand-50);
  color: var(--brand-700);
  border: 1px solid var(--brand-100);
}

.step-dot-item.failed {
  background: var(--red-50);
  color: var(--red-700);
  border: 1px solid var(--red-200);
}

/* ---------- Modals & Slide-Over Drawers ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.14s ease;
}

.modal-box {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scaleUp 0.16s ease;
}

.modal-box.modal-lg {
  max-width: 720px;
}

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

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body > * {
  flex-shrink: 0;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-default);
  background: var(--bg-canvas);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* Right Drawer (PC) / Bottom Sheet (Mobile) */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(2px);
  z-index: 105;
  display: flex;
  justify-content: flex-end;
  animation: fadeIn 0.14s ease;
}

.drawer-panel {
  width: 100%;
  max-width: 520px;
  height: 100%;
  background: #FFFFFF;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.16s ease-out;
}

.drawer-panel.drawer-wide {
  max-width: 640px;
}

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
}

.drawer-body > * {
  flex-shrink: 0;
}

.drawer-footer {
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-default);
  background: #FFFFFF;
  box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.04);
  flex-shrink: 0;
}

/* ---------- OTP Highlight Card & Mail List ---------- */
.otp-banner {
  background: linear-gradient(135deg, #EFF6FF 0%, #EEF2FF 100%);
  border: 1px solid #BFDBFE;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.otp-code {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--brand-700);
  line-height: 1.1;
}

.mail-item {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--bg-surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.mail-item:hover {
  border-color: var(--brand-600);
  background: #FAFCFF;
}

.mail-item.unread {
  border-left: 3px solid var(--brand-600);
}

.mail-subject {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mail-from {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.mail-snippet {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.5;
}

.mail-body-expanded {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-default);
  font-size: 13px;
  color: var(--text-primary);
  white-space: pre-wrap;
  line-height: 1.65;
  background: var(--bg-canvas);
  padding: 12px;
  border-radius: var(--radius-xs);
}

/* ---------- Daily Settlement Cards ---------- */
.settlement-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-xs);
}

.settlement-card.unpaid {
  border-left: 4px solid var(--amber-600);
}

.settlement-card.settled {
  border-left: 4px solid var(--green-600);
}

.money-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-canvas);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.money-cell-label {
  font-size: 11px;
  color: var(--text-muted);
}

.money-cell-val {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* ---------- Login Page ---------- */
.login-page {
  min-height: 100vh;
  background: radial-gradient(circle at 12% 18%, #DBEAFE 0%, transparent 40%),
              radial-gradient(circle at 88% 82%, #EDE9FE 0%, transparent 40%),
              var(--bg-canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-shell {
  width: 100%;
  max-width: 880px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  overflow: hidden;
}

.login-hero {
  background: linear-gradient(155deg, #1E3A8A 0%, #1D4ED8 52%, #4338CA 100%);
  color: #fff;
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
}

.login-form-side {
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ---------- Customer Self-Service Portal ---------- */
.portal-page {
  min-height: 100vh;
  background: var(--bg-canvas);
}

.portal-preview-ribbon {
  background: #0F172A;
  color: #F8FAFC;
  padding: 8px 16px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.portal-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  padding: 16px 20px;
}

.portal-container {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.portal-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.portal-mailbox-item {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  margin-bottom: 8px;
  transition: all 0.14s;
}

.portal-mailbox-item:hover {
  border-color: var(--brand-600);
}

.portal-mailbox-item.active {
  border-color: var(--brand-600);
  background: var(--brand-50);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

/* ---------- Code / Export Block ---------- */
.export-box {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: #0F172A;
  color: #E2E8F0;
  padding: 14px;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.55;
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
}

.toast {
  background: #0F172A;
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideDown 0.18s ease;
}

.toast.toast-success { background: #065F46; }
.toast.toast-error { background: #991B1B; }
.toast.toast-info { background: #1E40AF; }

/* ---------- Responsive Helpers ---------- */
.desktop-only { display: block; }
.mobile-only { display: none; }
.mobile-only-flex { display: none !important; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleUp { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }
@keyframes slideInRight { from { transform: translateX(36px); } to { transform: translateX(0); } }
@keyframes slideInUp { from { transform: translateY(48px); } to { transform: translateY(0); } }
@keyframes slideDown { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Tablet (<= 1024px) ---------- */
@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-main-side, .grid-2 {
    grid-template-columns: 1fr;
  }
  .portal-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Mobile (<= 767px, rock-solid down to 360px) ---------- */
@media (max-width: 767px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; }
  .mobile-only-flex { display: inline-flex !important; }

  .sidebar {
    display: none;
  }

  .main-wrap {
    margin-left: 0;
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    padding: 0 14px;
    height: 54px;
  }

  .topbar-subtitle {
    display: none;
  }

  .content-area {
    padding: 14px 12px 24px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .kpi-card {
    padding: 12px 13px;
  }

  .kpi-value {
    font-size: 19px;
  }

  .card-header {
    padding: 13px 14px;
  }

  .card-body {
    padding: 14px;
  }

  .form-grid, .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .money-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Domain & Mailbox Mobile Layout */
  .domain-parent-row {
    padding: 12px;
  }

  .mailbox-row {
    padding: 10px 12px 10px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .mailbox-row::before {
    display: none;
  }

  .mailbox-actions {
    width: 100%;
    justify-content: flex-end;
    padding-top: 6px;
    border-top: 1px dashed var(--border-subtle);
  }

  .mailbox-actions .btn {
    height: 36px;
    flex: 1;
  }

  .mailbox-actions .dropdown-wrap {
    flex: 0 0 auto;
  }

  .mailbox-actions .dropdown-wrap .btn {
    width: 36px;
    flex: none;
  }

  /* Bottom Navigation Bar */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-default);
    z-index: 40;
  }

  .mob-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    padding: 6px 2px;
    position: relative;
  }

  .mob-nav-btn svg {
    width: 20px;
    height: 20px;
  }

  .mob-nav-btn.active {
    color: var(--brand-600);
  }

  .mob-nav-dot {
    position: absolute;
    top: 7px;
    right: calc(50% - 16px);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--amber-600);
  }

  /* Drawers & Modals become sleek Mobile Bottom Sheets */
  .drawer-overlay {
    align-items: flex-end;
  }

  .drawer-panel, .drawer-panel.drawer-wide {
    max-width: 100%;
    height: 92vh;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    animation: slideInUp 0.2s ease;
  }

  .overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-box, .modal-box.modal-lg {
    max-width: 100%;
    max-height: 92vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-hero {
    padding: 24px 20px;
  }

  .login-form-side {
    padding: 24px 20px;
  }

  .toast-container {
    top: auto;
    bottom: calc(var(--bottom-nav-h) + 12px);
    left: 12px;
    right: 12px;
    max-width: none;
  }
}
