:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --purple: #7c3aed;
  --shadow: 0 20px 45px rgba(15, 23, 42, .08);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}

.sidebar {
  width: 288px;
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid #eef2f7;
  flex: 0 0 auto;
  z-index: 60;
}

.sidebar-inner {
  height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: 18px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 950;
  box-shadow: 0 14px 28px rgba(37, 99, 235, .25);
}

.brand-row h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1;
  letter-spacing: -.05em;
  text-transform: uppercase;
}

.brand-row h1 span {
  color: var(--primary);
  font-weight: 500;
  text-transform: lowercase;
  letter-spacing: -.03em;
}

.brand-row small {
  color: var(--muted-light);
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.nav-list {
  display: grid;
  gap: 12px;
  flex: 1;
  align-content: start;
}

.nav-item {
  width: 100%;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
  text-align: left;
  transition: .18s ease;
}

.nav-item b {
  margin-left: auto;
  opacity: 0;
  transition: .18s ease;
}

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

.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 16px 30px rgba(37, 99, 235, .18);
}

.nav-item.active b {
  opacity: 1;
}

.daily-card {
  border: 1px solid #eef2f7;
  border-radius: 28px;
  background: var(--surface-soft);
  padding: 20px;
}

.daily-card p {
  margin: 0 0 14px;
  color: var(--muted-light);
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.daily-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border: 1px solid #eaf0f7;
  padding: 12px;
  border-radius: 14px;
  margin-top: 9px;
  font-size: 12px;
  font-weight: 850;
}

.daily-row span {
  color: var(--muted-light);
  font-style: italic;
}

.daily-row strong {
  color: var(--primary);
}

.danger-text {
  color: var(--danger) !important;
}

.main-panel {
  flex: 1;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.content-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 44px 56px;
}

#appContent {
  max-width: 1180px;
  margin: 0 auto;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid #eef2f7;
  padding: 16px 20px;
  align-items: center;
  justify-content: space-between;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 16px;
  background: var(--surface-soft);
  color: var(--text);
  display: grid;
  place-items: center;
  font-weight: 950;
  font-size: 22px;
}

.mobile-only {
  display: none;
}

.hero-card {
  background: linear-gradient(135deg, #1e293b, #020617);
  color: #fff;
  border-radius: 30px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 26px;
}

.hero-card h3,
.hero-card p {
  margin: 0;
}

.hero-card h3 {
  font-size: 18px;
  font-weight: 950;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero-card p {
  margin-top: 6px;
  color: #94a3b8;
  font-size: 13px;
}

.btn-light {
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .10);
  color: #fff;
  border-radius: 16px;
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 900;
  transition: .18s ease;
}

.btn-light:hover {
  background: rgba(255, 255, 255, .18);
}

.grid-main {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 26px;
}

.stack {
  display: grid;
  gap: 18px;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 3px 20px rgba(15, 23, 42, .03);
}

.card-pad {
  padding: 24px;
}

.balance-card p,
.section-title p,
.stat-line span,
label {
  color: var(--muted-light);
}

.balance-card p {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .14em;
}

.balance-card h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 36px);
  font-weight: 950;
  letter-spacing: -.05em;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.section-title h3,
.section-title h2,
.section-title p {
  margin: 0;
}

.section-title h3,
.section-title h2 {
  font-weight: 950;
  letter-spacing: -.03em;
}

.section-title p {
  font-size: 13px;
  margin-top: 4px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: block;
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .10em;
  margin-bottom: 7px;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  border-radius: 16px;
  padding: 14px 14px;
  outline: none;
  font-weight: 800;
  transition: .15s ease;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .10);
  background: #fff;
}

.input-wrap {
  position: relative;
}

.input-wrap span {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-light);
  font-weight: 950;
  font-size: 14px;
}

.input-wrap input {
  padding-left: 42px;
}

.input-wrap.rate input {
  color: var(--primary-dark);
  background: #eff6ff;
  border-color: #bfdbfe;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  background: var(--surface-soft);
  border-radius: 16px;
}

.segmented button {
  border: 0;
  border-radius: 12px;
  padding: 11px 10px;
  background: transparent;
  color: var(--muted-light);
  font-size: 12px;
  font-weight: 950;
  transition: .16s ease;
}

.segmented button.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 6px 14px rgba(15, 23, 42, .06);
}

.result-box {
  display: none;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--primary);
  color: #fff;
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 18px 35px rgba(37, 99, 235, .18);
}

.result-box.show {
  display: flex;
}

.result-box small {
  display: block;
  text-transform: uppercase;
  letter-spacing: .14em;
  opacity: .7;
  font-weight: 950;
  font-size: 10px;
}

.result-box strong {
  display: block;
  margin-top: 2px;
  font-size: 25px;
  font-weight: 950;
}

.result-icon {
  background: rgba(255, 255, 255, .18);
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 950;
}

