*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #161822;
  --bg-card: #1c1f2b;
  --bg-sidebar: #11131a;
  --bg-hover: #252836;
  --bg-input: #141620;
  --border: #2a2d3a;
  --border-focus: #6c5ce7;
  --text: #e1e4ed;
  --text-secondary: #8b8fa8;
  --text-muted: #5c6078;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-hover: #7d6ff0;
  --green: #00c897;
  --green-bg: rgba(0, 200, 151, 0.1);
  --yellow: #f6c445;
  --yellow-bg: rgba(246, 196, 69, 0.1);
  --red: #ff5c72;
  --red-bg: rgba(255, 92, 114, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
  width: 230px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.logo-icon { width: 22px; height: 22px; color: var(--accent); }

.sidebar-nav { flex: 1; padding: 12px 10px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }

.nav-icon { width: 18px; height: 18px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 7px; height: 7px;
  background: var(--green);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px rgba(0, 200, 151, 0.4);
}

/* Main */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  min-width: 0;
}

.main::-webkit-scrollbar { width: 6px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

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

.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  letter-spacing: -0.1px;
}

.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(108, 92, 231, 0.25); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(108, 92, 231, 0.35); transform: translateY(-1px); }

.btn-outline { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg-hover); color: var(--text); border-color: var(--text-muted); }

.btn-rate {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
}
.btn-rate:hover { background: var(--bg-hover); color: var(--accent); border-color: var(--accent); }

.btn-rate .icon-sm { width: 16px; height: 16px; transition: transform 0.6s; }
.btn-rate.spinning .icon-sm { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.btn-icon {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 6px 8px; border-radius: var(--radius-xs);
  transition: all 0.15s; display: inline-flex; align-items: center;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }
.btn-icon-danger:hover { background: var(--red-bg); color: var(--red); }

.action-btns { display: flex; gap: 2px; }
.icon-sm { width: 15px; height: 15px; }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.stat-card:hover { border-color: var(--text-muted); }

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-currency {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent-light);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 4px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}
.stat-currency:hover { border-color: var(--accent); }
.stat-currency option { background: var(--bg-card); color: var(--text); }

.stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.stat-green { color: var(--green); }
.stat-yellow { color: var(--yellow); }

/* Table */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 14px 18px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.data-table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

