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

:root {
  --ink: #0d0f12;
  --paper: #f3f7f3;
  --paper-strong: #ffffff;
  --accent: #1a6b4a;
  --accent-light: #e6f2ed;
  --accent-mid: #2d9e72;
  --gold: #c9a84c;
  --muted: #6b7280;
  --border: #ddd9d0;
  --sidebar-w: 300px;
  --sidebar-bg: #0d1a14;
  --hero-shadow: 0 28px 72px rgba(22, 70, 48, 0.12);
  --card-shadow: 0 16px 40px rgba(24, 61, 43, 0.08);
  --surface: rgba(255,255,255,0.84);
  --surface-strong: #ffffff;
  --surface-muted: #eef4ef;
  --success: #2f7a58;
  --ink-soft: #435046;
  --border-strong: rgba(32, 77, 56, 0.14);
}

html, body { height: 100%; }

body {
  font-family: 'DM Sans', sans-serif;
  color: var(--ink);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(45,158,114,0.11), transparent 28%),
    radial-gradient(circle at top right, rgba(201,168,76,0.10), transparent 24%),
    linear-gradient(180deg, #f7fbf8 0%, #eef5f0 100%);
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 36px 28px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
  overflow: hidden;
}

.sidebar::before {
  content: '';
  position: absolute;
  top: -80px; right: -60px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(45,158,114,0.18) 0%, transparent 70%);
  pointer-events: none;
}
.sidebar::after {
  content: '';
  position: absolute;
  bottom: 40px; left: -80px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,168,76,0.10) 0%, transparent 70%);
  pointer-events: none;
}

.brand {
  display: block;
  margin-bottom: 44px;
}

.brand-logo {
  display: block;
  width: 100%;
  max-width: 220px;
}

.brand-logo img {
  width: 100%;
  height: auto;
  display: block;
}

.nav-label {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  margin-bottom: 10px;
  padding-left: 4px;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: rgba(255,255,255,0.55);
  font-size: 0.88rem;
  font-weight: 400;
  transition: background 0.18s, color 0.18s;
}

.nav-item a:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
}

.nav-item.active a {
  background: rgba(45,158,114,0.2);
  color: #fff;
  font-weight: 500;
}

.nav-item .nav-icon {
  width: 18px; height: 18px;
  opacity: 0.8;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.sidebar-footer-text {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.25);
  line-height: 1.6;
}

.sidebar-footer-text strong {
  color: rgba(255,255,255,0.45);
  font-weight: 500;
}

/* ── MAIN CONTENT ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 48px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(16px);
  background: rgba(243,247,243,0.88);
}

.topbar-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}

.topbar-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--accent-light);
  color: var(--accent);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid rgba(45,158,114,0.14);
  box-shadow: 0 8px 22px rgba(33,91,61,0.08);
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent-mid);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.content {
  flex: 1;
  padding: 40px 48px 56px;
  width: 100%;
  max-width: 1340px;
  margin: 0 auto;
}

/* ── FORM CARD ── */
.form-card {
  background: rgba(255,255,255,0.88);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  animation: fadeUp 0.5s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.form-card-header {
  padding: 28px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.84) 0%, rgba(240,247,242,0.92) 100%);
}

.form-card-header .icon-box {
  width: 44px; height: 44px;
  background: var(--accent-light);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.form-card-header h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.22rem;
  color: var(--ink);
}

.form-card-header p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.form-body {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel-note {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--paper);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

/* Settings block */
.batch-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 18px;
  background: var(--paper);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.batch-settings > div {
  flex: 1 1 180px;
}

.batch-settings > button {
  flex: 0 0 auto;
}

.field-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.01em;
  margin-bottom: 6px;
  display: block;
}

.select-wrap {
  position: relative;
}

.text-input {
  width: 100%;
  background: var(--paper-strong);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--ink);
  transition: border-color 0.2s, background 0.2s;
  outline: none;
}

