:root {
  --bg: #edf2f6;
  --bg-soft: #f6f9fb;
  --surface: #ffffff;
  --surface2: #f3f7fa;
  --surface3: #e8f0f5;
  --border: #d4e0ea;
  --border-strong: #b8cad8;
  --text: #1a3344;
  --text-soft: #3d5566;
  --muted: #6b8294;
  --primary: #3d8fd4;
  --primary-hover: #2f7cbc;
  --primary-soft: #e6f2fb;
  --accent: #2db88a;
  --accent-soft: #e5f7ef;
  --accent-hover: #24a077;
  --danger: #e05656;
  --danger-soft: #fdeeee;
  --success: #22a86a;
  --warn: #d4a017;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 3px rgba(26, 51, 68, 0.06), 0 1px 2px rgba(26, 51, 68, 0.04);
  --shadow: 0 10px 30px rgba(26, 51, 68, 0.08), 0 4px 12px rgba(26, 51, 68, 0.04);
  --shadow-lg: 0 20px 50px rgba(26, 51, 68, 0.12);
  font-family: "DM Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

body {
  background:
    radial-gradient(circle at 0% 0%, rgba(61, 143, 212, 0.12) 0%, transparent 42%),
    radial-gradient(circle at 100% 0%, rgba(45, 184, 138, 0.14) 0%, transparent 38%),
    linear-gradient(180deg, #f4f8fb 0%, var(--bg) 55%, #e9f0f4 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden { display: none !important; }

.view { min-height: 100vh; }

.login-card {
  max-width: 420px;
  margin: 10vh auto;
  padding: 2.5rem;
  border: 1px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
}

.brand { text-align: center; margin-bottom: 2rem; }
.logo {
  width: 58px;
  height: 58px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 24px rgba(61, 143, 212, 0.28);
}
.logo.small {
  width: 34px;
  height: 34px;
  font-size: 1rem;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(61, 143, 212, 0.2);
}
.brand h1 {
  font-size: 1.65rem;
  font-weight: 700;
  margin-bottom: .25rem;
  letter-spacing: -0.02em;
}
.brand p, .muted { color: var(--muted); font-size: .92rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-soft);
  margin: .75rem 0 .35rem;
}

input, select {
  width: 100%;
  padding: .72rem .95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #94a8b8; }
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(61, 143, 212, 0.15);
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: .68rem 1.15rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: .15s ease;
}
.btn.primary {
  background: linear-gradient(135deg, var(--primary) 0%, #4aa3de 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(61, 143, 212, 0.28);
}
.btn.primary:hover {
  background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary) 100%);
  transform: translateY(-1px);
}
.btn.ghost {
  background: var(--surface);
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.btn.ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface2);
}
.btn.danger {
  background: var(--surface);
  color: var(--danger);
  border: 1px solid #efb8b8;
}
.btn.danger:hover { background: var(--danger-soft); }

#login-form button { width: 100%; margin-top: 1.25rem; }
.error { color: var(--danger); font-size: .85rem; margin-top: .75rem; text-align: center; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}
.brand-inline {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--text);
}
.topbar-actions { display: flex; align-items: center; gap: 1rem; }

.layout { display: flex; min-height: calc(100vh - 65px); }

.sidebar {
  width: 220px;
  padding: 1.1rem;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(8px);
}
.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: .75rem 1rem;
  margin-bottom: .4rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  font-size: .95rem;
  font-weight: 500;
  transition: .15s ease;
}
.nav-btn:hover {
  background: var(--surface2);
  color: var(--text);
}
.nav-btn.active {
  background: linear-gradient(135deg, var(--primary-soft) 0%, var(--accent-soft) 100%);
  color: var(--primary-hover);
  box-shadow: inset 0 0 0 1px rgba(61, 143, 212, 0.15);
}

.content { flex: 1; padding: 1.75rem 2rem; overflow-y: auto; }
.content h2 {
  margin-bottom: 1.25rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.stat span {
  display: block;
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.03em;
}
.stat label { color: var(--muted); font-size: .85rem; font-weight: 500; }

.info-card {
  padding: 1.35rem;
  background: linear-gradient(180deg, #ffffff 0%, var(--surface2) 100%);
}
.info-card h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.info-card dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: .55rem .75rem;
}
.info-card dt { color: var(--muted); font-size: .85rem; font-weight: 500; }
.info-card dd {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: .9rem;
  color: var(--text-soft);
}

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }

