/* Self-hosted webfonts: the families the UI has always declared (Inter +
   JetBrains Mono), actually delivered. Latin subsets, variable weights. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("./fonts/inter-var-latin.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("./fonts/jetbrains-mono-var-latin.woff2") format("woff2");
}

:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-2: #f4f7fa;
  --border: #dde6ec;
  --text: #303640;
  --muted: #7a8792;
  --soft: #a7b3be;
  --primary: #63c4e8;
  --primary-soft: rgba(99, 196, 232, 0.18);
  --success: #63c4e8;
  --success-soft: #e6f7fd;
  --danger: #e95757;
  --danger-soft: #fdeaea;
  --info: #4db3df;
  --info-soft: #e4f6fc;
  --shadow: 0 8px 22px rgba(48, 54, 64, 0.09);
  --glass: rgba(255, 255, 255, 0.84);
  --line-glow: rgba(99, 196, 232, 0.32);
  --teal: #63c4e8;
  --cyan: #63c4e8;
  --rose: #e95757;
  --ink: #303640;
  --sidebar: #303640;
  --sidebar-2: #252b34;
  --orange: #f89a2a;
}

.dark {
  --bg: #202832;
  --surface: #303640;
  --surface-2: #252b34;
  --border: #46515d;
  --text: #f7fbfe;
  --muted: #c6d0d8;
  --soft: #8e9aa5;
  --primary: #63c4e8;
  --primary-soft: rgba(99, 196, 232, 0.16);
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.32);
  --glass: rgba(48, 54, 64, 0.82);
  --line-glow: rgba(99, 196, 232, 0.22);
}

* {
  box-sizing: border-box;
}

*::before,
*::after {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  background: linear-gradient(135deg, #edf2f5, var(--bg) 48%, #f7fafc);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
  text-rendering: geometricPrecision;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img,
svg,
canvas,
video {
  max-width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar-overlay,
.mobile-menu-toggle,
.mobile-menu-button {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(22px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 38px;
}

.sidebar-user-card {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-user-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  flex: 0 0 36px;
}

.sidebar-user-avatar .app-icon {
  width: 18px;
  height: 18px;
}

.sidebar-user-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sidebar-user-copy strong {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-copy span {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-change-password-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.sidebar-change-password-button .app-icon {
  width: 14px;
  height: 14px;
}

.sidebar-change-password-button:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

.change-password-layout {
  width: min(720px, 100%);
  margin-inline: auto;
}

.change-password-panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.94));
}

.change-password-form {
  display: grid;
  gap: 12px;
  max-width: 460px;
}

.change-password-form > label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.change-password-form input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font: inherit;
}

.change-password-form input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
  cursor: default;
}

.change-password-hints {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.change-password-login-required {
  margin-bottom: 8px;
}

.change-password-empty {
  display: grid;
  gap: 10px;
  padding: 18px;
  text-align: center;
}

.change-password-empty strong {
  font-size: 16px;
  color: var(--text);
}

.change-password-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.topbar-head {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
  flex: 1 1 auto;
}

.topbar-title-wrap {
  min-width: 0;
}

.topbar-version-line {
  margin: 3px 0 0;
  line-height: 1;
}

.topbar-version-line .app-version-chip {
  margin-left: 0;
}

.topbar-quick-actions {
  display: none;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.topbar-action-rail {
  gap: 0;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow-sm);
}

.topbar-action-rail .icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  line-height: 0;
}

.topbar-action-rail .icon-button + .icon-button {
  box-shadow: inset 1px 0 0 color-mix(in srgb, var(--border) 80%, transparent);
}

.topbar-action-rail .app-icon {
  width: 18px;
  height: 18px;
}

.topbar-action-rail .top-new-trade-button {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.mobile-menu-button .app-icon {
  width: 18px;
  height: 18px;
}

.topbar-mobile-only {
  display: none !important;
}

.topbar-desktop-only {
  display: revert;
}

@media (max-width: 760px) {
  .topbar-mobile-only {
    display: inline-grid !important;
  }
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.sidebar-footer label,
.eyebrow,
.panel p,
.metric span,
.metric small,
.task-list,
.report-tile span {
  color: var(--muted);
}

.sidebar .brand strong {
  color: #ffffff;
}

.sidebar .brand span,
.sidebar .sidebar-footer label {
  color: #aeb9c3;
}

.global-metal-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
}

.global-metal-toggle button {
  min-height: 30px;
  font-size: 12px;
}

.global-metal-toggle button[data-global-metal="silver"].active {
  background: linear-gradient(135deg, #5bc4ea, #3b9fd4);
}

.nav {
  display: grid;
  gap: 5px;
  align-content: start;
  overflow-y: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.nav-section {
  display: grid;
  gap: 4px;
}

.nav-group {
  position: relative;
  width: 100%;
  margin: 6px 0 2px;
  padding: 6px 24px 6px 8px;
  color: rgba(255, 255, 255, 0.48);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

.nav-group::after {
  position: absolute;
  right: 9px;
  top: 50%;
  content: "›";
  font-size: 16px;
  line-height: 1;
  transform: translateY(-50%) rotate(0deg);
  transition: transform 140ms ease;
}

.nav-section.open .nav-group {
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}

.nav-section.open .nav-group::after {
  transform: translateY(-50%) rotate(90deg);
}

.nav-section-items {
  display: none;
  gap: 5px;
}

.nav-section.open .nav-section-items {
  display: grid;
}

.nav-item.nav-item--denied,
.nav-item[hidden],
.nav-section.nav-section--denied,
.nav-section[hidden] {
  display: none !important;
}

.topbar-view-link--denied,
.topbar [data-view-link][hidden] {
  display: none !important;
}

.top-trade-card[hidden],
.top-trade-card.topbar-ui--hidden {
  display: none !important;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 0 8px;
  color: #aeb9c3;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
}

.nav-item span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
}

.nav-item.active,
.nav-item:hover {
  color: #ffffff;
  background: rgba(99, 196, 232, 0.16);
  border-color: rgba(99, 196, 232, 0.28);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.working-date-control {
  display: grid;
  gap: 5px;
}

.working-date-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
  align-items: center;
}

.working-date-row input {
  min-height: 34px;
  font-size: 12px;
}

.working-date-row .icon-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.working-date-row .icon-button.is-active {
  color: #ffffff;
  background: #7f1d1d;
  border-color: rgba(248, 113, 113, 0.55);
}

.app-version-line {
  color: #cbd5e1;
  font-size: 11px;
  line-height: 1.3;
  letter-spacing: 0;
  font-weight: 600;
}

.app-version-chip {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.35);
  color: #cbd5e1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.2;
  vertical-align: middle;
  white-space: nowrap;
}

.dark .app-version-chip {
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.55);
}

select,
input,
textarea {
  width: 100%;
  min-height: 34px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  outline: none;
}

textarea {
  resize: vertical;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.main {
  min-width: 0;
  padding: 14px;
}

.dashboard-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 14px;
  min-height: 68px;
  margin-bottom: 10px;
  padding: 10px 12px;
  overflow: hidden;
  border: 1px solid rgba(99, 196, 232, 0.44);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(99, 196, 232, 0.96), rgba(99, 196, 232, 0.72)),
    repeating-linear-gradient(90deg, transparent 0 30px, rgba(255, 255, 255, 0.13) 30px 31px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.dashboard-hero::after {
  position: absolute;
  inset: auto 12px 8px 12px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, #ffffff, rgba(248, 154, 42, 0.88), transparent);
}

.hero-copy {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: center;
  max-width: 720px;
}

.hero-copy h2 {
  font-size: 21px;
  line-height: 1.1;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #ffffff;
}

.hero-copy p:last-child {
  max-width: 600px;
  margin: 3px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  line-height: 1.55;
}

.hero-radar {
  position: relative;
  align-self: center;
  justify-self: center;
  width: 58px;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(248, 154, 42, 0.8) 0 3px, transparent 4px),
    repeating-radial-gradient(circle, transparent 0 30px, rgba(255, 255, 255, 0.4) 31px 32px),
    conic-gradient(from 30deg, rgba(255, 255, 255, 0.7), transparent 26%, rgba(248, 154, 42, 0.75), transparent 56%);
  box-shadow: 0 0 28px rgba(255, 255, 255, 0.25);
}

.hero-radar span {
  position: absolute;
  inset: 18%;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 50%;
}

.hero-radar span:nth-child(2) {
  inset: 34%;
  border-color: rgba(255, 255, 255, 0.55);
}

.hero-radar span:nth-child(3) {
  inset: 49%;
  background: var(--orange);
  border: 0;
  box-shadow: 0 0 22px var(--orange);
}

.dashboard-command {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--glass);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.segmented,
.widget-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-metal-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(74px, 1fr));
}

.dashboard-metal-toggle .segment {
  min-height: 30px;
  padding: 0 12px;
}

.segment {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.segment.active,
.segment:hover {
  color: var(--text);
}

#widgetPicker {
  width: 210px;
}

.dash-strip {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(260px, 1.25fr) minmax(260px, 1.25fr) minmax(170px, 0.8fr);
  gap: 10px;
  margin-bottom: 10px;
}

.today-trade-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px;
  overflow: visible;
  border: 1px solid rgba(99, 196, 232, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(145deg, var(--glass), color-mix(in srgb, var(--surface-2), transparent 18%));
  box-shadow: var(--shadow);
}

.today-trade-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.today-trade-head div {
  display: grid;
  gap: 2px;
}

.today-trade-head strong {
  font-size: 15px;
  font-weight: 900;
}

.today-trade-head span,
.today-trade-head b {
  color: var(--muted);
  font-size: 12px;
}

.today-trade-grid {
  display: grid;
  gap: 4px;
}

.today-trade-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(230px, 1fr);
  gap: 8px;
  align-items: stretch;
}

.today-trade-row {
  display: grid;
  grid-template-columns: minmax(88px, 0.8fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(96px, 0.7fr);
  gap: 8px;
  align-items: center;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid rgba(221, 230, 236, 0.82);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
}

.today-trade-row-head {
  min-height: 26px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.today-trade-row strong {
  font-weight: 900;
}

.today-trade-row > span {
  min-width: 0;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-weight: 800;
}

.today-trade-row .muted {
  color: var(--muted);
}

.today-trade-row .buy-cell,
.today-trade-row .sell-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 4px 7px;
  border-radius: 999px;
}

.today-trade-row .buy-cell {
  background: rgba(99, 196, 232, 0.12);
}

.today-trade-row .sell-cell {
  background: rgba(34, 197, 94, 0.11);
}

.today-trade-row .buy-cell b,
.today-trade-row .sell-cell b {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.today-trade-row.total {
  border-color: rgba(31, 41, 55, 0.42);
  background: rgba(31, 41, 55, 0.045);
}

.today-net-card {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(99, 196, 232, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
}

.today-net-card-head,
.today-net-line,
.today-net-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.today-net-card-head strong {
  font-size: 13px;
  font-weight: 900;
}

.today-net-line {
  min-height: 26px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(221, 230, 236, 0.75);
}

.today-net-line span,
.today-net-total span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.today-net-line b,
.today-net-total strong {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

.today-net-line small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.today-net-total {
  min-height: 34px;
  padding: 7px;
  border-radius: 8px;
  background: rgba(31, 41, 55, 0.045);
}

.today-net-total strong {
  font-size: 17px;
  font-weight: 900;
}

.dashboard-trade-detail-card .table-wrap table {
  min-width: 760px;
}

.neo-stat {
  position: relative;
  display: grid;
  gap: 4px;
  min-height: 68px;
  padding: 10px;
  overflow: hidden;
  border: 1px solid rgba(99, 196, 232, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(145deg, var(--glass), color-mix(in srgb, var(--surface-2), transparent 18%));
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.neo-stat::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  transform: translateX(-100%);
  animation: scanline 6s linear infinite;
}

.neo-stat span,
.neo-stat small {
  color: var(--muted);
}

.neo-stat strong {
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 17px;
  color: var(--text);
}

.dash-cash-words {
  display: grid;
  gap: 2px;
  line-height: 1.15;
}

.dash-cash-words b {
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-cash-words em {
  color: var(--muted);
  font-style: normal;
}

.neo-stat.detail-stat {
  grid-template-columns: minmax(104px, 0.72fr) minmax(126px, 1fr);
  gap: 6px;
  align-items: stretch;
}

.dash-stat-main {
  display: grid;
  align-content: center;
  gap: 5px;
  min-width: 0;
}

.dash-stat-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-993-total {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: baseline;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
}

.dash-993-total b {
  color: #007b45;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 900;
}

.neo-stat.detail-stat .dash-breakdown {
  display: grid;
  gap: 4px;
  align-content: center;
  text-align: right;
  min-width: 0;
}

.dash-break-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px;
  align-items: center;
  min-width: 0;
  padding: 2px 5px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.42);
  font-size: 10.5px;
  line-height: 1.15;
}

.dash-break-row b {
  color: var(--text);
  font-weight: 800;
}

.dash-break-row em {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-break-row.positive {
  background: rgba(16, 185, 129, 0.11);
}

.dash-break-row.negative {
  background: rgba(127, 29, 29, 0.08);
}

.dash-break-row.positive em {
  color: #007b45;
}

.dash-break-row.negative em {
  color: #8f1d2c;
}

@media (max-width: 1180px) {
  .dash-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .today-trade-row {
    grid-template-columns: minmax(84px, 0.75fr) minmax(130px, 1fr) minmax(130px, 1fr) minmax(88px, 0.7fr);
  }

  .dashboard-command {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .dashboard-command .segmented,
  .dashboard-command .widget-actions {
    flex: 1 1 320px;
  }

  .dashboard-metal-toggle {
    min-width: 180px;
  }

  #widgetPicker {
    flex: 1 1 180px;
    width: auto;
    min-width: 160px;
  }
}

@media (max-width: 1100px) {
  .dashboard-board {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .widget-card,
  .widget-card.large,
  .widget-card.full,
  .widget-card[data-widget-id="pendingTrades"],
  .widget-card[data-widget-id="executedTrades"],
  .widget-card[data-widget-id="trades"],
  .widget-card[data-widget-id="leaderboard"] {
    grid-column: 1 / -1;
  }

  .widget-card[data-widget-id="pendingTrades"] .pending-trade-card {
    grid-template-columns: minmax(180px, 1fr) minmax(170px, 0.95fr) minmax(180px, 0.95fr) auto;
  }

  .widget-card[data-widget-id="trades"] .recent-trade-card,
  .widget-card[data-widget-id="executedTrades"] .executed-trade-card {
    grid-template-columns: minmax(180px, 0.95fr) minmax(220px, 1.25fr) minmax(130px, 0.72fr) auto;
  }

  .trading-heat-board {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .heat-card.total {
    grid-column: auto;
  }
}

.dashboard-board {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 10px;
  align-items: start;
}

.widget-card {
  position: relative;
  container-type: inline-size;
  grid-column: span 3;
  min-height: 158px;
  padding: 10px;
  overflow: hidden;
  border: 1px solid rgba(99, 196, 232, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(145deg, var(--glass), color-mix(in srgb, var(--surface), transparent 6%)),
    linear-gradient(180deg, rgba(99, 196, 232, 0.055), transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  transition: transform 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.widget-card.large {
  grid-column: span 6;
}

.widget-card[data-widget-id="pendingTrades"],
.widget-card[data-widget-id="executedTrades"],
.widget-card[data-widget-id="trades"],
.widget-card[data-widget-id="leaderboard"] {
  grid-column: span 6;
}

.widget-card.pending-wide,
.widget-card[data-widget-id="pendingTrades"] {
  grid-column: span 9;
}

.widget-card.full {
  grid-column: 1 / -1;
}

.widget-card.tall {
  min-height: 260px;
}

.widget-card.dragging {
  opacity: 0.48;
  transform: scale(0.985);
}

.widget-card.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow);
}

.widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.widget-title {
  display: flex;
  align-items: center;
  gap: 7px;
}

.drag-handle {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: grab;
}

.widget-card:active .drag-handle {
  cursor: grabbing;
}

.widget-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.widget-card[data-widget-id="pendingTrades"] .widget-head {
  gap: 6px;
}

.widget-card[data-widget-id="pendingTrades"] .widget-controls {
  flex: 1;
  justify-content: space-between;
}

.pending-header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.pending-metal-toggle,
.pending-queue-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(58px, 1fr));
}

.pending-queue-toggle {
  grid-template-columns: minmax(70px, 1fr) minmax(54px, 0.8fr);
}

.pending-metal-toggle > .pending-tab,
.pending-queue-toggle > .pending-tab {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.pending-city-compact {
  width: 132px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
}

.mini-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface), transparent 10%);
  color: var(--muted);
}

.mini-button svg {
  width: 15px;
  height: 15px;
  stroke-width: 2.2;
  pointer-events: none;
}

.app-icon {
  width: 15px;
  height: 15px;
  display: inline-block;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  pointer-events: none;
  vertical-align: -2px;
}

.mini-button:has(svg)::before,
.mini-button:has(svg)::after {
  display: none;
}

.mini-button:hover {
  color: var(--text);
  background: var(--surface-2);
}

.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.mini-button.danger:hover {
  color: #ffffff;
  border-color: var(--danger);
  background: var(--danger);
}

.mini-button.icon-eye::before {
  content: "";
  width: 13px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.mini-button.icon-eye::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.mini-button.icon-print::before {
  content: "";
  width: 13px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 2px;
  box-shadow: 0 -5px 0 -2px currentColor;
}

.mini-button.icon-edit::before {
  content: "";
  width: 13px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(-35deg);
}

.mini-button.icon-delete::before {
  content: "";
  width: 11px;
  height: 12px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 1px 1px 3px 3px;
}

.mini-button.icon-delete::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 2px;
  background: currentColor;
  transform: translateY(-7px);
}

.mini-button.icon-restore::before {
  content: "R";
  font-size: 12px;
  font-weight: 900;
}

.mini-button.icon-qr {
  font-size: 10px;
  font-weight: 900;
}

.pending-trade-list {
  display: grid;
  gap: 8px;
  width: 100%;
}

.pending-party-group {
  display: grid;
  gap: 5px;
}

.pending-party-group.multi {
  padding: 7px;
  border: 2px solid rgba(31, 41, 55, 0.56);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.025);
}

.pending-party-head {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 2px;
}

.pending-party-group.multi .pending-party-head {
  display: flex;
}

.pending-party-head strong {
  color: var(--text);
  font-weight: 900;
}

.pending-party-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.pending-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.pending-toolbar .pending-tabs {
  margin-bottom: 0;
}

.pending-toolbar label {
  min-width: 170px;
}

.pending-type-tabs {
  margin-bottom: 6px;
}

.pending-future-date-filter {
  display: flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  margin: -1px 0 7px;
}

.pending-future-date-filter[hidden] {
  display: none !important;
}

.pending-future-date-filter .date-stepper {
  align-items: center;
  gap: 4px;
}

.pending-future-date-filter .mini-button {
  width: 30px;
  height: 30px;
  min-height: 30px;
}

.pending-future-date-filter input {
  width: 138px;
  min-height: 30px;
  padding: 4px 7px;
  font-size: 12px;
}

.future-import-note {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.future-import-note {
  color: #9a6d08;
}

.future-pull-action {
  color: #9a6d08;
  border-color: rgba(184, 134, 11, 0.28);
  background: rgba(184, 134, 11, 0.08);
}

.future-forward-action {
  color: #0e7490;
  border-color: rgba(14, 116, 144, 0.28);
  background: rgba(14, 165, 233, 0.1);
}

.future-import-reverse {
  color: #8b1e3f;
  border-color: rgba(139, 30, 63, 0.26);
  background: rgba(139, 30, 63, 0.08);
}

.future-forward-reverse {
  color: #6d28d9;
  border-color: rgba(109, 40, 217, 0.26);
  background: rgba(109, 40, 217, 0.08);
}

.trade-transfer-action {
  color: #0f766e;
  border-color: rgba(15, 118, 110, 0.26);
  background: rgba(20, 184, 166, 0.09);
}

.pending-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.pending-tab {
  min-height: 31px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
  box-shadow: none;
}

.pending-tab.active {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.42);
  background: linear-gradient(135deg, #43c3e8, #2f7df2);
  box-shadow: 0 9px 22px rgba(47, 125, 242, 0.22);
}

.pending-trade-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 1.1fr) minmax(230px, 0.9fr) minmax(210px, auto);
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.pending-trade-card.side-badge-row,
.pending-trade-card.overdue-row {
  padding-left: 23px;
}

.widget-card[data-widget-id="pendingTrades"] .pending-trade-card {
  grid-template-columns: minmax(230px, 0.95fr) minmax(260px, 1.2fr) minmax(250px, auto);
  gap: 7px;
  min-height: 31px;
  padding: 4px 8px;
}

.widget-card[data-widget-id="pendingTrades"] .pending-tabs {
  gap: 4px;
}

.widget-card[data-widget-id="pendingTrades"] .pending-type-tabs .pending-tab {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.widget-card[data-widget-id="pendingTrades"] .pending-main strong {
  font-size: 12.5px;
}

.widget-card[data-widget-id="pendingTrades"] .pending-meta b {
  font-size: 14px;
}

.widget-card[data-widget-id="pendingTrades"] .pending-voucher-line,
.widget-card[data-widget-id="pendingTrades"] .pending-meta span,
.widget-card[data-widget-id="pendingTrades"] .pending-date-line,
.widget-card[data-widget-id="pendingTrades"] .future-import-note {
  font-size: 11px;
}

.widget-card[data-widget-id="pendingTrades"] .pending-trade-card.side-badge-row,
.widget-card[data-widget-id="pendingTrades"] .pending-trade-card.overdue-row {
  padding-left: 19px;
}

.widget-card[data-widget-id="pendingTrades"] .pending-trade-card.dual-badge-row {
  padding-left: 33px;
}

.pending-trade-scroll {
  max-height: 545px;
  overflow-y: auto;
  padding-right: 3px;
}

.pending-pagination {
  margin-top: 7px;
}

.pending-trade-card.sell-row {
  border-color: rgba(34, 197, 94, 0.28);
  background:
    linear-gradient(90deg, rgba(34, 197, 94, 0.08), transparent 58%),
    var(--surface-2);
}

.pending-main,
.pending-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.pending-main strong,
.pending-meta b {
  font-family: "JetBrains Mono", Consolas, monospace;
}

.pending-main strong {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.15;
}

.pending-meta b {
  font-size: 15px;
  font-weight: 900;
  color: var(--primary);
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-city-badge {
  flex: 0 0 auto;
  color: #0e7490;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.pending-trade-card.sell-row .pending-meta b {
  color: #16a34a;
}

.pending-voucher-line,
.pending-meta span,
.pending-date-line,
.future-import-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.pending-date-line,
.future-import-note {
  display: block;
  text-align: right;
  white-space: normal;
}

.pending-actions {
  display: grid;
  gap: 2px;
  justify-items: end;
  min-width: 0;
}

.pending-action-buttons {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.widget-card[data-widget-id="pendingTrades"] .pending-actions {
  align-self: center;
}

.widget-card[data-widget-id="pendingTrades"] .pending-action-buttons .mini-button {
  width: 25px;
  height: 25px;
}

.widget-card[data-widget-id="pendingTrades"] .pending-date-line {
  margin-top: -1px;
  font-size: 10px;
  line-height: 1.05;
  white-space: nowrap;
}

.pending-side-badges {
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: -1px;
  display: flex;
  width: auto;
}

.pending-side-badge,
.pending-overdue-badge {
  display: grid;
  place-items: center;
  width: 15px;
  padding: 3px 0;
  border: 1px solid rgba(220, 38, 38, 0.35);
  border-radius: 0;
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.16), rgba(220, 38, 38, 0.08));
  color: #b91c1c;
  font-family: Arial, "Segoe UI", sans-serif;
  font-size: 7.5px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.pending-side-badges .pending-side-badge:first-child {
  border-radius: 8px 0 0 8px;
}

.pending-side-badges .pending-side-badge + .pending-side-badge {
  border-left: 0;
}

.pending-side-badge.overdue,
.pending-overdue-badge {
  border-color: rgba(220, 38, 38, 0.35);
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.16), rgba(220, 38, 38, 0.08));
  color: #b91c1c;
}

.pending-side-badge.transferred {
  border-color: rgba(15, 118, 110, 0.32);
  background: linear-gradient(180deg, rgba(20, 184, 166, 0.18), rgba(20, 184, 166, 0.08));
  color: #0f766e;
}

.pending-trade-card.transferred-row {
  border-color: rgba(20, 184, 166, 0.28);
}

.transfer-note {
  color: #0f766e;
  font-weight: 800;
}

.pending-slip-lock {
  display: none;
  width: fit-content;
  margin-top: 2px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(184, 134, 11, 0.12);
  color: #8a6107;
  font-size: 11px;
  font-weight: 800;
}

.pending-actions .slip-bound-action {
  color: #8a6107;
  border-color: rgba(184, 134, 11, 0.42);
  background: rgba(184, 134, 11, 0.16);
}

.pending-actions .slip-bound-action:hover {
  color: #ffffff;
  border-color: #b8860b;
  background: #b8860b;
}

.pending-actions {
  display: grid;
  gap: 2px;
  justify-items: end;
  min-width: 0;
}

.pending-action-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
}

.pending-actions .mini-button {
  width: 26px;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
}

.recent-trade-list {
  display: grid;
  gap: 6px;
}

.recent-trade-page-list {
  display: grid;
  gap: 6px;
}

.recent-trade-card {
  display: grid;
  grid-template-columns: minmax(210px, 0.9fr) minmax(320px, 1.45fr) minmax(150px, 0.65fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.widget-card[data-widget-id="trades"] .recent-trade-card {
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr) minmax(0, 0.7fr) auto;
  gap: 8px;
  min-height: 42px;
  padding: 6px 8px;
}

.widget-card[data-widget-id="trades"] .recent-trade-party strong,
.widget-card[data-widget-id="trades"] .recent-trade-desc b,
.widget-card[data-widget-id="trades"] .recent-trade-value strong {
  font-size: 12.5px;
}

.widget-card[data-widget-id="trades"] .recent-trade-party span,
.widget-card[data-widget-id="trades"] .recent-trade-desc span {
  font-size: 11px;
}

.recent-trade-card.sell-row {
  border-color: rgba(34, 197, 94, 0.25);
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.07), transparent 52%), var(--surface-2);
}

.recent-trade-card.has-adjustment {
  border-color: rgba(31, 41, 55, 0.5);
  box-shadow: inset 3px 0 0 rgba(184, 134, 11, 0.74);
}

.recent-adjustment-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 22px auto minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 2px;
  padding: 6px 8px;
  border: 1px dashed rgba(184, 134, 11, 0.52);
  border-radius: 8px;
  background: rgba(184, 134, 11, 0.08);
}

.recent-adjustment-row span {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: #8a6107;
}

.recent-adjustment-row span svg {
  width: 14px;
  height: 14px;
}

.recent-adjustment-row strong,
.recent-adjustment-row b,
.recent-adjustment-row em {
  overflow: hidden;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-adjustment-row b {
  color: var(--text);
}

.recent-adjustment-row em {
  color: var(--muted);
  font-style: normal;
}

.recent-trade-party,
.recent-trade-desc,
.recent-trade-value {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.recent-trade-party strong {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-trade-party span,
.recent-trade-desc span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-trade-desc b,
.recent-trade-value strong {
  overflow: hidden;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.16;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-trade-desc b {
  color: var(--primary);
}

.recent-trade-card.sell-row .recent-trade-desc b {
  color: #16a34a;
}

.recent-trade-value {
  justify-items: end;
  text-align: right;
}

.recent-trade-actions {
  display: flex;
  gap: 5px;
}

.recent-trade-actions .mini-button {
  width: 28px;
  height: 28px;
}

.executed-trade-list {
  display: grid;
  gap: 6px;
}

.executed-trade-card {
  display: grid;
  grid-template-columns: minmax(210px, 0.9fr) minmax(340px, 1.5fr) minmax(150px, 0.65fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.widget-card[data-widget-id="executedTrades"] .executed-trade-card {
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.28fr) minmax(0, 0.72fr) auto;
  gap: 8px;
  min-height: 42px;
  padding: 6px 8px;
}

.widget-card[data-widget-id="executedTrades"] .executed-party strong,
.widget-card[data-widget-id="executedTrades"] .executed-desc b,
.widget-card[data-widget-id="executedTrades"] .executed-value strong {
  font-size: 12.5px;
}

.widget-card[data-widget-id="executedTrades"] .executed-party span,
.widget-card[data-widget-id="executedTrades"] .executed-desc span {
  font-size: 11px;
}

.executed-trade-card.sell-row {
  border-color: rgba(34, 197, 94, 0.25);
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.07), transparent 52%), var(--surface-2);
}

.executed-party,
.executed-desc,
.executed-value {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.executed-party strong {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.executed-party span,
.executed-desc span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.executed-desc b,
.executed-value strong {
  overflow: hidden;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.16;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.executed-desc b {
  color: var(--primary);
}

.executed-trade-card.sell-row .executed-desc b {
  color: #16a34a;
}

.executed-value {
  justify-items: end;
  text-align: right;
}

.executed-actions {
  display: flex;
  gap: 5px;
}

.executed-actions .mini-button {
  width: 28px;
  height: 28px;
}

.dashboard-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 2px;
}

.dashboard-pagination span {
  min-width: 42px;
  color: var(--muted);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.dashboard-pagination .mini-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.staff-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.staff-actions .mini-button {
  width: auto;
  min-width: 64px;
  padding: 0 10px;
}

.inline-input {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 8px;
}

.purity-rows-wrap {
  margin-top: 12px;
}

.flow-bars {
  display: grid;
  gap: 11px;
}

.flow-row {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 10px;
  align-items: center;
}

.flow-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.flow-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--orange));
}

.holo-stack {
  display: grid;
  gap: 10px;
}

.ranking-board {
  display: grid;
  gap: 10px;
}

.ranking-top {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) minmax(170px, 0.55fr);
  min-height: 142px;
  overflow: hidden;
  color: #ffffff;
  border-radius: 8px;
  background: linear-gradient(135deg, #f47a1f, var(--orange));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.rank-number {
  display: grid;
  place-items: center;
  background: #ee6615;
  font-size: 34px;
  font-weight: 800;
}

.rank-party,
.rank-score {
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 18px;
}

.rank-party strong {
  font-size: 27px;
  line-height: 1.05;
}

.rank-score {
  border-left: 1px solid rgba(255, 255, 255, 0.45);
  text-align: center;
}

.rank-party span,
.rank-score span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.rank-score strong {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 31px;
}

.ranking-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.rank-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  min-height: 72px;
  overflow: hidden;
  color: #ffffff;
  border-radius: 8px;
}

.rank-card b {
  display: grid;
  grid-row: 1 / 3;
  place-items: center;
  min-height: 100%;
  font-size: 16px;
}

.rank-card strong {
  align-self: end;
  padding: 10px 10px 0;
  font-size: 14px;
  line-height: 1.06;
}

.rank-card span,
.rank-card em {
  align-self: start;
  padding: 5px 10px 10px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-style: normal;
  font-weight: 800;
}

.rank-card span {
  font-size: 15px;
}

.rank-card em {
  font-size: 13px;
}

.rank-card.blue {
  background: #63c4e8;
}

.rank-card.blue b {
  background: #429fca;
}

.rank-card.muted {
  grid-template-columns: 42px minmax(0, 1fr);
  background: #adbac6;
}

.rank-card.muted b {
  background: #83909c;
}

.rank-card.muted strong {
  align-self: center;
  padding: 0 12px;
  color: rgba(255, 255, 255, 0.84);
}

.trading-heat-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  gap: 8px;
}

.heat-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 12px;
  align-items: center;
  min-height: 84px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.heat-card > div {
  display: grid;
  gap: 3px;
}

.heat-card strong {
  color: var(--text);
  font-size: 15px;
}

.heat-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.heat-card b,
.heat-card em {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-style: normal;
  font-weight: 900;
  text-align: right;
}

.heat-card b {
  font-size: 15px;
}

.heat-card em {
  grid-column: 1 / -1;
  justify-self: end;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(99, 196, 232, 0.12);
}

.heat-card.orange {
  border-color: rgba(249, 161, 50, 0.36);
  background: linear-gradient(135deg, rgba(249, 161, 50, 0.18), var(--surface-2));
}

.heat-card.blue {
  border-color: rgba(99, 196, 232, 0.42);
  background: linear-gradient(135deg, rgba(99, 196, 232, 0.16), var(--surface-2));
}

.heat-card.green {
  border-color: rgba(34, 197, 94, 0.34);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.13), var(--surface-2));
}

.heat-card.total {
  grid-column: 1 / -1;
  min-height: 64px;
  border-color: rgba(31, 41, 55, 0.48);
  background: linear-gradient(135deg, rgba(31, 41, 55, 0.08), var(--surface));
}

@container (max-width: 560px) {
  .widget-card[data-widget-id="pendingTrades"] .pending-trade-card,
  .widget-card[data-widget-id="trades"] .recent-trade-card,
  .widget-card[data-widget-id="executedTrades"] .executed-trade-card {
    grid-template-columns: 1fr;
    gap: 6px;
    align-items: start;
  }

  .widget-card[data-widget-id="pendingTrades"] .pending-main,
  .widget-card[data-widget-id="pendingTrades"] .pending-meta,
  .widget-card[data-widget-id="pendingTrades"] .pending-actions,
  .widget-card[data-widget-id="trades"] .recent-trade-party,
  .widget-card[data-widget-id="trades"] .recent-trade-desc,
  .widget-card[data-widget-id="trades"] .recent-trade-value,
  .widget-card[data-widget-id="executedTrades"] .executed-party,
  .widget-card[data-widget-id="executedTrades"] .executed-desc,
  .widget-card[data-widget-id="executedTrades"] .executed-value {
    min-width: 0;
    justify-items: start;
    text-align: left;
  }

  .widget-card[data-widget-id="pendingTrades"] .pending-main strong,
  .widget-card[data-widget-id="pendingTrades"] .pending-voucher-line,
  .widget-card[data-widget-id="pendingTrades"] .pending-meta b,
  .widget-card[data-widget-id="pendingTrades"] .pending-meta span,
  .widget-card[data-widget-id="pendingTrades"] .pending-date-line,
  .widget-card[data-widget-id="pendingTrades"] .future-import-note,
  .widget-card[data-widget-id="trades"] .recent-trade-party strong,
  .widget-card[data-widget-id="trades"] .recent-trade-party span,
  .widget-card[data-widget-id="trades"] .recent-trade-desc b,
  .widget-card[data-widget-id="trades"] .recent-trade-desc span,
  .widget-card[data-widget-id="trades"] .recent-trade-value strong,
  .widget-card[data-widget-id="executedTrades"] .executed-party strong,
  .widget-card[data-widget-id="executedTrades"] .executed-party span,
  .widget-card[data-widget-id="executedTrades"] .executed-desc b,
  .widget-card[data-widget-id="executedTrades"] .executed-desc span,
  .widget-card[data-widget-id="executedTrades"] .executed-value strong {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .widget-card[data-widget-id="pendingTrades"] .pending-actions,
  .widget-card[data-widget-id="trades"] .recent-trade-actions,
  .widget-card[data-widget-id="executedTrades"] .executed-actions {
    justify-content: flex-start;
    justify-items: start;
  }

  .widget-card[data-widget-id="pendingTrades"] .pending-date-line,
  .widget-card[data-widget-id="pendingTrades"] .future-import-note {
    text-align: left;
  }
}

.holo-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2), transparent 20%);
}

.risk-meter {
  display: grid;
  place-items: center;
  min-height: 210px;
}

.risk-ring {
  display: grid;
  place-items: center;
  width: 180px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--surface) 0 52%, transparent 53%),
    conic-gradient(var(--primary) 0 54%, var(--orange) 54% 78%, var(--danger) 78% 100%);
}

.risk-ring strong {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 34px;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 80;
  min-width: min(420px, calc(100vw - 32px));
  max-width: min(560px, calc(100vw - 32px));
  padding: 13px 18px;
  border: 1px solid rgba(14, 165, 233, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(20, 184, 166, 0.94), rgba(56, 189, 248, 0.94)),
    var(--surface);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.22);
  color: #ffffff;
  font-weight: 900;
  text-align: center;
  transform: translate(-50%, -18px);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.toast.error {
  border-color: rgba(127, 29, 29, 0.72);
  background:
    linear-gradient(90deg, rgba(127, 29, 29, 0.98), rgba(185, 28, 28, 0.96)),
    #7f1d1d;
  box-shadow: 0 18px 42px rgba(127, 29, 29, 0.34);
}

.toast.success {
  border-color: rgba(14, 165, 233, 0.34);
}

.toast-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(31, 41, 55, 0.5);
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(2px);
  transition: opacity 160ms ease;
}

.toast-backdrop.show {
  opacity: 1;
}

@keyframes scanline {
  0% {
    transform: translateX(-100%);
  }
  60%,
  100% {
    transform: translateX(100%);
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.page-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-refresh-button {
  width: 28px;
  height: 28px;
  min-height: 28px;
}

.page-refresh-button[hidden] {
  display: none !important;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  line-height: 1.25;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 15px;
}

.top-actions,
.form-actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ticker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.live-rate-ticker {
  gap: 6px;
  padding: 4px 7px;
  color: inherit;
  text-align: left;
}

.top-user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 168px;
  min-height: 44px;
  padding: 4px 6px 4px 10px;
  border: 1px solid rgba(74, 181, 224, 0.24);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(74, 181, 224, 0.09), rgba(255, 255, 255, 0.88));
  box-shadow: var(--shadow);
}

.top-user-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.top-user-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.top-user-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-user-card .top-logout-button {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 10px;
}

.top-user-card .top-logout-button .app-icon {
  width: 18px;
  height: 18px;
}

.top-trade-card {
  display: grid;
  align-content: center;
  min-width: 104px;
  min-height: 40px;
  gap: 2px;
  padding: 5px 9px;
  border: 1px solid rgba(12, 170, 110, 0.2);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(12, 170, 110, 0.075), rgba(255, 255, 255, 0.88));
  box-shadow: var(--shadow);
}

.top-trade-card.silver {
  border-color: rgba(74, 181, 224, 0.24);
  background: linear-gradient(135deg, rgba(74, 181, 224, 0.09), rgba(255, 255, 255, 0.88));
}

.top-trade-card span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.top-trade-card strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dark .top-trade-card,
.dark .top-trade-card.silver {
  background: linear-gradient(135deg, rgba(99, 196, 232, 0.12), rgba(15, 23, 42, 0.66));
}

.live-rate-chip {
  display: grid;
  min-width: 118px;
  gap: 1px;
  padding: 3px 7px;
  border: 1px solid rgba(12, 170, 110, 0.2);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(12, 170, 110, 0.08), rgba(255, 255, 255, 0.86));
}

.live-rate-chip.silver {
  border-color: rgba(74, 181, 224, 0.24);
  background: linear-gradient(135deg, rgba(74, 181, 224, 0.09), rgba(255, 255, 255, 0.86));
}

.ticker span,
.live-rate-chip small {
  color: var(--muted);
  font-size: 12px;
}

.live-rate-chip span {
  font-weight: 900;
  text-transform: uppercase;
}

.live-rate-chip strong {
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
}

#ratesDialog {
  width: min(620px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  overflow: visible;
}

.rates-dialog-card {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.rates-popup-table {
  max-height: none;
  overflow: hidden !important;
}

.rates-table {
  display: table;
  table-layout: fixed;
  width: 100%;
  min-width: 0 !important;
  border-collapse: collapse;
}

.rates-table th,
.rates-table td {
  min-width: 0;
  padding: 7px 9px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rates-table th:nth-child(1),
.rates-table td:nth-child(1) {
  width: 28%;
}

.rates-table th:nth-child(2),
.rates-table td:nth-child(2),
.rates-table th:nth-child(3),
.rates-table td:nth-child(3) {
  width: 24%;
}

.rates-table th:nth-child(4),
.rates-table td:nth-child(4) {
  width: 24%;
}

.rates-table th:nth-child(5),
.rates-table td:nth-child(5) {
  display: none;
}

.live-rate-chip strong.rate-up,
.live-rate-row.rate-up strong {
  color: #058548;
}

.live-rate-chip strong.rate-down,
.live-rate-row.rate-down strong {
  color: #7f1d1d;
}

.rate-arrow {
  display: inline-block;
  margin-right: 4px;
  font-size: 13px;
  line-height: 1;
  transform: translateY(-1px);
}

.live-rate-chip small {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticker strong,
td:nth-child(5),
td:nth-child(6),
.metric strong,
dd {
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
}

.ticker em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
}

.ticker.is-live em {
  color: var(--success);
}

.ticker.is-offline em {
  color: var(--danger);
}

.live-rate-row {
  grid-template-columns: minmax(84px, 1fr) auto;
}

.live-rate-row small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
}

.live-rate-matrix.stale {
  opacity: 0.72;
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0 10px;
  background: var(--surface);
  color: var(--text);
}

.primary-button {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.primary-button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

.ghost-button:hover,
.icon-button:hover {
  background: var(--surface-2);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  padding: 0;
  line-height: 0;
  font-size: 18px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.kpi-grid,
.dashboard-grid,
.vault-grid,
.report-grid {
  display: grid;
  gap: 10px;
}

.kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.metric,
.panel,
.report-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  gap: 7px;
  min-height: 82px;
  padding: 10px;
}

.metric strong {
  font-size: 23px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.6fr);
}

.wide {
  grid-row: span 2;
}

.panel {
  min-width: 0;
  padding: 10px;
}

.purity-layout {
  display: grid;
  grid-template-columns: minmax(500px, 0.9fr) minmax(560px, 1.1fr);
  gap: 10px;
  align-items: start;
  width: min(100%, 1180px);
  max-width: 1180px;
  margin: 0 auto;
}

.purity-entry-panel,
.purity-list-panel {
  overflow: visible;
}

.purity-entry-panel {
  padding: 9px;
}

.purity-list-panel {
  padding: 9px;
}

.purity-entry-header,
.purity-list-header {
  gap: 8px;
  margin-bottom: 8px;
}

.purity-entry-header p,
.purity-list-header p {
  margin-top: 2px;
  line-height: 1.25;
}

.purity-entry-header .header-actions {
  flex-wrap: nowrap;
}

.purity-entry-header .ghost-button {
  min-width: 64px;
}

.compact-form.purity-form-grid {
  grid-template-columns: minmax(86px, 0.55fr) minmax(0, 1.45fr) minmax(112px, 1fr);
  gap: 6px;
  align-items: start;
}

.compact-form.purity-form-grid > .purity-customer-field {
  grid-column: 1 / -1;
  margin-top: 0;
}

.compact-form.purity-form-grid > .purity-purity-pair {
  grid-column: 2 / -1;
}

.purity-purity-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
  min-width: 0;
}

.purity-pair-field {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.purity-entry-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.purity-entry-title-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.purity-entry-head-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.purity-new-slip-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
}

.purity-entry-voucher {
  font-size: 11px;
  white-space: nowrap;
}

.compact-form.purity-form-grid > label {
  gap: 4px;
  min-width: 0;
}

.compact-form.purity-form-grid input,
.compact-form.purity-form-grid select {
  height: 32px;
  min-height: 32px;
  min-width: 0;
  padding: 5px 8px;
}

.compact-form.purity-form-grid .inline-input {
  grid-template-columns: minmax(46px, 0.6fr) minmax(58px, 0.72fr);
  gap: 5px;
}

.purity-actions {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  flex-wrap: nowrap !important;
  align-items: stretch;
  gap: 7px;
  margin-top: 7px;
}

.purity-actions button {
  flex: none !important;
  min-width: 0;
  width: 100%;
  min-height: 36px;
  padding-inline: clamp(5px, 1.4vw, 10px);
  font-size: clamp(10px, 2.6vw, 12px);
  white-space: nowrap;
}

#paResult {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  margin-top: 7px;
  padding: 8px;
  border: 1px solid rgba(91, 192, 228, 0.26);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(91, 192, 228, 0.1), rgba(255, 255, 255, 0.75));
  color: var(--text);
}

#paResult span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

#paResult em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  line-height: 1.1;
}

#paResult b {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purity-rows-wrap {
  max-height: 168px;
  margin-top: 7px;
  overflow: auto;
}

.purity-rows-wrap table {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
}

.purity-rows-wrap th,
.purity-rows-wrap td {
  padding: 6px 7px;
}

.purity-rows-wrap th:first-child,
.purity-rows-wrap td:first-child {
  width: 38px;
}

.purity-rows-wrap th:last-child,
.purity-rows-wrap td:last-child {
  width: 62px;
  text-align: center;
}

.slip-note-field {
  margin-top: 7px;
}

.slip-note-field input {
  min-height: 32px;
}

.purity-slip-table table {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.purity-slip-table {
  max-height: none;
  overflow: visible;
}

.table-wrap.purity-slip-table {
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

.purity-slip-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  box-shadow: 0 1px 0 var(--border);
}

.purity-slip-table th,
.purity-slip-table td {
  padding: 5px 4px;
  vertical-align: middle;
  min-width: 0;
}

.purity-slip-table th:first-child,
.purity-slip-table td:first-child {
  width: 23%;
}

.purity-slip-table th:nth-child(2),
.purity-slip-table td:nth-child(2) {
  width: 15%;
}

.purity-slip-table th:nth-child(3),
.purity-slip-table td:nth-child(3) {
  width: 12%;
}

.purity-slip-table th:nth-child(4),
.purity-slip-table td:nth-child(4) {
  width: 10%;
}

.purity-slip-table th:nth-child(5),
.purity-slip-table td:nth-child(5) {
  width: 13%;
}

.purity-slip-table th:nth-child(6),
.purity-slip-table td:nth-child(6) {
  width: 6%;
  text-align: center;
}

.purity-slip-table th:last-child,
.purity-slip-table td:last-child {
  width: 21%;
}

.purity-slip-table th {
  font-size: 10.5px;
  line-height: 1.15;
}

.purity-slip-row {
  background: #ffffff;
}

.purity-slip-row:hover {
  background: rgba(91, 192, 228, 0.06);
}

.purity-slip-id {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.purity-slip-id strong {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 900;
  line-height: 1.12;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purity-slip-id small {
  color: var(--muted);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 10.5px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono-value {
  color: var(--text);
  display: block;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11.2px;
  font-weight: 700;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono-value.strong {
  font-weight: 900;
}

.purity-weight-value small {
  color: #0e7490;
  font-family: inherit;
  font-size: 10.4px;
  font-weight: 900;
}

.purity-status-stack {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.purity-status-badge {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.purity-status-badge.available {
  color: #0284c7;
  border-color: rgba(2, 132, 199, 0.24);
  background: rgba(14, 165, 233, 0.12);
}

.purity-status-badge.bound {
  color: #9a6d08;
  border-color: rgba(184, 134, 11, 0.26);
  background: rgba(184, 134, 11, 0.12);
}

.purity-status-badge.draft {
  color: #475569;
  border-color: rgba(100, 116, 139, 0.28);
  background: rgba(100, 116, 139, 0.12);
}

.purity-status-badge.danger {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.24);
  background: rgba(220, 38, 38, 0.1);
}

.purity-status-stack small {
  color: var(--muted);
  font-size: 10.5px;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purity-row-actions {
  justify-content: flex-end;
  gap: 2px;
  flex-wrap: nowrap;
}

.purity-row-actions .mini-button {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #fff;
}

.purity-row-actions .action-view {
  color: #475569;
}

.purity-row-actions .action-print {
  color: #0f766e;
  border-color: rgba(15, 118, 110, 0.22);
  background: rgba(20, 184, 166, 0.08);
}

.purity-row-actions .action-edit {
  color: #2563eb;
  border-color: rgba(37, 99, 235, 0.2);
}

.purity-row-actions .action-sticker {
  color: #7c3aed;
  border-color: rgba(124, 58, 237, 0.22);
}

.purity-row-actions .action-restore {
  color: #0f766e;
}

.purity-row-actions .action-delete {
  color: #991b1b;
  border-color: rgba(153, 27, 27, 0.24);
}

.purity-row-actions .mini-button:hover {
  color: #fff;
  background: #26323f;
  border-color: #26323f;
}

.purity-list-header {
  align-items: center;
}

.purity-list-header h2,
.purity-entry-header h2 {
  font-size: 14px;
}

.purity-list-header p,
.purity-entry-header p {
  font-size: 11px;
}

.purity-list-header .date-filter {
  width: 150px;
}

.purity-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.purity-tabs .pending-tab {
  min-height: 32px;
  padding: 0 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-title-row h2 {
  margin: 0;
}

.balance-title-row {
  align-items: center;
}

.date-filter {
  min-width: 150px;
}

.purity-tabs {
  margin-bottom: 8px;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.date-info-cell {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.info-dot {
  position: relative;
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  cursor: help;
}

.info-dot svg {
  width: 14px;
  height: 14px;
}

.info-dot::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 20;
  left: 0;
  bottom: calc(100% + 8px);
  display: none;
  width: min(420px, 70vw);
  padding: 9px 10px;
  border: 1px solid rgba(31, 41, 55, 0.18);
  border-radius: 8px;
  background: rgba(31, 41, 55, 0.96);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  white-space: normal;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.18);
}

.info-dot:hover::after {
  display: none;
}

.balance-report-layout {
  display: grid;
  grid-template-columns: minmax(620px, 760px) minmax(260px, 320px);
  gap: 10px;
  align-items: start;
  width: min(100%, 1090px);
  margin: 0 auto;
}

.balance-report-main-panel,
.balance-report-settings-panel {
  padding: 9px;
}

.balance-report-main-panel .panel-header {
  margin-bottom: 8px;
}

.balance-report-main-panel .header-actions {
  gap: 6px;
}

.balance-report-settings-panel {
  position: sticky;
  top: 10px;
}

.balance-report-filters-shell {
  display: block;
}

.balance-report-filters-summary {
  display: none;
  list-style: none;
}

.balance-report-filters-summary::-webkit-details-marker {
  display: none;
}

.balance-report-settings-panel .compact-header {
  margin-bottom: 8px;
}

.balance-report-settings-panel .compact-header h2 {
  font-size: 14px;
}

.balance-report-settings-panel .compact-header p {
  font-size: 11px;
}

.balance-report-controls {
  display: grid;
  gap: 7px;
  justify-items: end;
  width: min(820px, 100%);
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(248, 251, 253, 0.92), rgba(255, 255, 255, 0.98));
}

.balance-report-settings-panel .balance-report-controls {
  justify-items: stretch;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
}

.balance-report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
  align-items: center;
  width: 100%;
}

.balance-report-settings-panel .balance-report-actions {
  justify-content: stretch;
}

.balance-report-settings-panel .balance-mode-switch {
  width: 100%;
}

.balance-mode-switch {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(54px, 1fr));
  gap: 0;
  width: 126px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}

.balance-mode-switch::before {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 7px 18px rgba(91, 192, 228, 0.26);
  transition: transform 160ms ease;
}

.balance-mode-switch.trade-active::before {
  transform: translateX(100%);
}

.balance-mode-switch button {
  position: relative;
  z-index: 1;
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.balance-mode-switch button.active {
  color: #ffffff;
}

.balance-filters {
  display: grid;
  grid-template-columns: minmax(130px, 0.7fr) minmax(150px, 0.8fr) minmax(260px, 1.6fr);
  gap: 7px;
  align-items: end;
  width: 100%;
}

.balance-report-settings-panel .balance-filters {
  grid-template-columns: 1fr;
  gap: 8px;
}

.balance-report-settings-panel .category-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.balance-report-settings-panel .category-checks .check-row {
  min-width: 0;
  justify-content: flex-start;
}

.balance-report-table table {
  min-width: 0;
  table-layout: fixed;
}

.balance-report-table th:first-child,
.balance-report-table td:first-child {
  width: 38%;
}

.balance-report-table th:not(:first-child),
.balance-report-table td:not(:first-child) {
  width: 20.66%;
}

.balance-filters label {
  gap: 3px;
  font-size: 11px;
}

.balance-filters select {
  min-height: 31px;
  padding: 4px 8px;
  font-size: 12px;
}

.category-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.category-checks .check-row {
  min-height: 31px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 800;
}

.category-checks .check-row input {
  width: 13px;
  height: 13px;
  min-height: 13px;
  padding: 0;
}

.balance-value {
  position: relative;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-weight: 800;
}

.balance-value.positive {
  color: #147a3f;
}

.balance-value.negative {
  color: #8b1e2d;
}

.balance-value.zero {
  color: var(--muted);
}

.balance-tooltip {
  position: absolute;
  left: 8px;
  top: calc(100% - 2px);
  z-index: 40;
  display: none;
  min-width: 220px;
  max-width: 300px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.18);
  white-space: normal;
}

.balance-tooltip span,
.floating-balance-tooltip span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  color: var(--muted);
  font-size: 12px;
}

.balance-tooltip b,
.floating-balance-tooltip b {
  color: var(--text);
}

.balance-value:hover .balance-tooltip {
  display: none;
}

.floating-balance-tooltip {
  position: fixed;
  z-index: 10000;
  display: grid;
  min-width: 220px;
  max-width: min(340px, 78vw);
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.22);
  pointer-events: none;
  white-space: normal;
}

.floating-balance-tooltip[hidden] {
  display: none !important;
}

.balance-report-table table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: 100%;
  min-width: 0;
}

.table-wrap.balance-report-table {
  overflow-x: auto;
  overflow-y: hidden;
}

.balance-report-table th {
  top: 0;
  z-index: 2;
  padding: 5px 8px;
  font-size: 11px;
}

.balance-report-table th:first-child,
.balance-report-table td:first-child {
  width: 34%;
}

.balance-report-table th:not(:first-child),
.balance-report-table td:not(:first-child) {
  width: 22%;
}

.balance-parent-row td {
  background: #ffffff;
  border-top: 1px solid rgba(31, 41, 55, 0.28);
  border-bottom: 1px solid rgba(31, 41, 55, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  padding: 6px 10px;
  height: 34px;
  vertical-align: middle;
}

.balance-parent-row td:first-child {
  border-left: 1px solid rgba(31, 41, 55, 0.28);
  border-top-left-radius: 7px;
}

.balance-parent-row td:last-child {
  border-right: 1px solid rgba(31, 41, 55, 0.28);
  border-top-right-radius: 7px;
}

.balance-parent-row strong {
  font-size: 12px;
}

.balance-city-row td {
  background: rgba(91, 192, 228, 0.06);
  border-bottom-color: rgba(31, 41, 55, 0.14);
  font-size: 12px;
}

.balance-city-row td:first-child {
  border-left: 2px solid rgba(31, 41, 55, 0.62);
}

.balance-city-row td:last-child {
  border-right: 2px solid rgba(31, 41, 55, 0.62);
}

.balance-city-detail-cell {
  padding-left: 16px;
}

.balance-city-detail-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(126px, 1fr));
  gap: 8px;
  width: min(100%, 620px);
  margin-left: auto;
}

.balance-city-detail-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.86);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-weight: 900;
}

.balance-city-detail-card small {
  color: var(--muted);
  font-family: inherit;
  font-size: 10px;
  text-transform: uppercase;
}

.balance-city-detail-card.positive {
  color: #147a3f;
  border-color: rgba(20, 122, 63, 0.28);
  background: rgba(20, 122, 63, 0.07);
}

.balance-city-detail-card.negative {
  color: #8b1e2d;
  border-color: rgba(139, 30, 45, 0.26);
  background: rgba(139, 30, 45, 0.06);
}

.balance-city-detail-card.zero {
  color: var(--muted);
}

.balance-group-end td {
  border-bottom: 2px solid rgba(31, 41, 55, 0.62);
}

.balance-group-end td:first-child {
  border-bottom-left-radius: 7px;
}

.balance-group-end td:last-child {
  border-bottom-right-radius: 7px;
}

.balance-group-start:not(:first-child) td {
  box-shadow: inset 0 6px 0 var(--surface-2);
  padding-top: 13px;
}

.balance-city-row .balance-value {
  font-size: 12px;
}

.balance-city-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding-left: 12px;
  color: var(--muted);
  font-weight: 800;
}

.balance-city-name svg {
  width: 15px;
  height: 15px;
  color: var(--primary);
}

.balance-city-name small {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(91, 192, 228, 0.15);
  color: var(--primary);
  font-size: 10px;
  font-weight: 900;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.cde-entry-panel {
  position: relative;
  width: min(100%, 936px);
  max-width: 936px;
  margin: 0 auto 14px;
  padding-top: 4px;
}

.cde-entries-panel {
  width: min(100%, 936px);
  max-width: 936px;
  margin: 0 auto;
}

.cde-entries-panel .table-wrap {
  max-height: 420px;
  overflow: auto;
}

.cde-entries-panel thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  box-shadow: 0 1px 0 var(--border);
}

.cde-entry-panel.collapsed {
  min-height: 44px;
  padding-bottom: 8px;
}

.cde-entry-panel.collapsed .panel-header {
  margin-bottom: 0;
}

.cde-entry-panel.collapsed .cde-workspace {
  display: none;
}

#toggleCdeForm {
  width: 28px;
  height: 28px;
  min-height: 28px;
}

.cde-collapse-float {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  width: 28px;
  height: 28px;
  min-height: 28px;
}

.cde-collapse-float[hidden] {
  display: none !important;
}

.panel p {
  margin: 4px 0 0;
  font-size: 12px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.accounts-table-wrap {
  max-height: 430px;
  overflow-y: auto;
}

.accounts-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  box-shadow: 0 1px 0 var(--border);
}

.rates-table input {
  width: 100%;
  max-width: 100%;
  min-height: 38px;
  padding-inline: 8px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-weight: 700;
}

@media (max-width: 620px) {
  .rates-dialog-card {
    padding: 12px;
  }

  .rates-table th,
  .rates-table td {
    padding: 6px 5px;
    font-size: 12px;
  }

  .rates-table input {
    min-height: 34px;
    padding-inline: 6px;
    font-size: 12px;
  }

  .rates-table th:nth-child(1),
  .rates-table td:nth-child(1) {
    width: 26%;
  }

  .rates-table th:nth-child(2),
  .rates-table td:nth-child(2),
  .rates-table th:nth-child(3),
  .rates-table td:nth-child(3) {
    width: 25%;
  }

  .rates-table th:nth-child(4),
  .rates-table td:nth-child(4) {
    width: 24%;
  }
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  white-space: nowrap;
}

.widget-card.full table {
  min-width: 0;
}

.widget-card.full {
  overflow-x: auto;
}

.cde-entry-table {
  min-width: 0;
  table-layout: fixed;
}

.cde-entry-table .cde-date-col {
  width: 122px;
}

.cde-entry-table .cde-metal-col {
  width: 132px;
}

.cde-entry-table .cde-cash-col {
  width: 158px;
}

.cde-entry-table .cde-actions-col {
  width: 118px;
}

.cde-entry-table th,
.cde-entry-table td {
  padding: 4px 7px;
  line-height: 1.2;
  vertical-align: middle;
}

.cde-entry-table thead th {
  padding: 5px 7px;
}

.cde-details-cell {
  min-width: 0;
  max-width: 0;
  overflow: hidden;
}

.cde-details-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.cde-details-inner span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cde-slip-row-icon {
  flex: 0 0 auto;
  width: 27px;
  height: 27px;
  min-height: 27px;
  color: #b8860b;
  border-color: rgba(184, 134, 11, 0.28);
  background: rgba(184, 134, 11, 0.08);
}

.cde-metal-value {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.cde-metal-value.clickable {
  cursor: pointer;
  border-radius: 6px;
}

.cde-metal-value.clickable:hover {
  background: rgba(91, 192, 228, 0.12);
  box-shadow: 0 0 0 3px rgba(91, 192, 228, 0.08);
}

.cde-metal-value.clickable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.cde-item-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: 7px;
  vertical-align: middle;
}

.cde-item-marker svg {
  width: 13px;
  height: 13px;
}

.cde-item-marker.tt {
  color: #8a6408;
  border-color: rgba(184, 134, 11, 0.28);
  background: rgba(184, 134, 11, 0.1);
}

.cde-item-marker.zero {
  color: #536675;
  border-color: rgba(83, 102, 117, 0.28);
  background: rgba(83, 102, 117, 0.1);
}

.cde-entry-table .balance-value,
.cde-entry-table .table-actions,
.cde-entry-table .date-info-cell {
  white-space: nowrap;
}

.cde-entry-table .date-info-cell {
  gap: 5px;
}

.cde-entry-table .info-dot {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

.cde-entry-table .info-dot svg {
  width: 12px;
  height: 12px;
}

.cde-entry-table .balance-value {
  overflow: visible;
  text-overflow: clip;
}

.cde-entry-table .cde-total-row td {
  background: #f8fbff;
  border-top: 2px solid rgba(14, 165, 233, 0.18);
  font-weight: 900;
  padding: 5px 7px;
}

.cde-entry-table .cde-total-row strong,
.cde-entry-table .cde-total-row small {
  display: block;
}

.cde-entry-table .cde-total-row small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
}

.cde-entry-table .table-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  justify-content: flex-start;
}

.cde-entry-table .table-actions .mini-button {
  width: 24px;
  height: 24px;
  min-height: 24px;
  flex: 0 0 auto;
}

.cde-entry-table .table-actions .mini-button svg,
.cde-entry-table .table-actions .mini-button .app-icon {
  width: 13px;
  height: 13px;
}

.cde-entry-table .cde-slip-row-icon {
  width: 24px;
  height: 24px;
  min-height: 24px;
}

th,
td {
  position: relative;
  padding: 7px 9px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

td {
  color: var(--text);
}

td strong,
td b {
  color: var(--text);
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

th:not(:last-child)::after,
td:not(:last-child)::after {
  content: "|";
  position: absolute;
  right: -2px;
  top: 50%;
  transform: translateY(-50%);
  color: color-mix(in srgb, var(--border), var(--muted) 30%);
  font-weight: 500;
  opacity: 0.75;
}

.table-actions {
  color: var(--muted);
}

.date-stepper {
  display: flex;
  align-items: end;
  gap: 6px;
}

.date-stepper .mini-button {
  width: 32px;
  height: 32px;
  min-height: 32px;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.confirm-password-field {
  margin-top: 10px;
}

.confirm-password-field[hidden],
.confirm-password-field.is-hidden {
  display: none !important;
}

.confirm-password-field small {
  min-height: 16px;
  color: var(--danger);
  font-size: 12px;
}

.city-transfer-card {
  width: min(520px, calc(100vw - 32px));
  max-width: 520px;
}

.city-transfer-card .panel-header {
  align-items: start;
}

.city-transfer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.city-transfer-grid .full-width {
  grid-column: 1 / -1;
  margin-top: 0;
}

.transfer-direction-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.transfer-direction-preview div {
  display: grid;
  gap: 3px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.transfer-direction-preview div:first-child {
  border-color: rgba(128, 0, 32, 0.24);
  background: rgba(128, 0, 32, 0.08);
}

.transfer-direction-preview div:last-child {
  border-color: rgba(0, 137, 74, 0.24);
  background: rgba(0, 150, 82, 0.08);
}

.transfer-direction-preview span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.transfer-direction-preview small {
  color: var(--text);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11px;
}

.city-transfer-card input,
.city-transfer-card select {
  min-height: 38px;
}

.city-transfer-card .form-actions {
  margin-top: 14px;
}

tbody tr:hover {
  background: var(--surface-2);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status.active {
  background: var(--success-soft);
  color: var(--success);
}

.status.pending {
  background: var(--primary-soft);
  color: var(--primary);
}

.status.info {
  background: var(--info-soft);
  color: var(--info);
}

.status.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.stock-list {
  display: grid;
  gap: 10px;
}

.stock-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.stock-row:last-child {
  border-bottom: 0;
}

.inventory-summary {
  grid-template-columns: minmax(120px, 0.8fr) minmax(150px, 1fr);
  align-items: stretch;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.inventory-summary.gold {
  border-color: rgba(184, 134, 11, 0.26);
  background: linear-gradient(135deg, rgba(184, 134, 11, 0.08), rgba(255, 255, 255, 0.84));
}

.inventory-summary.silver {
  border-color: rgba(113, 128, 142, 0.28);
  background: linear-gradient(135deg, rgba(135, 149, 161, 0.1), rgba(255, 255, 255, 0.86));
}

.inventory-total {
  display: grid;
  align-content: center;
  gap: 5px;
  min-width: 0;
}

.inventory-total b {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 16px;
  color: var(--text);
}

.inventory-details {
  display: grid;
  gap: 5px;
  align-content: center;
}

.inventory-detail {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  min-height: 24px;
  padding: 4px 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.68);
}

.inventory-detail em {
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
}

.inventory-detail strong {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
}

.inventory-detail small {
  color: var(--primary);
  font-size: 10px;
}

.inventory-cash {
  padding: 8px 2px 2px;
}

.bar {
  height: 6px;
  margin-top: 7px;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 999px;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--primary);
}

.task-list {
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.task-list li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar {
  margin-bottom: 10px;
}

.toolbar input {
  max-width: 420px;
}

.toolbar select {
  max-width: 190px;
}

.trade-layout {
  display: grid;
  grid-template-columns: minmax(560px, 620px) minmax(292px, 304px);
  gap: 12px;
  align-items: start;
  width: min(100%, 936px);
  min-width: min(100%, 760px);
  max-width: 936px;
  margin: 0 auto;
}

.trade-main {
  min-width: 0;
}

.trade-main:has(+ .trade-summary) {
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.trade-layout.editing-mode .trade-main {
  border-color: rgba(184, 134, 11, 0.42);
  box-shadow:
    0 12px 28px rgba(184, 134, 11, 0.12),
    0 0 0 3px rgba(184, 134, 11, 0.08);
}

.trade-summary {
  min-width: 292px;
}

.last-trades-panel {
  grid-column: 1 / -1;
  min-width: 0;
}

.voucher {
  font-family: "JetBrains Mono", Consolas, monospace;
  color: var(--primary);
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.trade-main .form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px 8px;
  align-items: start;
}

.trade-main .form-grid > label:not(.wide-field):not(.full-width) {
  min-height: 54px;
}

.trade-main label {
  gap: 4px;
}

.trade-main select,
.trade-main input,
.trade-main textarea {
  min-height: 32px;
  padding: 5px 9px;
}

.trade-main .touch-option {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 11px;
}

.trade-main .trade-party-field,
.trade-main .trade-city-field,
.trade-main .trade-choice-field,
.trade-main .trade-path-field,
.trade-main .weight-field,
.trade-main .trade-rate-field {
  grid-column: span 2;
}

.trade-main .trade-city-field select,
.trade-main .trade-choice-field select {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  opacity: 0;
  pointer-events: none;
}

.trade-main .trade-city-field .touch-options,
.trade-main .trade-choice-field .touch-options {
  display: grid;
}

.trade-party-field,
.party-search-field {
  position: relative;
}

.trade-party-combo,
.party-combo {
  position: relative;
  min-width: 0;
  flex: 1 1 auto;
}

.trade-party-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.trade-party-transfer-affordance,
.trade-transfer-affordance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.trade-party-transfer-affordance[hidden],
.trade-transfer-affordance[hidden] {
  display: none !important;
}

.trade-transfer-arrow {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.trade-party-transfer-target {
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.trade-transfer-info-btn {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 999px;
}

.pending-party-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.trade-transfer-affordance.is-compact .trade-party-transfer-target {
  display: none;
}

.transfer-log-table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

.transfer-log-table {
  min-width: 0 !important;
  width: 100%;
  white-space: normal;
}

.transfer-log-table .numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.trade-party-combo input,
.party-combo input {
  width: 100%;
}

.trade-party-results,
.party-results {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  z-index: 20;
  display: grid;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 14px 30px rgba(48, 54, 64, 0.16);
}

.trade-party-results[hidden],
.party-results[hidden] {
  display: none;
}

.trade-party-option,
.trade-party-empty,
.party-option,
.party-empty {
  min-height: 34px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid rgba(221, 230, 236, 0.7);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 12px;
  font-weight: 800;
}

.trade-party-option,
.party-option {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.party-option-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.party-city-badge {
  flex: 0 0 auto;
  color: #0b78a3;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.trade-party-balance-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  min-height: 24px;
  padding: 2px 1px 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.trade-party-balance-summary.is-empty {
  min-height: 0;
  padding: 0;
}

.trade-party-balance-summary span {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  max-width: 100%;
  font-weight: 800;
  white-space: nowrap;
}

.trade-party-balance-summary span b {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.trade-party-balance-summary .mini-button {
  width: 24px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border-radius: 7px;
}

.trade-party-balance-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.trade-party-balance-totals article {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.trade-party-balance-totals span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.trade-party-balance-totals b {
  font-family: "Roboto Mono", monospace;
  font-size: 14px;
}

.trade-party-balance-wrap table {
  min-width: 760px;
}

.trade-party-balance-wrap td:first-child {
  display: grid;
  gap: 2px;
}

.trade-party-balance-wrap td:first-child small {
  color: #0b78a3;
  font-size: 10px;
  font-weight: 900;
}

.trade-party-balance-detail {
  display: grid;
  gap: 3px;
  min-width: 260px;
  color: var(--muted);
  font-size: 11px;
}

.trade-party-option:last-child,
.trade-party-empty:last-child,
.party-option:last-child,
.party-empty:last-child {
  border-bottom: 0;
}

.trade-party-option:hover,
.trade-party-option.active,
.party-option:hover,
.party-option.active {
  background: var(--primary-soft);
  color: var(--text);
}

.trade-party-empty,
.party-empty {
  color: var(--muted);
}

.trade-main .touch-field,
.trade-main .combo-field {
  align-content: start;
}

.trade-main .touch-options {
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.trade-main .touch-options.two {
  grid-template-columns: repeat(2, 76px);
}

.trade-main .touch-options.three,
.trade-main .touch-options.six {
  grid-template-columns: repeat(3, 86px);
}

.trade-main .touch-options.four {
  grid-template-columns: repeat(4, 76px);
}

.trade-main #metalTabs {
  grid-template-columns: repeat(2, 82px);
}

.trade-main .trade-city-field .touch-options {
  grid-template-columns: repeat(2, 84px);
}

.trade-choice-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  align-items: start;
}

.trade-main .trade-side-options {
  grid-template-columns: repeat(2, 72px);
}

.trade-main .trade-item-options {
  grid-template-columns: repeat(3, 74px);
}

.trade-main .wide-field,
.trade-main .full-width {
  grid-column: 1 / -1;
}

.trade-main .form-grid > .touch-field.wide-field:first-child {
  grid-column: span 2;
}

.trade-main .form-grid > .touch-field.wide-field:first-child + .trade-party-field {
  grid-column: span 2;
}

.trade-main #tradeWeight,
.trade-main #tradeRate {
  max-width: 100%;
}

.trade-main .trade-note-field {
  margin-top: 8px;
}

.trade-main #tradeNotes {
  height: 44px;
  min-height: 44px;
  resize: none;
}

.trade-main .form-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  margin-top: 8px;
}

.trade-footer-voucher {
  justify-self: start;
  font-size: 12px;
}

.compact-form {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.users-admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 390px);
  gap: 10px;
  align-items: start;
  justify-content: stretch;
  width: min(1280px, 100%);
  margin-inline: auto;
}

.user-matrix-panel {
  min-width: 0;
  width: 100%;
}

.user-admin-panel,
.user-matrix-panel {
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}

.user-admin-panel .panel-header,
.user-matrix-panel .panel-header {
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
}

.user-admin-panel .panel-header h2,
.user-matrix-panel .panel-header h2 {
  font-size: 15px;
}

.user-admin-panel .panel-header p,
.user-matrix-panel .panel-header p {
  font-size: 11px;
}

.user-admin-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.user-admin-form > label {
  min-height: auto;
  gap: 4px;
  font-size: 11px;
}

.user-admin-form input,
.user-admin-form select {
  height: 32px;
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
}

.permission-chip-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 2px;
}

.permission-chip-row label {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 6px;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5fbff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.permission-chip-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  min-height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

.user-admin-panel .form-actions {
  margin-top: 7px;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.user-admin-panel .form-actions button,
.user-admin-panel .panel-header .primary-button {
  min-height: 32px;
  padding: 7px 11px;
}

.user-matrix-wrap {
  border-color: rgba(14, 165, 233, 0.2);
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.user-matrix-table {
  width: 100%;
  min-width: 520px;
  table-layout: auto;
}

.user-matrix-table th,
.user-matrix-table td {
  padding: 6px 8px;
  line-height: 1.2;
  vertical-align: middle;
}

.user-matrix-table th {
  white-space: nowrap;
  font-size: 10px;
}

.user-matrix-table td code {
  display: inline-block;
  max-width: 120px;
  overflow-wrap: anywhere;
  font-size: 11px;
}

.user-pages-cell {
  min-width: 108px;
  max-width: 180px;
  white-space: normal;
  line-height: 1.25;
  font-size: 11px;
}

.user-matrix-table td strong {
  font-size: 12px;
}

.user-matrix-name-cell {
  min-width: 108px;
}

.user-matrix-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

.user-role-chip {
  display: inline-flex;
  align-items: center;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.2;
  white-space: nowrap;
}

.user-role-chip--admin {
  color: #5b21b6;
  background: rgba(139, 92, 246, 0.14);
  border-color: rgba(139, 92, 246, 0.28);
}

.user-role-chip--manager {
  color: #1d4ed8;
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.28);
}

.user-role-chip--accountant {
  color: #0f766e;
  background: rgba(20, 184, 166, 0.14);
  border-color: rgba(20, 184, 166, 0.28);
}

.user-role-chip--staff {
  color: #b45309;
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.28);
}

.dark .user-role-chip--admin {
  color: #ddd6fe;
  background: rgba(139, 92, 246, 0.22);
  border-color: rgba(167, 139, 250, 0.35);
}

.dark .user-role-chip--manager {
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(96, 165, 250, 0.35);
}

.dark .user-role-chip--accountant {
  color: #99f6e4;
  background: rgba(20, 184, 166, 0.22);
  border-color: rgba(45, 212, 191, 0.35);
}

.dark .user-role-chip--staff {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(251, 191, 36, 0.35);
}

.user-matrix-table td small {
  color: var(--muted);
  font-size: 10px;
}

.user-matrix-table tbody tr {
  background: #fbfdff;
}

.user-matrix-table tbody tr:nth-child(even) {
  background: #f6fbfb;
}

.user-matrix-table tbody tr.blocked-user-row {
  background: #fff1f2;
}

.user-matrix-table .table-actions {
  justify-content: flex-end;
}

.login-dialog {
  border: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.2), transparent 34%),
    linear-gradient(135deg, #eff7fb 0%, #f8fbff 42%, #edf7f4 100%);
  overflow: hidden;
}

.login-dialog::backdrop {
  background: #eef6f9;
}

.login-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
  background: rgba(255, 255, 255, 0.96);
}

.login-card label {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.login-card input {
  height: 40px;
}

.login-brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.login-brand strong {
  font-size: 24px;
}

.login-brand span {
  color: var(--muted);
  font-weight: 800;
}

.login-message {
  min-height: 18px;
  margin: 8px 0;
  color: #b91c1c;
  font-weight: 800;
  font-size: 12px;
}

body.auth-booting .app-shell,
body.login-required .app-shell {
  display: none;
}

body.auth-booting,
body.login-required {
  overflow: hidden;
}

body.auth-booting::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9997;
  background:
    radial-gradient(circle at 76% 12%, rgba(56, 189, 248, 0.2), transparent 32%),
    linear-gradient(135deg, #eff7fb 0%, #f8fbff 48%, #edf7f4 100%);
}

body.auth-booting::after {
  content: "Loading secure session...";
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 9998;
  width: min(360px, calc(100vw - 36px));
  padding: 24px 28px;
  border: 1px solid rgba(99, 196, 232, 0.34);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 70px rgba(31, 45, 58, 0.16);
  color: var(--text);
  font-weight: 850;
  text-align: center;
  transform: translate(-50%, -50%);
}

body.capra-update-active .login-dialog::before {
  content: "Update in progress - CAPRA latest version install ho rahi hai. Please thori der baad refresh karein.";
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 2;
  width: min(620px, calc(100vw - 28px));
  padding: 12px 16px;
  border: 1px solid rgba(99, 196, 232, 0.42);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(231, 247, 253, 0.96));
  box-shadow: 0 18px 60px rgba(31, 45, 58, 0.18);
  color: var(--text);
  font-weight: 850;
  text-align: center;
  transform: translateX(-50%);
}

.manage-entries-layout {
  display: grid;
  grid-template-columns: minmax(680px, 980px) minmax(220px, 260px);
  gap: 10px;
  align-items: start;
  justify-content: center;
  width: min(1260px, 100%);
  margin-inline: auto;
}

.manage-entries-panel,
.manage-filter-panel {
  background: linear-gradient(180deg, #ffffff 0%, #f8fcff 100%);
}

.manage-filter-panel {
  border-color: rgba(56, 189, 248, 0.28);
}

.manage-date-filter {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

.manage-date-filter input {
  height: 36px;
}

.filter-stack {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.filter-stack > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.manage-filter-tabs.vertical-tabs {
  grid-template-columns: 1fr;
}

.manage-entries-wrap {
  border-color: rgba(14, 165, 233, 0.22);
}

.manage-entries-table th,
.manage-entries-table td {
  padding: 5px 8px;
  line-height: 1.16;
  vertical-align: top;
}

.manage-entries-table tbody tr {
  background: #fbfdff;
}

.manage-entries-table tbody tr:nth-child(even) {
  background: #f6fbf8;
}

.manage-entries-table tbody tr.manage-linked-row {
  background: linear-gradient(90deg, rgba(20, 184, 166, 0.12), rgba(240, 249, 255, 0.92));
  box-shadow: inset 3px 0 0 #14b8a6;
}

.manage-entries-table td strong {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.manage-entries-table td small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
  margin-top: 2px;
  max-width: 280px;
  overflow-wrap: anywhere;
}

.manage-date-cell {
  width: 110px;
  white-space: nowrap;
}

.manage-date-cell .status {
  margin-top: 1px;
  padding: 2px 5px;
  font-size: 9px;
}

.manage-party-cell {
  min-width: 190px;
}

.manage-party-cell strong {
  font-size: 13px;
}

.manage-party-cell small {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.manage-item-cell {
  min-width: 210px;
}

.manage-entries-table .table-actions,
.manage-entry-actions {
  display: inline-flex;
  flex-shrink: 0;
  gap: 4px;
  justify-content: flex-end;
  padding: 2px;
  border: 1px solid color-mix(in srgb, var(--border), var(--primary) 14%);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface), #fff 8%);
}

.manage-entry-actions .mini-button,
.manage-entry-action-btn {
  width: 28px;
  height: 28px;
}

.cde-workspace {
  display: grid;
  grid-template-columns: minmax(560px, 620px) minmax(260px, 270px);
  gap: 10px;
  align-items: start;
  width: 100%;
}

.cde-form-card {
  min-width: 0;
}

.cde-form-card.editing .cde-edit-locked-field {
  position: relative;
}

.cde-form-card.editing .cde-edit-locked-field::after {
  position: absolute;
  inset: 18px 0 0;
  z-index: 3;
  display: grid;
  place-items: center;
  content: "Edit mode";
  color: var(--text);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.62);
  border: 1px dashed rgba(48, 54, 64, 0.24);
  border-radius: 8px;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

.cde-form-card.editing .cde-ledger-options,
.cde-form-card.editing #cdeParty,
.cde-form-card.editing #cdeType {
  opacity: 0.55;
}

.cde-form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 8px;
}

.cde-form-grid > label:not(.wide-field):not(.full-width) {
  min-height: 56px;
}

.cde-form-grid select,
.cde-form-grid input,
.cde-form-grid textarea {
  min-height: 32px;
  padding: 5px 8px;
}

.cde-form-grid label {
  gap: 4px;
}

.cde-form-grid label.full-width {
  margin-top: 2px;
}

.cde-ledger-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cde-ledger-field .field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.melting-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 220px);
  gap: 10px;
  align-items: start;
  width: min(100%, 860px);
  margin-inline: auto;
  min-width: 0;
}

#melting.view.active {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.melting-form-card,
.melting-ledger-panel {
  min-width: 0;
}

.melting-form-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 6px;
}

.melting-form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 8px;
}

.melting-form-grid > label:not(.wide-field):not(.full-width) {
  min-height: 56px;
  height: auto;
}

.melting-form-grid input,
.melting-form-grid select {
  min-height: 32px;
  padding: 5px 8px;
}

.melting-form-grid label {
  gap: 4px;
  min-height: 0;
}

.melting-form-grid.send-mode .melting-receive-field {
  display: none;
}

.melting-form-grid.receive-mode .melting-batch-panel {
  display: none;
}

.melting-form-grid > label.wide-field {
  grid-column: auto;
}

.melting-form-grid > .full-width,
.melting-form-grid > label.full-width {
  grid-column: 1 / -1;
}

.melting-metal-options,
.melting-type-options {
  max-width: 220px;
}

.melting-slip-attach {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(86px, 0.45fr);
  gap: 6px;
}

.melting-batch-panel {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 7px;
  border: 1px solid rgba(14, 165, 233, 0.22);
  border-radius: 8px;
  background: rgba(240, 249, 255, 0.5);
}

.melting-batch-inputs {
  display: grid;
  grid-template-columns: minmax(92px, 0.9fr) minmax(92px, 0.9fr) 82px minmax(112px, 1fr) 78px;
  gap: 5px;
  align-items: end;
}

.melting-batch-inputs label {
  min-height: 0;
  min-width: 0;
}

.melting-batch-inputs .mini-button {
  min-height: 32px;
  min-width: 0;
  white-space: nowrap;
}

.melting-add-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: auto;
  min-width: 0;
  height: 32px;
  padding-inline: 5px;
  font-size: 11px;
  font-weight: 900;
}

.melting-add-button b {
  font-size: 11px;
  line-height: 1;
}

.melting-add-button svg,
.melting-add-button [data-icon] {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.melting-silver-add {
  grid-column: auto;
}

.melting-batch-wrap {
  max-height: 116px;
  overflow: auto;
}

.melting-batch-table {
  min-width: 0;
  table-layout: fixed;
}

.melting-batch-table th,
.melting-batch-table td {
  padding: 3px 4px;
  font-size: 10.5px;
  white-space: nowrap;
}

.melting-batch-table th:first-child,
.melting-batch-table td:first-child {
  width: 24px;
}

.melting-batch-table th:last-child,
.melting-batch-table td:last-child {
  width: 48px;
}

.melting-draft-row td {
  background: rgba(14, 165, 233, 0.06);
  color: #0e7490;
  font-weight: 800;
}

.melting-draft-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.12);
  color: #0e7490;
  font-size: 9.5px;
  font-weight: 900;
  line-height: 1;
}

.melting-batch-total {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.melting-batch-total span {
  display: grid;
  gap: 2px;
  padding: 5px 7px;
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
}

.melting-batch-total b {
  color: var(--text);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11.5px;
}

.melting-form-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.melting-form-actions strong {
  color: var(--text);
  font-size: 12px;
}

.melting-balance-panel {
  display: grid;
  gap: 8px;
}

.melting-balance-card {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.melting-balance-card span,
.melting-balance-card small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.melting-balance-card strong {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 15px;
  line-height: 1.1;
}

.melting-balance-card.positive {
  border-color: rgba(37, 170, 119, 0.28);
  background: linear-gradient(135deg, rgba(37, 170, 119, 0.1), #fff);
}

.melting-balance-card.negative {
  border-color: rgba(244, 151, 54, 0.34);
  background: linear-gradient(135deg, rgba(244, 151, 54, 0.1), #fff);
}

.melting-ledger-panel {
  width: min(100%, 990px);
  margin-inline: auto;
}

.melting-ledger-header {
  align-items: center;
  gap: 12px;
}

.melting-ledger-tabs {
  justify-content: center;
  min-width: 150px;
}

.melting-ledger-header .compact-date-filter {
  display: grid;
  grid-template-columns: 28px minmax(138px, 150px) 28px auto;
  gap: 5px;
  align-items: end;
  justify-content: end;
  min-width: 0;
}

.melting-ledger-header .compact-date-filter .mini-button {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
}

.melting-ledger-header .compact-date-filter label {
  gap: 3px;
  min-width: 0;
}

.melting-ledger-header .compact-date-filter input[type="date"] {
  width: 100%;
  min-height: 32px;
  padding: 4px 8px;
}

.melting-ledger-header .compact-date-filter .inline-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.melting-ledger-header .compact-date-filter .inline-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
  min-height: 14px;
  padding: 0;
}

.melting-table-wrap {
  overflow-x: auto;
}

.melting-ledger-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.melting-ledger-table th,
.melting-ledger-table td {
  padding: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.melting-ledger-table th:first-child,
.melting-ledger-table td:first-child {
  width: 132px;
}

.melting-ledger-table th:nth-child(2),
.melting-ledger-table td:nth-child(2) {
  width: 34px;
  text-align: center;
}

.melting-ledger-table th:nth-child(3),
.melting-ledger-table td:nth-child(3) {
  width: 88px;
}

.melting-ledger-table th:nth-child(4),
.melting-ledger-table td:nth-child(4) {
  width: 70px;
}

.melting-ledger-table th:nth-child(6),
.melting-ledger-table td:nth-child(6) {
  width: 90px;
}

.melting-ledger-table th:last-child,
.melting-ledger-table td:last-child {
  width: 112px;
}

.melting-ledger-row td:first-child {
  white-space: nowrap;
}

.melting-voucher-date {
  display: grid;
  gap: 2px;
  max-width: 100%;
  overflow: hidden;
}

.melting-voucher-date strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.melting-voucher-date small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.05;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.melting-action-pill {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid transparent;
  border-radius: 999px;
}

.melting-action-pill svg {
  width: 14px;
  height: 14px;
}

.melting-action-pill.send {
  color: #0ea5e9;
  border-color: rgba(14, 165, 233, 0.24);
  background: rgba(14, 165, 233, 0.1);
}

.melting-action-pill.receive {
  color: #16a34a;
  border-color: rgba(22, 163, 74, 0.24);
  background: rgba(22, 163, 74, 0.1);
}

.melting-batch-start,
.melting-linked-row {
  background: rgba(14, 165, 233, 0.045);
}

.melting-batch-start td {
  border-top: 1px solid rgba(14, 165, 233, 0.34);
}

.melting-batch-start td:first-child,
.melting-linked-row td:first-child {
  border-left: 3px solid #0ea5e9;
  padding-left: 7px;
}

.melting-batch-start td:first-child {
  border-top-left-radius: 7px;
}

.melting-batch-start td:last-child {
  border-top-right-radius: 7px;
}

.melting-linked-row td {
  border-bottom: 1px solid rgba(14, 165, 233, 0.34);
}

.melting-linked-row td:first-child {
  border-bottom-left-radius: 7px;
  box-shadow: inset 10px 0 0 rgba(14, 165, 233, 0.08);
}

.melting-linked-row td:last-child {
  border-bottom-right-radius: 7px;
}

.melting-ledger-row td:first-child small,
.melting-detail-cell span {
  color: var(--muted);
  font-size: 11px;
}

.melting-detail-cell {
  max-width: none;
  overflow: hidden;
  vertical-align: top;
  white-space: normal;
}

.melting-detail-stack {
  display: grid;
  gap: 3px;
  min-width: 0;
  max-width: 100%;
  line-height: 1.15;
}

.melting-detail-stack > span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.melting-batch-summary {
  display: block;
  min-width: 0;
  max-width: 100%;
  margin-top: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 900;
  line-height: 1.2;
}

.melting-batch-summary.pending {
  color: #9a6d08;
}

.melting-batch-summary.positive {
  color: #16a34a;
}

.melting-batch-summary.negative {
  color: #dc2626;
}

.melting-batch-summary.neutral {
  color: #0e7490;
}

.metal-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.metal-pill.gold {
  color: #8a5b04;
  background: rgba(188, 139, 28, 0.14);
  border: 1px solid rgba(188, 139, 28, 0.25);
}

.metal-pill.silver {
  color: #475569;
  background: rgba(148, 163, 184, 0.16);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.melting-row-actions {
  gap: 2px;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.melting-row-actions .mini-button {
  width: 25px;
  min-width: 25px;
  height: 25px;
  padding: 0;
}

@media (max-width: 760px) {
  .melting-batch-inputs {
    grid-template-columns: minmax(86px, 1fr) minmax(86px, 1fr) 76px;
  }

  .melting-silver-add {
    grid-column: 1 / 3;
  }
}

.melting-receive-action {
  color: #0f766e;
  border-color: rgba(15, 118, 110, 0.24);
  background: rgba(20, 184, 166, 0.09);
}

.cde-notes-actions {
  display: grid;
  grid-template-columns: minmax(220px, 0.6fr) minmax(0, 1fr) auto auto auto auto;
  gap: 8px;
  align-items: center;
}

.cde-notes-actions.full-width {
  grid-column: 1 / -1;
  margin-top: 2px;
}

.cde-notes-actions label {
  min-width: 0;
}

.cde-notes-actions textarea {
  height: 32px;
  min-height: 32px;
  max-height: 32px;
  resize: none;
}

.cde-note-field {
  grid-column: 1;
}

.cde-notes-actions #cdeVoucherLabel {
  grid-column: 3;
}

.cde-notes-actions #toggleCdeForm {
  grid-column: 4;
}

.cde-notes-actions #cancelCdeEdit {
  grid-column: 5;
}

.cde-notes-actions #saveCde {
  grid-column: 6;
  justify-self: end;
}

.cde-notes-actions .ghost-button,
.cde-notes-actions .primary-button {
  min-height: 32px;
  white-space: nowrap;
}

.cde-form-grid .touch-option {
  min-height: 32px;
}

.cde-ledger-options {
  width: fit-content;
  max-width: 100%;
  grid-template-columns: repeat(2, 92px);
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.cde-item-field {
  gap: 4px;
}

.cde-item-options {
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  min-height: 32px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.cde-item-options .touch-option {
  min-height: 26px;
  padding: 0 6px;
  border-radius: 7px;
  font-size: 11px;
}

.cde-entry-pairs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 8px;
  grid-column: 1 / -1;
}

.cde-pair-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(184, 134, 11, 0.18);
  border-radius: 8px;
  background: rgba(184, 134, 11, 0.055);
}

.cde-tt-picker {
  display: none;
  grid-column: 1 / -1;
  grid-template-columns: minmax(140px, 0.8fr) minmax(0, 1fr);
  gap: 6px;
  align-items: start;
}

.cde-tt-picker.show {
  display: grid;
}

.cde-tt-direction {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.cde-tt-direction .touch-option {
  min-height: 30px;
}

.cde-tt-picker small {
  grid-column: 1 / -1;
  min-height: 0;
  color: var(--muted);
  font-size: 11px;
}

.cde-slip-field {
  display: none;
  grid-column: span 2;
}

.cde-slip-field.show {
  display: grid;
}

.cde-slip-attach {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(72px, 0.6fr) auto;
  gap: 6px;
}

.cde-slip-attach .ghost-button {
  min-height: 32px;
  padding: 0 9px;
}

.cde-slip-direction {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.cde-slip-direction.show {
  display: grid;
}

.cde-slip-direction .touch-option {
  min-height: 30px;
}

.cde-ledger-transfer-field {
  display: none;
  grid-column: 1 / -1;
  grid-template-columns: minmax(230px, 1fr) minmax(150px, 0.52fr);
  gap: 8px;
  align-items: end;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(91, 192, 222, 0.22);
  border-radius: 8px;
  background: rgba(91, 192, 222, 0.055);
}

.cde-ledger-transfer-field.show {
  display: grid;
}

.cde-account-transfer-field {
  display: none;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(99, 196, 232, 0.24);
  border-radius: 8px;
  background: rgba(99, 196, 232, 0.055);
}

.cde-account-transfer-field.show {
  display: grid;
}

.cde-account-transfer-card {
  display: grid;
  gap: 6px;
}

.cde-account-transfer-card label {
  min-height: 0;
}

.cde-account-transfer-preview {
  grid-column: 1 / -1;
  display: grid;
  gap: 0;
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(99, 196, 232, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11px;
}

.cde-account-transfer-preview strong {
  color: var(--text);
}

.preview-flow,
.preview-party-row {
  display: grid;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
}

.preview-flow {
  grid-template-columns: auto auto 1fr;
  border-bottom: 1px solid rgba(99, 196, 232, 0.2);
  background: rgba(99, 196, 232, 0.08);
  font-weight: 900;
}

.preview-party-row {
  grid-template-columns: minmax(120px, 1.1fr) auto auto auto auto auto auto auto;
  border-bottom: 1px solid rgba(48, 54, 64, 0.1);
}

.preview-party-row:last-child {
  border-bottom: 0;
}

.preview-party-row b {
  color: var(--text);
}

.preview-party-row .preview-before {
  color: var(--muted);
  font-weight: 800;
}

.preview-party-row .preview-arrow {
  color: var(--muted);
}

.preview-party-row strong {
  font-weight: 950;
}

.preview-party-row strong.positive {
  color: var(--success);
}

.preview-party-row strong.negative {
  color: var(--danger);
}

.cde-transfer-options .touch-option {
  min-height: 32px;
}

.cde-ledger-transfer-field label,
.cde-ledger-transfer-field input,
.cde-ledger-transfer-field .touch-options {
  min-width: 0;
}

.cde-transfer-preview {
  grid-column: 1 / -1;
  display: grid;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--muted);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11px;
  line-height: 1.35;
}

.cde-transfer-preview strong {
  color: var(--text);
}

.cde-pair-card.slip-locked {
  border-color: rgba(77, 179, 223, 0.38);
  background: rgba(77, 179, 223, 0.08);
}

.cde-pair-card.slip-locked input:disabled {
  color: var(--text);
  background: #eef7fb;
  opacity: 1;
}

.cde-pair-card.cash {
  border-color: rgba(91, 192, 222, 0.22);
  background: rgba(91, 192, 222, 0.06);
}

.cde-pair-card > span {
  display: none;
}

.cde-pair-card label {
  min-height: 0;
}

.cde-pair-card label small {
  min-height: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.cde-ledger-options .touch-option.locked {
  cursor: not-allowed;
  opacity: 0.78;
}

.cde-form-card .form-actions {
  margin-top: 8px;
}

.form-grid > label {
  align-self: start;
  min-width: 0;
}

.form-grid > label:not(.wide-field):not(.full-width) {
  min-height: 78px;
}

.compact-form > label:not(.wide-field):not(.full-width) {
  min-height: 92px;
}

.compact-form.melting-form-grid > label:not(.wide-field):not(.full-width) {
  min-height: 56px;
}

.cde-form-grid > label:not(.wide-field):not(.full-width) {
  min-height: 56px;
}

.cde-form-grid label {
  align-content: start;
}

.wide-field {
  grid-column: 1 / -1;
}

.slip-note-field {
  margin-top: 10px;
}

.visually-hidden-select {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.touch-field {
  position: relative;
}

.combo-field {
  display: grid;
  gap: 6px;
}

.hidden-touch {
  display: none;
}

.hidden-field {
  display: none !important;
}

.touch-options.hidden-touch {
  display: none;
}

.touch-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 6px;
}

.touch-options.two {
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

.touch-options.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.touch-options.cde-item-options {
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
}

.touch-options.four {
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
}

.touch-options.five {
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
}

.touch-options.six {
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
}

.touch-option {
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  box-shadow: none;
  white-space: normal;
  overflow-wrap: anywhere;
}

.touch-option:hover {
  border-color: var(--primary);
}

.touch-option.active {
  color: #ffffff;
  border-color: var(--primary);
  background: var(--primary);
}

.touch-option.buy.active,
.touch-option.gold.active {
  background: #b8860b;
  border-color: #9a6d08;
  color: #ffffff;
}

.cde-ledger-options .touch-option.gold.active {
  box-shadow: 0 10px 24px rgba(184, 134, 11, 0.18);
}

.cde-ledger-options .touch-option.silver.active {
  background: #8795a1;
  border-color: #71808e;
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(113, 128, 142, 0.2);
}

.touch-option.sell.active {
  background: var(--orange);
  border-color: var(--orange);
}

.city-toggle .touch-option.active,
.trade-city-field .touch-option.active {
  color: #ffffff;
  border-color: #15946f;
  background: linear-gradient(180deg, #36c28c, #0f8a66);
  box-shadow: 0 8px 18px rgba(16, 185, 129, 0.2);
}

.trade-choice-field .touch-option.buy.active {
  background: linear-gradient(180deg, #c8961d, #a97305);
  border-color: #9a6d08;
}

.trade-choice-field .touch-option.sell.active {
  background: linear-gradient(180deg, #ffa83b, #f28d1a);
  border-color: #e68417;
}

.touch-option.silver.active {
  background: linear-gradient(180deg, #f4f6f8, #b8c0c8);
  border-color: #9aa5ae;
  color: #303640;
}

.touch-option.hidden-by-metal {
  display: none;
}

#rateRangeStatus {
  color: var(--muted);
  font-size: 12px;
}

#rateRangeStatus.error {
  color: var(--danger);
}

#rateRangeStatus.ok {
  color: var(--primary);
}

.slip-field {
  display: none;
}

.slip-field.show {
  display: grid;
}

.slip-attach {
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(130px, 1fr) repeat(2, minmax(58px, auto));
  gap: 6px;
  align-items: center;
}

.trade-main .slip-attach {
  grid-template-columns: minmax(180px, 0.85fr) minmax(170px, 1fr) auto auto;
}

.trade-main .slip-field small,
.trade-main #rateRangeStatus,
.trade-main #ttQuantityStatus,
.trade-main #futureDateStatus {
  min-height: 16px;
  font-size: 11px;
  line-height: 1.25;
}

.trade-main #rateRangeStatus:empty,
.trade-main #ttQuantityStatus:empty,
.trade-main #futureDateStatus:empty {
  display: none;
  min-height: 0;
}

.slip-details {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.slip-field.attached .slip-details {
  display: grid;
}

.slip-label-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
}

.slip-view-button {
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
}

.slip-view-button[hidden] {
  display: none;
}

.slip-stat {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.slip-stat span {
  color: var(--muted);
  font-size: 11px;
}

.slip-stat strong {
  font-family: "JetBrains Mono", Consolas, monospace;
  color: var(--text);
}

.slip-chip-list {
  display: grid;
  gap: 6px;
  grid-column: 1 / -1;
  min-width: 0;
}

.slip-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  min-width: 0;
}

.slip-chip strong {
  color: var(--text);
}

.slip-chip span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-family: "JetBrains Mono", Consolas, monospace;
  overflow-wrap: anywhere;
}

.slip-field small {
  color: var(--muted);
  font-size: 12px;
}

.slip-field.attached small {
  color: var(--primary);
}

.future-date-field {
  display: none;
}

.future-date-field.show {
  display: grid;
}

.future-date-field.show,
.tt-quantity-field.show,
.cde-tt-field.show,
.slip-field.show {
  align-content: start;
}

.future-date-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.future-date-field small {
  color: var(--muted);
  font-size: 12px;
}

.tt-quantity-field {
  display: none;
}

.tt-quantity-field.show {
  display: grid;
}

.trade-main .tt-quantity-field.show {
  grid-column: span 2;
}

.cde-tt-field {
  display: none;
}

.cde-tt-field.show {
  display: grid;
}

#cdeToPartyField,
#cdeToCityField,
#cdeDirectionField {
  display: none;
}

#cdeToPartyField.show,
#cdeToCityField.show,
#cdeDirectionField.show {
  display: grid;
}

.tt-quantity-row {
  display: grid;
  grid-template-columns: minmax(92px, 108px) minmax(0, 1fr);
  gap: 6px;
}

.tt-quantity-row select,
.tt-quantity-row input {
  min-width: 0;
}

.form-grid > label > small,
#rateRangeStatus,
.tt-quantity-field small,
.cde-tt-field small,
.future-date-field small,
.slip-field small {
  display: block;
  min-height: 30px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.tt-quantity-field small,
.cde-tt-field small {
  color: var(--muted);
  font-size: 12px;
}

.trade-main .tt-quantity-field small {
  min-height: 0;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weight-field.hidden-for-tt {
  display: none;
}

#cdeAmountField.hidden-for-tt {
  display: none;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.full-width {
  margin-top: 12px;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

.trade-summary,
.last-trades-panel {
  position: static;
  top: auto;
}

.trade-summary {
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.trade-summary .summary-highlight {
  align-items: center;
  padding-block: 12px;
}

.trade-summary .summary-highlight dt {
  font-size: 13px;
}

.trade-summary .summary-highlight dd {
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  font-weight: 900;
}

.last-trades-panel {
  align-self: start;
}

.trade-summary.gold-theme {
  border-color: rgba(184, 134, 11, 0.32);
  box-shadow:
    0 14px 34px rgba(184, 134, 11, 0.14),
    0 0 0 3px rgba(184, 134, 11, 0.06);
}

.trade-summary.silver-theme {
  border-color: rgba(154, 165, 174, 0.42);
  box-shadow:
    0 14px 34px rgba(154, 165, 174, 0.18),
    0 0 0 3px rgba(222, 229, 235, 0.5);
}

.ledger-history-panel {
  margin-top: 14px;
}

.last-trades {
  display: grid;
  gap: 7px;
}

.last-trade-results {
  display: grid;
  gap: 5px;
}

.last-trade-tools {
  display: grid;
  grid-template-columns: minmax(150px, auto) minmax(220px, 1.15fr) repeat(3, minmax(100px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 8px;
}

.compact-tabs {
  margin: 0;
}

.last-trade-item-tabs {
  grid-column: 1 / -1;
}

.last-trade-tools label {
  gap: 4px;
}

.last-trade-tools input,
.last-trade-tools select {
  min-height: 34px;
  padding: 0 8px;
}

.last-trade-tools label .date-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.last-trade-tools label .date-stepper input[type="date"] {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  padding: 0 8px;
}

.last-trade-tools label .date-stepper .mini-button {
  width: 32px;
  height: 32px;
  min-height: 32px;
  flex: 0 0 32px;
}

.cde-entries-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px 14px;
  width: 100%;
  max-width: 100%;
}

.cde-entry-status-tabs {
  flex: 0 0 auto;
  margin: 0;
}

.cde-entries-toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 10px;
  flex: 1 1 280px;
  min-width: 0;
}

.cde-entries-toolbar .date-stepper {
  flex: 0 1 auto;
  min-width: 0;
}

.cde-all-entries-check {
  flex: 0 0 auto;
  white-space: nowrap;
}

.cde-entries-panel .panel-header {
  gap: 12px;
}

.cde-entry-table tr.deleted-row {
  opacity: 0.72;
}

.last-trade-row {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.18fr) minmax(92px, 0.68fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-2), #fff 8%) 0%, var(--surface-2) 100%);
}

.last-trade-row.deleted-row {
  opacity: 0.72;
}

.last-trade-party,
.last-trade-desc,
.last-trade-value,
.last-trade-main,
.last-trade-detail {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.last-trade-party strong,
.last-trade-main strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.last-trade-party span,
.last-trade-main span,
.last-trade-desc span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-family: "JetBrains Mono", Consolas, monospace;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.last-trade-desc b,
.last-trade-detail b {
  overflow: hidden;
  color: var(--primary);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.last-trade-value {
  justify-items: end;
  text-align: right;
}

.last-trade-value strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.15;
}

.last-trade-row.sell-row .last-trade-desc b,
.last-trade-row.sell-row .last-trade-detail b {
  color: #16a34a;
}

.last-trade-actions {
  display: inline-flex;
  flex-shrink: 0;
  gap: 4px;
  align-items: center;
  padding: 3px;
  border: 1px solid color-mix(in srgb, var(--border), var(--primary) 18%);
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface), #fff 10%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.last-trade-actions .mini-button,
.last-trade-action-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.last-trade-actions .mini-button.danger {
  color: #dc2626;
  border-color: color-mix(in srgb, #fecaca, var(--border) 40%);
  background: color-mix(in srgb, #fff1f2, var(--surface) 30%);
}

.last-trade-actions .mini-button.danger:hover {
  color: #fff;
  background: #dc2626;
  border-color: #dc2626;
}

.last-trade-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.last-trade-pagination > div,
.last-trade-pagination-controls {
  display: flex;
  align-items: center;
  gap: 7px;
}

.last-trade-pagination strong {
  min-width: 44px;
  color: var(--text);
  text-align: center;
  font-family: "JetBrains Mono", Consolas, monospace;
}

.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.ledger-history {
  display: grid;
  gap: 10px;
}

.ledger-entry {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.ledger-entry strong,
.ledger-entry b {
  font-family: "JetBrains Mono", Consolas, monospace;
}

.ledger-entry span {
  color: var(--muted);
  font-size: 12px;
}

.ledger-empty {
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

dl {
  display: grid;
  gap: 12px;
  margin: 14px 0;
}

dl div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 800;
}

.notice {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.ledger-preview {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.ledger-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.ledger-group h3 {
  margin: 0;
  padding: 9px 10px;
  background: var(--primary);
  color: #ffffff;
  font-size: 12px;
  text-transform: uppercase;
}

.ledger-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 9px 10px;
  border-top: 1px solid var(--border);
}

.ledger-line span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.ledger-line strong {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  white-space: nowrap;
}

.ledger-line.positive strong {
  color: var(--primary);
}

.ledger-line.negative strong {
  color: var(--danger);
}

.vault-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.vault-card {
  display: grid;
  gap: 14px;
}

.vault-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.vault-card strong {
  font-size: 17px;
}

.report-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.report-tile {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 18px;
  text-align: left;
  color: var(--text);
}

.report-tile:hover {
  border-color: var(--primary);
}

.report-tile.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent), var(--surface) 86%);
}

.report-tile span {
  line-height: 1.5;
}

.report-output-panel {
  margin-top: 14px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.settings-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.settings-card span {
  color: var(--muted);
  font-size: 13px;
}

.print-settings-card {
  grid-column: span 2;
}

.db-backup-card {
  grid-column: span 2;
  border-color: rgba(14, 165, 233, 0.24);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(240, 249, 255, 0.7));
}

.settings-db-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reset-settings-card {
  grid-column: span 2;
  border-color: rgba(220, 38, 38, 0.18);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(254, 242, 242, 0.68));
}

.settings-reset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.reset-module-button {
  justify-content: center;
  min-height: 34px;
  font-size: 12px;
  font-weight: 900;
}

.reset-module-button.danger {
  color: #991b1b;
  border-color: rgba(220, 38, 38, 0.28);
  background: rgba(254, 226, 226, 0.72);
}

.reset-module-button.danger:hover {
  color: #fff;
  background: #991b1b;
  border-color: #991b1b;
}

.settings-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.printer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.printer-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.printer-list span {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.printer-list small {
  color: var(--muted);
  font-size: 10px;
}

.check-row {
  display: flex;
  grid-auto-flow: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.ghost-button.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger), var(--border) 45%);
}

.audit-toolbar {
  margin-bottom: 12px;
}

.account-detail-panel {
  margin-top: 14px;
}

.account-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.account-form-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.account-form-grid .check-row {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding-top: 20px;
}

.account-form-grid .wide-field {
  grid-column: span 2;
}

.broker-field {
  display: none !important;
}

.broker-field.show {
  display: grid !important;
}

.duplicate-warning {
  display: none;
  padding: 10px 12px;
  border: 1px solid rgba(248, 154, 42, 0.38);
  border-radius: 8px;
  background: rgba(248, 154, 42, 0.12);
  color: #8a530d;
  font-weight: 800;
}

.duplicate-warning.show {
  display: block;
}

.vault-detail-panel {
  display: none;
  margin-top: 14px;
}

.vault-statement-card {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  gap: 12px;
}

.vault-statement-toolbar {
  display: grid;
  grid-template-columns: minmax(140px, 170px) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.vault-statement-toolbar label {
  gap: 4px;
}

.vault-statement-tabs {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.vault-statement-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.vault-summary-cell {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
}

.vault-summary-cell span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.vault-summary-cell b,
.vault-summary-cell strong {
  overflow: hidden;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vault-summary-cell b::before {
  content: "Open ";
  color: var(--muted);
  font-family: Inter, system-ui, sans-serif;
  font-size: 9.5px;
}

.vault-summary-cell strong::before {
  content: "Close ";
  color: var(--muted);
  font-family: Inter, system-ui, sans-serif;
  font-size: 9.5px;
}

.vault-statement-wrap {
  max-height: 430px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.vault-statement-table {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.vault-statement-table th,
.vault-statement-table td {
  box-sizing: border-box;
  padding: 6px;
  border-right: 0;
  vertical-align: top;
  font-size: 11.5px;
}

.vault-statement-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.vault-statement-table tbody tr {
  background: var(--surface);
}

.vault-statement-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--surface-2), transparent 45%);
}

.vault-statement-table tbody tr:hover {
  background: rgba(91, 192, 222, 0.08);
}

.vault-statement-table th:first-child,
.vault-statement-table td:first-child {
  width: 10%;
}

.vault-statement-table th:nth-child(2),
.vault-statement-table td:nth-child(2) {
  width: 19%;
}

.vault-statement-table th:nth-child(3),
.vault-statement-table td:nth-child(3) {
  width: 30%;
}

.vault-statement-table th:nth-child(4),
.vault-statement-table td:nth-child(4),
.vault-statement-table th:nth-child(5),
.vault-statement-table td:nth-child(5),
.vault-statement-table th:nth-child(6),
.vault-statement-table td:nth-child(6) {
  width: 13.5%;
}

.vault-statement-table th:nth-child(4),
.vault-statement-table th:nth-child(5),
.vault-statement-table th:nth-child(6),
.vault-statement-table td:nth-child(4),
.vault-statement-table td:nth-child(5),
.vault-statement-table td:nth-child(6) {
  text-align: right;
}

.vault-statement-table td strong,
.vault-statement-table td b,
.vault-statement-table td small {
  display: block;
}

.vault-statement-table td small {
  color: var(--muted);
  font-size: 9.5px;
}

.vault-statement-table .statement-voucher {
  color: var(--ink);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 10px;
  font-weight: 900;
}

.statement-form b {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.statement-detail {
  color: var(--ink);
  line-height: 1.25;
  word-break: break-word;
}

.statement-money {
  overflow: hidden;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vault-balance-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.vault-balance-chips span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 10.5px;
  font-weight: 900;
  white-space: nowrap;
}

.vault-balance-chips b {
  color: var(--muted);
  font-family: Inter, system-ui, sans-serif;
  font-size: 10px;
  text-transform: uppercase;
}

.vault-statement-table .positive {
  color: var(--primary);
  font-weight: 900;
  white-space: nowrap;
}

.vault-statement-table .negative {
  color: var(--danger);
  font-weight: 900;
  white-space: nowrap;
}

.expense-tabs {
  width: min(1120px, 100%);
  margin: 0 auto 10px;
  justify-content: flex-start;
}

.expense-workspace {
  display: block;
  width: min(1120px, 100%);
  margin-inline: auto;
}

.expense-card {
  width: min(780px, 100%);
  margin-inline: auto;
}

.expense-log-panel {
  width: min(1120px, 100%);
  margin-inline: auto;
}

.expense-balance-panel {
  width: min(1120px, 100%);
  margin-inline: auto;
}

.expense-card[hidden] {
  display: none;
}

.expense-log-panel[hidden],
.expense-balance-panel[hidden] {
  display: none;
}

.expense-labor-form,
.expense-transaction-form,
.expense-daily-form {
  gap: 8px;
  align-items: end;
}

.expense-labor-form {
  grid-template-columns: minmax(210px, 1fr) 140px 160px auto;
}

.expense-transaction-form {
  grid-template-columns: minmax(210px, 1fr) 180px 140px;
}

.expense-daily-form {
  grid-template-columns: minmax(260px, 1fr) 140px;
}

.expense-labor-form label,
.expense-transaction-form label,
.expense-daily-form label {
  gap: 4px;
}

.expense-labor-form input,
.expense-labor-form select,
.expense-transaction-form input,
.expense-transaction-form select,
.expense-daily-form input,
.expense-daily-form select {
  min-height: 34px;
  padding: 6px 9px;
}

.expense-labor-form .primary-button {
  width: 150px;
  min-height: 36px;
  align-self: end;
  white-space: nowrap;
}

.expense-transaction-form .full-width,
.expense-daily-form .full-width {
  grid-column: 1 / -1;
}

.expense-balance-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.expense-balance-strip span {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.expense-balance-strip em {
  color: var(--muted);
  font-style: normal;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.expense-balance-strip b {
  overflow: hidden;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expense-labor-wrap,
.expense-log-wrap {
  max-height: 360px;
  overflow-y: auto;
  overflow-x: hidden;
}

.expense-ledger-tools {
  display: flex;
  gap: 10px;
  align-items: end;
  justify-content: flex-end;
}

.expense-ledger-tabs {
  align-items: center;
}

.expense-total-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 4px 8px;
  border: 1px solid rgba(239, 68, 68, 0.28);
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 950;
  vertical-align: middle;
}

.expense-balance-table tr.staff-salary-cleared {
  background: rgba(16, 185, 129, 0.12);
  box-shadow: inset 3px 0 0 var(--success);
}

.expense-balance-table tr.staff-salary-cleared td {
  border-color: rgba(16, 185, 129, 0.2);
}

.staff-balance-total {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  max-width: 560px;
}

.staff-balance-total span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.staff-balance-total b {
  color: var(--ink);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
}

.expense-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.expense-topbar .expense-tabs {
  flex: 1 1 auto;
  margin-bottom: 0;
}

.expense-month-filter {
  flex: 0 0 170px;
}

.expense-month-filter input {
  min-width: 0;
}

.expense-table {
  width: 100%;
  table-layout: fixed;
}

.expense-table th,
.expense-table td {
  padding: 7px 8px;
  font-size: 12px;
  vertical-align: middle;
}

.expense-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expense-table td small {
  color: var(--muted);
  font-size: 10.5px;
  white-space: normal;
}

.ledger-date-voucher,
.ledger-vault-cell {
  display: grid;
  gap: 2px;
  line-height: 1.12;
  min-width: 0;
}

.ledger-date-voucher strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 950;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-date-voucher small {
  color: var(--muted);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 10px;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-vault-cell span {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 900;
  text-transform: uppercase;
}

.ledger-vault-cell strong {
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 950;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expense-settlement-amounts {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.expense-settlement-amounts span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  line-height: 1.12;
}

.expense-settlement-amounts em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expense-settlement-amounts b {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 10.8px;
  font-weight: 950;
  white-space: nowrap;
}

.expense-settlement-amounts .settlement-total {
  margin-top: 2px;
  padding-top: 3px;
  border-top: 1px dashed var(--border);
}

.expense-table tr.expense-linked-row {
  background: rgba(91, 192, 222, 0.1);
  box-shadow: inset 3px 0 0 var(--primary);
}

.expense-table tr.expense-linked-row td {
  border-top: 1px solid rgba(91, 192, 222, 0.28);
  border-bottom: 1px solid rgba(91, 192, 222, 0.28);
  vertical-align: middle;
}

.expense-table .mini-button {
  width: 30px;
  height: 30px;
  padding: 5px 8px;
}

.expense-balance-table .compact-money-input {
  width: 100%;
  min-height: 30px;
  padding: 5px 7px;
  text-align: right;
}

.staff-select-cell,
.salary-clear-actions {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.staff-select-cell input {
  width: 15px;
  height: 15px;
}

.salary-clear-actions .mini-button {
  width: 28px;
  height: 28px;
}

.staff-bulk-clear {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(91, 192, 222, 0.26);
  border-radius: 8px;
  background: rgba(91, 192, 222, 0.08);
}

.staff-bulk-clear span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.receipt-cut {
  margin: 24px 0 20px;
  padding-top: 14px;
  border-top: 3px dashed #111;
}

.salary-slip-total span,
.salary-slip-total strong {
  font-weight: 950;
}

.salary-slip-total strong {
  font-size: 15px;
}

.salary-slip-payable {
  display: grid;
  gap: 6px;
  margin: 12px 0 6px;
  padding: 10px 4px 8px;
  border-top: 3px solid #111;
  border-bottom: 2px solid #111;
  text-align: center;
}

.salary-slip-payable span {
  color: #0f172a;
  font-size: 14px;
  font-weight: 950;
  text-transform: uppercase;
}

.salary-slip-payable strong {
  font-size: 30px;
  line-height: 1.1;
}

.salary-slip-head {
  display: grid;
  gap: 3px;
  margin: 0 0 12px;
  text-align: center;
}

.salary-slip-head h3 {
  margin: 0;
  font-size: 26px;
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1.05;
}

.salary-slip-head span,
.salary-slip-head small {
  color: #475569;
  font-size: 11px;
}

.salary-slip-section {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #94a3b8;
}

.salary-slip-history {
  display: grid;
  gap: 2px;
  margin: 5px 0 4px;
}

.salary-slip-history h4 {
  margin: 0;
  color: #0f172a;
  font-size: 11px;
  font-weight: 950;
}

.salary-slip-history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  padding: 1px 0;
  font-size: 11px;
}

.salary-slip-history-row em {
  overflow: hidden;
  color: #0f172a;
  font-style: normal;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.salary-slip-history-row strong {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11.5px;
  font-weight: 950;
}

.salary-slip-history-empty {
  color: #64748b;
  font-size: 10.5px;
}

@media (max-width: 980px) {
  .expense-labor-form,
  .expense-transaction-form,
  .expense-daily-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .expense-balance-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .expense-labor-form .primary-button {
    width: 100%;
  }
}

@media (max-width: 780px) {
  .vault-statement-toolbar {
    grid-template-columns: 1fr;
  }

  .vault-statement-summary {
    grid-template-columns: 1fr;
  }
}

.account-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.account-detail-panel .account-detail-grid:empty {
  display: none;
}

.account-stat {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.account-stat span {
  color: var(--muted);
  font-size: 12px;
}

.cde-helper-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr);
  gap: 10px;
  margin: 10px 0;
}

.cde-balance-card,
.cde-type-help {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.cde-balance-card strong,
.cde-type-help strong {
  color: var(--text);
}

.cde-balance-stack {
  display: grid;
  gap: 5px;
}

.cde-city-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  gap: 3px;
  align-items: stretch;
  min-height: 30px;
  padding: 4px;
  border: 1px solid rgba(135, 153, 171, 0.24);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 248, 252, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 4px 14px rgba(15, 23, 42, 0.06);
}

.cde-city-tabs .mini-button {
  width: 100%;
  height: 28px;
  min-height: 28px;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  font-weight: 900;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  white-space: nowrap;
}

.cde-city-tabs .mini-button.active {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.42);
  background: linear-gradient(135deg, #43c3e8, #2f7df2);
  box-shadow: 0 6px 16px rgba(47, 125, 242, 0.2);
}

.cde-city-tabs .mini-button:hover:not(.active) {
  background: rgba(67, 195, 232, 0.11);
  color: var(--text);
  transform: none;
}

.cde-balance-section {
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.cde-balance-section.positive {
  border-color: rgba(0, 137, 74, 0.28);
  background: linear-gradient(135deg, rgba(0, 150, 82, 0.13), rgba(255, 255, 255, 0.88));
}

.cde-balance-section.negative {
  border-color: rgba(128, 0, 32, 0.28);
  background: linear-gradient(135deg, rgba(128, 0, 32, 0.13), rgba(255, 255, 255, 0.9));
}

.cde-balance-section.neutral {
  background: var(--surface-2);
}

.cde-balance-section > span,
.cde-balance-lines,
.cde-type-help span {
  color: var(--muted);
  font-size: 12px;
}

.cde-balance-section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}

.cde-balance-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  width: 100%;
}

.cde-balance-title {
  display: block;
}

.cde-transfer-icon {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  flex: 0 0 18px;
  color: var(--primary);
  border-color: rgba(99, 196, 232, 0.35);
  border-radius: 999px;
  background: rgba(99, 196, 232, 0.12);
}

.cde-transfer-icon svg {
  width: 12px;
  height: 12px;
}

.cde-transfer-icon:hover {
  color: #ffffff;
  background: var(--primary);
}

.cde-balance-section > b,
.cde-balance-lines b {
  color: var(--text);
  font-family: "JetBrains Mono", Consolas, monospace;
}

.cde-balance-section-head b {
  text-align: right;
  white-space: nowrap;
}

.cde-balance-lines {
  display: grid;
  gap: 1px;
  margin-top: 1px;
}

.cde-balance-lines span {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11px;
}

.cde-balance-lines .cde-balance-empty {
  color: var(--muted);
  font-family: inherit;
}

.timeline {
  display: grid;
  gap: 12px;
}

.event {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

dialog {
  width: min(460px, calc(100vw - 28px));
  color: var(--text);
  background: transparent;
  border: 0;
  padding: 0;
}

dialog.wide-dialog {
  width: min(980px, calc(100vw - 28px));
}

#vaultStatementDialog {
  width: min(1120px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  overflow: visible;
}

#cityTransferDialog {
  width: min(560px, calc(100vw - 28px));
}

#physicalExecuteDialog {
  width: min(560px, calc(100vw - 28px));
}

#vaultSwitchDialog {
  width: min(620px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  overflow: visible;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.58);
}

.dialog-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

#pendingForwardDialog {
  width: min(380px, calc(100vw - 28px));
}

.vault-switch-card {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  gap: 14px;
  padding: 18px;
  border: 2px solid rgba(220, 38, 38, 0.55);
  background: linear-gradient(180deg, #fff7f7, var(--surface) 58%);
  box-shadow: 0 24px 70px rgba(127, 29, 29, 0.28);
}

.vault-switch-alert {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(220, 38, 38, 0.42);
  border-radius: 8px;
  background: rgba(220, 38, 38, 0.1);
  color: #7f1d1d;
}

.vault-switch-alert strong {
  font-size: 19px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.vault-switch-alert span,
.vault-switch-note {
  color: #7f1d1d;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.vault-switch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.vault-switch-grid div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.vault-switch-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.vault-switch-grid strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vault-switch-card .form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.vault-switch-card .form-actions button {
  min-width: 0;
  white-space: nowrap;
}

#confirmVaultSwitch {
  min-width: 178px;
}

@media (max-width: 520px) {
  .vault-switch-grid {
    grid-template-columns: 1fr;
  }

  .vault-switch-card .form-actions {
    justify-content: stretch;
  }

  .vault-switch-card .form-actions button {
    flex: 1 1 150px;
  }
}

.pending-transfer-card {
  position: relative;
  width: min(860px, calc(100vw - 28px));
  gap: 10px;
}

.transfer-party-results-overlay {
  z-index: 80;
  right: auto;
  max-height: 190px;
}

.pending-transfer-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.pending-transfer-summary div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.pending-transfer-summary span {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
}

.pending-transfer-summary strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-transfer-wrap {
  max-height: 340px;
  overflow: auto;
}

.pending-transfer-table {
  min-width: 760px;
}

.pending-transfer-table th,
.pending-transfer-table td {
  padding: 5px 6px;
  vertical-align: middle;
}

.pending-transfer-table th:first-child,
.pending-transfer-table td:first-child {
  width: 220px;
}

.pending-transfer-table th:nth-child(2),
.pending-transfer-table td:nth-child(2),
.pending-transfer-table th:nth-child(3),
.pending-transfer-table td:nth-child(3) {
  width: 110px;
}

.pending-transfer-table select,
.pending-transfer-table input {
  min-height: 32px;
  width: 100%;
  padding: 5px 7px;
}

.pending-transfer-table input.locked-rate {
  border-color: rgba(148, 163, 184, 0.38);
  background:
    linear-gradient(135deg, rgba(148, 163, 184, 0.12), rgba(255, 255, 255, 0.92));
  color: #64748b;
  cursor: not-allowed;
}

.pending-transfer-table input.editable-rate {
  border-color: rgba(14, 165, 233, 0.38);
  background: #fff;
  color: var(--text);
}

.pending-transfer-table td:nth-child(5) {
  min-width: 150px;
}

.pending-transfer-table td:nth-child(5) span,
.pending-transfer-table td:nth-child(5) small {
  display: block;
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
}

.pending-transfer-table td:nth-child(5) small {
  color: var(--muted);
  font-size: 10.5px;
}

.mini-segment {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(45px, 1fr));
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(135, 153, 171, 0.24);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 248, 252, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 4px 14px rgba(15, 23, 42, 0.06);
}

.transfer-mode-switch {
  min-width: 104px;
}

.mini-segment button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  box-shadow: none;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.transfer-mode-switch.same-rate button.active {
  color: #fff;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  box-shadow: 0 6px 14px rgba(22, 163, 74, 0.18);
}

.transfer-mode-switch.new-rate button.active {
  color: #fff;
  background: linear-gradient(135deg, #43c3e8, #2f7df2);
  box-shadow: 0 6px 14px rgba(14, 165, 233, 0.18);
}

.transfer-mode-switch button:not(.active):hover {
  background: rgba(67, 195, 232, 0.11);
  color: var(--text);
}

.pending-transfer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pending-transfer-footer strong {
  color: var(--muted);
  font-size: 12px;
}

.pending-transfer-footer strong.negative,
.pending-transfer-summary strong.negative,
.pending-transfer-table small.negative {
  color: #dc2626;
}

.pending-transfer-table small.positive {
  color: #16a34a;
}

.lucide-label-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.lucide-label-button svg {
  width: 15px;
  height: 15px;
}

.pending-forward-card label {
  display: grid;
  gap: 6px;
}

.pending-forward-card input {
  min-height: 36px;
}

.pending-forward-card small {
  color: var(--muted);
  font-weight: 800;
}

.physical-execute-card {
  gap: 14px;
}

.physical-execute-card [hidden] {
  display: none !important;
}

.physical-execute-card .panel-header {
  align-items: flex-start;
}

.physical-execute-heading {
  display: grid;
  gap: 6px;
}

.physical-execute-heading h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  line-height: 1.1;
}

.physical-execute-heading p {
  margin: 0;
  color: var(--muted);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
}

.physical-execute-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.physical-execute-chips span {
  padding: 5px 9px;
  border: 1px solid rgba(99, 196, 232, 0.26);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-2), transparent 8%);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.physical-execute-chips span.buy {
  color: #0f766e;
  background: rgba(20, 184, 166, 0.12);
}

.physical-execute-chips span.sell {
  color: #15803d;
  background: rgba(34, 197, 94, 0.12);
}

.execute-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.compact-choice-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.physical-adjust-rate {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(99, 196, 232, 0.24);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2), transparent 14%);
}

.physical-adjust-rate > span {
  color: var(--muted);
  font-weight: 800;
}

.locked-execute-weight {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid rgba(99, 196, 232, 0.26);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2), transparent 10%);
}

.locked-execute-weight span {
  color: var(--muted);
  font-weight: 700;
}

.locked-execute-weight strong {
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 14px;
}

.compact-slip-attach {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 0.55fr);
  gap: 8px;
}

.execution-preview-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(99, 196, 232, 0.28);
  border-radius: 8px;
  background: color-mix(in srgb, var(--brand-soft), var(--surface) 58%);
}

.execution-preview-box div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.execution-preview-box div:last-of-type {
  border-bottom: 0;
  padding-bottom: 0;
}

.execution-preview-box span {
  color: var(--muted);
}

.execution-preview-box strong {
  text-align: right;
}

.execution-preview-box p {
  margin: 2px 0 0;
  color: var(--text);
  font-weight: 700;
}

.receipt-dialog {
  max-width: 460px;
}

.receipt-dialog.report-preview {
  width: min(96vw, 980px);
  max-width: 980px;
}

#receiptDialog.report-preview-dialog {
  max-width: none;
  overflow: visible;
}

.receipt-dialog.report-preview .panel-header p {
  color: var(--muted);
}

.receipt-dialog.report-preview .receipt-paper {
  max-height: none;
  overflow: visible;
  border: 0;
  border-radius: 16px;
  background: #eef4f8;
  padding: 14px;
}

.receipt-dialog.report-preview .statement-print.capra-a4-report {
  width: min(100%, 794px);
  margin: 0 auto;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 22px 55px rgba(15, 23, 42, 0.18);
  padding: 22px;
}

#puritySlipDialog {
  width: min(420px, calc(100vw - 24px));
}

.receipt-paper {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fffdf7;
  color: #222;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
}

#puritySlipOutput {
  max-height: min(62vh, 620px);
  overflow: auto;
}

.receipt-paper h3 {
  margin: 0;
  text-align: center;
}

.slip-print-brand {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
  text-align: center;
}

.slip-print-brand strong {
  color: #111;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
}

.slip-print-brand span {
  display: block;
  width: 70%;
  height: 3px;
  margin: 0 auto;
  border-top: 2px solid #111;
  border-bottom: 1px solid #111;
}

.slip-print-brand em {
  color: #222;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.slip-print-summary {
  display: grid;
  border: 1px solid #111;
  border-radius: 4px;
  overflow: hidden;
}

.slip-print-summary div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 6px;
  border-bottom: 1px dotted #888;
}

.slip-print-summary div:last-child {
  border-bottom: 0;
}

.slip-print-summary span {
  color: #555;
}

.slip-print-summary strong {
  color: #111;
  text-align: right;
  overflow-wrap: anywhere;
}

.receipt-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dotted #c9c1b1;
  padding-bottom: 4px;
}

.trade-intl-rate {
  display: block;
  margin-top: 4px;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.trade-intl-rate.rate-up {
  color: #008f4c;
}

.trade-intl-rate.rate-down {
  color: #8b1e2d;
}

.cde-balance-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.voucher-print-card {
  color: #111827;
  font-family: "Segoe UI", Arial, sans-serif;
}

.voucher-print-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 2px solid #111827;
  padding-bottom: 8px;
}

.voucher-print-head strong {
  font-size: 20px;
  line-height: 1.1;
}

.voucher-print-head span,
.voucher-print-meta {
  color: #475569;
  font-size: 11px;
  font-weight: 800;
}

.voucher-print-meta {
  border-bottom: 1px dashed #94a3b8;
  padding: 6px 0 10px;
}

.voucher-print-hero {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  text-align: center;
}

.voucher-print-hero span {
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.voucher-print-hero strong {
  font-size: 18px;
}

.voucher-print-table td:first-child {
  width: 36%;
  color: #64748b;
  font-weight: 800;
}

.voucher-print-balance,
.voucher-print-note {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  border-top: 1px dashed #94a3b8;
  padding-top: 8px;
}

.voucher-print-balance span {
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.general-report-panel {
  margin-top: 12px;
}

.general-report-table-wrap {
  max-height: none;
  overflow-x: auto;
}

.general-report-table {
  min-width: 680px;
}

.general-report-table th,
.general-report-table td {
  padding: 7px 8px;
  font-size: 12px;
  vertical-align: middle;
}

.general-report-table tbody tr.positive-row {
  background: linear-gradient(90deg, rgba(22, 163, 74, 0.08), transparent);
}

.general-report-table tbody tr.negative-row {
  background: linear-gradient(90deg, rgba(220, 38, 38, 0.08), transparent);
}

.general-report-table td:nth-child(2),
.general-report-table td:nth-child(3),
.general-report-table td:nth-child(4) {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.general-report-table td:first-child small {
  display: block;
  margin-top: 2px;
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
}

.general-report-expand summary {
  cursor: pointer;
  color: #0f6f8f;
  font-size: 11px;
  font-weight: 900;
}

.general-report-detail-lines {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.general-report-detail-lines div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px dotted #cbd5e1;
  padding-top: 4px;
}

.general-report-detail-lines span {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.general-report-detail-lines strong {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11px;
}

.general-report-total-row {
  border-top: 2px solid #94a3b8;
  background: #eef6fb;
}

.general-pnl-section {
  display: grid;
  gap: 8px;
  margin: 12px auto 0;
}

.general-pnl-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.general-pnl-heading span,
.general-pnl-heading strong {
  border: 1px solid rgba(14, 116, 144, 0.18);
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.1);
  color: #075985;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: 0;
  padding: 5px 10px;
  text-transform: uppercase;
}

.general-pnl-heading strong {
  background: #fff;
  color: #64748b;
  text-transform: none;
}

.general-pnl-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.general-pnl-card {
  min-height: 116px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  padding: 10px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.general-pnl-metal-card {
  display: grid;
  gap: 8px;
}

.general-pnl-metal-card.gold {
  border-color: rgba(202, 138, 4, 0.28);
  background: linear-gradient(135deg, rgba(255, 251, 235, 0.98), rgba(255, 255, 255, 0.94));
}

.general-pnl-metal-card.silver {
  border-color: rgba(100, 116, 139, 0.24);
  background: linear-gradient(135deg, rgba(248, 250, 252, 0.98), rgba(240, 249, 255, 0.94));
}

.general-pnl-action-card {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 7px;
  border-color: rgba(14, 116, 144, 0.28);
  background: linear-gradient(135deg, rgba(236, 253, 245, 0.96), rgba(240, 249, 255, 0.96));
  text-align: center;
}

.general-pnl-action-card > span,
.general-pnl-card-head span {
  color: #64748b;
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}

.general-pnl-action-card > strong,
.general-pnl-card-head strong {
  color: #0f172a;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 15px;
  font-weight: 950;
}

.general-pnl-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(203, 213, 225, 0.75);
  padding-bottom: 6px;
}

.general-pnl-lines {
  display: grid;
  gap: 4px;
}

.general-pnl-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #64748b;
  font-size: 11px;
  font-weight: 850;
}

.general-pnl-line strong {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 950;
}

.general-pnl-divider {
  height: 1px;
  margin: 2px 0;
  background: linear-gradient(90deg, transparent, rgba(15, 23, 42, 0.32), transparent);
}

.general-pnl-status {
  width: max-content;
  max-width: 100%;
  margin: 10px auto 0;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 950;
}

.general-pnl-status.closed {
  background: rgba(34, 197, 94, 0.12);
  color: #047857;
}

.general-pnl-status.pending {
  background: rgba(14, 165, 233, 0.12);
  color: #0369a1;
}

.compact-report-confirm {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12px;
}

.general-report-print-cover,
.general-report-print-details {
  display: none;
}

.general-report-final-row {
  border-top: 2px solid #334155;
  background: #fff7ed;
}

.general-report-final-row.zero {
  background: #ecfdf5;
}

.general-report-final-row.difference {
  background: #fff1f2;
}

.general-report-detail {
  margin-top: 10px;
  border: 1px solid #d7e2eb;
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
}

.general-report-detail summary {
  cursor: pointer;
  font-weight: 900;
}

.receipt-table {
  min-width: 0;
  margin-top: 8px;
  white-space: normal;
}

.receipt-table th,
.receipt-table td {
  padding: 5px 4px;
  font-size: 11px;
}

.melting-receipt-simple {
  display: grid;
  gap: 4px;
}

.melting-receipt-simple h3 {
  margin: 0 0 4px;
  text-align: center;
}

.melting-receipt-section {
  margin: 7px 0 0;
  padding-top: 5px;
  border-top: 1px solid #111;
  font-size: 12px;
  text-align: left;
}

.melting-receipt-table {
  width: 100%;
  margin-top: 2px;
  border-collapse: collapse;
  table-layout: fixed;
}

.melting-receipt-table th,
.melting-receipt-table td {
  padding: 4px 3px;
  border-bottom: 1px dotted #c9c1b1;
  font-size: 10.5px;
}

.melting-receipt-table th:first-child,
.melting-receipt-table td:first-child {
  width: 20px;
}

.melting-receipt-table th:nth-child(2),
.melting-receipt-table td:nth-child(2) {
  width: 74px;
}

.melting-receipt-table td:last-child {
  overflow-wrap: anywhere;
}

.slip-print-table {
  border-top: 2px solid #111;
  border-bottom: 2px solid #111;
}

.slip-print-table th {
  border-bottom: 1px solid #111;
  color: #222;
  font-weight: 900;
}

.slip-print-card {
  display: grid;
  gap: 8px;
}

.slip-print-hero {
  display: grid;
  gap: 6px;
  padding: 2px 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.slip-print-card .slip-print-brand {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  text-align: left;
}

.slip-print-card .slip-print-brand span {
  display: inline;
  width: auto;
  height: auto;
  margin: 0;
  border: 0;
  color: #111;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 1.5px;
}

.slip-print-card .slip-print-brand strong {
  display: grid;
  gap: 3px;
  justify-items: end;
  max-width: 130px;
  color: #111;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.1;
  text-align: right;
  text-transform: uppercase;
}

.slip-print-customer {
  display: grid;
  gap: 2px;
  padding-top: 7px;
  border-top: 2px solid #111;
}

.slip-print-customer em,
.slip-print-total-grid span,
.slip-print-note span,
.slip-print-footer span {
  color: #555;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.slip-print-customer strong {
  color: #111;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.slip-print-total-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.slip-print-total-grid div,
.slip-print-note {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 7px;
  border: 1px solid #111;
  border-radius: 8px;
  background: #fff;
}

.slip-print-note strong {
  color: #111;
  font-size: 12px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.slip-print-status {
  width: fit-content;
  padding: 1px 7px;
  border: 1px solid #111;
  border-radius: 999px;
  color: #111;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.slip-print-total-grid div {
  border-color: #111;
  background: #111;
}

.slip-print-total-grid span,
.slip-print-total-grid strong {
  color: #fff;
}

.slip-print-total-grid strong {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.1;
}

.slip-print-card .slip-print-table {
  margin-top: 0;
  border-top: 2px solid #111;
  border-right: 0;
  border-bottom: 2px solid #111;
  border-left: 0;
  border-radius: 0;
  overflow: hidden;
}

.slip-print-card .slip-print-table th,
.slip-print-card .slip-print-table td {
  border-bottom: 1px solid #111;
}

.slip-print-card .slip-print-table tbody tr:last-child td {
  border-bottom: 0;
}

.slip-print-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
  border-top: 2px solid #111;
}

.slip-print-footer span {
  color: #111;
  font-size: 12px;
  line-height: 1.15;
}

.slip-print-footer strong {
  color: #111;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.15;
}

@media print {
  .statement-print .general-pnl-section {
    display: grid;
    margin-top: 10px;
    break-inside: avoid;
  }

  .statement-print .general-pnl-card {
    border: 1px solid #111;
    border-radius: 10px;
    background: #fff;
    box-shadow: none;
    padding: 8px;
  }

  .statement-print .general-pnl-heading span,
  .statement-print .general-pnl-heading strong,
  .statement-print .general-pnl-status {
    border: 1px solid #111;
    background: #fff;
    color: #111;
  }

  .statement-print .general-pnl-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .statement-print .general-pnl-action-card .primary-button {
    display: none;
  }

  .statement-print .general-pnl-divider {
    background: #111;
    height: 1px;
    margin: 3px 0;
  }

  .statement-print .general-report-expand {
    display: none;
  }

  .statement-print .general-report-print-details {
    display: grid;
  }

  .receipt-cut {
    margin: 30px 0 24px;
    padding-top: 16px;
    border-top: 3px dashed #111;
    break-inside: avoid;
  }

  .salary-slip-head h3 {
    font-size: 28px;
  }

  .salary-slip-payable strong {
    font-size: 32px;
  }

  .salary-slip-history-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    font-size: 11px;
  }

  .salary-slip-history-row strong {
    font-size: 11.5px;
  }

  body:has(#puritySlipDialog[open]) > *:not(#puritySlipDialog),
  body:has(#puritySlipDialog[open]) .toast,
  body:has(#puritySlipDialog[open]) .panel-header,
  body:has(#puritySlipDialog[open]) .form-actions {
    display: none;
  }

  body:has(#puritySlipDialog[open]) #puritySlipDialog {
    position: static;
    display: block;
    width: 80mm;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  body:has(#puritySlipDialog[open]) #puritySlipDialog form,
  body:has(#puritySlipDialog[open]) #puritySlipOutput {
    display: block;
    max-height: none;
    overflow: visible;
    padding: 0;
    border: 0;
    background: #fff;
  }

  body:has(#puritySlipDialog[open]) #puritySlipOutput {
    font-size: 10px;
  }

  dialog::backdrop {
    display: none;
  }
}

@media (max-width: 760px) {
  .general-pnl-card {
    border-radius: 14px;
    padding: 12px;
  }

  .general-pnl-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1180px) {
  .purity-layout {
    grid-template-columns: minmax(0, 1fr);
    width: min(100%, 936px);
    max-width: 936px;
  }

  .compact-form.purity-form-grid {
    grid-template-columns: minmax(90px, 0.65fr) minmax(0, 1.35fr) minmax(160px, 1fr);
  }
}

@media (max-width: 980px) and (min-width: 761px) {
  .compact-form.purity-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .purity-customer-field {
    grid-column: 1 / -1;
  }

  .compact-form.purity-form-grid > .purity-purity-pair {
    grid-column: 1 / -1;
  }

  .cde-workspace,
  .melting-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .melting-balance-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .purity-actions {
    gap: 6px;
  }

  .purity-slip-table table {
    min-width: 0;
  }
}

@media (max-width: 1120px) {
  .balance-report-layout {
    grid-template-columns: minmax(0, 760px);
    justify-content: center;
    width: min(100%, 780px);
  }

  .balance-report-settings-panel {
    position: static;
    order: -1;
  }

  .balance-report-settings-panel .balance-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .balance-report-settings-panel .category-checks {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .trade-layout {
    grid-template-columns: minmax(420px, 620px) minmax(292px, 304px);
    width: min(100%, 936px);
    min-width: 0;
  }

  .last-trades {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .last-trade-results,
  .last-trade-pagination {
    grid-column: 1 / -1;
  }

  .last-trade-tools {
    grid-template-columns: minmax(170px, 0.9fr) repeat(4, minmax(110px, 0.7fr));
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .sidebar {
    align-items: center;
    padding: 14px;
  }

  .brand div:last-child,
  .nav-item {
    font-size: 0;
  }

  .nav {
    width: 100%;
  }

  .nav-item {
    justify-content: center;
    gap: 0;
    padding: 0;
  }

  .nav-item span {
    font-size: 16px;
  }

  .sidebar-footer {
    display: none;
  }

  .kpi-grid,
  .dashboard-grid,
  .vault-grid,
  .report-grid {
    grid-template-columns: 1fr 1fr;
  }

  .trade-layout {
    grid-template-columns: minmax(380px, 1fr);
    overflow-x: visible;
  }

  .dashboard-hero {
    grid-template-columns: minmax(0, 1fr) 92px;
  }

  .dash-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .widget-card,
  .widget-card.large,
  .widget-card.full {
    grid-column: 1 / -1;
  }

  .pending-trade-card {
    grid-template-columns: 1fr 1fr;
  }

  .widget-card[data-widget-id="pendingTrades"] .pending-trade-card {
    grid-template-columns: minmax(0, 1fr) minmax(150px, auto);
  }

  .widget-card[data-widget-id="trades"] .recent-trade-card,
  .widget-card[data-widget-id="executedTrades"] .executed-trade-card {
    grid-template-columns: 1fr minmax(120px, auto);
  }

  .widget-card[data-widget-id="pendingTrades"] .pending-actions,
  .widget-card[data-widget-id="trades"] .recent-trade-value,
  .widget-card[data-widget-id="executedTrades"] .executed-value {
    justify-items: start;
    text-align: left;
  }

  .widget-card[data-widget-id="pendingTrades"] .pending-meta {
    grid-column: 1;
  }

  .widget-card[data-widget-id="pendingTrades"] .pending-actions,
  .widget-card[data-widget-id="trades"] .recent-trade-actions,
  .widget-card[data-widget-id="executedTrades"] .executed-actions {
    justify-content: flex-end;
  }

  .trading-heat-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .heat-card.total {
    grid-column: 1 / -1;
  }

  .today-trade-layout {
    grid-template-columns: 1fr;
  }

  .today-trade-row {
    grid-template-columns: minmax(82px, 0.8fr) minmax(108px, 1fr) minmax(108px, 1fr) minmax(82px, 0.75fr);
  }

  .pending-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .pending-actions {
    justify-content: flex-start;
  }

  .ranking-top {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .rank-score {
    grid-column: 1 / -1;
    border-top: 1px solid rgba(255, 255, 255, 0.45);
    border-left: 0;
  }

  .ranking-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trade-summary,
  .last-trades-panel,
  .wide {
    grid-column: 1 / -1;
  }

  .trade-summary,
  .last-trades-panel {
    grid-row: auto;
    position: static;
  }

  .last-trades {
    grid-template-columns: 1fr;
  }

  .cde-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cde-slip-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .mobile-menu-toggle {
    display: inline-grid;
    flex: 0 0 40px;
    place-items: center;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: block;
    background: rgba(15, 23, 42, 0.46);
    border: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 90;
    width: min(286px, 84vw);
    height: 100vh;
    align-items: stretch;
    overflow: hidden;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  body.nav-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar .brand div:last-child,
  .nav-item {
    font-size: 14px;
  }

  .nav {
    display: grid;
    width: 100%;
    overflow-y: auto;
  }

  .nav-item {
    justify-content: flex-start;
    gap: 10px;
    padding: 0 8px;
    font-size: 14px;
  }

  .nav-item span {
    font-size: 15px;
  }

  .sidebar-footer {
    display: grid;
  }

  .balance-report-layout {
    width: 100%;
  }

  .balance-report-main-panel .panel-header {
    align-items: stretch;
    gap: 8px;
  }

  .balance-report-main-panel .header-actions {
    justify-content: stretch;
  }

  .balance-report-main-panel .header-actions button {
    flex: 1 1 0;
  }

  .balance-report-settings-panel .balance-filters,
  .balance-report-settings-panel .category-checks {
    grid-template-columns: 1fr;
  }

  .balance-report-table {
    overflow-x: auto;
  }

  .balance-report-table table {
    min-width: 620px;
  }

  .topbar,
  .top-actions,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .topbar > .top-actions {
    grid-column: 1 / -1;
  }

  .live-rate-ticker {
    width: 100%;
    justify-content: space-between;
  }

  .top-user-card {
    width: 100%;
    min-width: 0;
  }

  .live-rate-chip {
    min-width: 0;
    flex: 1 1 0;
  }

  .kpi-grid,
  .dashboard-grid,
  .dash-strip,
  .dashboard-board,
  .vault-grid,
  .report-grid,
  .trade-layout,
  .purity-layout,
  .cde-workspace,
  .melting-workspace,
  .form-grid,
  .account-form-grid {
    grid-template-columns: 1fr;
  }

  .account-form-grid .wide-field {
    grid-column: span 1;
  }

  .cde-slip-field {
    grid-column: 1 / -1;
  }

  .trade-layout {
    overflow-x: visible;
  }

  .purity-form-grid,
  .melting-form-grid,
  .compact-form.purity-form-grid {
    grid-template-columns: 1fr;
  }

  .melting-form-actions,
  .melting-slip-attach {
    grid-template-columns: 1fr;
  }

  .melting-balance-panel {
    grid-template-columns: 1fr;
  }

  #paResult {
    grid-template-columns: 1fr;
  }

  .trade-main,
  .trade-summary,
  .last-trades-panel {
    min-width: 0;
  }

  .touch-options,
  .touch-options.four,
  .touch-options.five,
  .touch-options.six {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trade-main .form-grid > .touch-field.wide-field:first-child,
  .trade-main .form-grid > .touch-field.wide-field:first-child + .trade-party-field,
  .trade-main .trade-choice-field,
  .trade-main .tt-quantity-field.show {
    grid-column: 1 / -1;
  }

  .trade-main .touch-options {
    width: 100%;
  }

  .trade-main .touch-options.two,
  .trade-main #metalTabs,
  .trade-main .trade-side-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trade-main .touch-options.four,
  .trade-main .trade-city-field .touch-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trade-main .touch-options.six,
  .trade-main .trade-item-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .last-trade-tools,
  .last-trade-row {
    grid-template-columns: 1fr;
  }

  .last-trade-value {
    justify-items: start;
    text-align: left;
  }

  .last-trade-actions {
    justify-content: flex-start;
    width: fit-content;
  }

  .inventory-summary {
    grid-template-columns: 1fr;
  }

  .inventory-detail strong {
    text-align: left;
  }

  .slip-attach {
    grid-template-columns: 1fr 1fr;
  }

  .slip-details {
    grid-template-columns: 1fr;
  }

  .tt-quantity-row {
    grid-template-columns: 1fr;
  }

  .future-date-row {
    grid-template-columns: 1fr 1fr;
  }

  .future-date-row input {
    grid-column: 1 / -1;
  }

  .cde-helper-grid,
  .cde-balance-totals,
  .cde-entry-pairs,
  .cde-notes-actions {
    grid-template-columns: 1fr;
  }

  .cde-note-field,
  .cde-notes-actions #cdeVoucherLabel,
  .cde-notes-actions #toggleCdeForm,
  .cde-notes-actions #cancelCdeEdit,
  .cde-notes-actions #saveCde {
    grid-column: 1;
  }

  .cde-ledger-transfer-field {
    grid-template-columns: 1fr;
  }

  .cde-account-transfer-field {
    grid-template-columns: 1fr;
  }

  .cde-account-transfer-preview {
    grid-column: 1;
  }

  .cde-pair-card {
    grid-template-columns: 1fr;
  }

  .balance-filters {
    grid-template-columns: 1fr;
  }

  .balance-report-controls {
    justify-items: stretch;
  }

  .balance-report-actions {
    justify-content: flex-start;
  }

  .balance-mode-switch {
    width: 132px;
  }

  .dashboard-command,
  .segmented,
  .widget-actions {
    align-items: stretch;
    flex-direction: column;
  }

  #widgetPicker {
    width: 100%;
  }

  .hero-copy h2 {
    font-size: 30px;
  }

  .ranking-grid {
    grid-template-columns: 1fr;
  }

  .ranking-top {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .rank-party strong {
    font-size: 22px;
  }

  .hero-radar {
    display: none;
  }

  .dashboard-hero {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 14px;
  }

  .ticker {
    justify-content: space-between;
  }

  .event {
    grid-template-columns: 1fr;
  }

  .ledger-entry {
    grid-template-columns: 1fr;
  }

  .pending-trade-card {
    grid-template-columns: 1fr;
  }

  .today-trade-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .today-trade-row,
  .today-trade-row-head {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .today-trade-row-head {
    display: none;
  }

  .today-trade-row .buy-cell,
  .today-trade-row .sell-cell {
    border-radius: 8px;
  }

  .recent-adjustment-row {
    grid-template-columns: 20px 1fr;
  }

  .recent-adjustment-row b,
  .recent-adjustment-row em {
    grid-column: 2;
  }

  .widget-card[data-widget-id="pendingTrades"] .pending-trade-card,
  .widget-card[data-widget-id="trades"] .recent-trade-card,
  .widget-card[data-widget-id="executedTrades"] .executed-trade-card {
    grid-template-columns: 1fr;
  }

  .widget-card[data-widget-id="pendingTrades"] .pending-actions,
  .widget-card[data-widget-id="trades"] .recent-trade-actions,
  .widget-card[data-widget-id="executedTrades"] .executed-actions,
  .dashboard-pagination {
    justify-content: flex-start;
  }
}

@media (max-width: 800px) {
  .compact-form.purity-form-grid {
    grid-template-columns: 1fr;
  }
}

.closing-shell,
.pnl-shell {
  width: min(100%, 1040px);
  margin: 0 auto;
}

.closing-shell,
.pnl-shell {
  display: grid;
  gap: 12px;
}

.closing-header,
.closing-tools,
.closing-footer,
.pnl-ledger-panel .panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.closing-header,
.pnl-ledger-panel .panel-header {
  justify-content: space-between;
}

.pnl-form-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}

.pnl-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pnl-title-line h2 {
  margin: 0;
  white-space: nowrap;
}

.compact-metal-tabs {
  flex-wrap: nowrap;
}

.compact-metal-tabs .pending-tab {
  min-height: 30px;
  padding: 5px 12px;
}

.capsule-toggle,
.pending-tabs,
.segmented,
.balance-mode-switch,
.dashboard-metal-toggle,
.global-metal-toggle,
.pending-metal-toggle,
.pending-queue-toggle,
.manage-filter-tabs {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px;
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  border: 1px solid rgba(135, 153, 171, 0.24);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 248, 252, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 8px 22px rgba(15, 23, 42, 0.07);
}

.manage-filter-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-radius: 12px;
}

.capsule-toggle button,
.pending-tabs > .pending-tab,
.pending-metal-toggle > .pending-tab,
.pending-queue-toggle > .pending-tab,
.manage-filter-tabs > .pending-tab,
.segmented > .segment,
.balance-mode-switch button,
.dashboard-metal-toggle .segment,
.global-metal-toggle button {
  min-height: 34px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  box-shadow: none;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.manage-filter-tabs > .pending-tab {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
}

.capsule-toggle button.active,
.pending-tabs > .pending-tab.active,
.pending-metal-toggle > .pending-tab.active,
.pending-queue-toggle > .pending-tab.active,
.manage-filter-tabs > .pending-tab.active,
.segmented > .segment.active,
.balance-mode-switch button.active,
.dashboard-metal-toggle .segment.active,
.global-metal-toggle button.active {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.42);
  background: linear-gradient(135deg, #43c3e8, #2f7df2);
  box-shadow: 0 9px 22px rgba(47, 125, 242, 0.22);
}

.capsule-toggle button:hover,
.pending-tabs > .pending-tab:hover,
.pending-metal-toggle > .pending-tab:hover,
.pending-queue-toggle > .pending-tab:hover,
.manage-filter-tabs > .pending-tab:hover,
.segmented > .segment:hover,
.balance-mode-switch button:hover,
.dashboard-metal-toggle .segment:hover,
.global-metal-toggle button:hover {
  color: var(--text);
  background: rgba(67, 195, 232, 0.11);
  transform: none;
}

.capsule-toggle button.active:hover,
.pending-tabs > .pending-tab.active:hover,
.pending-metal-toggle > .pending-tab.active:hover,
.pending-queue-toggle > .pending-tab.active:hover,
.manage-filter-tabs > .pending-tab.active:hover,
.segmented > .segment.active:hover,
.balance-mode-switch button.active:hover,
.dashboard-metal-toggle .segment.active:hover,
.global-metal-toggle button.active:hover {
  color: #ffffff;
  background: linear-gradient(135deg, #43c3e8, #2f7df2);
  transform: none;
}

.balance-metal-toggle {
  min-width: min(100%, 290px);
}

.balance-metal-toggle button {
  flex: 1 1 0;
  min-width: 78px;
}

.balance-mode-switch {
  grid-template-columns: none;
}

.balance-mode-switch::before {
  display: none;
}

.balance-mode-switch,
.dashboard-metal-toggle,
.global-metal-toggle,
.compact-metal-tabs,
.balance-metal-toggle {
  flex-wrap: nowrap;
}

.balance-report-settings-panel .balance-mode-switch,
.global-metal-toggle {
  width: 100%;
}

.balance-report-settings-panel .balance-mode-switch button,
.global-metal-toggle button,
.dashboard-metal-toggle .segment {
  flex: 1 1 0;
}

.dark .capsule-toggle,
.dark .pending-tabs,
.dark .segmented,
.dark .balance-mode-switch,
.dark .dashboard-metal-toggle,
.dark .pending-metal-toggle,
.dark .pending-queue-toggle,
.dark .manage-filter-tabs,
.dark .global-metal-toggle {
  border-color: rgba(148, 163, 184, 0.22);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 22px rgba(0, 0, 0, 0.22);
}

.sidebar .global-metal-toggle {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.sidebar .global-metal-toggle button {
  color: #aeb9c3;
}

.sidebar .global-metal-toggle button:hover:not(.active) {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
}

.closing-tools {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.closing-tools .date-filter,
.pnl-form-panel .date-filter {
  min-width: 164px;
}

.closing-stat-grid,
.closing-source-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.closing-stat,
.closing-source-card {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.closing-stat span,
.closing-source-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.closing-stat strong,
.closing-source-card strong {
  display: block;
  margin-top: 2px;
  font-size: 15px;
  font-weight: 900;
}

.closing-stat small,
.closing-source-card small,
.closing-status {
  color: var(--muted);
  font-size: 12px;
}

.closing-subline {
  display: inline-block;
  margin-top: 2px;
  color: #007b45;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11px;
  font-weight: 900;
}

.closing-stat.positive-card {
  border-color: rgba(13, 156, 84, 0.28);
  background: linear-gradient(135deg, rgba(50, 196, 126, 0.1), var(--surface));
}

.closing-stat.negative-card {
  border-color: rgba(233, 87, 87, 0.32);
  background: linear-gradient(135deg, rgba(233, 87, 87, 0.1), var(--surface));
}

.closing-stat.actual-closing-card {
  border-color: rgba(99, 196, 232, 0.35);
  background: linear-gradient(135deg, rgba(99, 196, 232, 0.12), var(--surface));
}

.actual-closing-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(99, 196, 232, 0.08), rgba(255, 255, 255, 0.94));
}

.actual-closing-preview div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: #fff;
}

.actual-closing-preview span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.actual-closing-preview b {
  font-size: 12px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.actual-closing-preview small {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.35;
}

.actual-closing-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.actual-closing-grid label {
  min-width: 0;
  gap: 4px;
  font-size: 11px;
}

.actual-closing-grid input {
  min-width: 0;
  min-height: 36px;
  padding: 7px 8px;
}

.actual-closing-grid [hidden] {
  display: none !important;
}

.actual-preview-row.system {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), #fff);
}

.actual-preview-row.actual {
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.1), #fff);
}

.actual-preview-row.diff {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), #fff);
}

#actualClosingDialog {
  width: min(660px, calc(100vw - 28px));
}

#actualClosingDialog .dialog-card {
  width: min(640px, calc(100vw - 26px));
  overflow: hidden;
}

.closing-detail-wrap,
.pnl-table-wrap {
  margin-top: 10px;
}

.closing-detail-wrap th,
.closing-detail-wrap td {
  padding: 6px 8px;
  font-size: 12px;
}

.closing-detail-wrap small,
.closing-detail-wrap td:nth-child(2) {
  font-size: 11px;
}

.closing-total-row {
  background: rgba(99, 196, 232, 0.12);
}

.closing-total-row td {
  border-top: 2px solid rgba(99, 196, 232, 0.28);
  font-weight: 900;
}

.closing-adjustment-panel {
  margin-top: 8px;
  padding: 7px;
  border: 1px solid rgba(99, 196, 232, 0.22);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(99, 196, 232, 0.08), rgba(255, 255, 255, 0.94));
}

.compact-panel-header {
  align-items: center;
  margin-bottom: 5px;
}

.compact-panel-header .ghost-button {
  min-height: 30px;
  padding: 5px 10px;
  background: rgba(99, 196, 232, 0.16);
  border-color: rgba(99, 196, 232, 0.42);
  color: var(--accent-strong);
  font-weight: 900;
}

.compact-panel-header h3 {
  margin: 0;
  font-size: 15px;
}

.closing-adjustment-form {
  grid-template-columns: 170px 170px 140px 140px 140px;
  gap: 8px;
}

.closing-adjustment-form .full-width {
  grid-column: 1 / -1;
}

.closing-adjustment-wrap {
  margin-top: 4px;
  border-color: rgba(99, 196, 232, 0.28);
  background: rgba(255, 255, 255, 0.72);
}

.closing-adjustment-wrap table {
  min-width: 650px;
}

.closing-adjustment-wrap th {
  padding: 5px 7px;
  background: rgba(99, 196, 232, 0.12);
  color: #506070;
}

.closing-adjustment-wrap td {
  padding: 5px 7px;
}

.closing-adjustment-wrap tbody tr:nth-child(odd) {
  background: rgba(46, 204, 113, 0.06);
}

.closing-adjustment-wrap tbody tr:nth-child(even) {
  background: rgba(99, 196, 232, 0.06);
}

.closing-adjustment-help {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.closing-adjustment-rate-input {
  min-height: 28px;
  max-width: 92px;
  padding: 3px 7px;
  border-color: rgba(99, 196, 232, 0.42);
  background: #fff;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-weight: 800;
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
}

.closing-source-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.closing-source-inline span {
  color: var(--muted);
  font-size: 11px;
}

.closing-source-inline b {
  font-family: "JetBrains Mono", Consolas, monospace;
}

.closing-footer {
  justify-content: space-between;
  margin-top: 10px;
}

.pnl-form-grid {
  grid-template-columns: 120px 140px minmax(180px, 1fr);
}

.pnl-form-grid .full-width {
  grid-column: 1 / -1;
}

.pnl-ledger-panel {
  margin-top: 0;
}

.compact-dialog {
  width: min(520px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.compact-dialog::backdrop {
  background: rgba(15, 23, 42, 0.44);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.dialog-head h3 {
  margin: 0;
  font-size: 16px;
}

.dialog-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.closing-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 980px) {
  .users-admin-layout {
    grid-template-columns: 1fr;
  }

  .manage-entries-layout {
    grid-template-columns: 1fr;
  }

  .manage-filter-panel {
    order: -1;
  }

  .manage-filter-tabs.vertical-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .closing-stat-grid,
  .closing-source-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pnl-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .closing-adjustment-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actual-closing-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actual-closing-preview {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .closing-stat-grid,
  .closing-source-grid,
  .pnl-form-grid,
  .closing-adjustment-form {
    grid-template-columns: 1fr;
  }

  .closing-tools,
  .pnl-form-panel .panel-header,
  .closing-footer {
    align-items: stretch;
    flex-direction: column;
    flex-wrap: wrap;
  }

  .actual-closing-grid {
    grid-template-columns: 1fr;
  }
}

/* Premium UI system refresh */
:root {
  --bg: #edf3f8;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-2: #f7fafc;
  --border: rgba(135, 153, 171, 0.28);
  --text: #172033;
  --muted: #68778a;
  --soft: #9aa8b8;
  --primary: #34b8e6;
  --primary-2: #2563eb;
  --secondary: #7c3aed;
  --success: #0f9f6e;
  --warning: #f59e0b;
  --danger: #e5484d;
  --info: #0ea5e9;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 10px 24px rgba(15, 23, 42, 0.08);
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 30px 80px rgba(15, 23, 42, 0.14);
  --focus-ring: 0 0 0 4px rgba(52, 184, 230, 0.16);
  --glass: rgba(255, 255, 255, 0.78);
  --sidebar: #131b2a;
  --sidebar-2: #0d1320;
  --ink: #172033;
}

