/* ============================================================
   Almaz dashboard — dark design system
   Layered neutrals + single emerald accent, Inter, 4px rhythm.
   ============================================================ */

@import url("fonts/fonts.css");

:root {
  /* surfaces: one hue family, depth via white-alpha layers */
  --bg: #09090b;
  --bg-aura-1: rgba(52, 211, 153, 0.05);
  --bg-aura-2: rgba(129, 140, 248, 0.04);
  --surface: #101013;
  --surface-2: #141418;
  --surface-3: #191920;
  --border: rgba(255, 255, 255, 0.06);
  --border-hi: rgba(255, 255, 255, 0.11);
  --border-hover: rgba(255, 255, 255, 0.16);

  /* text */
  --text: #fafafa;
  --text-2: #a1a1aa;
  --text-3: #68686f;

  /* accents */
  --accent: #34d399;
  --accent-hi: #6ee7b7;
  --accent-ink: #052e1e;
  --accent-dim: rgba(52, 211, 153, 0.12);
  --violet: #a78bfa;
  --amber: #fbbf24;
  --sky: #38bdf8;
  --danger: #f87171;
  --danger-dim: rgba(248, 113, 113, 0.12);

  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 9px;

  --shadow-pop: 0 8px 30px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 560px at 88% -12%, var(--bg-aura-1), transparent 62%),
    radial-gradient(1000px 480px at -12% -4%, var(--bg-aura-2), transparent 58%),
    var(--bg);
  color: var(--text);
  font: 400 14.5px/1.55 "Inter", "Segoe UI", system-ui, sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "ss01";
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

::selection { background: rgba(52, 211, 153, 0.28); }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 8px; border: 2.5px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.18); }
::-webkit-scrollbar-track { background: transparent; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.02em; }
h1 { font-size: 21px; }
h2 { font-size: 18px; }
h3 { font-size: 14.5px; }

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 12px; font-weight: 450; }
.accent { color: var(--accent); }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.strong { font-weight: 600; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 14px;
  padding: 11px 24px;
  background: rgba(9, 9, 11, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-badge {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, rgba(52,211,153,.18), rgba(52,211,153,.05));
  border: 1px solid rgba(52, 211, 153, 0.25);
  box-shadow: 0 0 16px rgba(52, 211, 153, 0.12);
}
.brand-name { font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: var(--text-3); margin-top: -2px; }

/* segmented preset control */
.presets {
  display: flex; gap: 2px; padding: 3px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
  border-radius: 11px;
}
.chip {
  border: 1px solid transparent; background: transparent; color: var(--text-2);
  padding: 5px 13px; border-radius: 8px; font: inherit; font-size: 12.5px;
  font-weight: 500; cursor: pointer; transition: all 0.16s var(--ease); white-space: nowrap;
}
.chip:hover { color: var(--text); }
.chip.active {
  color: var(--text); background: var(--surface-3);
  border-color: var(--border-hi); box-shadow: 0 1px 0 rgba(255,255,255,.05) inset, 0 2px 8px rgba(0,0,0,.3);
}

.topbar-links { margin-left: auto; display: flex; gap: 2px; }
.icon-link {
  display: grid; place-items: center; width: 34px; height: 34px;
  color: var(--text-3); border-radius: var(--r-sm);
  transition: all 0.15s var(--ease);
}
.icon-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); text-decoration: none; }

/* --------------------------------------------------------------- layout */
.container { max-width: 1200px; margin: 0 auto; padding: 22px 24px 64px; }
.container.narrow { max-width: 560px; }

.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: border-color 0.18s var(--ease);
}
.footer { text-align: center; margin-top: 26px; font-size: 12.5px; color: var(--text-3); }

/* ------------------------------------------------------------ quick add */
.quick-add {
  display: flex; flex-wrap: wrap; gap: 9px; align-items: stretch;
  padding: 14px;
  position: sticky; top: 68px; z-index: 50;
  box-shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.6);
  background: linear-gradient(180deg, rgba(20,20,24,.92), rgba(16,16,19,.92));
  backdrop-filter: blur(10px);
}
.quick-add:focus-within {
  border-color: rgba(52, 211, 153, 0.4);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.08), 0 12px 40px -12px rgba(0, 0, 0, 0.6);
}