.btn-primary,
.btn-dark,
.btn-danger,
.btn-soft {
  border: 0;
  border-radius: 16px;
  padding: 15px 18px;
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .10em;
  transition: .16s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 16px 28px rgba(37, 99, 235, .18);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-dark {
  width: 100%;
  background: #0f172a;
  color: #fff;
  box-shadow: 0 16px 28px rgba(15, 23, 42, .15);
}

.btn-dark:hover {
  background: #020617;
}

.btn-soft {
  background: #f1f5f9;
  color: var(--text);
}

.btn-danger {
  background: #fee2e2;
  color: var(--danger);
}

.table-card {
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.table-header {
  padding: 22px 24px;
  background: rgba(248, 250, 252, .7);
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.table-title {
  margin: 0;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
  font-weight: 950;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

thead {
  background: #f8fafc;
  color: var(--muted-light);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 950;
}

th,
td {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}

tbody tr:hover {
  background: #f8fafc;
}

.td-right {
  text-align: right;
}

.td-center {
  text-align: center;
}

.muted-small {
  color: var(--muted-light);
  font-size: 10px;
  font-weight: 900;
}

.desc-cell {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: -.02em;
}

.badge.sell {
  background: #fef3c7;
  color: #92400e;
}

.badge.buy {
  background: #ede9fe;
  color: #5b21b6;
}

.delete-btn {
  border: 0;
  background: transparent;
  color: #cbd5e1;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  font-size: 18px;
}

.delete-btn:hover {
  background: #fee2e2;
  color: var(--danger);
}

.empty-row td {
  padding: 80px 20px;
  text-align: center;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 12px;
  font-weight: 950;
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 26px;
}

.report-header h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 950;
  letter-spacing: -.04em;
}

.report-header p {
  margin: 4px 0 0;
  color: var(--muted-light);
  font-size: 14px;
  font-weight: 700;
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-bottom: 24px;
}

.report-card {
  overflow: hidden;
}

.report-card-title {
  color: #fff;
  padding: 14px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .13em;
  font-size: 10px;
  font-weight: 950;
}

.report-card-title.brl {
  background: var(--primary);
}

.report-card-title.bob {
  background: var(--success);
}

.report-lines {
  padding: 22px;
  display: grid;
  gap: 14px;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 10px;
  font-size: 14px;
}

.stat-line strong {
  font-weight: 950;
}

.stat-line.final {
  border-bottom: 0;
  padding-top: 4px;
  padding-bottom: 0;
  text-transform: uppercase;
  color: var(--text);
}

.stat-line.final strong {
  color: var(--primary);
  font-size: 20px;
}

.settings-wrap {
  max-width: 760px;
  margin: 0 auto;
}

.settings-card {
  padding: 34px;
  border-radius: 38px;
}

.big-rate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.big-rate-grid label {
  text-align: center;
}

.big-rate-grid input {
  font-size: 42px;
  text-align: center;
  padding: 24px 16px;
  border-radius: 28px;
  font-weight: 950;
}

.info-box {
  margin-top: 28px;
  display: flex;
  gap: 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  border-radius: 28px;
  padding: 20px;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .62);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 30px;
  box-shadow: 0 30px 80px rgba(2, 6, 23, .28);
  overflow: hidden;
}

.modal-head {
  padding: 22px;
  background: #f8fafc;
  border-bottom: 1px solid #eef2f7;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-head h3 {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: -.03em;
  font-size: 20px;
  font-weight: 950;
}

.modal-body {
  padding: 28px;
  display: grid;
  gap: 18px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 999;
  max-width: min(380px, calc(100vw - 40px));
  background: #0f172a;
  color: #fff;
  padding: 14px 16px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 850;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  background: #991b1b;
}

.toast.success {
  background: #065f46;
}

.overlay {
  display: none;
}

@media (max-width: 1024px) {
  .mobile-only {
    display: flex;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 30px 60px rgba(15, 23, 42, .18);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .overlay.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .58);
    backdrop-filter: blur(4px);
    z-index: 50;
  }

  .main-panel {
    width: 100%;
  }

  .content-wrap {
    padding: 22px;
  }

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

@media (max-width: 720px) {
  .hero-card,
  .report-header {
    align-items: stretch;
    flex-direction: column;
  }

  .field-grid,
  .report-grid,
  .big-rate-grid {
    grid-template-columns: 1fr;
  }

  .content-wrap {
    padding: 16px;
  }

  .card-pad,
  .settings-card {
    padding: 20px;
  }

  .big-rate-grid input {
    font-size: 34px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .btn-primary,
  .btn-dark,
  .btn-soft,
  .hero-card,
  .toast,
  .delete-btn {
    display: none !important;
  }

  .main-panel {
    height: auto;
    overflow: visible;
  }

  .content-wrap {
    padding: 0;
    overflow: visible;
  }

  .card {
    box-shadow: none;
  }

  th,
  td {
    padding: 10px;
  }
}
