:root {
  --bg: #0a0f1e;
  --surface: #131b2e;
  --surface-2: #1a2440;
  --surface-hover: #1e2a4a;
  --border: #253358;
  --border-soft: #1c2645;
  --text: #eef1f8;
  --text-muted: #8b94b3;
  --text-faint: #5c6690;
  --accent: #5b7cfa;
  --accent-hover: #4665e0;
  --accent-soft: rgba(91, 124, 250, 0.15);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.15);
  --warning: #f5a623;
  --warning-soft: rgba(245, 166, 35, 0.15);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 7px;
  --shadow-card: 0 1px 2px rgba(0,0,0,.2), 0 8px 24px -12px rgba(0,0,0,.5);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- App shell ---------- */

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

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 24px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: -0.01em;
}

.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 400;
  margin-top: 1px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .12s ease, color .12s ease;
}

.nav-link svg { flex-shrink: 0; opacity: .8; }

.nav-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-link.active {
  background: var(--accent-soft);
  color: #b9c6ff;
}

.sidebar-footer {
  border-top: 1px solid var(--border-soft);
  padding-top: 12px;
  margin-top: 12px;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border-soft);
}

.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.topbar .topbar-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.content {
  padding: 28px 32px 48px;
  max-width: 1040px;
  width: 100%;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px 24px;
  margin-bottom: 22px;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.card-title {
  font-size: 14.5px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.card-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 18px;
  line-height: 1.5;
}

.count-badge {
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}

/* ---------- Forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  align-items: end;
}

.field label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

input, select {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-family: var(--font);
  transition: border-color .12s ease, box-shadow .12s ease;
}

input::placeholder { color: var(--text-faint); }

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b94b3' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 28px;
}

.hint {
  color: var(--text-faint);
  font-size: 11.5px;
  margin-top: 12px;
  line-height: 1.6;
}

.hint code {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}

/* ---------- Buttons ---------- */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background .12s ease, transform .05s ease;
}

button:active { transform: translateY(1px); }

.btn-primary, button[type="submit"] {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover, button[type="submit"]:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); }

.btn-danger {
  background: transparent;
  color: #f6a3a3;
  border: 1px solid rgba(239, 68, 68, .35);
  padding: 6px 12px;
  font-size: 12px;
}
.btn-danger:hover { background: var(--danger-soft); }

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  text-decoration: none;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Table ---------- */

.table-wrap { overflow-x: auto; }

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

thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--border-soft);
}

tbody td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.015); }

.domain-name { font-weight: 600; }
.domain-name a { text-decoration: none; color: var(--text); }
.domain-name a:hover { color: var(--accent); }
.domain-name .ext-icon { color: var(--text-faint); font-size: 11px; margin-left: 4px; }

.marketplace-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
  white-space: nowrap;
}

.countdown {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}
.countdown.soon { color: var(--warning); }
.countdown.critical { color: var(--danger); }

.badges { display: flex; gap: 4px; flex-wrap: wrap; }
.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--success-soft);
  color: #7ee2a8;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-faint);
  font-size: 13px;
}

/* ---------- Flash messages ---------- */

.flash {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
}
.flash-success { background: var(--success-soft); color: #a6f0c0; border-left-color: var(--success); }
.flash-error { background: var(--danger-soft); color: #f8b4b4; border-left-color: var(--danger); }

/* ---------- Login page ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(91,124,250,.12), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(139,92,246,.10), transparent 40%),
    var(--bg);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
}

.login-brand .brand-icon { width: 44px; height: 44px; border-radius: 12px; font-size: 20px; }
.login-brand h1 { font-size: 16px; margin: 0; font-weight: 700; }
.login-brand p { font-size: 12px; color: var(--text-muted); margin: 0; }

.login-card .field { margin-bottom: 14px; }
.login-card button[type="submit"] { width: 100%; padding: 10px; margin-top: 6px; }

/* ---------- Stat tiles ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.stat-value {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 6px;
}

.stat-card.stat-total .stat-value { color: var(--text); }
.stat-card.stat-safe { border-color: rgba(91, 124, 250, .35); }
.stat-card.stat-safe .stat-value { color: #8ba3ff; }
.stat-card.stat-warning { border-color: rgba(245, 166, 35, .4); }
.stat-card.stat-warning .stat-value { color: var(--warning); }
.stat-card.stat-critical { border-color: rgba(239, 68, 68, .45); }
.stat-card.stat-critical .stat-value { color: var(--danger); }

.section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  margin: 26px 0 12px;
}

.section-heading .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.section-heading.h-critical .dot { background: var(--danger); }
.section-heading.h-warning .dot { background: var(--warning); }
.section-heading.h-safe .dot { background: #8ba3ff; }
.section-heading .count { color: var(--text-faint); font-weight: 500; }

/* ---------- Domain cards + countdown widget ---------- */

.domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.domain-card {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 16px 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.domain-card.urgent { border-color: rgba(245, 166, 35, .5); }
.domain-card.critical { border-color: rgba(239, 68, 68, .6); box-shadow: 0 0 0 1px rgba(239, 68, 68, .15); }
.domain-card.is-expired { opacity: .55; }

.domain-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.domain-card-name {
  font-size: 14.5px;
  font-weight: 700;
  margin-bottom: 6px;
  word-break: break-word;
}
.domain-card-name a { text-decoration: none; color: var(--text); }
.domain-card-name a:hover { color: var(--accent); }

.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.countdown-box {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  text-align: center;
}

.cd-value {
  display: block;
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.cd-label {
  display: block;
  font-size: 9.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 2px;
}

.domain-card.urgent .cd-value { color: var(--warning); }
.domain-card.critical .cd-value { color: var(--danger); }

.bid-info {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.bid-info-empty {
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.5;
}

.bid-current {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.bid-amount {
  font-size: 16px;
  font-weight: 800;
  color: var(--success);
}

.bid-by {
  font-size: 11.5px;
  color: var(--text-muted);
}

.bid-meta {
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 2px;
}

.bid-history-details {
  margin-top: 8px;
}

.bid-history-details summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  list-style: none;
}
.bid-history-details summary::-webkit-details-marker { display: none; }
.bid-history-details summary:before { content: "▸ "; }
.bid-history-details[open] summary:before { content: "▾ "; }

.bid-history-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 160px;
  overflow-y: auto;
}

.bid-history-list li {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-muted);
}
.bid-history-list li:last-child { border-bottom: none; }
.bid-history-list li span:last-child { font-weight: 700; color: var(--text); }

.domain-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
}

/* ---------- Domain table rows (detail table) ---------- */

.domain-row.is-expired { opacity: .55; }

.bid-cell-amount {
  font-size: 14px;
  font-weight: 800;
  color: var(--success);
}

.bid-cell-meta {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}

.cell-faint {
  color: var(--text-faint);
  font-size: 12px;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.duration-inputs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.duration-inputs .field label { text-align: center; }
.duration-inputs input { text-align: center; font-variant-numeric: tabular-nums; }

.search-bar {
  margin-bottom: 20px;
}

.search-bar input {
  max-width: 320px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
  margin: 28px 0 12px;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    gap: 16px;
  }
  .brand { padding: 0; }
  .nav { flex-direction: row; }
  .sidebar-footer { border-top: none; border-left: 1px solid var(--border-soft); padding-top: 0; padding-left: 12px; margin-top: 0; margin-left: auto; }
  .content { padding: 20px 16px 40px; }
  .topbar { padding: 16px; }
}