.amount-from { color: var(--accent-light); font-weight: 600; font-variant-numeric: tabular-nums; }
.amount-to { color: var(--green); font-weight: 600; font-variant-numeric: tabular-nums; }
.rate-cell { color: var(--text-secondary); font-size: 12px; font-variant-numeric: tabular-nums; }
.desc-cell { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date-cell { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  font-family: inherit;
}

.status-issued {
  background: var(--green-bg);
  color: var(--green);
  border-color: rgba(0, 200, 151, 0.2);
}
.status-issued:hover { background: rgba(0, 200, 151, 0.18); }

.status-pending {
  background: var(--yellow-bg);
  color: var(--yellow);
  border-color: rgba(246, 196, 69, 0.2);
}
.status-pending:hover { background: rgba(246, 196, 69, 0.18); }

.status-dot-sm {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.status-issued .status-dot-sm { background: var(--green); box-shadow: 0 0 6px rgba(0, 200, 151, 0.5); }
.status-pending .status-dot-sm { background: var(--yellow); box-shadow: 0 0 6px rgba(246, 196, 69, 0.5); }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon { width: 44px; height: 44px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 14px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal::-webkit-scrollbar { width: 5px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

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

.modal-header h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }

.modal-close {
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer; padding: 4px; border-radius: var(--radius-xs);
  transition: all 0.15s; display: flex;
}
.modal-close:hover { color: var(--text); background: var(--bg-hover); }

.modal-body { padding: 20px 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.form-group { margin-bottom: 15px; }
.form-group label {
  display: block;
  margin-bottom: 7px;
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-currency { flex: 0 0 130px !important; }
.form-rate { flex: 2 !important; }

/* Custom inputs */
.custom-input,
.custom-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.15s;
}

.custom-input:focus,
.custom-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.custom-input::placeholder { color: var(--text-muted); }

.custom-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b8fa8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 36px;
}

.custom-select option {
  background: var(--bg-card);
  color: var(--text);
  padding: 8px;
}

.rate-row { display: flex; gap: 8px; }
.rate-row input { flex: 1; }

.converted-preview {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: -0.3px;
}

.modal-error {
  background: var(--red-bg);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-top: 10px;
  display: none;
  border: 1px solid rgba(255, 92, 114, 0.2);
}

.modal-error.show { display: block; }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  animation: slideIn 0.25s ease;
  min-width: 280px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Detail overlay */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
  display: none;
  align-items: flex-end;
}
.detail-overlay.active { display: flex; }

.detail-card {
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px 20px 32px;
  animation: slideUp 0.25s ease;
  position: relative;
}

.detail-close {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.detail-header { margin-bottom: 18px; padding-right: 30px; }
.detail-header h3 { font-size: 17px; font-weight: 700; word-break: break-word; }
.detail-date { font-size: 12px; color: var(--text-muted); margin-top: 4px; display: block; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.detail-item {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.detail-label { display: block; font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.detail-val { font-size: 14px; font-weight: 600; }

.detail-actions { display: flex; gap: 8px; }
.detail-actions .btn { flex: 1; justify-content: center; }

.tr-tap { cursor: pointer; }
.tr-tap:active { background: var(--bg-hover) !important; }

/* Responsive */
@media (max-width: 1024px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { padding: 8px; }
  .page-title { font-size: 17px; }
  .topbar { flex-direction: row; gap: 8px; align-items: center; }
  .topbar .btn { padding: 8px 14px; font-size: 13px; flex-shrink: 0; }

  /* Stats: 2 cols, compact */
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 16px; }
  .stat-card { padding: 10px 11px; border-radius: var(--radius-sm); }
  .stat-value { font-size: 16px; }
  .stat-label { font-size: 9.5px; letter-spacing: 0.3px; flex-wrap: wrap; gap: 3px; }
  .stat-currency { font-size: 10px; padding: 1px 5px; }

  /* Table: horizontal scroll on mobile */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
  }
  .data-table { min-width: 650px; }
  .data-table td,
  .data-table th { display: none; }
  .data-table th:nth-child(1), .data-table td:nth-child(1),
  .data-table th:nth-child(2), .data-table td:nth-child(2),
  .data-table th:nth-child(3), .data-table td:nth-child(3),
  .data-table th:nth-child(5), .data-table td:nth-child(5),
  .data-table th:nth-child(6), .data-table td:nth-child(6),
  .data-table th:nth-child(7), .data-table td:nth-child(7) {
    display: table-cell;
  }
  .data-table th, .data-table td { padding: 10px 8px; font-size: 13px; white-space: nowrap; }
  .data-table th { font-size: 10px; padding: 10px 8px; }
  .tr-tap { cursor: pointer; }
  .tr-tap:active { background: var(--bg-hover); }

  /* Actions in a column */
  .action-btns { flex-direction: column; gap: 1px; }
  .btn-icon { padding: 5px 6px; }
  .btn-icon .icon-sm { width: 13px; height: 13px; }

  /* Modal */
  .modal {
    width: 100%; max-width: 100vw; max-height: 100vh;
    border-radius: 0; margin: 0;
    display: flex; flex-direction: column;
  }
  .modal-overlay { align-items: flex-end; }
  .modal-overlay.active .modal { animation: slideUp 0.25s ease; }
  .modal-body { padding: 12px; flex: 1; overflow-y: auto; }
  .modal-header { padding: 10px 12px; flex-shrink: 0; }
  .modal-footer { padding: 8px 12px; flex-shrink: 0; }
  .modal-header h2 { font-size: 14px; }

  .form-row { flex-direction: column; gap: 0; }
  .form-currency, .form-rate { flex: 1 !important; }
  .custom-input, .custom-select { font-size: 16px; padding: 10px 12px; height: 44px; }
  .custom-select { background-position: right 10px center; padding-right: 34px; }
  .form-group { margin-bottom: 10px; }
  .form-group label { font-size: 11px; margin-bottom: 4px; }

  .converted-preview { font-size: 18px; padding: 10px; }
  .btn-rate { min-width: 44px; min-height: 44px; }

  .toast-container { left: 6px; right: 6px; bottom: 6px; }
  .toast { min-width: 0; font-size: 11px; padding: 10px 14px; }

  .status-badge { padding: 4px 7px; font-size: 10px; }
}

@media (max-width: 400px) {
  .stats-row { gap: 4px; }
  .stat-card { padding: 8px 9px; }
  .stat-value { font-size: 14px; }
  .stat-label { font-size: 8.5px; }
  .stat-currency { font-size: 9px; }
  .data-table th, .data-table td { padding: 7px 4px; font-size: 10.5px; }
  .data-table th { font-size: 8px; }
  .desc-cell { max-width: 70px; }
  .topbar .btn { padding: 7px 10px; font-size: 12px; }
}

.logo-icon-img { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; }