.dark {
  --bg: #111827;
  --surface: rgba(27, 37, 54, 0.94);
  --surface-2: #162033;
  --border: rgba(148, 163, 184, 0.22);
  --text: #f7fbff;
  --muted: #b8c4d3;
  --soft: #8795a8;
  --primary: #38bdf8;
  --primary-2: #60a5fa;
  --secondary: #a78bfa;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.22);
  --shadow-sm: 0 12px 30px rgba(0, 0, 0, 0.28);
  --shadow: 0 20px 56px rgba(0, 0, 0, 0.34);
  --shadow-lg: 0 36px 90px rgba(0, 0, 0, 0.46);
  --glass: rgba(27, 37, 54, 0.78);
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 16% -8%, rgba(52, 184, 230, 0.22), transparent 30%),
    radial-gradient(circle at 86% 6%, rgba(124, 58, 237, 0.13), transparent 28%),
    linear-gradient(135deg, #f8fbfe 0%, var(--bg) 48%, #eaf1f7 100%);
  font-size: 14px;
  line-height: 1.45;
  text-rendering: optimizeLegibility;
}

.dark body {
  background:
    radial-gradient(circle at 18% -6%, rgba(56, 189, 248, 0.16), transparent 32%),
    radial-gradient(circle at 86% 8%, rgba(167, 139, 250, 0.12), transparent 30%),
    linear-gradient(135deg, #0d1320 0%, #111827 48%, #0f172a 100%);
}

.main {
  padding: 18px;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 28%),
    linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  box-shadow: 12px 0 36px rgba(15, 23, 42, 0.18);
}

