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

:root {
  --primary: #f6821f;
  --primary-hover: #e5721a;
  --bg: #f0f2f5;
  --card: #ffffff;
  --header-bg: #1b1b32;
  --header-text: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --error: #dc2626;
  --info: #2563eb;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---- Login ---- */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1b1b32 0%, #2d2b55 100%);
}

.login-card {
  background: var(--card);
  padding: 48px 40px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  color: var(--primary);
  margin-bottom: 16px;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}

.login-card .form-group { margin-bottom: 16px; }

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  transition: border-color 0.2s;
}

.login-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(246, 130, 31, 0.15);
}

.error-text {
  color: var(--error);
  font-size: 13px;
  margin-top: 12px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  gap: 6px;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary {
  background: #f1f5f9;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: #e2e8f0; }

.btn-ghost {
  background: transparent;
  color: var(--header-text);
  opacity: 0.8;
}
.btn-ghost:hover { opacity: 1; }

.btn-block { width: 100%; padding: 12px; }

.btn-sm {
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 6px;
}

.btn-edit {
  background: #eff6ff;
  color: var(--info);
  border: 1px solid #bfdbfe;
}
.btn-edit:hover { background: #dbeafe; }

.btn-delete {
  background: #fef2f2;
  color: var(--error);
  border: 1px solid #fecaca;
}
.btn-delete:hover { background: #fee2e2; }

/* ---- Header ---- */
.app-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.zone-select {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 14px;
  max-width: 240px;
}

.zone-select option { color: #000; background: #fff; }
.zone-select:focus { outline: none; border-color: var(--primary); }

/* ---- Main Content ---- */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 200px;
}

.search-input {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  width: 100%;
  max-width: 320px;
  background: var(--card);
  transition: border-color 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(246, 130, 31, 0.1);
}

.record-count {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ---- Loading ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px;
  color: var(--text-secondary);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-secondary);
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ---- Table ---- */
.table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.records-table th {
  text-align: left;
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  white-space: nowrap;
}

.records-table td {
  padding: 10px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.records-table tbody tr:hover {
  background: #f8fafc;
}

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

.th-type { width: 80px; }
.th-ttl { width: 80px; }
.th-proxy { width: 100px; }
.th-actions { width: 140px; }

.cell-name {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
  font-size: 13px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-content {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
  font-size: 13px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.cell-ttl {
  font-size: 13px;
  color: var(--text-secondary);
}

.cell-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

/* Type badges */
.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  font-family: "SF Mono", monospace;
  color: #fff;
  letter-spacing: 0.03em;
}

.type-A { background: #3b82f6; }
.type-AAAA { background: #8b5cf6; }
.type-CNAME { background: #22c55e; }
.type-MX { background: #eab308; color: #422006; }
.type-TXT { background: #64748b; }
.type-NS { background: #ec4899; }
.type-SRV { background: #14b8a6; }
.type-CAA { background: #f97316; }
.type-SOA { background: #6366f1; }
.type-PTR { background: #a855f7; }
.type-SPF { background: #78716c; }
.type-DNSKEY { background: #0ea5e9; }
.type-DS { background: #06b6d4; }
.type-NAPTR { background: #84cc16; color: #1a2e05; }
.type-SMIMEA { background: #f43e5e; }
.type-SSHFP { background: #d946ef; }
.type-TLSA { background: #0d9488; }
.type-URI { background: #7c3aed; }

/* Proxy badges */
.proxy-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.proxy-on { background: #f0fdf4; color: var(--success); }
.proxy-off { background: #fef2f2; color: var(--text-secondary); }
.proxy-na { color: var(--text-secondary); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.modal-close-btn:hover { color: var(--text); }

.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
}

/* ---- Forms ---- */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(246, 130, 31, 0.1);
}

.form-group textarea {
  resize: vertical;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 13px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > .form-group { flex: 1; }
.form-row-3 > .form-group { flex: 1; }

.form-group-type { flex: 0 0 110px !important; }
.form-group-name { flex: 1 !important; }

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500 !important;
  padding-top: 28px;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.optional {
  font-weight: 400;
  color: var(--text-secondary);
}

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  top: 72px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s ease-out;
  max-width: 400px;
}

.toast-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.toast-error { background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }
.toast-info { background: #eff6ff; color: var(--info); border: 1px solid #bfdbfe; }

.toast-fade {
  animation: toast-out 0.3s ease-in forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(40px); }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .app-header {
    padding: 0 16px;
    height: auto;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
  }

  .header-right {
    width: 100%;
  }

  .zone-select {
    flex: 1;
    max-width: none;
  }

  .main-content { padding: 16px; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left { flex-direction: column; }
  .search-input { max-width: none; }

  .form-row { flex-direction: column; gap: 0; }
  .form-group-type { flex: auto !important; }

  .checkbox-label { padding-top: 0; }

  .cell-name, .cell-content { max-width: 160px; }

  #toast-container { right: 16px; left: 16px; }
  .toast { max-width: none; }
}
