:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --border: #e3e7ee;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px; background: #111827; color: #d1d5db;
  display: flex; flex-direction: column; padding: 20px 12px; position: sticky; top: 0; height: 100vh;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.logo-icon {
  width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff; font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.logo-title { font-size: 15px; font-weight: 600; color: #fff; }
.logo-sub { font-size: 12px; color: #9ca3af; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 8px;
  background: transparent; color: #d1d5db; font-size: 14px; cursor: pointer; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }

.sidebar-footer { padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.conn-status { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 12px; color: #9ca3af; }
.conn-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; }
.conn-status.ok .dot { background: #22c55e; }
.conn-status.ok { color: #86efac; }
.conn-status.err .dot { background: #ef4444; }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.rate-limit { font-size: 12px; color: var(--muted); }

.content { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.view { display: none; }
.view.active { display: flex; flex-direction: column; gap: 20px; }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card h2 { font-size: 15px; margin-bottom: 12px; }
.quick-card h2 { margin-bottom: 12px; }

.quota-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.quota-card { padding: 18px 20px; }
.quota-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.quota-value { font-size: 30px; font-weight: 700; }
.quota-value.accent { color: var(--primary); }
.quota-value.small { font-size: 18px; padding-top: 6px; }

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar .grow { flex: 1; min-width: 200px; }

/* Inputs & buttons */
.input, select.input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  background: #fff; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.input.search { width: 220px; }

.btn {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
  color: var(--text); font-size: 14px; cursor: pointer; transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: #f3f4f6; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f3f4f6; color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* Table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f9fafb; }
.table tbody tr:hover { background: #f9fafb; }
.table .actions { display: flex; gap: 6px; }
.table .actions .btn { padding: 3px 8px; font-size: 12px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge.active { background: #dcfce7; color: var(--success); }
.badge.suspended { background: #fef3c7; color: var(--warn); }
.badge.expired { background: #fee2e2; color: var(--danger); }
.badge.neutral { background: #f3f4f6; color: var(--muted); }

.empty-hint, .muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }
.empty-hint { text-align: center; padding: 30px 0; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; color: var(--muted); }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.req { color: var(--danger); }
.preview { margin-top: 14px; padding: 12px; background: #f0f6ff; border: 1px dashed #93c5fd; border-radius: 8px; color: var(--primary); font-family: ui-monospace, monospace; font-size: 13px; }

.env-hint { margin-top: 14px; font-size: 12px; color: var(--muted); }

/* WHOIS */
.whois-result { margin-top: 16px; }
.whois-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.whois-grid .item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.whois-grid .item b { color: var(--muted); font-weight: 500; }
.ns-list { display: flex; gap: 6px; flex-wrap: wrap; }
.ns-list span { padding: 2px 8px; background: #f3f4f6; border-radius: 6px; font-size: 12px; }

/* Detail info */
.detail-info { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.detail-info .item { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.detail-info .item b { display: block; color: var(--muted); font-weight: 500; font-size: 12px; margin-bottom: 2px; }

/* Modals */
.modal { display: none; position: fixed; inset: 0; background: rgba(17,24,39,.55); z-index: 100; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 12px; width: 520px; max-width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,.2); display: flex; flex-direction: column;
}
.modal-box.wide { width: 680px; }
.modal-box.small { width: 420px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; }
.modal-close { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }

.secret-box { margin-top: 16px; padding: 14px; background: #fefce8; border: 1px solid #fde68a; border-radius: 8px; }
.secret-title { font-weight: 600; color: var(--warn); margin-bottom: 10px; }
.secret-item { margin-bottom: 8px; font-size: 13px; }
.secret-item code { background: #fff; padding: 2px 8px; border-radius: 4px; border: 1px solid var(--border); word-break: break-all; }

/* Toast */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 16px; border-radius: 8px; color: #fff; font-size: 13.5px; box-shadow: 0 8px 20px rgba(0,0,0,.18);
  animation: slideIn .2s ease; max-width: 360px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
.toast.warn { background: var(--warn); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

@media (max-width: 768px) {
  .sidebar { width: 64px; padding: 16px 8px; }
  .logo-title, .logo-sub, .sidebar-footer .nav-item { display: none; }
  .sidebar-footer .conn-status { font-size: 0; justify-content: center; }
  .form-grid, .detail-info, .whois-grid { grid-template-columns: 1fr; }
}