.brand-mark {
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 12px 26px rgba(52, 184, 230, 0.28);
}

.nav-item,
.nav-group,
.global-metal-toggle,
.sidebar-footer select,
.working-date-row input {
  border-radius: var(--radius-md);
}

.nav-item {
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.nav-item.active,
.nav-item:hover {
  transform: translateX(2px);
  background: linear-gradient(135deg, rgba(52, 184, 230, 0.22), rgba(96, 165, 250, 0.13));
  border-color: rgba(125, 211, 252, 0.38);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: -18px -18px 10px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(135, 153, 171, 0.2);
  background: color-mix(in srgb, var(--bg), transparent 12%);
  backdrop-filter: blur(18px);
}

.topbar .eyebrow {
  margin: 0;
  font-size: 9px;
  line-height: 1;
}

.topbar .page-title-row h1 {
  line-height: 1.1;
}

.topbar-version-line {
  margin: 2px 0 0;
}

.topbar .primary-button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.topbar #themeToggle {
  width: 36px;
  height: 36px;
  min-height: 36px;
}

@media screen and (min-width: 761px) {
  body:has(#trade.view.active) .topbar,
  body:has(#cde.view.active) .topbar {
    padding-block: 6px;
    margin-bottom: 8px;
  }

  body:has(#trade.view.active) .topbar-eyebrow,
  body:has(#cde.view.active) .topbar-eyebrow {
    display: none;
  }

  body:has(#trade.view.active) .topbar-title-wrap,
  body:has(#cde.view.active) .topbar-title-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 8px;
    row-gap: 0;
  }

  body:has(#trade.view.active) .page-title-row,
  body:has(#cde.view.active) .page-title-row {
    grid-column: 1;
    min-width: 0;
  }

  body:has(#trade.view.active) .topbar-version-line,
  body:has(#cde.view.active) .topbar-version-line {
    grid-column: 2;
    margin: 0;
    align-self: center;
  }

  body:has(#trade.view.active) .top-user-card,
  body:has(#cde.view.active) .top-user-card,
  body:has(#trade.view.active) .top-trade-card,
  body:has(#cde.view.active) .top-trade-card {
    min-height: 38px;
    padding-block: 4px;
  }

  body:has(#trade.view.active) .live-rate-ticker,
  body:has(#cde.view.active) .live-rate-ticker {
    min-height: 34px;
    padding-block: 3px;
  }
}

h1 {
  font-size: clamp(18px, 1.5vw, 22px);
  font-weight: 800;
  letter-spacing: -0.015em;
}

.update-progress-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(620px, calc(100vw - 28px));
  padding: 12px 16px;
  border: 1px solid rgba(99, 196, 232, 0.42);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(231, 247, 253, 0.94)),
    var(--surface);
  box-shadow: 0 18px 60px rgba(31, 45, 58, 0.18);
  color: var(--text);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.update-progress-banner::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(99, 196, 232, 0.44);
  animation: updatePulse 1.4s infinite;
}

.update-progress-banner strong {
  white-space: nowrap;
}

.update-progress-banner span {
  color: var(--muted);
  font-size: 0.88rem;
}

.update-progress-banner[hidden] {
  display: none;
}

.update-progress-banner[data-state="complete"] {
  border-color: rgba(34, 197, 94, 0.42);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(236, 253, 245, 0.94)),
    var(--surface);
}

.update-progress-banner[data-state="complete"]::before {
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
  animation: updateCompletePulse 1.1s infinite;
}

@keyframes updateCompletePulse {
  70% {
    box-shadow: 0 0 0 16px rgba(34, 197, 94, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

@keyframes updatePulse {
  70% {
    box-shadow: 0 0 0 12px rgba(99, 196, 232, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(99, 196, 232, 0);
  }
}

h2 {
  font-size: clamp(14px, 1.1vw, 17px);
  font-weight: 750;
}

.eyebrow {
  color: var(--primary-2);
  letter-spacing: 0.08em;
  font-weight: 850;
}

.dashboard-hero {
  min-height: 152px;
  border: 1px solid rgba(125, 211, 252, 0.32);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.94), rgba(22, 37, 62, 0.92)),
    linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.dashboard-hero::after {
  opacity: 0.52;
}

.hero-copy h2 {
  font-size: clamp(25px, 3.1vw, 42px);
  text-transform: none;
  font-weight: 900;
}

.dashboard-command,
.today-trade-summary,
.panel,
.widget-card,
.neo-stat,
.metric,
.kpi-card,
.report-tile,
.account-card,
.vault-card,
.closing-stat,
.closing-source-card {
  border-color: var(--border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.66)),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.dark .dashboard-command,
.dark .today-trade-summary,
.dark .panel,
.dark .widget-card,
.dark .neo-stat,
.dark .metric,
.dark .kpi-card,
.dark .report-tile,
.dark .account-card,
.dark .vault-card,
.dark .closing-stat,
.dark .closing-source-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018)),
    var(--surface);
}

.panel,
.widget-card {
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.panel:hover,
.widget-card:hover {
  border-color: rgba(52, 184, 230, 0.28);
  box-shadow: var(--shadow);
}

.dashboard-board,
.dash-strip,
.kpi-grid,
.vault-grid,
.report-grid,
.accounts-grid {
  gap: 14px;
}

.primary-button,
.ghost-button,
.icon-button,
.mini-button,
button {
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.primary-button {
  border: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.2);
}

.primary-button:hover,
.ghost-button:hover,
.icon-button:hover,
.mini-button:hover {
  transform: translateY(-1px);
}

.ghost-button,
.icon-button,
.mini-button {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-xs);
}

.dark .ghost-button,
.dark .icon-button,
.dark .mini-button {
  background: rgba(255, 255, 255, 0.045);
}

.global-metal-toggle button.active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #ffffff;
  box-shadow: 0 14px 28px rgba(52, 184, 230, 0.22);
}

select,
input,
textarea {
  border-color: var(--border);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.58)),
    var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.54), var(--shadow-xs);
}

.dark select,
.dark input,
.dark textarea {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
    var(--surface-2);
}

select:focus,
input:focus,
textarea:focus {
  border-color: rgba(52, 184, 230, 0.72);
  box-shadow: var(--focus-ring);
}

.table-wrap,
.accounts-table-wrap,
.balance-report-table,
.cde-entry-table,
.melting-table-wrap,
.expense-table,
.vault-statement-table {
  border-radius: var(--radius-lg);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}

table {
  background: transparent;
}

th {
  color: #526175;
  background: color-mix(in srgb, var(--surface-2), #ffffff 32%);
  font-weight: 850;
}

td {
  border-color: rgba(135, 153, 171, 0.2);
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover {
  background: rgba(52, 184, 230, 0.055);
}

.status,
.badge,
.voucher {
  border-radius: 999px;
}

.ledger-empty,
.empty-state {
  border: 1px dashed rgba(52, 184, 230, 0.3);
  border-radius: var(--radius-lg);
  background: rgba(52, 184, 230, 0.055);
}

.detail-section-title {
  margin: 18px 0 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.closing-adjustment-type {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.closing-detail-button {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 999px;
}

.closing-detail-button svg {
  width: 15px;
  height: 15px;
}

dialog,
.dialog-card,
.login-card {
  border-radius: var(--radius-xl);
}

.dialog-card,
.login-card {
  box-shadow: var(--shadow-lg);
}

.last-trade-row,
.pending-trade-card,
.recent-trade-card,
.executed-trade-card,
.holo-row,
.ledger-row {
  border-radius: var(--radius-md);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.last-trade-row:hover,
.pending-trade-card:hover,
.recent-trade-card:hover,
.executed-trade-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

@media (max-width: 760px) {
  .main {
    padding: 12px;
  }

  .topbar {
    margin: -12px -12px 12px;
    padding: 12px;
  }

  .dashboard-hero {
    min-height: 138px;
    border-radius: var(--radius-lg);
  }

  .panel,
  .widget-card,
  .dashboard-command,
  .today-trade-summary {
    border-radius: var(--radius-lg);
  }
}

/* Responsive and print hardening layer. Keep this shared; avoid page-only overflow hacks. */
.app-shell,
.main,
.view,
.panel,
.widget-card,
.dashboard-board,
.dashboard-grid,
.dash-strip,
.kpi-grid,
.vault-grid,
.accounts-grid,
.report-grid,
.trade-layout,
.cde-form-grid,
.form-grid,
.compact-form,
.pnl-form-grid,
.account-form-grid,
.balance-report-layout,
.general-report-body,
.general-report,
.table-wrap,
.dialog-card {
  min-width: 0;
}

.main,
.view,
.panel,
.widget-card,
.dashboard-board,
.dashboard-grid,
.dash-strip,
.kpi-grid,
.vault-grid,
.accounts-grid,
.report-grid {
  max-width: 100%;
}

.table-wrap,
.accounts-table-wrap,
.balance-report-table,
.general-report-table-wrap,
.cde-entry-table,
.melting-table-wrap,
.expense-table,
.vault-statement-table,
.pnl-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table,
.accounts-table-wrap table,
.balance-report-table table,
.general-report-table-wrap table,
.cde-entry-table table,
.melting-table-wrap table,
.expense-table table,
.vault-statement-table table,
.pnl-table-wrap table {
  max-width: none;
}

.panel-header,
.topbar,
.top-actions,
.header-actions,
.form-actions:not(.purity-actions),
.toolbar,
.pending-toolbar,
.balance-title-row,
.closing-header,
.closing-tools,
.pnl-ledger-panel .panel-header {
  min-width: 0;
  flex-wrap: wrap;
}

.topbar > div,
.panel-header > div,
.page-title-row,
.hero-copy,
.trade-party-field,
.touch-field,
.last-trade-row,
.pending-trade-card,
.recent-trade-card,
.executed-trade-card,
.ledger-row,
.holo-row {
  min-width: 0;
}

.panel h2,
.panel h3,
.page-title-row h1,
.hero-copy h2,
.receipt-line strong,
.voucher-print-head strong,
.status,
.badge,
.voucher {
  overflow-wrap: anywhere;
}

.dialog-card {
  width: 100%;
  max-width: 100%;
  max-height: min(90vh, 900px);
  overflow-x: clip;
  overflow-y: visible;
}

.receipt-dialog.report-preview {
  --dialog-width: 1040px;
}

#confirmDialog {
  width: min(520px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  overflow: visible;
}

.confirm-dialog-card {
  gap: 12px;
  min-height: 0;
  padding: clamp(18px, 3vw, 24px);
  overflow: visible;
}

.confirm-dialog-card .panel-header {
  align-items: flex-start;
  flex-wrap: nowrap;
  gap: 12px;
  margin-bottom: 0;
}

.confirm-dialog-card .panel-header > div {
  min-width: 0;
}

.confirm-dialog-card .panel-header .icon-button {
  flex: 0 0 auto;
}

#confirmTitle {
  margin: 0;
  line-height: 1.12;
}

#confirmMessage {
  max-width: 100%;
  margin: 8px 0 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.confirm-dialog-card .form-actions {
  justify-content: flex-end;
  margin-top: 2px;
}

.confirm-dialog-card .form-actions button {
  flex: 0 1 auto;
  min-width: 104px;
}

@media (max-width: 1024px) {
  .dash-strip,
  .dashboard-board,
  .kpi-grid,
  .vault-grid,
  .accounts-grid,
  .report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .balance-report-layout,
  .trade-layout,
  .today-trade-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body.nav-open {
    overflow: hidden;
  }

  .sidebar {
    width: min(320px, calc(100vw - 28px));
    max-width: calc(100vw - 28px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .sidebar-footer {
    display: grid;
  }

  .topbar {
    align-items: flex-start;
    gap: 10px;
  }

  .top-actions,
  .header-actions,
  .form-actions:not(.purity-actions),
  .toolbar,
  .closing-tools {
    width: 100%;
    justify-content: stretch;
  }

  .top-actions > *,
  .header-actions > button,
  .form-actions:not(.purity-actions) > button,
  .toolbar > *,
  .closing-tools > * {
    flex: 1 1 150px;
    min-width: 0;
  }

  .topbar {
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
  }

  .topbar > div:first-of-type {
    min-width: 0;
  }

  .topbar .eyebrow {
    margin-bottom: 0;
  }

  .topbar .page-title-row h1 {
    font-size: clamp(16px, 4.2vw, 19px);
    line-height: 1.12;
    font-weight: 750;
  }

  .topbar > .top-actions {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
  }

  .topbar .top-actions > * {
    min-width: 0;
  }

  .top-user-card,
  .live-rate-ticker {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    box-shadow: var(--shadow-sm);
  }

  .top-user-card {
    min-height: 48px;
    padding: 7px 8px 7px 12px;
  }

  .top-user-copy span {
    font-size: 11px;
  }

  .top-user-copy strong {
    font-size: 16px;
  }

  .top-user-card .top-logout-button {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
    min-height: 38px;
  }

  .top-trade-card {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 7px 9px;
    box-shadow: var(--shadow-sm);
  }

  .top-trade-card span {
    font-size: 10px;
  }

  .top-trade-card strong {
    font-size: clamp(15px, 4.6vw, 18px);
  }

  .live-rate-ticker {
    min-height: 54px;
    padding: 6px;
  }

  .live-rate-chip {
    min-width: 0;
    padding: 6px 8px;
  }

  .live-rate-chip strong {
    font-size: clamp(16px, 5.3vw, 21px);
  }

  #liveRateStatus {
    flex: 0 0 auto;
    align-self: center;
    padding-inline: 2px;
    font-size: 12px;
  }

  .topbar #themeToggle {
    width: 44px;
    height: 44px;
    min-height: 44px;
    justify-self: start;
  }

  .topbar [data-view-link="trade"] {
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 10px;
  }

  .topbar-view-link--denied,
  .topbar [data-view-link][hidden] {
    display: none !important;
  }

  .dash-strip,
  .dashboard-board,
  .kpi-grid,
  .vault-grid,
  .accounts-grid,
  .report-grid,
  .balance-filters,
  .form-grid,
  .compact-form,
  .cde-form-grid,
  .pnl-form-grid,
  .account-form-grid,
  .melting-form-grid,
  .purity-form-grid {
    grid-template-columns: 1fr !important;
  }

  .panel,
  .widget-card,
  .dashboard-command,
  .today-trade-summary,
  .receipt-paper {
    padding: clamp(10px, 3.5vw, 14px);
  }

  .pending-tabs,
  .capsule-toggle {
    width: 100%;
  }

  .pending-tab,
  .capsule-toggle button {
    flex: 1 1 120px;
  }

  .table-wrap,
  .accounts-table-wrap,
  .balance-report-table,
  .general-report-table-wrap {
    margin-right: -2px;
    margin-left: -2px;
  }
}

.print-only {
  display: none !important;
}

.print-page,
.print-a4,
.print-a4-landscape,
.print-thermal,
.receipt-paper,
.statement-print {
  box-sizing: border-box;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.print-a4,
.statement-print.capra-a4-report {
  width: min(100%, 210mm);
  margin: 0 auto;
  color: #0f172a;
  background: #ffffff;
}

.print-a4-landscape {
  width: min(100%, 297mm);
}

.print-thermal {
  width: 80mm;
  max-width: 100%;
  margin: 0 auto;
  color: #111111;
  background: #ffffff;
  font-family: Arial, "Segoe UI", sans-serif;
}

.print-thermal-58 {
  width: 58mm;
}

.print-thermal-80 {
  width: 80mm;
}

.print-header,
.print-section,
.print-summary,
.print-total-box,
.print-footer,
.avoid-break {
  break-inside: avoid;
  page-break-inside: avoid;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
}

.print-table th,
.print-table td {
  padding: 6px 7px;
  border-bottom: 1px solid #d7dee8;
  text-align: left;
  vertical-align: top;
}

.print-table th {
  color: #0f172a;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.numeric,
.amount,
.text-right {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.text-center {
  text-align: center !important;
}

.text-muted {
  color: #64748b !important;
}

.page-break {
  break-before: page;
  page-break-before: always;
}

@media print {
  @page {
    size: A4;
    margin: 10mm;
  }

  html,
  body {
    width: auto;
    max-width: none;
    overflow: visible !important;
    color: #111111 !important;
    background: #ffffff !important;
  }

  body {
    font-family: Arial, "Segoe UI", sans-serif;
    font-size: 11px;
    line-height: 1.35;
  }

  .screen-only,
  .no-print,
  .sidebar,
  .sidebar-overlay,
  .topbar,
  .mobile-menu-toggle,
  .toast,
  .header-actions,
  .toolbar,
  .form-actions,
  .pagination,
  button:not(.print-keep) {
    display: none !important;
  }

  .print-only {
    display: block !important;
  }

  .app-shell,
  .main,
  .view,
  .panel,
  .widget-card,
  .table-wrap {
    display: block !important;
    width: auto !important;
    max-width: none !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    border: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
  }

  .view:not(.active) {
    display: none !important;
  }

  .print-page,
  .print-a4,
  .statement-print.capra-a4-report,
  .receipt-paper {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
    border: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
  }

  .print-table,
  table {
    border-collapse: collapse !important;
    page-break-inside: auto;
  }

  tr,
  .avoid-break,
  .print-section,
  .print-total-box {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* ============================================================
   Craft layer (v0.1.45)
   Execution polish only: type scale, spacing rhythm, elevation,
   states, and responsive repair. No palette or layout changes.
   Screen-only so the print stylesheet stays untouched.
   ============================================================ */
@media screen {
  /* ---- 1. Tokens: one radius scale, one quiet elevation scale ---- */
  :root {
    --line: var(--border);
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow: 0 2px 4px rgba(15, 23, 42, 0.04), 0 10px 24px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 8px 20px rgba(15, 23, 42, 0.08), 0 24px 56px rgba(15, 23, 42, 0.16);
    --focus-ring: 0 0 0 3px rgba(52, 184, 230, 0.25);
    --main-pad: clamp(16px, 1.8vw, 24px);
  }

  .dark {
    --ink: #f7fbff;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.24);
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 10px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.28), 0 24px 56px rgba(0, 0, 0, 0.44);
  }

  /* Dark-mode contrast repair: chips that kept light-only backgrounds */
  .dark .top-user-card {
    border-color: rgba(56, 189, 248, 0.26);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(15, 23, 42, 0.6));
  }

  .dark .live-rate-chip {
    border-color: rgba(16, 185, 129, 0.24);
    background: linear-gradient(135deg, rgba(15, 159, 110, 0.14), rgba(15, 23, 42, 0.55));
  }

  .dark .live-rate-chip.silver {
    border-color: rgba(56, 189, 248, 0.26);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(15, 23, 42, 0.55));
  }

  .dark .dash-break-row {
    background: rgba(255, 255, 255, 0.07);
  }

  .dark .today-trade-row {
    border-color: rgba(148, 163, 184, 0.16);
    background: rgba(255, 255, 255, 0.045);
  }

  .dark .today-trade-row-head {
    border-color: transparent;
    background: transparent;
  }

  .dark .today-trade-row.total {
    border-color: rgba(148, 163, 184, 0.3);
    background: rgba(255, 255, 255, 0.06);
  }

  .dark .today-net-card {
    border-color: rgba(56, 189, 248, 0.2);
    background: rgba(255, 255, 255, 0.04);
  }

  .dark .today-net-line {
    border-bottom-color: rgba(148, 163, 184, 0.16);
  }

  .dark .today-net-total {
    background: rgba(255, 255, 255, 0.06);
  }

  /* Restraint: no perpetual shimmer on stat cards */
  .neo-stat::before {
    animation: none;
    opacity: 0;
  }

  /* ---- 2. Typography: deliberate scale, tamed weights ---- */
  body {
    font-size: 14px;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  h1 {
    font-size: clamp(21px, 1.7vw, 26px);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
  }

  h2 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.3;
  }

  h3 {
    font-weight: 700;
    letter-spacing: -0.005em;
  }

  .eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
  }

  .brand-mark {
    font-weight: 800;
  }

  th {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  td {
    line-height: 1.45;
  }

  /* Chip / label micro-type: consistent size, weight, tracking */
  .top-user-copy span,
  .top-trade-card span,
  .live-rate-chip span {
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
  }

  .neo-stat span,
  .metric span {
    font-weight: 600;
  }

  .top-user-copy span,
  .top-trade-card span,
  .live-rate-chip span {
    font-size: 10px;
  }

  .top-user-copy strong {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
  }

  .top-trade-card strong,
  .live-rate-chip strong {
    font-weight: 700;
  }

  .heat-card span,
  .task-list li,
  .panel p {
    font-weight: 500;
  }

  .heat-card b,
  .heat-card em {
    font-weight: 700;
  }

  .heat-card strong {
    font-weight: 700;
    letter-spacing: -0.01em;
  }

  .nav-group {
    font-weight: 700;
    letter-spacing: 0.1em;
  }

  .nav-item {
    font-weight: 600;
  }

  .global-metal-toggle button {
    font-weight: 700;
  }

  .status,
  .badge {
    font-weight: 600;
  }

  button {
    letter-spacing: 0.005em;
  }

  /* ---- 3. States: visible focus, calm motion, reduced-motion ---- */
  :focus {
    outline: none;
  }

  :focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
  }

  button:focus-visible,
  .nav-item:focus-visible,
  select:focus-visible,
  input:focus-visible,
  textarea:focus-visible,
  a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  select:focus,
  input:focus,
  textarea:focus {
    border-color: rgba(52, 184, 230, 0.72);
    box-shadow: var(--focus-ring);
  }

  ::selection {
    background: rgba(52, 184, 230, 0.28);
  }

  button:active {
    transform: translateY(0);
  }

  .primary-button:active {
    transform: translateY(0) scale(0.99);
  }

  /* Cards stay seated: elevation shifts, no jitter */
  .panel:hover,
  .widget-card:hover {
    transform: none;
    box-shadow: var(--shadow);
  }

  .last-trade-row:hover,
  .pending-trade-card:hover,
  .recent-trade-card:hover,
  .executed-trade-card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }

  .nav-item.active,
  .nav-item:hover {
    transform: none;
  }

  /* ---- 4. Spacing rhythm: one 4/8px scale for shell + boards ---- */
  .main {
    padding: var(--main-pad);
  }

  .topbar {
    margin: calc(-1 * var(--main-pad)) calc(-1 * var(--main-pad)) 16px;
    padding: 12px var(--main-pad);
    gap: 12px;
  }

  .dashboard-board,
  .dash-strip,
  .kpi-grid,
  .vault-grid,
  .report-grid,
  .accounts-grid {
    gap: 16px;
  }

  .dash-strip {
    margin-bottom: 16px;
  }

  .panel,
  .widget-card,
  .dashboard-command,
  .today-trade-summary {
    padding: 16px;
  }

  /* ---- 5. Topbar: equal heights, aligned chips ---- */
  .top-actions {
    gap: 8px;
  }

  .top-user-card,
  .top-trade-card,
  .live-rate-ticker {
    min-height: 52px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
  }

  .top-user-card {
    min-width: 170px;
    padding: 6px 6px 6px 12px;
  }

  .top-trade-card {
    min-width: 118px;
    padding: 6px 12px;
  }

  .topbar .icon-button,
  .topbar #themeToggle {
    width: 40px;
    min-height: 40px;
    border-radius: var(--radius-md);
  }

  .topbar [data-view-link="trade"] {
    min-height: 40px;
    padding: 0 16px;
    border-radius: var(--radius-md);
  }

  /* ---- 6. Controls: consistent heights, quiet elevation ---- */
  .primary-button,
  .ghost-button {
    min-height: 36px;
    padding: 0 14px;
    border-radius: var(--radius-md);
    font-weight: 600;
  }

  .primary-button {
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.28), 0 5px 14px rgba(37, 99, 235, 0.18);
  }

  .primary-button:hover {
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.28), 0 8px 20px rgba(37, 99, 235, 0.24);
  }

  .icon-button {
    min-height: 36px;
    width: 36px;
    border-radius: var(--radius-md);
  }

  .page-refresh-button {
    width: 32px;
    height: 32px;
    min-height: 32px;
  }

  .mini-button {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
  }

  .segment,
  .pending-tabs > .pending-tab,
  .segmented > .segment {
    min-height: 32px;
    white-space: nowrap;
  }

  .pending-tab.active,
  .segment.active,
  .global-metal-toggle button.active {
    box-shadow: 0 1px 2px rgba(52, 184, 230, 0.3), 0 4px 12px rgba(52, 184, 230, 0.22);
  }

  select,
  input,
  textarea {
    border-radius: var(--radius-md);
  }

  /* ---- 7. Chips never break mid-word ---- */
  .status,
  .badge {
    overflow-wrap: normal;
    white-space: nowrap;
    flex: 0 0 auto;
    min-height: 20px;
    padding: 0 8px;
  }

  .task-list li {
    align-items: flex-start;
    line-height: 1.45;
  }

  .task-list li .status {
    margin-top: 1px;
  }

  /* Paired tabs share their row instead of stacking */
  .last-trade-tools .pending-tabs {
    flex-wrap: nowrap;
  }

  .last-trade-tools .pending-tab {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 10px;
  }

  /* ---- 8. Empty states: one recipe ---- */
  .ledger-empty,
  .empty-state {
    padding: 20px 16px;
    border: 1px dashed color-mix(in srgb, var(--primary), transparent 62%);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--primary), transparent 95%);
    color: var(--muted);
    font-size: 13px;
    text-align: center;
  }

  /* ---- 9. Sidebar: aligned icons, disciplined rhythm ---- */
  .nav-item span .app-icon,
  .nav-item span svg {
    width: 16px;
    height: 16px;
    stroke-width: 1.9;
  }

  .nav-item span {
    color: currentColor;
    opacity: 0.85;
  }

  .nav-item.active span {
    opacity: 1;
  }

  .app-version-line {
    letter-spacing: 0.02em;
  }

  /* ---- 10. Signature: the live market pulse ---- */
  .live-rate-chip strong,
  .top-trade-card strong {
    font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
    font-size: 15px;
    letter-spacing: -0.01em;
  }

  .live-rate-chip {
    border-radius: var(--radius-sm);
  }

  #liveRateStatus {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
  }

  #liveRateStatus::before {
    content: "";
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--warning, #f59e0b);
  }

  .live-rate-ticker.is-live #liveRateStatus::before {
    background: var(--success, #0f9f6e);
    animation: livePulse 2.4s ease-out infinite;
  }

  .live-rate-ticker.is-offline #liveRateStatus::before {
    background: var(--danger, #e5484d);
  }

  @keyframes livePulse {
    0% {
      box-shadow: 0 0 0 0 rgba(15, 159, 110, 0.4);
    }
    70%,
    100% {
      box-shadow: 0 0 0 6px rgba(15, 159, 110, 0);
    }
  }

  /* ---- 11. Login: composed card, not a full-width strip ---- */
  .login-card {
    width: min(400px, calc(100vw - 32px));
    max-width: 400px;
    padding: 28px 26px 26px;
    border: 1px solid var(--border);
  }

  .login-brand {
    padding-bottom: 14px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
  }

  .login-brand strong {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
  }

  .login-brand span {
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .login-card label {
    margin-top: 14px;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .login-card input {
    height: 44px;
  }

  .login-card .primary-button,
  .login-card button[value="login"] {
    min-height: 44px;
    margin-top: 16px;
  }

  /* ---- 12. Tablet rail (761-900px): icons only, nothing clipped ---- */
  @media (max-width: 900px) and (min-width: 761px) {
    .sidebar {
      padding: 14px 10px;
      gap: 12px;
      overflow: hidden;
    }

    .brand {
      justify-content: center;
    }

    .brand > div:last-child {
      display: none;
    }

    .global-metal-toggle {
      display: grid;
      grid-template-columns: 1fr;
      gap: 3px;
      width: 100%;
      padding: 3px;
      border-radius: var(--radius-md);
    }

    .global-metal-toggle button {
      min-height: 26px;
      padding: 0;
      font-size: 10.5px;
      letter-spacing: 0.04em;
    }

    .nav-group {
      height: 17px;
      margin: 8px 0 2px;
      padding: 0;
      font-size: 0;
      pointer-events: auto;
    }

    .nav-group::before {
      content: "";
      position: absolute;
      top: 50%;
      left: 50%;
      width: 28px;
      height: 2px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.14);
      transform: translate(-50%, -50%);
    }

    .nav-group::after {
      display: none;
    }

    .nav-item {
      width: 44px;
      min-height: 40px;
      margin: 0 auto;
    }

    .nav-item span {
      width: 100%;
      height: 100%;
    }

    .nav-item span .app-icon,
    .nav-item span svg {
      width: 18px;
      height: 18px;
    }
  }

  /* ---- 13. Mobile (<=760px): breathing room, no cramped stacks ---- */
  @media (max-width: 760px) {
    :root {
      --main-pad: 12px;
    }

    .topbar {
      margin-bottom: 12px;
    }

    .panel,
    .widget-card,
    .dashboard-command,
    .today-trade-summary {
      padding: 14px;
    }

    .dashboard-board,
    .dash-strip,
    .kpi-grid,
    .vault-grid,
    .report-grid,
    .accounts-grid {
      gap: 12px;
    }

    .dashboard-command {
      display: grid;
      gap: 8px;
    }

    .dashboard-command .segmented {
      display: grid;
      grid-auto-flow: column;
      grid-auto-columns: 1fr;
      gap: 6px;
      width: 100%;
    }

    .dashboard-command .dashboard-metal-toggle {
      width: 100%;
      min-width: 0;
    }

    .dashboard-command .widget-actions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      width: 100%;
    }

    .dashboard-command .widget-actions #widgetPicker {
      grid-column: 1 / -1;
      width: 100%;
      min-width: 0;
    }

    .icon-button,
    .mini-button,
    .page-refresh-button {
      min-width: 40px;
      min-height: 40px;
    }

    .mini-button {
      width: 40px;
      height: 40px;
    }

    .segment,
    .pending-tab,
    .primary-button,
    .ghost-button,
    select,
    input,
    .nav-item {
      min-height: 44px;
    }

    .top-user-card,
    .top-trade-card,
    .live-rate-ticker {
      min-height: 48px;
    }

    .form-actions #saveTradeButton {
      flex: 1 1 100%;
      grid-column: 1 / -1;
      width: 100%;
    }
  }

  /* ---- 14. Small phones: heat cards stack cleanly ---- */
  @media (max-width: 640px) {
    .trading-heat-board {
      grid-template-columns: 1fr !important;
    }

    .heat-card {
      min-height: 0;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 4px 12px;
    }

    .heat-card > div {
      min-width: 0;
    }

    .heat-card strong {
      font-size: 14px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
}

/* Respect reduced-motion everywhere, including print previews */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   Mobile header + dashboard polish (v0.1.50)
   ============================================================ */
@media screen and (max-width: 760px) {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 70;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 10px 10px;
    margin-bottom: 8px;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
  }

  .topbar-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
  }

  .mobile-menu-toggle,
  .mobile-menu-button {
    display: inline-grid !important;
    place-items: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    min-height: 40px;
    margin-top: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    font-size: 0;
  }

  .topbar-title-wrap {
    flex: 1 1 auto;
    min-width: 0;
  }

  .topbar-eyebrow {
    display: none;
  }

  .topbar-version-line {
    margin-top: 2px;
  }

  .topbar-version-line .app-version-chip {
    font-size: 9px;
    padding: 1px 7px;
  }

  .page-title-row {
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .page-title-row h1 {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: clamp(16px, 4.2vw, 19px);
    line-height: 1.12;
    font-weight: 750;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-quick-actions {
    display: flex;
    flex: 0 0 auto;
  }

  .topbar-mobile-only {
    display: inline-grid;
  }

  .topbar-desktop-only {
    display: none !important;
  }

  .topbar > .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .top-trade-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-height: 34px;
    padding: 0 10px;
    min-width: 0;
  }

  .live-rate-ticker {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    grid-column: 1 / -1;
    width: 100%;
    min-height: 34px;
    padding: 4px 8px;
  }

  .top-trade-card span {
    flex: 0 1 auto;
    overflow: hidden;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-trade-card strong {
    flex: 0 0 auto;
    font-size: 12px;
    white-space: nowrap;
  }

  .live-rate-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    min-width: 0;
    min-height: 28px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .live-rate-chip span {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .live-rate-chip strong {
    font-size: 11px;
    white-space: nowrap;
  }

  .live-rate-chip small {
    display: none;
  }

  #liveRateStatus {
    font-size: 9px;
    font-style: normal;
    white-space: nowrap;
  }

  .sidebar-user-card {
    display: flex;
    flex-wrap: wrap;
  }

  .main {
    padding: 10px;
  }

  #dashboard .dashboard-command {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    margin-bottom: 8px;
  }

  #dashboard .dashboard-command > .segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }

  #dashboard .dashboard-command > .segmented .segment,
  #dashboard .dashboard-metal-toggle .segment {
    min-height: 36px;
    font-size: 12px;
    font-weight: 700;
  }

  #dashboard .dashboard-metal-toggle {
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #dashboard .widget-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  #dashboard #widgetPicker {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 38px;
  }

  #dashboard .widget-actions #addWidget,
  #dashboard .widget-actions #resetDashboard {
    min-height: 38px;
    width: 100%;
  }

  #dashboard .dash-strip {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 8px;
  }

  #dashboard .neo-stat {
    min-height: 0;
    padding: 12px;
    gap: 6px;
  }

  #dashboard .neo-stat strong {
    font-size: clamp(16px, 4.8vw, 20px);
    line-height: 1.15;
    word-break: break-word;
  }

  #dashboard .neo-stat.detail-stat {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #dashboard .neo-stat.detail-stat .dash-breakdown {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    text-align: left;
  }

  #dashboard .dash-break-row {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 6px 8px;
    font-size: 10px;
  }

  #dashboard .dash-break-row em {
    white-space: normal;
    text-align: right;
  }

  #dashboard .dash-cash-words b {
    white-space: normal;
    font-size: 10px;
    line-height: 1.25;
  }

  #dashboard .today-trade-summary {
    padding: 10px;
    margin-bottom: 8px;
    overflow: hidden;
  }

  #dashboard .today-trade-head {
    gap: 8px;
  }

  #dashboard .today-trade-grid,
  #dashboard .today-trade-layout {
    gap: 8px;
  }

  #dashboard .today-trade-row {
    padding: 8px 10px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
  }

  #dashboard .dashboard-board {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  #dashboard .widget-card {
    grid-column: 1 / -1 !important;
    min-height: 0;
  }

  #dashboard .widget-card .panel-header h2 {
    font-size: 14px;
  }
}

