:root {
  /* Colors */
  --primary: #4F46E5;
  --primary-hover: #4338ca;
  --bg-body: #f3f4f6;
  --bg-card: #ffffff;
  --text-main: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;

  /* Accents */
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;

  /* Spacing & Radius */
  --radius: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
}

/* Layout */
.dashboard-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon {
  font-size: 32px;
  color: var(--primary);
}

h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.025em;
}

/* Main Content */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Filters Card */
.filters-card {
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 20px;
  border: 1px solid var(--border);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 200px;
}

.filter-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
}

.select-wrapper {
  position: relative;
}

select,
input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-main);
  background: var(--bg-card);
  appearance: none;
  transition: all 0.2s;
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.select-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
}

.filter-actions {
  display: flex;
  align-items: flex-end;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
  height: 42px;
  /* Match input height */
}

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

.btn-primary:active {
  transform: translateY(1px);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}

.stat-card {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.stat-icon.gross {
  background-color: #ecfdf5;
  color: var(--success);
}

.stat-icon.refund {
  background-color: #fef2f2;
  color: var(--danger);
}

.stat-icon.net {
  background-color: #eff6ff;
  color: var(--primary);
}

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-content h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
}

/* Chart Card */
.chart-card {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.chart-header {
  margin-bottom: 24px;
}

.chart-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.chart-wrapper {
  position: relative;
  height: 400px;
  width: 100%;
}

/* Responsive */
@media (max-width: 768px) {
  .dashboard-container {
    padding: 16px;
  }

  .filters-card {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
  }

  .btn-primary {
    width: 100%;
    justify-content: center;
  }

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

/* Transactions Table */
.transactions-card {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.table-header {
  margin-bottom: 16px;
}

.table-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.table-container {
  width: 100%;
  overflow-x: auto;
}

.transactions-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.transactions-table th,
.transactions-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.transactions-table th {
  background-color: #f9fafb;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.transactions-table tr:last-child td {
  border-bottom: none;
}

.transactions-table tr:hover {
  background-color: #f9fafb;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
}


.badge-primary {
  background-color: #e0e7ff;
  color: var(--primary);
}

.badge-success {
  background-color: #ecfdf5;
  color: var(--success);
}


.badge-warning {
  background-color: #fffbeb;
  color: var(--warning);
}

.badge-danger {
  background-color: #fef2f2;
  color: var(--danger);
}

.badge-default {
  background-color: #f3f4f6;
  color: var(--text-muted);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* View Mode Toggle */
.view-mode-toggle {
  display: flex;
  gap: 8px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.mode-btn:hover {
  color: var(--text-main);
  background: #f9fafb;
}

.mode-btn.active {
  background: var(--primary);
  color: white;
}

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

/* View Sections */
.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

/* Modal overlay */
.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;      /* top align */
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9999;
  overflow: auto;              /* allow overlay scroll on small screens */
}

/* Modal content: scroll inside */
.modal-content {
  width: 100%;
  max-width: 760px;
  max-height: calc(100vh - 48px);  /* never exceed viewport */
  overflow: auto;                  /* scroll inside */
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.modal-content h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-content label {
  display: block;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
}

.modal-content input {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
}

.modal-content hr {
  margin: 16px 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* Sticky action bar so Save/Cancel always reachable */
.modal-actions {
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
  padding-top: 12px;
  margin-top: 16px;
  border-top: 1px solid var(--border);

  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-actions button {
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.modal-actions button#saveAppBtn {
  background: var(--primary);
  color: #fff;
  border: none;
}
.modal-actions button#saveAppBtn:hover {
  background: var(--primary-hover);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

/* prevent checkbox being stretched */
.checkbox-row input[type="checkbox"] {
  width: auto !important;
  height: auto !important;
  margin: 0;
}

/* label inline, no extra spacing like normal labels */
.checkbox-row label {
  margin: 0 !important;
  font-weight: 600;
}

.checkbox-row{
  display:flex;
  align-items:center;
  gap:10px;
  margin-top:12px;
}

.checkbox-row input[type="checkbox"]{
  width:18px !important;
  height:18px !important;
  margin:0 !important;
}

.checkbox-text{
  font-weight:600;
  font-size:14px;
  line-height:18px;
}

/* Apps header */
.apps-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin: 8px 0 14px;
}

.apps-header h2{
  font-size: 22px;
  font-weight: 800;
  margin: 0;
}

/* Buttons */
.btn-secondary{
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: box-shadow .15s ease, transform .05s ease;
}
.btn-secondary:hover{
  box-shadow: 0 10px 24px rgba(0,0,0,.08);
}
.btn-sm{
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 13px;
}

/* Apps table */
.apps-table,
.transactions-table{
  width:100%;
  border-collapse: separate;
  border-spacing: 0;
}

.apps-table thead th,
.transactions-table thead th{
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  text-align: left;
  padding: 12px 14px;
}

.apps-table tbody td,
.transactions-table tbody td{
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.apps-table tbody tr:hover{
  background: #fcfcff;
}

/* Nice "Adjust enabled" indicator */
.adjust-pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: #fff;
}
.adjust-pill.on{
  border-color: rgba(16,185,129,.35);
}
.adjust-pill.off{
  border-color: rgba(239,68,68,.35);
}
.dot{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ef4444;
}
.adjust-pill.on .dot{
  background:#10b981;
}

/* ===== Apps Management polish ===== */
#appsView .apps-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  margin: 10px 0 14px;
}

#appsView .apps-header h2{
  margin:0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

#appsView .apps-header .btn-primary{
  height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* App table card look */
#appsView .table-container{
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

#appsView table{
  width:100%;
  border-collapse: separate;
  border-spacing: 0;
}

#appsView thead th{
  background: #fafafa;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

#appsView tbody td{
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 14px;
}

#appsView tbody tr:hover{
  background: #fcfcff;
}

/* Column helpers */
.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
}

/* Adjust status pill */
.adjust-pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid var(--border);
  background: #fff;
}

.adjust-pill .dot{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ef4444;
}

.adjust-pill.on{
  border-color: rgba(16,185,129,.35);
}

.adjust-pill.on .dot{
  background: #10b981;
}

.adjust-pill.off{
  border-color: rgba(239,68,68,.35);
}

/* Buttons */
.btn-secondary{
  height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: box-shadow .15s ease, transform .05s ease, background .15s ease;
}

.btn-secondary:hover{
  box-shadow: 0 10px 24px rgba(0,0,0,.08);
  background: #fff;
}

.btn-secondary:active{
  transform: translateY(1px);
}

.btn-ghost{
  height: 36px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.btn-ghost:hover{
  background: #f5f5f5;
}

/* Right align actions */
.actions-cell{
  text-align: right;
  white-space: nowrap;
}