.amount-wrap { position: relative; flex: 2 1 230px; display: flex; }
.amount-wrap .suffix {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 15px; font-weight: 600; pointer-events: none;
}
.amount-input { padding-right: 38px !important; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.amount-input::placeholder { font-size: 14.5px; font-weight: 450; }
.quick-add .input:not(.amount-input) { flex: 1 1 148px; }
.quick-add .btn { flex: 0 0 auto; }

/* -------------------------------------------------------------- inputs */
.input {
  background: rgba(0, 0, 0, 0.32); color: var(--text);
  border: 1px solid var(--border-hi); border-radius: var(--r-sm);
  padding: 9px 12px; font: inherit; outline: none; min-width: 0;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease), background 0.16s var(--ease);
}
.input:hover { border-color: var(--border-hover); }
.input:focus { border-color: rgba(52, 211, 153, 0.5); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.1); background: rgba(0,0,0,.42); }
.input::placeholder { color: var(--text-3); }
input[type="date"].input::-webkit-calendar-picker-indicator {
  filter: invert(0.55); cursor: pointer; opacity: .7;
}

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 9px 17px; font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; user-select: none; transition: all 0.16s var(--ease);
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(180deg, #3ddba2, #10b981);
  color: var(--accent-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.22) inset, 0 6px 18px -6px rgba(16, 185, 129, 0.55);
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); filter: brightness(0.98); }

.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border-hi); }
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); border-color: var(--border-hover); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px;
  background: transparent; border: none; color: var(--text-3);
  border-radius: 8px; cursor: pointer; transition: all 0.15s var(--ease);
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-dim); }

/* ---------------------------------------------------------------- cards */
.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(172px, 1fr));
  gap: 10px; margin: 14px 0 16px;
}
.stat { padding: 14px 16px 13px; position: relative; overflow: hidden; }
.stat:hover { border-color: var(--border-hi); }
.stat-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-3); text-transform: uppercase;
  letter-spacing: 0.08em; font-weight: 600;
}
.stat-icon {
  width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center; margin-bottom: 10px;
}
.stat-value { font-size: 25px; font-weight: 650; letter-spacing: -0.02em; margin-top: 6px; }
.stat-sub { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.stat.hero {
  border-color: rgba(52, 211, 153, 0.22);
  background:
    radial-gradient(140px 90px at 88% -10%, rgba(52, 211, 153, 0.13), transparent 70%),
    linear-gradient(180deg, var(--surface-2), var(--surface));
}
.stat.hero .stat-value { color: var(--accent-hi); }

.tint-green { background: rgba(52, 211, 153, 0.11); color: var(--accent); }
.tint-violet { background: rgba(167, 139, 250, 0.11); color: var(--violet); }
.tint-amber { background: rgba(251, 191, 36, 0.11); color: var(--amber); }
.tint-sky { background: rgba(56, 189, 248, 0.11); color: var(--sky); }

/* --------------------------------------------------------------- charts */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.chart-card { padding: 16px 18px 12px; min-height: 300px; display: flex; flex-direction: column; }
.chart-wide { grid-column: 1 / -1; }
.chart-wide-low { grid-column: 1 / -1; min-height: 250px; }
.chart-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 10px;
}
.chart-title .dot { width: 7px; height: 7px; border-radius: 3px; }
.chart { flex: 1; min-height: 0; }

/* ApexCharts overrides */
.apexcharts-tooltip {
  background: var(--surface-3) !important;
  border: 1px solid var(--border-hi) !important;
  box-shadow: var(--shadow-pop) !important;
  border-radius: 10px !important;
  color: var(--text) !important;
  font-family: "Inter", sans-serif !important;
  font-size: 12.5px !important;
  padding: 4px 2px !important;
}
.apexcharts-tooltip .apexcharts-tooltip-title {
  background: transparent !important; border-bottom: 1px solid var(--border) !important;
  font-weight: 600 !important; padding: 5px 10px !important;
}
.apexcharts-tooltip-series-group { padding: 3px 10px !important; }
.apexcharts-xaxistooltip { display: none !important; }
.apexcharts-legend-text { color: var(--text-2) !important; font-size: 12px !important; }
.apexcharts-radial-axis, .apexcharts-datalabels text { font-family: "Inter" !important; }

/* ---------------------------------------------------------------- table */
.table-card { padding: 8px 6px 6px; }
.table-filter {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 4px;
}
.table-filter .sep { color: var(--text-3); }
.table-filter .grow { flex: 1 1 170px; }
.table-scroll { overflow-x: auto; border-radius: var(--r-md); }

table.deals { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.deals th {
  position: sticky; top: 0; z-index: 2;
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--text-3); font-weight: 600; padding: 10px 12px;
  background: rgba(14, 14, 17, 0.96); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-hi); white-space: nowrap;
}
table.deals td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.deals tbody tr { transition: background 0.12s var(--ease); }
table.deals tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
table.deals tbody tr:last-child td { border-bottom: none; }

table.deals .num, table.deals th.num { text-align: right; }
table.deals .nowrap { white-space: nowrap; }
td.num.amount-cell { font-weight: 650; font-size: 14px; }
.date-cell { color: var(--text-2); white-space: nowrap; }
.date-cell b { color: var(--text); font-weight: 600; }

.buyer-cell { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 650; letter-spacing: 0.02em;
  background: hsl(var(--h, 160) 32% 16%); color: hsl(var(--h, 160) 65% 68%);
}
.buyer-cell a { color: var(--text); }
.buyer-cell a:hover { color: var(--accent); }
.buyer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linklike {
  background: none; border: none; padding: 0; font: inherit;
  color: var(--text); cursor: pointer; text-align: left;
}
.linklike:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.buyer-cell .icon-btn { width: 26px; height: 26px; opacity: .55; }
.buyer-cell:hover .icon-btn { opacity: 1; }