@media screen and (min-width: 414px) and (max-width: 760px) {
  #dashboard .dash-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #dashboard .neo-stat:first-child,
  #dashboard .neo-stat:last-child {
    grid-column: 1 / -1;
  }
}

/* ============================================================
   Balance Report mobile polish (v0.1.51)
   Desktop/laptop layout unchanged above 760px.
   ============================================================ */
@media screen and (max-width: 760px) {
  #balance-report .balance-report-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    margin: 0;
  }

  #balance-report .balance-report-settings-panel {
    position: static;
    order: -1;
    padding: 10px;
  }

  #balance-report .balance-report-filters-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    user-select: none;
  }

  #balance-report .balance-report-filters-summary span {
    font-size: 13px;
    font-weight: 800;
    color: var(--text);
  }

  #balance-report .balance-report-filters-summary small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  #balance-report .balance-report-filters-shell[open] .balance-report-filters-summary {
    margin-bottom: 10px;
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  }

  #balance-report .balance-report-settings-body .compact-header {
    display: none;
  }

  #balance-report .balance-report-main-panel {
    padding: 10px;
    min-width: 0;
  }

  #balance-report .balance-report-main-panel .panel-header {
    display: grid;
    gap: 10px;
    margin-bottom: 10px;
  }

  #balance-report .balance-report-main-panel .panel-header > div:first-child {
    min-width: 0;
  }

  #balance-report .balance-title-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  #balance-report .balance-title-row h2 {
    font-size: 18px;
  }

  #balance-report .balance-metal-toggle {
    width: 100%;
    min-width: 0;
  }

  #balance-report .balance-metal-toggle button {
    min-width: 0;
    min-height: 36px;
    font-size: 11px;
  }

  #balance-report #balanceReportSubtitle {
    font-size: 11px;
    line-height: 1.35;
  }

  #balance-report .balance-report-main-panel .header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  #balance-report .balance-report-main-panel .header-actions button {
    min-height: 38px;
    width: 100%;
    flex: initial;
  }

  #balance-report .balance-report-controls {
    gap: 10px;
    padding: 0;
  }

  #balance-report .balance-report-settings-panel .balance-mode-switch {
    min-height: 38px;
  }

  #balance-report .balance-report-settings-panel .balance-mode-switch button {
    min-height: 34px;
    font-size: 12px;
  }

  #balance-report .balance-report-settings-panel .balance-filters {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #balance-report .balance-report-settings-panel .balance-filters label,
  #balance-report .balance-report-settings-panel .balance-filters select {
    width: 100%;
    min-height: 38px;
    font-size: 13px;
  }

  #balance-report .balance-report-settings-panel .category-checks {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #balance-report .balance-report-settings-panel .category-checks .check-row {
    min-height: 36px;
    padding: 0 8px;
    font-size: 11px;
  }

  #balance-report .balance-report-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
  }

  #balance-report .balance-report-table table {
    min-width: 0 !important;
    width: 100%;
    table-layout: fixed;
    font-size: 11px;
  }

  #balance-report .balance-report-table th,
  #balance-report .balance-report-table td {
    padding: 7px 5px;
    vertical-align: middle;
    overflow-wrap: anywhere;
  }

  #balance-report .balance-report-table th:first-child,
  #balance-report .balance-report-table td:first-child {
    width: 36%;
    position: sticky;
    left: 0;
    z-index: 2;
    background: inherit;
    box-shadow: 1px 0 0 color-mix(in srgb, var(--border) 70%, transparent);
  }

  #balance-report .balance-report-table thead th:first-child {
    z-index: 3;
    background: color-mix(in srgb, var(--surface-2) 92%, transparent);
  }

  #balance-report .balance-report-table th:not(:first-child),
  #balance-report .balance-report-table td:not(:first-child) {
    width: 21.33%;
    text-align: right;
    font-size: 10px;
    white-space: nowrap;
  }

  #balance-report .balance-parent-row strong {
    display: block;
    font-size: 11px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  #balance-report .balance-parent-row td {
    height: auto;
    min-height: 34px;
    padding: 8px 5px;
  }

  #balance-report .balance-value {
    font-size: 10px;
    line-height: 1.2;
  }

  #balance-report .balance-city-row td {
    font-size: 11px;
    padding: 8px 5px;
  }

  #balance-report .balance-city-name {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    font-size: 11px;
  }

  #balance-report .balance-city-name small {
    font-size: 9px;
  }

  #balance-report .balance-city-detail-cell {
    padding: 6px 5px 8px;
  }

  #balance-report .balance-city-detail-strip {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    width: 100%;
    margin-left: 0;
  }

  #balance-report .balance-city-detail-card {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 10px;
  }

  #balance-report .balance-city-detail-card small {
    font-size: 9px;
  }
}