.list { display: flex; flex-direction: column; gap: .65rem; }
.list.compact { margin-top: 1rem; }

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.list-item:hover {
  border-color: #b8d4ea;
  box-shadow: var(--shadow);
}
.list-item .meta { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.list-item .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.mailbox-item { align-items: flex-start; gap: 1rem; }
.mailbox-main { flex: 1; min-width: 220px; }
.mailbox-stats { margin-top: .55rem; }
.quota-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  margin-bottom: .35rem;
}
.quota-label { color: var(--muted); font-size: .82rem; }
.quota-bar {
  height: 8px;
  background: var(--surface3);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.quota-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 999px;
  transition: width .2s ease;
}
.quota-bar.warn .quota-fill {
  background: linear-gradient(90deg, #e8c547, var(--warn));
}
.quota-bar.danger .quota-fill {
  background: linear-gradient(90deg, #f07171, var(--danger));
}
.mailbox-meta { margin-top: .45rem; }

dialog {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  background: var(--surface);
  color: var(--text);
  padding: 1.5rem;
  max-width: 820px;
  width: 92vw;
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(26, 51, 68, 0.28); backdrop-filter: blur(3px); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }

.detail-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.detail-header h3 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }

.tabs-inline {
  display: flex;
  gap: .35rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .65rem;
  flex-wrap: wrap;
}
.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: .55rem 1rem;
  cursor: pointer;
  border-radius: 999px;
  font-weight: 500;
  transition: .15s ease;
}
.tab-btn:hover { background: var(--surface2); color: var(--text); }
.tab-btn.active {
  background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft));
  color: var(--primary-hover);
  box-shadow: inset 0 0 0 1px rgba(61, 143, 212, 0.18);
}

.detail-panel { min-height: 200px; }
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  padding: .85rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.inline-form input { flex: 1; min-width: 120px; }
.inline-form input[type=number] { max-width: 100px; }

.dns-record {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  margin-bottom: .65rem;
  font-size: .88rem;
}
.dns-record .type {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary), #5eb0e8);
  color: #fff;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
  margin-right: .5rem;
}
.dns-record .name { margin: .4rem 0; }
.dns-record .dns-name .copyable-text,
.dns-record .dns-value .copyable-text {
  font-family: ui-monospace, "Cascadia Code", monospace;
  word-break: break-all;
  color: var(--text-soft);
}
.dns-record .dns-value {
  background: var(--surface);
  padding: .55rem;
  border-radius: 8px;
  margin-top: .35rem;
  border: 1px solid var(--border);
}
.dns-record .note { color: var(--muted); font-size: .8rem; margin-top: .35rem; }

.copyable-row {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}
.copyable-text { flex: 1; min-width: 0; }
.btn-copy {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: .15s ease;
}
.btn-copy:hover {
  color: var(--primary);
  border-color: #9ecae8;
  background: var(--primary-soft);
}
.btn-copy.copied {
  color: var(--success);
  border-color: #9edfc0;
  background: var(--accent-soft);
}
.btn-copy svg { width: 14px; height: 14px; }

.client-section {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  margin-bottom: .75rem;
  box-shadow: var(--shadow-sm);
}
.client-section h4 {
  font-size: .95rem;
  margin-bottom: .75rem;
  color: var(--primary-hover);
  font-weight: 600;
}
.client-section dl {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: .45rem .75rem;
  align-items: start;
}
.client-section dt {
  color: var(--muted);
  font-size: .85rem;
  font-weight: 500;
}
.client-section dd { font-size: .88rem; }
.client-section .client-value {
  font-family: ui-monospace, "Cascadia Code", monospace;
  word-break: break-all;
  color: var(--text-soft);
}
.client-section .note {
  display: block;
  color: var(--muted);
  font-size: .8rem;
  margin-top: .25rem;
}

.badge {
  display: inline-block;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--success);
}
.badge.off {
  background: var(--danger-soft);
  color: var(--danger);
}

@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    display: flex;
    gap: .5rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .nav-btn { flex: 1; text-align: center; }
  .content { padding: 1.25rem; }
}
