/* FinPulse — finalytics.ae design language on a dark app surface. */

:root {
  --bg: #060a14;
  --surface: #0b1120;
  --surface-2: #101830;
  --card-border: rgba(255, 255, 255, 0.08);
  --card-border-strong: rgba(255, 255, 255, 0.14);
  --text: #f3f5fa;
  --text-2: #aab2c5;
  --text-3: #6f7890;
  --blue: #2e6bff;
  --mint: #2dd79f;
  --grad: linear-gradient(92deg, #2e6bff, #1e9bd7 55%, #2dd79f);
  /* validated chart series (dark surface #0b1120) */
  --s1: #3f7ef2;
  --s2: #17a97d;
  --s3: #c98500;
  --s4: #e66767;
  --good: #2dd79f;
  --warn: #f5b83d;
  --bad: #ff7a7a;
  --radius: 16px;
  --font: "Inter", -apple-system, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(46, 107, 255, 0.14), transparent 60%),
    radial-gradient(700px 420px at -10% 110%, rgba(45, 215, 159, 0.08), transparent 60%);
}
#app { position: relative; z-index: 1; }

h1, h2, h3 { font-weight: 800; letter-spacing: -0.02em; }
a { color: inherit; }
button { font-family: inherit; }

.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------- nav */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px;
  padding: 0 28px; height: 64px;
  background: rgba(6, 10, 20, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-border);
}
.logo { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.logo .pulse-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--mint); margin-left: 6px; vertical-align: 12px;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45, 215, 159, 0.5); }
  50% { box-shadow: 0 0 0 7px rgba(45, 215, 159, 0); }
}
.logo em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 8px 14px; border-radius: 10px; text-decoration: none;
  color: var(--text-2); font-weight: 600; font-size: 13.5px; white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.nav a.active { color: var(--text); background: rgba(46, 107, 255, 0.16); }

.sync-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: 999px;
  border: 1px solid rgba(45, 215, 159, 0.35);
  color: var(--mint); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.sync-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); animation: pulse 2.4s infinite; }
.user-menu { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.user-menu button {
  background: none; border: 1px solid var(--card-border); color: var(--text-2);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 12.5px;
}
.user-menu button:hover { border-color: var(--card-border-strong); color: var(--text); }

/* ---------------------------------- layout */
.page { max-width: 1240px; margin: 0 auto; padding: 28px 28px 80px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; }
.page-head .asof { color: var(--text-3); font-size: 12.5px; }

.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.two-col { grid-template-columns: 1.6fr 1fr; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ---------------------------------- cards */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.012));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card:nth-child(2) { animation-delay: 0.05s; } .card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.15s; } .card:nth-child(5) { animation-delay: 0.2s; }
/* failsafe: entrance animation must never gate visibility (frozen animation
   clocks in embedded webviews / reduced-motion environments) */
body.settled .card, body.settled .login-card { animation: none; }

.card h3 { font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 14px; }
.card .h3row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card .h3row h3 { margin-bottom: 0; }

.tile .label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.tile .value { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; margin: 6px 0 2px; }
.tile .sub { font-size: 12px; color: var(--text-3); }
.delta { font-size: 12px; font-weight: 700; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--text-3); }

/* ---------------------------------- chips & badges */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  border: 1px solid;
}
.chip.good { color: var(--good); border-color: rgba(45, 215, 159, 0.4); }
.chip.warn { color: var(--warn); border-color: rgba(245, 184, 61, 0.4); }
.chip.bad { color: var(--bad); border-color: rgba(255, 122, 122, 0.45); }
.chip.muted { color: var(--text-3); border-color: var(--card-border); }
.badge-cur { font-size: 10px; font-weight: 700; color: var(--text-3); border: 1px solid var(--card-border); border-radius: 5px; padding: 1px 5px; }

/* ---------------------------------- tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-3); padding: 8px 10px; border-bottom: 1px solid var(--card-border); }
td { padding: 10px; font-size: 13px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
th.r, td.r { text-align: right; }
tr.clickable { cursor: pointer; transition: background 0.12s; }
tr.clickable:hover { background: rgba(255, 255, 255, 0.03); }
.caret { display: inline-block; transition: transform 0.18s; color: var(--text-3); margin-right: 8px; font-size: 10px; }
.open > td .caret { transform: rotate(90deg); }
.subrow { background: rgba(0, 0, 0, 0.22); }
.subrow td { padding: 6px 10px; font-size: 12.5px; color: var(--text-2); }
.overdue-days { color: var(--bad); font-weight: 700; }

/* sticky first column for wide statements */
.scroll-x { overflow-x: auto; }
.statement th:first-child, .statement td:first-child {
  position: sticky; left: 0; background: #0d1322; min-width: 210px; z-index: 2;
}
.statement th, .statement td { white-space: nowrap; }

/* ---------------------------------- charts */
.chart-wrap { position: relative; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 10; display: none;
  background: #141c33; border: 1px solid var(--card-border-strong);
  border-radius: 10px; padding: 9px 12px; font-size: 12px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45); min-width: 130px;
}
.chart-tip .t-title { color: var(--text-3); font-size: 11px; margin-bottom: 5px; font-weight: 700; }
.chart-tip .t-row { display: flex; justify-content: space-between; gap: 14px; }
.chart-tip .t-row .k { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.chart-tip .t-row .sw { width: 8px; height: 8px; border-radius: 2px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 9px; height: 9px; border-radius: 3px; }

/* aging bar */
.aging-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; background: transparent; }
.aging-bar div { min-width: 2px; }
.aging-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: var(--text-2); }

/* ---------------------------------- login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 420px; text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--card-border); border-radius: 20px; padding: 44px 36px;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.login-card .logo { font-size: 26px; margin-bottom: 6px; }
.login-card p { color: var(--text-2); font-size: 13.5px; margin: 10px 0 24px; }
.login-card input {
  width: 100%; padding: 13px 16px; border-radius: 11px; font-size: 14px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--card-border);
  color: var(--text); outline: none; margin-bottom: 12px;
}
.login-card input:focus { border-color: rgba(46, 107, 255, 0.6); }
.btn-grad {
  width: 100%; padding: 13px 18px; border: none; border-radius: 11px;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 14px;
  cursor: pointer; transition: transform 0.12s, box-shadow 0.12s;
}
.btn-grad:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(46, 107, 255, 0.35); }
.login-note { font-size: 12px; color: var(--text-3); margin-top: 18px; }
.login-msg { font-size: 13px; margin-top: 14px; color: var(--mint); }
.login-msg.err { color: var(--bad); }

/* compliance strip */
.comp-strip { display: grid; gap: 10px; }
.comp-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 15px; border-radius: 11px;
  background: rgba(255, 255, 255, 0.028); border: 1px solid var(--card-border);
}
.comp-item .l { font-size: 13px; font-weight: 600; }
.comp-item .d { font-size: 11.5px; color: var(--text-3); }

/* footer */
.foot { max-width: 1240px; margin: 0 auto; padding: 0 28px 40px; color: var(--text-3); font-size: 12px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* empty state */
.empty { text-align: center; color: var(--text-3); padding: 48px 20px; font-size: 13.5px; }

/* skeleton shimmer */
.skel { position: relative; overflow: hidden; background: rgba(255,255,255,0.04); border-radius: 8px; min-height: 16px; }
.skel::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

@media (max-width: 720px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .user-menu .email { display: none; }
  .sync-chip { display: none; }
  .page { padding: 18px 14px 70px; }
  .page-head h1 { font-size: 21px; }
  .tile .value { font-size: 23px; }
}