/* ============================================================
   Update-in-progress banner mobile fix (v0.1.52)
   Pill shape becomes a readable card on phones; desktop unchanged.
   ============================================================ */
@media screen and (max-width: 760px) {
  .update-progress-banner {
    top: max(8px, env(safe-area-inset-top, 0px));
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
    transform: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 12px 14px 12px 34px;
    border-radius: 14px;
  }

  .update-progress-banner::before {
    position: absolute;
    top: 15px;
    left: 12px;
  }

  .update-progress-banner strong {
    white-space: normal;
    font-size: 14px;
    line-height: 1.25;
  }

  .update-progress-banner span {
    display: block;
    width: 100%;
    font-size: 12px;
    line-height: 1.45;
  }

  body.capra-update-active .login-dialog::before {
    display: none;
  }
}

/* ============================================================
   All-pages responsive + laptop repair (v0.1.56)
   Fixes rigid multi-column min-widths that overflow laptop
   viewports (sidebar + ~900px grids). Mobile rules per view.
   ============================================================ */

@media screen and (max-width: 1280px) {
  .users-admin-layout,
  .manage-entries-layout,
  .cde-workspace,
  .melting-workspace,
  .trade-layout,
  .balance-report-layout,
  .purity-layout,
  .closing-shell,
  .pnl-shell {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .balance-report-settings-panel,
  .manage-filter-panel,
  .melting-balance-panel,
  .trade-summary {
    position: static;
    min-width: 0;
    max-width: none;
  }

  .balance-report-settings-panel {
    order: -1;
  }

  .manage-filter-panel {
    order: -1;
  }

  .closing-tools,
  .pnl-form-panel .panel-header {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .closing-tools .date-filter,
  .pnl-form-panel .date-filter {
    min-width: 0;
    flex: 1 1 150px;
  }

  .pnl-title-line h2 {
    white-space: normal;
  }

  .expense-labor-form,
  .expense-transaction-form,
  .expense-daily-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }

  .expense-labor-form .primary-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .expense-transaction-form .full-width,
  .expense-daily-form .full-width {
    grid-column: 1 / -1;
  }

  .print-settings-card,
  .db-backup-card,
  .reset-settings-card {
    grid-column: 1 / -1;
  }

  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .wide {
    grid-row: auto;
  }

  .trade-layout {
    min-width: 0;
  }

  .last-trades-panel,
  .trade-summary,
  .last-trades {
    grid-column: 1 / -1;
  }
}

@media screen and (max-width: 1024px) {
  .closing-stat-grid,
  .closing-source-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .expense-balance-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vault-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trade-main .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .user-admin-form {
    grid-template-columns: 1fr;
  }

  .general-report-panel .button-row {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .general-report-panel .button-row > * {
    flex: 1 1 140px;
    min-width: 0;
  }
}

@media screen and (max-width: 760px) {
  html,
  body {
    overflow-x: clip;
  }

  .main {
    padding: 12px;
  }

  /* ---- Shared toolbars & headers ---- */
  #accounts .toolbar,
  #reports .report-toolbar,
  #audit .audit-toolbar,
  .expense-topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: stretch;
  }

  #accounts .toolbar input,
  #accounts .toolbar select,
  #reports .report-toolbar select,
  #audit .audit-toolbar input,
  #audit .audit-toolbar select,
  .expense-month-filter {
    width: 100%;
    max-width: none;
  }

  #accounts .toolbar .primary-button,
  #reports .report-toolbar button {
    width: 100%;
  }

  .panel-header,
  .compact-panel-header,
  .closing-header,
  .purity-entry-header,
  .purity-list-header,
  .melting-form-card .panel-header,
  #adjustment-extra .panel-header,
  #transfers .panel-header,
  #whatsapp .panel-header,
  #deleted .panel-header,
  #rates .panel-header,
  .account-detail-panel .panel-header,
  .expense-log-panel .panel-header,
  .expense-balance-panel .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .panel-header .header-actions,
  .panel-header .closing-tools,
  .panel-header .button-row,
  .panel-header .expense-ledger-tools,
  .panel-title-row,
  .balance-title-row {
    width: 100%;
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .panel-header .header-actions > *,
  .panel-header .button-row > *,
  .closing-footer-actions > *,
  .staff-bulk-clear > button {
    flex: 1 1 140px;
    min-width: 0;
  }

  .panel-title-row.balance-title-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .balance-metal-toggle,
  .balance-mode-switch,
  .global-metal-toggle,
  .dashboard-metal-toggle {
    width: 100%;
    flex-wrap: wrap;
  }

  /* ---- Accounts ---- */
  #accounts .account-tabs {
    width: 100%;
  }

  #accounts .account-tabs .pending-tab {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 8px;
    font-size: 12px;
  }

  /* ---- Balance report (reinforce v0.1.51) ---- */
  #balance-report .balance-report-filters-shell:not([open]) .balance-report-settings-body {
    display: none;
  }

  #balance-report .balance-report-filters-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    cursor: pointer;
    list-style: none;
  }

  #balance-report .balance-report-settings-panel .compact-header {
    display: none;
  }

  #balance-report .balance-filters {
    grid-template-columns: 1fr !important;
  }

  #balance-report .category-checks {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* ---- Trade ---- */
  #trade .trade-layout {
    gap: 10px;
  }

  #trade .trade-main .form-grid {
    grid-template-columns: 1fr !important;
  }

  #trade .trade-main .trade-party-field,
  #trade .trade-main .trade-city-field,
  #trade .trade-main .trade-choice-field,
  #trade .trade-main .trade-path-field,
  #trade .trade-main .weight-field,
  #trade .trade-main .trade-rate-field,
  #trade .trade-main .wide-field,
  #trade .trade-main .full-width {
    grid-column: 1 / -1;
  }

  #trade .trade-choice-row {
    display: grid;
    gap: 8px;
  }

  #trade .touch-options.two,
  #trade .touch-options.four,
  #trade .touch-options.five,
  #trade .touch-options.six {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #trade .touch-options.six .touch-option {
    font-size: 10px;
    padding-inline: 4px;
  }

  #trade .slip-attach,
  #trade .future-date-row,
  #trade .tt-quantity-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  #trade .slip-attach button,
  #trade .future-date-row button {
    width: 100%;
  }

  #trade .trade-party-balance-totals {
    grid-template-columns: 1fr;
  }

  #trade .last-trade-tools {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  #trade .last-trade-tools .pending-tabs {
    width: 100%;
  }

  #trade .pending-trade-card,
  #trade .recent-trade-card,
  #trade .executed-trade-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  #trade .form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  #trade .form-actions .primary-button,
  #trade .form-actions .ghost-button {
    width: 100%;
  }

  /* ---- CDE ---- */
  #cde .cde-form-grid {
    grid-template-columns: 1fr !important;
  }

  #cde .cde-notes-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  #cde .cde-notes-actions button {
    width: 100%;
  }

  #cde .cde-entry-panel .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  #cde .cde-entries-panel .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  #cde .cde-entries-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  #cde .cde-entry-status-tabs {
    width: 100%;
  }

  #cde .cde-entries-toolbar-filters {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  #cde .cde-entries-toolbar .date-stepper {
    width: 100%;
    justify-content: space-between;
  }

  #trade .last-trade-tools label .date-stepper {
    width: 100%;
  }

  #cde .cde-transfer-preview,
  #cde .cde-account-transfer-preview {
    font-size: 11px;
  }

  /* ---- Purity ---- */
  #purity .purity-entry-panel,
  #purity .purity-list-panel {
    padding: 10px;
  }

  #purity .purity-entry-header {
    margin-bottom: 8px;
  }

  #purity .purity-entry-title-copy h2 {
    font-size: 16px;
    line-height: 1.12;
  }

  #purity .purity-entry-title-copy p {
    font-size: 10px;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  #purity .purity-entry-head-tools .voucher {
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #purity .purity-new-slip-button {
    width: 40px;
    height: 40px;
    min-height: 40px;
  }

  #purity .compact-form.purity-form-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px;
  }

  #purity .purity-weight-field {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 4px;
    min-width: 0;
  }

  #purity .purity-purity-pair {
    grid-column: 1 / -1;
  }

  #purity .purity-purity-pair {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
  }

  #purity .purity-pair-field {
    gap: 3px;
    font-size: 10px;
    letter-spacing: 0.01em;
  }

  #purity .purity-pair-field .inline-input {
    grid-template-columns: minmax(0, 1fr) minmax(54px, 0.78fr);
    gap: 4px;
  }

  #purity .purity-pair-field input,
  #purity .purity-pair-field select {
    min-height: 34px;
    height: 34px;
    padding: 4px 6px;
    font-size: 12px;
  }

  #purity .purity-customer-field {
    gap: 4px;
  }

  #purity .purity-actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px;
    margin-top: 8px;
    width: 100%;
    flex-wrap: nowrap;
  }

  #purity .purity-actions .primary-button,
  #purity .purity-actions .ghost-button {
    flex: none !important;
    width: 100%;
    min-width: 0;
    min-height: 36px;
    padding-inline: clamp(3px, 1vw, 8px);
    font-size: clamp(9px, 2.35vw, 11px);
    white-space: nowrap;
  }

  #purity .purity-actions #addPurityRow,
  #purity .purity-actions #savePurityDraft,
  #purity .purity-actions #savePuritySlip {
    grid-column: auto;
  }

  #purity #paResult {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    margin-top: 8px;
  }

  #purity #paResult b {
    font-size: 14px;
  }

  #purity .purity-rows-wrap {
    margin-top: 8px;
    max-height: 220px;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #purity .slip-note-field {
    margin-top: 8px;
    gap: 4px;
    font-size: 11px;
  }

  #purity .purity-list-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  #purity .purity-list-header .date-filter {
    width: 100%;
  }

  #purity .purity-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  #purity .purity-tabs .pending-tab {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 11px;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }

  #purity .table-wrap.purity-slip-table {
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }

  #purity .purity-slip-table table {
    min-width: 520px;
    width: 100%;
    table-layout: auto;
    white-space: nowrap;
    font-size: 10.5px;
  }

  #purity .purity-slip-table th,
  #purity .purity-slip-table td {
    overflow-wrap: normal;
    word-break: normal;
    white-space: nowrap;
    padding: 5px 6px;
  }

  #purity .purity-slip-table th {
    font-size: 10px;
    line-height: 1.2;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }

  #purity .purity-rows-wrap table {
    min-width: 360px;
    width: 100%;
    table-layout: auto;
    white-space: nowrap;
    font-size: 11px;
  }

  #purity .purity-rows-wrap th,
  #purity .purity-rows-wrap td {
    overflow-wrap: normal;
    word-break: normal;
    white-space: nowrap;
  }

  /* ---- Vaults ---- */
  #vaults .vault-grid {
    grid-template-columns: 1fr !important;
  }

  #vaults .vault-card header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* ---- Melting ---- */
  #melting.view.active {
    justify-items: stretch;
  }

  #melting .melting-workspace {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    gap: 8px;
  }

  #melting .melting-form-card,
  #melting .melting-ledger-panel {
    padding: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #melting .melting-form-grid {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }

  #melting .melting-metal-options,
  #melting .melting-type-options {
    max-width: none;
    width: 100%;
  }

  #melting .melting-batch-panel {
    padding: 8px;
    min-width: 0;
  }

  #melting .melting-batch-inputs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    align-items: end;
  }

  #melting .melting-batch-inputs #addMeltingBatchRow {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 36px;
  }

  #melting .melting-silver-add {
    grid-column: 1;
    min-width: 0;
  }

  #melting .melting-batch-inputs #addMeltingSilverRow {
    grid-column: 2;
    width: 100%;
    min-height: 36px;
  }

  #melting .melting-batch-wrap {
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #melting .melting-batch-table {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
    white-space: normal;
    font-size: 11px;
  }

  #melting .melting-batch-table th,
  #melting .melting-batch-table td {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  #melting .melting-batch-total {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  #melting .melting-form-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
  }

  #melting .melting-form-actions strong {
    grid-column: 1 / -1;
    font-size: 11px;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  #melting .melting-form-actions #resetMelting,
  #melting .melting-form-actions #saveMelting {
    width: 100%;
    min-height: 38px;
    font-size: 12px;
  }

  #melting .melting-balance-panel {
    grid-template-columns: 1fr !important;
  }

  #melting .melting-form-head {
    justify-content: flex-start;
  }

  #melting .melting-ledger-header {
    display: grid;
    gap: 8px;
  }

  #melting .melting-ledger-panel .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  #melting .melting-ledger-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }

  #melting .melting-ledger-tabs .pending-tab {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 11px;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }

  #melting .melting-ledger-header .compact-date-filter {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 6px;
    width: 100%;
    align-items: center;
  }

  #melting .melting-ledger-header .compact-date-filter label {
    min-width: 0;
  }

  #melting .melting-ledger-header .compact-date-filter input[type="date"] {
    width: 100%;
    min-width: 0;
  }

  #melting .melting-table-wrap {
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #melting .melting-ledger-table {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
    white-space: normal;
    font-size: 11px;
  }

  #melting .melting-ledger-table th,
  #melting .melting-ledger-table td {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  #melting .melting-ledger-panel .header-actions,
  #melting .melting-ledger-panel .toolbar {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  /* ---- Expenses ---- */
  #expenses .expense-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
    padding: 4px;
    border-radius: 12px;
  }

  #expenses .expense-tabs .pending-tab {
    min-height: 38px;
    padding: 8px 6px;
    font-size: 11px;
    line-height: 1.2;
    white-space: normal;
    text-align: center;
  }

  #expenses .expense-labor-form,
  #expenses .expense-transaction-form,
  #expenses .expense-daily-form {
    grid-template-columns: 1fr !important;
  }

  #expenses .expense-labor-form .primary-button {
    width: 100%;
  }

  #expenses .expense-balance-strip {
    grid-template-columns: 1fr;
  }

  #expenses .expense-ledger-tools {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
  }

  #expenses .expense-ledger-tabs {
    width: 100%;
  }

  #expenses .staff-bulk-clear {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  #expenses .staff-bulk-clear button {
    width: 100%;
  }

  /* ---- Day close + general report ---- */
  #day-close .closing-stat-grid,
  #day-close .closing-source-grid {
    grid-template-columns: 1fr 1fr;
  }

  #day-close .closing-adjustment-panel .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  #day-close .closing-adjustment-panel .panel-header button {
    width: 100%;
  }

  #day-close .closing-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  #day-close .closing-footer-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  #day-close .closing-footer-actions button {
    width: 100%;
  }

  #day-close .general-report-panel .button-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
  }

  #day-close .general-report-panel .button-row button {
    width: 100%;
  }

  #day-close .general-report-body,
  #day-close .general-pnl-grid {
    min-width: 0;
  }

  /* ---- Profit & loss ---- */
  #profit-loss .pnl-form-grid {
    grid-template-columns: 1fr !important;
  }

  #profit-loss .pnl-form-panel .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  #profit-loss .pnl-title-line {
    flex-wrap: wrap;
  }

  #profit-loss .compact-metal-tabs {
    width: 100%;
    flex-wrap: wrap;
  }

  #profit-loss .pnl-ledger-panel .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  /* ---- Adjustment & extra ---- */
  #adjustment-extra .panel-header .date-filter {
    width: 100%;
  }

  #adjustment-extra .panel-header .date-filter input {
    width: 100%;
  }

  /* ---- Transfers ---- */
  #transfers .compact-form {
    grid-template-columns: 1fr !important;
  }

  #transfers .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  #transfers .form-actions button {
    width: 100%;
  }

  /* ---- Manage entries ---- */
  #manage-entries .manage-filter-tabs.vertical-tabs {
    grid-template-columns: 1fr;
  }

  #manage-entries .manage-filter-tabs .pending-tab {
    font-size: 11px;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }

  /* ---- Reports ---- */
  #reports .report-grid {
    grid-template-columns: 1fr !important;
  }

  #reports .report-tile {
    min-height: 96px;
    padding: 14px;
  }

  /* ---- Users ---- */
  #users .permission-chip-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  #users .permission-chip-row label {
    width: 100%;
  }

  #users .user-admin-panel .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  #users .user-admin-panel .form-actions button {
    width: 100%;
  }

  /* ---- WhatsApp / deleted ---- */
  #whatsapp .panel-header,
  #deleted .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  /* ---- Settings ---- */
  #settings .settings-grid {
    grid-template-columns: 1fr !important;
  }

  #settings .settings-db-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  #settings .settings-db-actions button {
    width: 100%;
  }

  /* ---- Rates ---- */
  #rates .rates-layout,
  #rates .panel {
    min-width: 0;
  }

  #rates .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  /* ---- Audit ---- */
  #audit .audit-toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  #audit .timeline {
    padding-left: 0;
  }

  #audit .timeline-item,
  #audit .audit-entry {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* ---- Dialogs (mobile) ---- */
  .compact-dialog-card,
  .dialog-card {
    width: min(100%, calc(100vw - 20px));
    max-width: calc(100vw - 20px);
    max-height: min(88vh, 900px);
    overflow-x: clip;
    overflow-y: auto;
  }

  .actual-closing-grid,
  .actual-closing-preview {
    grid-template-columns: 1fr !important;
  }

  .confirm-dialog-card .form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .confirm-dialog-card .form-actions button {
    width: 100%;
    min-width: 0;
  }

  /* ---- Tables: scroll inside wrappers only ---- */
  .table-wrap,
  .accounts-table-wrap,
  .balance-report-table,
  .general-report-table-wrap,
  .cde-entry-table,
  .melting-table-wrap,
  .expense-table,
  .expense-labor-wrap,
  .expense-log-wrap,
  .vault-statement-table,
  .pnl-table-wrap,
  .manage-entries-wrap,
  .closing-adjustment-wrap,
  .closing-detail-wrap,
  .user-matrix-wrap,
  .purity-slip-table {
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table,
  .accounts-table-wrap table,
  .manage-entries-table,
  .expense-table,
  .melting-ledger-table {
    min-width: 560px;
  }

  #purity .purity-slip-table table,
  #purity .purity-rows-wrap table {
    min-width: 520px;
  }

  .widget-card .table-wrap table {
    min-width: 520px;
  }
}

