:root {
  color-scheme: light dark;
  font-family: "Poppins", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.6;

  --bg-gradient: radial-gradient(circle at top right, #fff4d0, #f7f7ff);
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --text-primary: #1a1a2f;
  --text-muted: #5e6072;
  --accent: #f0b429;
  --accent-strong: #c68a10;
  --highlight: linear-gradient(135deg, #f9d976, #f39f86);
  --shadow-soft: 0 20px 60px -25px rgba(20, 20, 43, 0.55);
  --border-subtle: rgba(26, 26, 47, 0.08);
  --success: #1f9d5c;
  --danger: #d14343;
}

body[data-locale="ar"] {
  font-family: "Cairo", "Poppins", "Segoe UI", system-ui, sans-serif;
}

body[data-locale="ar"] .summary-title,
body[data-locale="ar"] .summary-caption,
body[data-locale="ar"] .focus-label,
body[data-locale="ar"] .focus-note,
body[data-locale="ar"] .karat-label,
body[data-locale="ar"] .karat-purity,
body[data-locale="ar"] .insight-card h3,
body[data-locale="ar"] .insight-card li,
body[data-locale="ar"] .board-actions .last-updated,
body[data-locale="ar"] .brand-copy small {
  text-align: right;
}

body[data-locale="ar"] .focus-label,
body[data-locale="ar"] .meta-label,
body[data-locale="ar"] .price-chip .label,
body[data-locale="ar"] .focus-note,
body[data-locale="ar"] .karat-label,
body[data-locale="ar"] .karat-purity {
  font-weight: 700;
}

body[data-locale="ar"] .meta-label,
body[data-locale="ar"] .price-chip .label {
  font-size: 1.05rem;
}

body[data-locale="ar"] .focus-note {
  font-size: 1.1rem;
}

body[data-locale="ar"] .focus-label {
  font-size: 1.3rem;
}

body[data-locale="ar"] .karat-label {
  font-size: 1.15rem;
}

body[data-locale="ar"] .karat-purity {
  font-size: 1rem;
}

body[data-locale="ar"] .focus-price,
body[data-locale="ar"] .focus-meta,
body[data-locale="ar"] .price-chip,
body[data-locale="ar"] .summary-value,
body[data-locale="ar"] .karat-prices,
body[data-locale="ar"] table {
  direction: ltr;
}

:root[data-theme="dark"] {
  --bg-gradient: radial-gradient(circle at top right, #1a1b2e, #0b0c17);
  --surface: rgba(20, 24, 39, 0.75);
  --surface-strong: rgba(26, 31, 52, 0.88);
  --text-primary: #eef2ff;
  --text-muted: #a0a3b6;
  --accent: #f7c948;
  --accent-strong: #f0b429;
  --highlight: linear-gradient(135deg, #f093fb, #f5576c);
  --shadow-soft: 0 25px 70px -35px rgba(0, 0, 0, 0.65);
  --border-subtle: rgba(255, 255, 255, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-gradient);
  color: var(--text-primary);
  font-size: clamp(1.05rem, 1vw + 0.95rem, 1.2rem);
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  gap: clamp(2rem, 3vw, 3rem);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 1.25rem;
}

.brand-icon {
  font-size: 1.6rem;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}

.brand-copy small {
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
}

.user-chip .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--highlight);
  position: relative;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-meta small {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.content {
  display: grid;
  gap: clamp(2rem, 3vw, 3rem);
}

.primary-btn,
.outline-btn,
.ghost-btn {
  font: inherit;
  border-radius: 999px;
  padding: 0.65rem 1.6rem;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.primary-btn {
  background: var(--accent);
  color: #10121f;
  box-shadow: var(--shadow-soft);
}

.primary-btn:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

.outline-btn {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.outline-btn:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.ghost-btn {
  background: transparent;
  color: var(--text-muted);
  padding-inline: 1.2rem;
}

.ghost-btn:hover {
  color: var(--accent-strong);
}

.last-updated {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.market-board {
  display: grid;
  gap: clamp(1.5rem, 3vw, 2.5rem);
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.summary-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 0.35rem;
  min-height: 110px;
}

.summary-card.prominent {
  background: var(--highlight);
  color: #211b15;
  box-shadow: 0 25px 45px -30px rgba(240, 148, 45, 0.65);
}

.summary-title {
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.summary-card.prominent .summary-title {
  color: rgba(33, 27, 21, 0.8);
}

.summary-value {
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 600;
}

.summary-card.prominent .summary-value {
  font-size: clamp(1.8rem, 4.5vw, 2.4rem);
}

.summary-caption {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.summary-card.prominent .summary-caption {
  color: rgba(33, 27, 21, 0.75);
}

.board-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr);
  gap: clamp(1.2rem, 2.5vw, 2rem);
  align-items: stretch;
}


.focus-card,
.karat-panel {
  background: var(--surface);
  border-radius: 28px;
  padding: clamp(1.25rem, 2.5vw, 1.75rem);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
}

.focus-card {
  display: grid;
  gap: 1.15rem;
  position: relative;
  overflow: hidden;
}

.focus-card::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  pointer-events: none;
}

.focus-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.focus-label {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.focus-location {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.focus-badge {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.focus-price {
  font-size: clamp(2.8rem, 7vw, 4.2rem);
  font-weight: 700;
  line-height: 1;
}

.focus-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.meta-label {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.meta-value {
  display: block;
  font-size: clamp(1.4rem, 3.5vw, 1.9rem);
  font-weight: 600;
  margin-top: 0.35rem;
  line-height: 1.15;
}

.focus-note {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text-muted);
}

.karat-panel {
  display: grid;
  gap: 1rem;
}

.karat-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.karat-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.karat-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.karat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.karat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(20, 20, 43, 0.06);
  border-radius: 16px;
  padding: 0.85rem 1rem;
  gap: 1rem;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.karat-item:hover,
.karat-item.is-active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
  background: var(--surface-strong);
}

.karat-label {
  display: block;
  font-weight: 600;
  font-size: 1rem;
}

.karat-purity {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.karat-prices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: center;
  text-align: right;
}

.price-chip {
  display: grid;
  gap: 0.3rem;
}

.price-chip span {
  display: block;
}

.price-chip .label {
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.price-chip .value {
  font-weight: 600;
}

.board-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.board-actions .last-updated {
  margin-left: auto;
  font-size: 0.9rem;
}

.ads-banner {
  margin: clamp(1.5rem, 4vw, 2.4rem) 0;
  background: var(--surface);
  border-radius: 24px;
  padding: clamp(1rem, 2.5vw, 1.6rem);
  border: 1px dashed rgba(26, 26, 47, 0.15);
  box-shadow: var(--shadow-soft);
  display: grid;
  justify-items: center;
  gap: 0.65rem;
}

.ads-banner .ads-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
}

body[data-theme="dark"] .ads-banner {
  border-color: rgba(255, 255, 255, 0.12);
}

.badge {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: rgba(240, 180, 41, 0.12);
  color: var(--accent-strong);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

.summary-card.prominent .badge {
  color: rgba(33, 27, 21, 0.8);
}

.insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.insight-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 1.5rem;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
}

.insight-card h3 {
  margin-top: 0;
  font-size: 1.2rem;
}

.insight-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.insight-card li {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
}

.insight-card li::before {
  content: "•";
  font-size: 1.2rem;
  color: var(--accent-strong);
}

.insight-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.05rem;
}

.insight-card th,
.insight-card td {
  padding: 0.6rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.insight-card table tr td:nth-child(3),
.insight-card table tr td:nth-child(4),
.insight-card table tr th:nth-child(3),
.insight-card table tr th:nth-child(4) {
  text-align: right;
}

.insight-card tbody tr:last-child td {
  border-bottom: none;
}

.page-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding-top: 1rem;
}

#currency-dialog {
  border: none;
  border-radius: 24px;
  padding: 0;
  max-width: min(420px, 90vw);
  box-shadow: var(--shadow-soft);
}

.currency-form {
  background: var(--surface-strong);
  border-radius: 24px;
  padding: 2rem;
  display: grid;
  gap: 1.25rem;
}

.currency-form h2 {
  margin: 0;
}

.currency-form p {
  margin: 0;
  color: var(--text-muted);
}

.field {
  display: grid;
  gap: 0.5rem;
}

.field select {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  font: inherit;
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(18px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.2);
}

.field select option {
  color: #111;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin: 0;
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .user-chip {
    align-self: flex-start;
  }

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

  .board-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .board-actions .last-updated {
    margin-left: 0;
  }
}
