html {
  direction: rtl;
}
*, *::before, *::after { box-sizing: border-box; }

body.dg-body {
  margin: 0;
  min-height: 100dvh;
  font-family: system-ui, "Segoe UI", Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: linear-gradient(to bottom, #f5f5f4, #fff 40%, #f5f5f4);
  color: #1c1917;
}

html.dg-theme-dark body.dg-body {
  background: linear-gradient(to bottom, #0c0a09, #1c1917 45%, #0c0a09);
  color: #fafaf9;
}

.dg-app { padding-bottom: 3rem; }

.dg-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(120, 113, 108, 0.25);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  padding: 1rem;
}
html.dg-theme-dark .dg-header {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(12, 10, 9, 0.85);
}
.dg-header-inner {
  max-width: 32rem;
  margin: 0 auto;
  position: relative;
  text-align: center;
  padding-top: 0.25rem;
}
.dg-theme-toggle {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 0.75rem;
  border: 1px solid #d6d3d1;
  background: #fff;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: #292524;
}
html.dg-theme-dark .dg-theme-toggle {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(41, 37, 36, 0.9);
  color: #fafaf9;
}
.dg-brand {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  color: #78350f;
}
html.dg-theme-dark .dg-brand { color: #fef3c7; }
.dg-tagline {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: #57534e;
}
html.dg-theme-dark .dg-tagline { color: #a8a29e; }
.dg-userbar {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  font-size: 0.75rem;
}
.dg-chip {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  background: #e7e5e4;
  font-weight: 600;
}
html.dg-theme-dark .dg-chip { background: rgba(68, 64, 60, 0.8); }
.dg-chip-link {
  text-decoration: none;
  color: inherit;
  border: 1px solid #14b8a6;
  background: #ccfbf1;
}
html.dg-theme-dark .dg-chip-link {
  background: rgba(19, 78, 74, 0.4);
  border-color: rgba(45, 212, 191, 0.5);
}

.dg-flash-wrap { max-width: 32rem; margin: 0.5rem auto; padding: 0 1rem; }
.dg-flash {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: #fef3c7;
  color: #92400e;
  text-align: center;
  font-size: 0.9rem;
}
html.dg-theme-dark .dg-flash {
  background: rgba(120, 53, 15, 0.35);
  color: #fde68a;
}

.dg-tabs {
  max-width: 32rem;
  margin: 1rem auto 0;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
@media (min-width: 640px) {
  .dg-tabs { grid-template-columns: repeat(4, 1fr); }
}
.dg-tab {
  display: block;
  text-align: center;
  padding: 0.75rem 0.5rem;
  border-radius: 0.75rem;
  border: 1px solid #d6d3d1;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  color: inherit;
  opacity: 0.88;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.dg-tab.is-active { opacity: 1; outline: 2px solid #57534e; outline-offset: 1px; }
html.dg-theme-dark .dg-tab.is-active { outline-color: #d6d3d1; }

.dg-tab-buy { background: #d1fae5; border-color: #6ee7b7; color: #064e3b; }
.dg-tab-sell { background: #ffe4e6; border-color: #fda4af; color: #881337; }
.dg-tab-ex { background: #fef3c7; border-color: #fcd34d; color: #78350f; }
.dg-tab-rep { background: #e7e5e4; border-color: #d6d3d1; color: #292524; }
html.dg-theme-dark .dg-tab-buy { background: rgba(6, 78, 59, 0.45); color: #d1fae5; border-color: rgba(52, 211, 153, 0.4); }
html.dg-theme-dark .dg-tab-sell { background: rgba(136, 19, 55, 0.45); color: #ffe4e6; border-color: rgba(251, 113, 133, 0.4); }
html.dg-theme-dark .dg-tab-ex { background: rgba(120, 53, 15, 0.4); color: #fef3c7; border-color: rgba(252, 211, 77, 0.35); }
html.dg-theme-dark .dg-tab-rep { background: rgba(41, 37, 36, 0.6); color: #e7e5e4; }

.dg-main { max-width: 32rem; margin: 0 auto; padding: 1.5rem 1rem; }

.dg-panel {
  border-radius: 1rem;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}
html.dg-theme-dark .dg-panel {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}
.dg-panel h2 { margin: 0 0 1rem; font-size: 1.1rem; }
.dg-panel-buy { background: rgba(209, 250, 229, 0.85); border-color: rgba(16, 185, 129, 0.35); }
html.dg-theme-dark .dg-panel-buy { background: rgba(6, 78, 59, 0.25); }
.dg-panel-sell { background: rgba(255, 228, 230, 0.85); border-color: rgba(244, 63, 94, 0.35); }
html.dg-theme-dark .dg-panel-sell { background: rgba(136, 19, 55, 0.25); }
.dg-panel-ex { background: rgba(254, 243, 199, 0.85); border-color: rgba(245, 158, 11, 0.4); }
html.dg-theme-dark .dg-panel-ex { background: rgba(120, 53, 15, 0.22); }
.dg-panel-stone { background: rgba(255, 255, 255, 0.9); }
html.dg-theme-dark .dg-panel-stone { background: rgba(28, 25, 23, 0.55); }
.dg-panel-teal { background: rgba(204, 251, 241, 0.9); border-color: rgba(20, 184, 166, 0.4); }
html.dg-theme-dark .dg-panel-teal { background: rgba(19, 78, 74, 0.35); }

.dg-form { display: flex; flex-direction: column; gap: 0.75rem; }
.dg-label { font-size: 0.85rem; font-weight: 600; color: #44403c; }
html.dg-theme-dark .dg-label { color: #d6d3d1; }
.dg-input, .dg-textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid #d6d3d1;
  font-size: 1rem;
  background: #fff;
  color: inherit;
}
html.dg-theme-dark .dg-input, html.dg-theme-dark .dg-textarea {
  background: rgba(12, 10, 9, 0.6);
  border-color: rgba(255, 255, 255, 0.12);
}
.dg-textarea { resize: vertical; min-height: 4rem; }

.dg-btn {
  display: inline-block;
  text-align: center;
  border: none;
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
}
.dg-btn-primary { background: #0d9488; }
.dg-btn-buy { background: #059669; width: 100%; }
.dg-btn-sell { background: #e11d48; width: 100%; }
.dg-btn-ex { background: #f59e0b; color: #1c1917; width: 100%; }
.dg-btn-small { font-size: 0.8rem; padding: 0.45rem 0.75rem; width: auto; }
.dg-btn-ghost {
  background: transparent;
  color: #b45309;
  border: 1px solid #fbbf24;
}
html.dg-theme-dark .dg-btn-ghost { color: #fcd34d; }
.dg-btn-danger { background: #be123c; }

.dg-karat-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.dg-karat-btn {
  min-width: 3.25rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #34d399;
  background: #a7f3d0;
  font-weight: 800;
  cursor: pointer;
  font-size: 0.9rem;
}
html.dg-theme-dark .dg-karat-btn {
  background: rgba(6, 95, 70, 0.5);
  border-color: rgba(52, 211, 153, 0.45);
  color: #ecfdf5;
}
.dg-panel-ex .dg-karat-btn {
  border-color: #fbbf24;
  background: #fde68a;
  color: #78350f;
}

.dg-calc-box {
  border-radius: 0.75rem;
  border: 1px solid #e7e5e4;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.85);
}
html.dg-theme-dark .dg-calc-box {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(12, 10, 9, 0.45);
}
.dg-calc-nums { font-size: 1.5rem; font-weight: 800; margin-top: 0.25rem; font-variant-numeric: tabular-nums; }
.dg-calc-total { border-color: #fcd34d; background: rgba(254, 243, 199, 0.6); }

.dg-muted { font-size: 0.8rem; color: #78716c; }
html.dg-theme-dark .dg-muted { color: #a8a29e; }
.dg-hint { font-size: 0.75rem; color: #78716c; margin: 0; }
html.dg-theme-dark .dg-hint { color: #a8a29e; }

.dg-subpanel {
  border-radius: 0.75rem;
  border: 1px solid rgba(251, 191, 36, 0.5);
  padding: 1rem;
  background: rgba(255, 255, 255, 0.55);
  margin-bottom: 0.5rem;
}
html.dg-theme-dark .dg-subpanel {
  border-color: rgba(251, 191, 36, 0.25);
  background: rgba(12, 10, 9, 0.25);
}
.dg-subhead { margin: 0 0 0.75rem; font-size: 0.95rem; }
.dg-mini-calc { font-size: 0.85rem; font-variant-numeric: tabular-nums; margin-top: 0.5rem; }

.dg-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
@media (min-width: 640px) {
  .dg-stats { grid-template-columns: repeat(4, 1fr); }
}
.dg-stat {
  border-radius: 0.75rem;
  border: 1px solid #e7e5e4;
  padding: 0.75rem;
  text-align: right;
  background: rgba(255, 255, 255, 0.85);
  font-size: 0.75rem;
}
html.dg-theme-dark .dg-stat {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(28, 25, 23, 0.5);
}
.dg-stat strong { display: block; margin-top: 0.25rem; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.dg-stat-highlight {
  border-color: #fcd34d;
  background: rgba(254, 243, 199, 0.85);
}
html.dg-theme-dark .dg-stat-highlight {
  background: rgba(120, 53, 15, 0.35);
}

.dg-tx-list { list-style: none; margin: 0; padding: 0; max-height: min(60vh, 480px); overflow-y: auto; }
.dg-tx-item {
  padding: 1rem;
  border-bottom: 1px solid #e7e5e4;
}
html.dg-theme-dark .dg-tx-item { border-color: rgba(255, 255, 255, 0.06); }
.dg-tx-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.dg-badge { font-size: 0.7rem; font-weight: 800; padding: 0.2rem 0.5rem; border-radius: 9999px; }
.dg-badge-buy { background: #a7f3d0; color: #064e3b; }
.dg-badge-sell { background: #fecdd3; color: #881337; }
.dg-badge-ex { background: #fde68a; color: #78350f; }
.dg-detail { margin: 0.5rem 0 0; font-size: 0.9rem; }
.dg-profit-block { margin-top: 0.35rem; font-size: 0.9rem; }
.dg-profit-line { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; color: #b45309; }
html.dg-theme-dark .dg-profit-line { color: #fcd34d; }
.dg-profit-sub { margin: 0.25rem 0 0; font-size: 0.85rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.dg-audit { margin: 0.35rem 0 0; font-size: 0.75rem; color: #78716c; }
html.dg-theme-dark .dg-audit { color: #a8a29e; }
.dg-note {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #e7e5e4;
  background: #f5f5f4;
  font-size: 0.75rem;
}
html.dg-theme-dark .dg-note {
  border-color: rgba(255, 255, 255, 0.06);
  background: rgba(12, 10, 9, 0.4);
}
.dg-tx-actions { margin-top: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.dg-inline-form { display: inline; margin: 0; }

.dg-act-list { list-style: none; margin: 0; padding: 0; max-height: 14rem; overflow-y: auto; font-size: 0.75rem; }
.dg-act-list li { padding: 0.5rem 0; border-bottom: 1px solid #f5f5f4; }
html.dg-theme-dark .dg-act-list li { border-color: rgba(255, 255, 255, 0.05); }
.dg-act-sum { margin: 0.2rem 0 0; color: #57534e; }
html.dg-theme-dark .dg-act-sum { color: #a8a29e; }
.dg-act-id { margin: 0.15rem 0 0; font-family: ui-monospace, monospace; font-size: 0.65rem; color: #a8a29e; }

.dg-empty { text-align: center; color: #78716c; padding: 1rem; }
.dg-inline-date { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem; }
.dg-inline-date .dg-input { max-width: 12rem; }

/* login */
.dg-login-card { max-width: 22rem; margin: 3rem auto; }
.dg-title { text-align: center; margin: 0; font-size: 1.75rem; color: #78350f; }
html.dg-theme-dark .dg-title { color: #fef3c7; }
.dg-error { color: #b91c1c; text-align: center; font-size: 0.9rem; }

.dg-link-back {
  display: inline-block;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: #0d9488;
  text-decoration: none;
}
.dg-header-title { margin: 0; font-size: 1.2rem; }

.dg-check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.dg-user-list { list-style: none; padding: 0; margin: 0; }
.dg-user-list li { padding: 0.35rem 0; border-bottom: 1px solid #e7e5e4; }
.dg-badge-admin { margin-inline-start: 0.5rem; background: #ccfbf1; color: #115e59; font-size: 0.65rem; padding: 0.1rem 0.4rem; border-radius: 0.25rem; }

.tabular-nums { font-variant-numeric: tabular-nums; }

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