@media screen and (max-width: 390px) {
  #expenses .expense-tabs {
    grid-template-columns: 1fr;
  }

  #day-close .closing-stat-grid,
  #day-close .closing-source-grid {
    grid-template-columns: 1fr;
  }

  #trade .touch-options.two,
  #trade .touch-options.four,
  #trade .touch-options.five,
  #trade .touch-options.six {
    grid-template-columns: 1fr;
  }

  #balance-report .category-checks {
    grid-template-columns: 1fr !important;
  }

  #purity .purity-tabs {
    grid-template-columns: 1fr;
  }

  #purity .purity-pair-field .inline-input {
    grid-template-columns: minmax(0, 1fr) minmax(48px, 0.7fr);
  }
}

/* ============================================================
   Page access dialog (v0.1.57)
   ============================================================ */
#pageAccessDialog {
  --dialog-width: min(920px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  margin: auto;
}

.page-access-dialog-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: min(90vh, 880px);
  min-height: 0;
  overflow: hidden;
}

.page-access-dialog-card > .panel-header,
.page-access-dialog-card > .page-access-toolbar,
.page-access-dialog-card > .page-access-admin-note,
.page-access-dialog-card > .form-actions {
  flex-shrink: 0;
}

.page-access-dialog-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 4px 12px 2px;
  scrollbar-gutter: stable;
}

