/* ==================== Reset & Base ==================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  background: #e8e8e8;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.9em;
}

/* ==================== Navbar ==================== */
.navbar {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-icon {
  font-size: 1.3rem;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.93rem;
  font-weight: 500;
  color: #666;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: #f0f0f0;
  color: #333;
}

.nav-link.active {
  background: #e8e8e8;
  color: #333;
}

/* ==================== Container ==================== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ==================== Page Title ==================== */
.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: #222;
}

/* ==================== Search Bar ==================== */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.search-bar input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 0.93rem;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

.search-bar input:focus {
  border-color: #888;
}

.auto-refresh-wrapper {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.auto-refresh-label {
  font-size: 0.85rem;
  color: #666;
  font-weight: 500;
  cursor: pointer;
}

/* Switch Styles */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #dcdcdc;
  transition: 0.3s;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px; width: 16px;
  left: 2px; bottom: 2px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: #333;
}

input:checked + .slider:before {
  transform: translateX(16px);
}

/* ==================== Buttons ==================== */
.btn {
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: #333;
  color: #fff;
  border-color: #333;
}

.btn-primary:hover {
  background: #555;
  border-color: #555;
}

.btn-secondary {
  background: #fff;
  color: #555;
  border-color: #d0d0d0;
}

.btn-secondary:hover {
  background: #f5f5f5;
  border-color: #bbb;
}

.btn-danger {
  background: #d9534f;
  color: #fff;
  border-color: #d9534f;
}

.btn-danger:hover {
  background: #c9302c;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.82rem;
}

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

/* ==================== Filter Bar ==================== */
.filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 5px 14px;
  border: 1px solid #d0d0d0;
  border-radius: 20px;
  background: #fff;
  font-size: 0.85rem;
  color: #666;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  border-color: #aaa;
  color: #333;
}

.filter-btn.active {
  background: #333;
  color: #fff;
  border-color: #333;
}

/* ==================== Mail Stats ==================== */
.mail-stats {
  padding: 0 0 8px;
  font-size: 0.85rem;
  color: #888;
}

/* ==================== Mail List ==================== */
.mail-list {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.mail-item {
  display: flex;
  align-items: flex-start;
  padding: 14px 18px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background 0.1s;
  gap: 12px;
}

.mail-item:last-child {
  border-bottom: none;
}

.mail-item:hover {
  background: #fafafa;
}

.mail-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4a9eff;
  margin-top: 7px;
  flex-shrink: 0;
}

.mail-content {
  flex: 1;
  min-width: 0;
}

.mail-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 3px;
}

.mail-recipient {
  font-size: 0.9rem;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-time {
  font-size: 0.8rem;
  color: #999;
  white-space: nowrap;
  flex-shrink: 0;
}

.mail-subject {
  font-size: 0.88rem;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-sender {
  font-size: 0.8rem;
  color: #999;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== Empty State ==================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-hint {
  font-size: 0.85rem;
  margin-top: 6px;
}

/* ==================== Pagination ==================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
  font-size: 0.9rem;
  color: #666;
}

/* ==================== Modal ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}

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

.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 720px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 24px 12px;
  gap: 16px;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #222;
  word-break: break-word;
}

.modal-close {
  font-size: 1.6rem;
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  padding: 0 4px;
}

.modal-close:hover {
  color: #333;
}

.modal-meta {
  padding: 0 24px 12px;
  font-size: 0.85rem;
  color: #666;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid #eee;
}

.modal-actions {
  padding: 10px 24px;
  display: flex;
  gap: 8px;
}

.modal-body {
  padding: 16px 24px 24px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: #444;
  overflow-x: auto;
}

.modal-body iframe {
  width: 100%;
  border: none;
  min-height: 300px;
}

/* ==================== Cards (Settings page) ==================== */
.card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.card-desc {
  font-size: 0.88rem;
  color: #777;
  margin-bottom: 14px;
}

.card-note {
  font-size: 0.82rem;
  color: #888;
  margin-top: 10px;
}

.card-note.success {
  color: #27ae60;
}

.card-note.error {
  color: #d9534f;
}

/* ==================== Add Domain Form ==================== */
.add-domain-form {
  display: flex;
  gap: 8px;
}

.add-domain-form input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 0.93rem;
  outline: none;
}

.add-domain-form input:focus {
  border-color: #888;
}

/* ==================== Domain List ==================== */
.domain-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.domain-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid #eee;
  border-radius: 6px;
  background: #fafafa;
}

.domain-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: #333;
}

.domain-item .btn-danger {
  padding: 4px 10px;
  font-size: 0.78rem;
}

/* ==================== Info Grid ==================== */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.info-item {
  padding: 12px 14px;
  border: 1px solid #eee;
  border-radius: 6px;
  background: #fafafa;
}

.info-label {
  display: block;
  font-size: 0.8rem;
  color: #999;
  margin-bottom: 4px;
}

.info-value {
  font-size: 1rem;
  font-weight: 600;
  color: #333;
}

/* ==================== DNS Table ==================== */
.dns-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.88rem;
}

.dns-table th, .dns-table td {
  padding: 10px 12px;
  text-align: left;
  border: 1px solid #e0e0e0;
}

.dns-table th {
  background: #f5f5f5;
  font-weight: 600;
  color: #555;
}

.help-content p {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 8px;
}

.loading {
  color: #999;
  font-size: 0.9rem;
  text-align: center;
  padding: 20px;
}

/* ==================== Responsive ==================== */
@media (max-width: 640px) {
  .nav-inner {
    padding: 0 14px;
  }

  .container {
    padding: 16px 14px 40px;
  }

  .search-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-bar input {
    min-width: 0;
  }

  .search-bar .btn {
    flex: 1;
  }

  .mail-header {
    flex-direction: column;
    gap: 2px;
  }

  .modal {
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
  }

  .modal-overlay {
    padding: 0;
  }

  .add-domain-form {
    flex-direction: column;
  }

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