:root {
  --bg: #0B0F14;
  --surface: #131A22;
  --surface-2: #1B242F;
  --surface-3: #212B37;
  --border: #26313D;
  --text: #E7ECF2;
  --muted: #8493A3;
  --muted-2: #5C6B7A;
  --gold: #D4A24C;
  --gold-soft: rgba(212, 162, 76, 0.14);
  --green: #4ADE80;
  --green-soft: rgba(74, 222, 128, 0.14);
  --amber: #F5B942;
  --amber-soft: rgba(245, 185, 66, 0.14);
  --blue: #60A5FA;
  --blue-soft: rgba(96, 165, 250, 0.14);
  --red: #F2695C;
  --red-soft: rgba(242, 105, 92, 0.14);
  --radius: 10px;
  font-family: 'IBM Plex Sans Bengali', 'IBM Plex Sans', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 10% 0%, rgba(212,162,76,0.06), transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(96,165,250,0.05), transparent 35%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.mono { font-family: 'IBM Plex Mono', monospace; }

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-mark {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--gold-soft);
  color: var(--gold);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.02em; }
.login-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; }
.login-error {
  background: var(--red-soft); color: var(--red);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 16px;
}
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 16px;
  text-align: center;
  letter-spacing: 0.3em;
  font-family: 'IBM Plex Mono', monospace;
}
.login-form input:focus { outline: none; border-color: var(--gold); }
.login-form button {
  background: var(--gold);
  color: #1a1204;
  border: none;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  transition: filter 0.15s;
}
.login-form button:hover { filter: brightness(1.08); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: rgba(11,15,20,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--gold-soft);
  color: var(--gold);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 19px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.brand-text h1 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.save-status { font-size: 12.5px; color: var(--muted); }
.save-status.dirty { color: var(--amber); }
.save-status.error { color: var(--red); }

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: filter 0.15s, transform 0.1s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: #1a1204; font-weight: 600; }
.btn-accent { background: var(--surface-3); border-color: var(--gold); color: var(--gold); font-weight: 600; }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--red-soft); border-color: transparent; color: var(--red); padding: 6px 10px; font-size: 12px; }
.btn-danger:hover { background: var(--red); color: #1a0a08; }

/* ---------- Layout ---------- */
.wrap { max-width: 1400px; margin: 0 auto; padding: 24px 20px 60px; min-width: 0; }

/* ---------- Tax bar ---------- */
.tax-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tax-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.tax-input {
  width: 90px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 600;
}
.tax-input:focus { outline: none; border-color: var(--gold); }
.tax-hint { font-size: 12px; color: var(--muted-2); }

/* ---------- Summary cards ---------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.summary-card .label {
  font-size: 12px; color: var(--muted);
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}
.summary-card .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.summary-card .value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 22px; font-weight: 600;
  letter-spacing: -0.01em;
}
.summary-card .sub { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }
.summary-card .after-tax {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  margin-top: 6px;
}
.summary-card .after-tax span { color: var(--muted-2); font-weight: 500; font-size: 11px; }
.summary-card.accent { border-color: rgba(212,162,76,0.35); }
.profit-stack { min-width: 0; }
.profit-stack .gross { color: var(--gold); font-weight: 600; }
.profit-stack .net {
  font-size: 10px;
  color: var(--green);
  font-family: 'IBM Plex Mono', monospace;
  margin-top: 2px;
  white-space: nowrap;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 14px;
}
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 13px;
  border-radius: 20px;
  font-size: 12.5px;
  cursor: pointer;
}
.tab.active { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); font-weight: 600; }
.toolbar-right { display: flex; gap: 10px; align-items: center; }
.search-box {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  width: 200px;
}
.search-box:focus { outline: none; border-color: var(--gold); }

/* ---------- Table ---------- */
.table-scroll {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 280px);
  -webkit-overflow-scrolling: touch;
}
.fd-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
}
.fd-table thead th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted-2);
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  position: sticky; top: 0;
  z-index: 2;
  white-space: normal;
  line-height: 1.25;
  word-break: break-word;
}
.fd-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}
.fd-table thead th.sortable:hover { color: var(--text); }
.fd-table thead th.sortable::after {
  content: '';
  display: inline-block;
  margin-left: 4px;
  opacity: 0.35;
  font-size: 9px;
}
.fd-table thead th.sort-asc::after { content: '▲'; opacity: 0.9; color: var(--gold); }
.fd-table thead th.sort-desc::after { content: '▼'; opacity: 0.9; color: var(--gold); }
.fd-table tbody td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  vertical-align: middle;
  overflow: hidden;
}
.fd-table tbody tr:hover { background: rgba(255,255,255,0.015); }
.fd-table tbody tr:last-child td { border-bottom: none; }

.fd-table input, .fd-table select {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 12px;
  padding: 4px 4px;
  border-radius: 5px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  font-family: 'IBM Plex Mono', monospace;
}
.fd-table input[type="text"], .fd-table select { font-family: 'IBM Plex Sans Bengali', 'IBM Plex Sans', sans-serif; }
.fd-table input:hover, .fd-table select:hover { border-color: var(--border); background: var(--surface-2); }
.fd-table input:focus, .fd-table select:focus {
  outline: none; border-color: var(--gold); background: var(--surface-2);
}
.fd-table input[type="date"] { color-scheme: dark; min-width: 0; font-size: 11px; }
.fd-table input[type="number"] { min-width: 0; }
.fd-table select { min-width: 0; font-size: 11px; }

.col-bank { width: 8%; }
.col-status { width: 9%; }
.col-id { width: 9%; }
.col-id input { font-weight: 600; }
.col-money { width: 8%; }
.col-profit input[readonly] { color: var(--gold); font-weight: 600; cursor: default; }
.col-rate { width: 7%; }
.col-date { width: 8%; }
.col-tenure { width: 5%; }
.col-renew-mode { width: 10%; }
.col-notes { width: 8%; }
.col-actions { width: 9%; text-align: right; white-space: nowrap; }
.col-actions .btn { margin-left: 4px; }
.btn-renew {
  background: var(--green-soft);
  border-color: transparent;
  color: var(--green);
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
}
.btn-renew:hover { background: var(--green); color: #06210f; }

.status-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600;
  padding: 2px 6px; border-radius: 20px;
  width: fit-content;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.badge.active { background: var(--green-soft); color: var(--green); }
.badge.pending { background: var(--amber-soft); color: var(--amber); }
.badge.confirmed { background: var(--blue-soft); color: var(--blue); }

.progress-track {
  height: 4px; border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }
.progress-fill.active { background: var(--green); }
.progress-fill.pending { background: var(--amber); }
.progress-fill.confirmed { background: var(--blue); }
.days-left { font-size: 10.5px; color: var(--muted-2); font-family: 'IBM Plex Mono', monospace; }

.col-actions .btn-danger { padding: 4px 6px; font-size: 11px; white-space: nowrap; }

.empty-state {
  padding: 60px 20px; text-align: center; color: var(--muted);
  font-size: 13.5px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(74,222,128,0.4); }
.toast.error { border-color: rgba(242,105,92,0.4); }

@media (max-width: 700px) {
  .wrap { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-box { width: 100%; }
}