.page-access-dialog-card .form-actions {
  margin-top: 2px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.page-access-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.page-access-topbar-wrap {
  min-width: 0;
}

.page-access-topbar-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.page-access-topbar-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.page-access-topbar-group {
  min-width: 0;
}

.page-access-admin-note {
  padding: 10px 12px;
  border: 1px solid rgba(52, 184, 230, 0.28);
  border-radius: 10px;
  background: color-mix(in srgb, var(--primary), transparent 92%);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.page-access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

.page-access-group {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 251, 255, 0.92));
  box-shadow: var(--shadow-xs);
}

.page-access-group h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.page-access-options {
  display: grid;
  gap: 6px;
}

.page-access-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.page-access-option:hover {
  border-color: color-mix(in srgb, var(--primary), transparent 45%);
  background: color-mix(in srgb, var(--primary), transparent 94%);
}

.page-access-option input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin-top: 1px;
  accent-color: var(--primary);
}

.page-access-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.page-access-option:has(input:checked) {
  border-color: rgba(52, 184, 230, 0.42);
  background: color-mix(in srgb, var(--primary), transparent 90%);
  box-shadow: inset 0 0 0 1px rgba(52, 184, 230, 0.12);
}

.page-access-option:has(input:disabled) {
  opacity: 0.72;
  cursor: not-allowed;
}