.text-input:focus {
  border-color: var(--accent-mid);
  background: #fff;
}

select {
  width: 100%;
  appearance: none;
  background: var(--paper-strong);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 11px 40px 11px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.2s;
  outline: none;
}

select:focus {
  border-color: var(--accent-mid);
  background: #fff;
}

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

/* Buttons */
.btn-batch-secondary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 12px 16px; background: #fff; color: var(--ink);
  border: 1.5px solid var(--border); border-radius: 10px;
  font-family: 'DM Sans', sans-serif; font-weight: 600; font-size: 0.85rem;
  cursor: pointer; white-space: nowrap; transition: border-color 0.2s, background 0.2s;
  height: 43px;
}
.btn-batch-secondary:hover { border-color: var(--accent-mid); background: var(--accent-light); }

.btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: auto;
  padding: 12px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(26,107,74,0.25);
  height: 43px;
}

.btn-submit:hover {
  background: var(--accent-mid);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(26,107,74,0.3);
}

.btn-submit:active { transform: translateY(0); }

.btn-batch-excel {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px; background: #0f766e; color: #fff;
  border: none; border-radius: 10px; font-family: 'Syne', sans-serif;
  font-weight: 700; font-size: 0.9rem; cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(15,118,110,0.2); transition: background 0.2s;
  height: 43px;
}
.btn-batch-excel:hover { background: #0d9488; transform: translateY(-2px); }

.btn-batch-tally {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 20px; background: #1e40af; color: #fff;
  border: none; border-radius: 12px; font-family: 'Syne', sans-serif;
  font-weight: 700; font-size: 0.9rem; cursor: pointer;
  box-shadow: 0 4px 16px rgba(30,64,175,0.25); transition: background 0.2s;
}
.btn-batch-tally:hover { background: #2563eb; transform: translateY(-2px); }

.btn-batch-xml {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 20px; background: #7c3aed; color: #fff;
  border: none; border-radius: 12px; font-family: 'Syne', sans-serif;
  font-weight: 700; font-size: 0.9rem; cursor: pointer;
  box-shadow: 0 4px 16px rgba(124,58,237,0.2); transition: background 0.2s;
}
.btn-batch-xml:hover { background: #9333ea; transform: translateY(-2px); }

.btn-batch-secondary:disabled,
.btn-batch-excel:disabled,
.btn-batch-tally:disabled,
.btn-batch-xml:disabled,
.btn-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none !important;
}

/* Status Box */
.batch-status-box {
  padding: 14px 16px; border-radius: 12px; background: var(--accent-light);
  font-size: 0.85rem; color: var(--ink); border: 1px solid var(--border-strong);
  line-height: 1.5;
}
.batch-status-box.error { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.batch-status-box.ok    { background: #dcfce7; color: #166534; border-color: #86efac; }

/* Summary Chips */
.upload-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 768px) {
  .upload-summary {
    grid-template-columns: 1fr;
  }
}
.summary-chip {
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface-muted);
  border: 1px solid rgba(45,158,114,0.15);
}
.summary-chip strong {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  color: var(--ink);
}
.summary-chip span {
  font-size: 0.8rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

/* Table Shell */
.table-shell {
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  overflow: auto;
  background: #fff;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  min-width: 1360px;
}
.history-table thead tr { background: var(--accent-light); }
.history-table th {
  padding: 11px 12px;
  text-align: left;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
.history-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0ede8;
  vertical-align: middle;
}
.history-table tbody tr:last-child td { border-bottom: none; }
.history-table tbody tr:hover td { background: var(--accent-light); }

.amount-cell {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Card styling */
.section-card {
  padding: 24px;
  border-radius: 24px;
  background: rgba(255,255,255,0.88);
  border: 1px solid var(--border-strong);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-card h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1.08rem;
  color: var(--ink);
}

.section-card p {
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.65;
}

.section-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.file-input-inline {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  outline: none;
}

.field-helper {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.batch-action-bar {
  display: flex; gap: 12px; flex-wrap: wrap;
}

/* Footer strip */
.info-strip {
  display: flex;
  gap: 16px;
  margin-top: 24px;
}

@media (max-width: 768px) {
  .info-strip {
    flex-direction: column;
  }
}

.info-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.84);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  flex: 1;
  box-shadow: var(--card-shadow);
}

.info-chip svg { color: var(--accent-mid); flex-shrink: 0; }

/* Responsive main */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .content { padding: 24px; }
  .topbar { padding: 16px 24px; }
}

/* ── SEARCH BAR & ACTION BAR ── */
.search-bar-container {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  align-items: center;
  background: var(--paper);
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.table-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  margin-bottom: 8px;
  padding: 0 4px;
}

.selected-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.btn-danger {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px; background: #991b1b; color: #fff;
  border: none; border-radius: 10px; font-family: 'Syne', sans-serif;
  font-weight: 700; font-size: 0.9rem; cursor: pointer;
  box-shadow: 0 4px 16px rgba(153, 27, 27, 0.2); transition: background 0.2s;
  height: 43px;
}
.btn-danger:hover { background: #b91c1c; transform: translateY(-2px); }
.btn-danger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none !important;
}

/* Row Selected Highlight */
.history-table tbody tr.row-selected td {
  background: #f0f7f3 !important;
  border-bottom-color: rgba(45,158,114,0.2);
}

/* ── MODAL POPUP WINDOWS ── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(13, 26, 20, 0.5);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.2s ease both;
}

.modal-content {
  background: #ffffff;
  border-radius: 18px;
  width: 92%;
  max-width: 900px;
  max-height: 88vh;
  box-shadow: 0 24px 64px rgba(13, 26, 20, 0.25);
  border: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(255,255,255,0.9) 0%, rgba(240,247,242,0.95) 100%);
}

.modal-header h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  transition: color 0.15s;
}
.close-btn:hover { color: #b91c1c; }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.grid-col-span-2 {
  grid-column: span 2;
}

.grid-col-span-4 {
  grid-column: span 4;
}

.modal-entries-table-container {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  margin-top: 8px;
}

.modal-entries-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.modal-entries-table th {
  background: var(--accent-light);
  padding: 10px 12px;
  text-align: left;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  border-bottom: 1.5px solid var(--border);
}

.modal-entries-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0ede8;
  vertical-align: middle;
}

.modal-entries-table tbody tr:last-child td {
  border-bottom: none;
}

.remove-entry-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}
.remove-entry-btn:hover { color: #b91c1c; }

.balance-tracker {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  margin-top: 12px;
  padding: 12px 18px;
  background: var(--paper);
  border-radius: 10px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
}

.balance-value {
  font-weight: 700;
}
.balance-value.balanced { color: var(--success); }
.balance-value.unbalanced { color: #b91c1c; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f9fbf9;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalScaleUp {
  from { transform: scale(0.96) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}


/* ── EXCEL BATCH IMPORT DASHBOARD & METRICS ── */
.import-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.import-card {
  background: var(--paper-strong);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-left: 4px solid var(--muted);
  transition: transform 0.2s, box-shadow 0.2s;
  min-height: 100px;
}

.import-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.04);
}

.import-card.accent {
  border-left-color: var(--accent);
}

.import-card.success {
  border-left-color: var(--success);
}

.import-card.warning {
  border-left-color: var(--gold);
}

.import-card.danger {
  border-left-color: #b91c1c;
}

.import-card span {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.import-card strong {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.import-card .card-footer {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-entries-table tbody tr:hover {
  background-color: rgba(45, 158, 114, 0.02);
}

.status-pill.disconnected {
  background: #f1f3f5 !important;
  color: #868e96 !important;
  border-color: #dee2e6 !important;
  box-shadow: none !important;
}

.status-pill.disconnected .status-dot {
  background: #868e96 !important;
  animation: none !important;
}