.avatar.avatar-lg { width: 42px; height: 42px; font-size: 16px; border-radius: 12px; }
.buyer-head { display: flex; align-items: center; gap: 13px; margin-bottom: 14px; }
.buyer-head-text a { font-size: 12px; }
.buyer-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin: 4px 0 16px;
}
.buyer-stat {
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 11px;
}
.buyer-stat .v { font-size: 15.5px; font-weight: 650; margin-top: 2px; }
.buyer-stat .l { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }

.actions-col { width: 80px; text-align: right; white-space: nowrap; }
tr .icon-btn { opacity: 0; }
tr:hover .icon-btn, tr:focus-within .icon-btn { opacity: 1; }
@media (hover: none) { tr .icon-btn { opacity: 1; } }

.badge-bot {
  font-size: 10.5px; padding: 2px 7px; border-radius: 999px;
  background: rgba(56, 189, 248, 0.1); color: var(--sky);
  border: 1px solid rgba(56, 189, 248, 0.18); font-weight: 550;
}
.note-cell { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.empty-row { text-align: center; padding: 44px 0 !important; color: var(--text-3); font-size: 14px; }
.table-total {
  display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap;
  padding: 12px 14px 8px; font-size: 13px; color: var(--text-2);
}
.table-total b { color: var(--text); font-weight: 600; }

/* ---------------------------------------------------------------- login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(700px 400px at 70% 0%, rgba(52, 211, 153, 0.08), transparent 60%),
    radial-gradient(600px 380px at 20% 100%, rgba(129, 140, 248, 0.06), transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 350px; padding: 34px 30px 30px; text-align: center;
  box-shadow: var(--shadow-pop);
}
.login-logo {
  width: 54px; height: 54px; margin: 0 auto 16px; border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, rgba(52, 211, 153, 0.22), rgba(52, 211, 153, 0.04));
  border: 1px solid rgba(52, 211, 153, 0.3);
  box-shadow: 0 0 32px rgba(52, 211, 153, 0.15);
}
.login-card .input { width: 100%; margin: 18px 0 12px; text-align: center; }

/* ------------------------------------------------------------- settings */
.settings-card { padding: 24px 26px; }
.settings-card .field { display: block; margin: 16px 0; }
.settings-card .field > span {
  display: block; font-size: 13px; font-weight: 550; color: var(--text-2); margin-bottom: 7px;
}
.settings-card .input { width: 100%; }
.settings-hr { border: none; border-top: 1px solid var(--border); margin: 22px 0 10px; }

/* --------------------------------------------------------------- dialog */
.dlg {
  border: 1px solid var(--border-hi); border-radius: var(--r-lg);
  background: var(--surface-2); color: var(--text);
  padding: 22px 24px; width: min(430px, 92vw);
  box-shadow: var(--shadow-pop);
}
.dlg::backdrop { background: rgba(4, 5, 7, 0.65); backdrop-filter: blur(5px); }
.dlg-form label { display: block; margin: 11px 0; font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.dlg-form .input { width: 100%; margin-top: 6px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

/* ---------------------------------------------------------------- alert */
.alert { padding: 10px 14px; border-radius: var(--r-sm); margin: 12px 0; font-size: 13.5px; }
.alert-error { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.25); }
.alert-ok { background: var(--accent-dim); color: var(--accent-hi); border: 1px solid rgba(52, 211, 153, 0.22); }
.alert-warn { background: rgba(251, 191, 36, 0.09); color: var(--amber); border: 1px solid rgba(251, 191, 36, 0.25); margin: 0 0 14px; }

/* sequential number badge for same-name buyers */
.dupe-badge {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  min-width: 18px; height: 18px; padding: 0 4px;
  border: 1.4px dashed hsl(var(--h, 160) 62% 60% / 0.75);
  border-radius: 6px;
  color: hsl(var(--h, 160) 68% 72%);
  background: hsl(var(--h, 160) 55% 55% / 0.09);
  font-size: 10.5px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; cursor: default;
}

/* ---------------------------------------------------------------- toast */
#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: rgba(22, 22, 26, 0.92); backdrop-filter: blur(8px);
  border: 1px solid var(--border-hi); color: var(--text);
  padding: 11px 20px; border-radius: 999px; box-shadow: var(--shadow-pop);
  z-index: 100; font-size: 13.5px; font-weight: 500; max-width: 90vw;
}
#toast.error { border-color: rgba(248, 113, 113, 0.4); color: var(--danger); }

/* ------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .charts { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .topbar-links { margin-left: 0; }
  .container { padding: 16px 14px 56px; }
  .quick-add { position: static; }
  .table-card { padding: 6px 2px 4px; }
  tr .icon-btn { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