.widget-card .table-wrap {
  contain: layout paint;
}

.widget-card .table-wrap table tbody {
  transition: none;
}

.dark .page-access-group {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.88));
}

@media screen and (max-width: 760px) {
  #pageAccessDialog {
    max-height: calc(100dvh - 16px);
    width: calc(100vw - 16px);
  }

  .page-access-dialog-card {
    max-height: min(92dvh, 900px);
    padding: 14px;
  }

  .page-access-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .page-access-toolbar .ghost-button {
    width: 100%;
  }

  .page-access-grid {
    grid-template-columns: 1fr;
  }

  #users .table-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

/* ============================================================
   Heading scale + colorful centered icon buttons (v0.1.59)
   ============================================================ */
.page-title-row h1,
#pageTitle {
  font-size: clamp(18px, 1.45vw, 21px);
  font-weight: 780;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.panel-header h2,
.compact-panel-header h2,
.purity-entry-header h2,
.purity-list-header h2 {
  font-size: clamp(14px, 1.05vw, 16px);
  font-weight: 750;
  line-height: 1.2;
}

.panel-header p,
.compact-panel-header p,
.purity-entry-header p,
.purity-list-header p {
  font-size: 11px;
  line-height: 1.35;
}

.icon-button.lucide-button,
.top-user-card .top-logout-button,
.page-refresh-button,
.purity-new-slip-button {
  display: inline-grid;
  place-items: center;
  padding: 0;
  line-height: 0;
}

.icon-button .app-icon,
.lucide-button .app-icon,
.mobile-menu-button .app-icon {
  display: block;
  width: 18px;
  height: 18px;
  margin: 0;
  vertical-align: 0;
  flex: none;
}

.topbar-action-rail .app-icon,
.top-user-card .top-logout-button .app-icon,
.page-refresh-button .app-icon {
  width: 17px;
  height: 17px;
  stroke-width: 2.15;
}

.icon-tone-danger {
  color: #e5484d;
  border-color: rgba(229, 72, 77, 0.24);
  background: linear-gradient(180deg, rgba(229, 72, 77, 0.14), rgba(229, 72, 77, 0.06));
}

.icon-tone-danger:hover {
  color: #ffffff;
  border-color: #e5484d;
  background: #e5484d;
}

.icon-tone-purple {
  color: #8b5cf6;
  border-color: rgba(139, 92, 246, 0.24);
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.14), rgba(139, 92, 246, 0.06));
}

.icon-tone-purple:hover {
  color: #ffffff;
  border-color: #8b5cf6;
  background: #8b5cf6;
}

.icon-tone-primary {
  color: #0ea5e9;
  border-color: rgba(14, 165, 233, 0.24);
  background: linear-gradient(180deg, rgba(14, 165, 233, 0.16), rgba(14, 165, 233, 0.06));
}

.icon-tone-primary:hover {
  color: #ffffff;
  border-color: #0ea5e9;
  background: linear-gradient(135deg, #34b8e6, #2563eb);
}

.icon-tone-success {
  color: #0f9f6e;
  border-color: rgba(15, 159, 110, 0.24);
  background: linear-gradient(180deg, rgba(15, 159, 110, 0.14), rgba(15, 159, 110, 0.06));
}

.icon-tone-success:hover {
  color: #ffffff;
  border-color: #0f9f6e;
  background: #0f9f6e;
}

.topbar-action-rail .icon-button.icon-tone-danger,
.topbar-action-rail .icon-button.icon-tone-purple,
.topbar-action-rail .icon-button.icon-tone-primary {
  border: 0;
  box-shadow: none;
}

.topbar-action-rail .top-new-trade-button.icon-tone-primary {
  color: #0284c7;
  background: linear-gradient(180deg, rgba(52, 184, 230, 0.2), rgba(37, 99, 235, 0.08));
}

.mobile-menu-button {
  color: #2563eb;
  background: linear-gradient(180deg, rgba(52, 184, 230, 0.12), rgba(255, 255, 255, 0.96));
}

.mobile-menu-button .app-icon {
  stroke: #2563eb;
}

#themeToggle.lucide-button {
  color: #8b5cf6;
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.12), rgba(255, 255, 255, 0.92));
}

.dark #themeToggle.lucide-button {
  color: #fbbf24;
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.16), rgba(15, 23, 42, 0.72));
}

.page-refresh-button {
  color: #0f9f6e;
  background: linear-gradient(180deg, rgba(15, 159, 110, 0.12), rgba(255, 255, 255, 0.92));
}

.purity-new-slip-button {
  color: #0284c7;
  border: 1px solid rgba(14, 165, 233, 0.24);
  background: linear-gradient(180deg, rgba(52, 184, 230, 0.16), rgba(37, 99, 235, 0.06));
}

.purity-new-slip-button:hover {
  color: #ffffff;
  border-color: #0ea5e9;
  background: linear-gradient(135deg, #34b8e6, #2563eb);
}

@media screen and (max-width: 760px) {
  .page-title-row h1,
  #pageTitle {
    font-size: clamp(15px, 4vw, 18px) !important;
    font-weight: 750;
  }

  .panel-header h2,
  .compact-panel-header h2,
  .purity-entry-header h2,
  .purity-list-header h2,
  .panel h2 {
    font-size: 14px !important;
    font-weight: 750;
  }

  .panel-header p,
  .compact-panel-header p,
  .panel p {
    font-size: 10px;
  }

  .topbar-action-rail .icon-button {
    width: 34px;
    height: 34px;
    min-height: 34px;
  }
}

/* ============================================================
   Mobile sidebar drawer only (v0.1.65)
   Does not change page/topbar layout — drawer scroll, footer, z-index.
   ============================================================ */
@media screen and (max-width: 760px) {
  .sidebar-overlay {
    z-index: 180;
  }

  .sidebar {
    z-index: 190;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: min(300px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    height: 100dvh;
    max-height: 100dvh;
    padding:
      max(10px, env(safe-area-inset-top, 0px))
      12px
      max(10px, env(safe-area-inset-bottom, 0px));
    overflow: hidden;
    box-shadow: 18px 0 48px rgba(15, 23, 42, 0.32);
  }

  .sidebar .brand {
    flex: 0 0 auto;
  }

  .sidebar-user-card {
    flex: 0 0 auto;
  }

  .sidebar .global-metal-toggle {
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
  }

  .sidebar .nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    align-content: start;
    gap: 6px;
    padding-right: 2px;
  }

  .sidebar-footer {
    flex: 0 0 auto;
    margin-top: 0;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  body.nav-open .topbar {
    z-index: 60;
  }

  .mobile-menu-button {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
  }
}

/* ============================================================
   Desktop topbar + unified segmented controls (v0.1.74)
   ============================================================ */
@media (min-width: 761px) {
  #mobileMenuToggle,
  .topbar .mobile-menu-toggle,
  .topbar .mobile-menu-button {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
  }

  .topbar-head {
    display: flex;
    align-items: flex-start;
    gap: 0;
    min-width: 0;
    flex: 1 1 auto;
  }

  .topbar-title-wrap {
    flex: 1 1 auto;
    min-width: 0;
  }
}

.segmented-shell,
.pending-tabs,
.segmented,
.capsule-toggle,
.balance-mode-switch,
.dashboard-metal-toggle,
.global-metal-toggle,
.pending-metal-toggle,
.pending-queue-toggle,
.manage-filter-tabs,
.cde-city-tabs,
.mini-segment {
  --segment-shell-radius: 10px;
  --segment-item-radius: 7px;
  display: inline-flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 2px;
  width: fit-content;
  max-width: 100%;
  padding: 3px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: var(--segment-shell-radius);
  background: color-mix(in srgb, var(--surface-2) 88%, #f8fafc);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.manage-filter-tabs,
.cde-city-tabs {
  display: grid;
  border-radius: 12px;
}

.manage-filter-tabs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented-shell > button,
.segmented-shell > .pending-tab,
.segmented-shell > .segment,
.pending-tabs > .pending-tab,
.pending-tabs > button,
.segmented > .segment,
.capsule-toggle > button,
.balance-mode-switch > button,
.dashboard-metal-toggle > .segment,
.global-metal-toggle > button,
.pending-metal-toggle > .pending-tab,
.pending-queue-toggle > .pending-tab,
.manage-filter-tabs > .pending-tab,
.cde-city-tabs > .mini-button,
.mini-segment > button {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 32px;
  padding: 0 14px;
  margin: 0;
  border: 0 !important;
  border-radius: var(--segment-item-radius) !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
  cursor: pointer;
  transform: none !important;
  -webkit-appearance: none;
  appearance: none;
}

.compact-tabs.pending-tabs > .pending-tab,
.last-trade-tools .pending-tabs > .pending-tab {
  min-height: 30px;
  padding: 0 12px;
  font-size: 12px;
}

.segmented-shell > button.active,
.segmented-shell > .pending-tab.active,
.pending-tabs > .pending-tab.active,
.segmented > .segment.active,
.capsule-toggle > button.active,
.balance-mode-switch > button.active,
.dashboard-metal-toggle > .segment.active,
.global-metal-toggle > button.active,
.pending-metal-toggle > .pending-tab.active,
.pending-queue-toggle > .pending-tab.active,
.manage-filter-tabs > .pending-tab.active,
.cde-city-tabs > .mini-button.active,
.mini-segment > button.active {
  color: #ffffff !important;
  background: linear-gradient(135deg, #43c3e8, #2f7df2) !important;
  box-shadow: 0 2px 10px rgba(47, 125, 242, 0.24) !important;
}

.segmented-shell > button:not(.active):hover,
.pending-tabs > .pending-tab:not(.active):hover,
.segmented > .segment:not(.active):hover,
.capsule-toggle > button:not(.active):hover,
.balance-mode-switch > button:not(.active):hover,
.dashboard-metal-toggle > .segment:not(.active):hover,
.global-metal-toggle > button:not(.active):hover,
.pending-metal-toggle > .pending-tab:not(.active):hover,
.pending-queue-toggle > .pending-tab:not(.active):hover,
.manage-filter-tabs > .pending-tab:not(.active):hover,
.cde-city-tabs > .mini-button:not(.active):hover,
.mini-segment > button:not(.active):hover {
  color: var(--text) !important;
  background: rgba(255, 255, 255, 0.72) !important;
  transform: none !important;
}

.transfer-mode-switch.same-rate > button.active {
  background: linear-gradient(135deg, #22c55e, #16a34a) !important;
}

.dark .segmented-shell,
.dark .pending-tabs,
.dark .segmented,
.dark .capsule-toggle,
.dark .balance-mode-switch,
.dark .dashboard-metal-toggle,
.dark .global-metal-toggle,
.dark .pending-metal-toggle,
.dark .pending-queue-toggle,
.dark .manage-filter-tabs,
.dark .cde-city-tabs,
.dark .mini-segment {
  border-color: rgba(148, 163, 184, 0.22);
  background: color-mix(in srgb, var(--surface-2) 90%, #0f172a);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.dark .pending-tabs > .pending-tab:not(.active):hover,
.dark .segmented > .segment:not(.active):hover,
.dark .manage-filter-tabs > .pending-tab:not(.active):hover {
  background: rgba(255, 255, 255, 0.06) !important;
}

/* ============================================================
   Modern print preview — thermal receipt styles injected by
   capra-print.js mountPreviewStyles(); keep only A4 preview shell.
   ============================================================ */
@media screen {
  .receipt-paper:has(> .capra-receipt),
  #receiptOutput:has(> .capra-receipt),
  #puritySlipOutput:has(> .capra-receipt) {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    max-height: min(62vh, 620px);
    padding: 14px;
    background: #eef4f8;
    border: 0;
    border-radius: 16px;
    font-family: Arial, "Segoe UI", sans-serif;
    color: #0f172a;
    white-space: normal;
  }

  #receiptOutput .capra-receipt-table,
  #puritySlipOutput .capra-receipt-table,
  .receipt-paper .capra-receipt-table {
    min-width: 0 !important;
    width: 100%;
    white-space: normal;
    table-layout: fixed;
  }

  #receiptOutput .capra-a4-doc,
  .receipt-dialog.report-preview .capra-a4-doc {
    width: min(100%, 794px);
    margin: 0 auto;
    padding: 22px;
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-radius: 14px;
    background: #fff;
    color: #0f172a;
    box-shadow: 0 22px 55px rgba(15, 23, 42, 0.16);
  }

  .receipt-dialog.report-preview .receipt-paper {
    background: #eef4f8;
    padding: 14px;
    border: 0;
    border-radius: 16px;
  }

  .receipt-dialog.report-preview .capra-a4-doc .general-report.print-mode {
    gap: 12px;
  }
}

@media screen {
  .db-loading {
    color: var(--muted, #64748b);
    font-size: 0.92rem;
    letter-spacing: 0.01em;
  }

  .is-db-saving {
    position: relative;
    pointer-events: none;
    opacity: 0.72;
  }

  .is-db-saving::after {
    content: attr(data-save-hint);
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 12px;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ink, #0f172a);
    background: color-mix(in srgb, var(--surface, #fff) 82%, transparent);
    border-radius: inherit;
    z-index: 2;
  }
}
