/* Finovas Global - view-specific styles */

/* ── Dashboard ───────────────────────────────────────────── */
.stat-row {
  display: grid; gap: 16px; margin-bottom: 16px;
  grid-template-columns: repeat(4, 1fr);
}
.qrow {
  display: grid; gap: 12px; margin-bottom: 16px;
  grid-template-columns: repeat(4, 1fr);
}
.qtile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 13px 15px;
  display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
}
.qtile::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  opacity: .8;
}
.qtile .qhead {
  display: flex; align-items: baseline; gap: 8px;
  color: var(--text-muted); font-size: 11px; letter-spacing: .04em;
  text-transform: uppercase; font-weight: 700;
}
.qtile .qhead b { color: var(--text); font-size: 13px; font-weight: 800; }
.qtile .qval { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.qtile .qsub { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }

.dash-cols { display: grid; gap: 16px; grid-template-columns: 1.7fr 1fr;
  align-items: start; }
.dash-cols-3 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr 1fr; }
.hero {
  position: relative;
  background:
    radial-gradient(ellipse 60% 70% at 30% 30%,
      rgba(124, 141, 255, .28), transparent 65%),
    radial-gradient(ellipse 40% 50% at 75% 80%,
      rgba(255, 120, 73, .20), transparent 65%),
    radial-gradient(ellipse 35% 45% at 90% 20%,
      rgba(63, 224, 168, .14), transparent 65%),
    linear-gradient(135deg, #0A1448 0%, #0E1B5A 50%, #14267A 100%);
  border-radius: var(--r-lg); padding: 30px 32px; margin-bottom: 22px;
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, .06);
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at center,
    rgba(0, 0, 0, .6), transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center,
    rgba(0, 0, 0, .6), transparent 75%);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { color: #fff; font-size: 25px; margin-top: 3px; letter-spacing: -.01em; }
.hero .pt { color: rgba(255, 255, 255, .74); }

/* ── Charts ──────────────────────────────────────────────── */
.chart { width: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; }
.legend i { display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-muted); }
.legend i b { width: 9px; height: 9px; border-radius: 3px; }
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut-center { text-align: center; }

/* ── Client cards ────────────────────────────────────────── */
.client-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
.client-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 18px; cursor: pointer;
  transition: .16s var(--ease); box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.client-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-pop);
  border-color: var(--border-strong); }
.client-card .cc-top { display: flex; gap: 12px; align-items: center; }
.client-card .cc-name { font-weight: 700; font-size: 14.5px; }
.client-card .cc-type { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.client-card .cc-stats { display: flex; gap: 16px; margin-top: 16px;
  padding-top: 14px; border-top: 1px solid var(--border); }
.client-card .cc-stat .l { font-size: 11px; color: var(--text-soft);
  font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.client-card .cc-stat .v { font-size: 15px; font-weight: 700; margin-top: 2px; }

.accent-indigo  { --ac: #3D4FF5; } .accent-violet { --ac: #5C73FF; }
.accent-teal    { --ac: #3FE0A8; } .accent-emerald { --ac: #0E9F6E; }
.accent-amber   { --ac: #FFC93D; } .accent-rose   { --ac: #FF6FAA; }
.accent-sky     { --ac: #7C8DFF; } .accent-coral  { --ac: #FF7849; }
.accent-navy    { --ac: #0E1B5A; } .accent-pink   { --ac: #FF85B8; }
.client-card .cc-bar { position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; background: var(--ac, var(--brand)); }
.avatar.ac { background: var(--ac, var(--gradient)); }
/* Soft aurora bloom in the client card background - uses the per-card accent
   color so each card has its own colored glow, no longer feels empty. */
.client-card .cc-bloom {
  position: absolute; top: -30%; right: -25%;
  width: 220px; height: 220px;
  background: radial-gradient(circle,
    color-mix(in srgb, var(--ac, var(--brand)) 35%, transparent),
    transparent 65%);
  filter: blur(8px);
  pointer-events: none;
  z-index: 0;
}
.client-card > * { position: relative; z-index: 1; }
.client-card .cc-bar { z-index: 2; }
.client-card .cc-avatar-wrap {
  position: relative;
  width: 48px; height: 48px;
  border-radius: 13px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 12px -2px color-mix(in srgb, var(--ac, var(--brand)) 40%, transparent);
}
.client-card .cc-logo {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  z-index: 1;
}
.client-card .cc-mono {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border-radius: 13px;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 700; color: #fff;
}
.client-card .cc-avatar-wrap.has-logo .cc-mono { display: none; }

/* ── Workspace ───────────────────────────────────────────── */
.ws-head {
  display: flex; align-items: center; gap: 15px; margin-bottom: 18px;
}
.ws-head .ws-av { width: 54px; height: 54px; border-radius: 15px; font-size: 21px; }
.ws-head h1 { font-size: 21px; }
.ws-head .ws-meta { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.ws-tabs {
  display: flex; gap: 2px; margin-bottom: 20px;
}

/* ── Document review ─────────────────────────────────────── */
.doc-review { display: grid; gap: 16px; grid-template-columns: 1fr 1.05fr; }
.doc-preview {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); min-height: 440px; display: grid;
  place-items: center; overflow: hidden; padding: 14px;
}
.doc-preview img { border-radius: var(--r-sm); box-shadow: var(--shadow); }
.doc-preview .ph { text-align: center; color: var(--text-soft); }
.doc-preview .ph .pic {
  width: 76px; height: 76px; margin: 0 auto 12px; border-radius: 20px;
  background: var(--surface-2); display: grid; place-items: center;
}
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kv .field.full { grid-column: 1 / -1; }
.items-table td .input { height: 33px; }
.conf-bar { display: flex; align-items: center; gap: 8px; }
.conf-bar .progress { flex: 1; }

/* ── Ledger ──────────────────────────────────────────────── */
.month-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.month-tab {
  border: 1px solid var(--border); background: var(--surface);
  padding: 7px 13px; border-radius: var(--r-sm); font-size: 12.5px;
  font-weight: 600; color: var(--text-muted); cursor: pointer;
  transition: .14s var(--ease);
}
.month-tab:hover { border-color: var(--border-strong); }
.month-tab.on { background: var(--gradient); color: #fff; border-color: transparent; }
.ledger-totals { display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px; margin-bottom: 16px; }
.lt { padding: 14px 16px; border-radius: var(--r); border: 1px solid var(--border);
  background: var(--surface); }
.lt .l { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.lt .v { font-size: 21px; font-weight: 800; margin-top: 3px; }
.lt.income { border-left: 3px solid var(--pos); }
.lt.expense { border-left: 3px solid var(--neg); }
.lt.net { border-left: 3px solid var(--brand); }
.ledger-head { padding: 16px 22px; margin-bottom: 16px; }
.lh-title { font-weight: 800; font-size: 16px; text-align: center;
  margin-bottom: 14px; letter-spacing: -.01em; }
.lh-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 28px;
  font-size: 13px; }
.lh-grid .full { grid-column: 1 / -1; }
.lh-grid span { color: var(--text-muted); margin-right: 8px; }
.lh-grid b { font-weight: 600; }
.ledger-grid th, .ledger-grid td { white-space: nowrap; }
.ledger-grid .num { font-variant-numeric: tabular-nums; }
.ledger-grid thead th:nth-last-child(2),
.ledger-grid tbody td:nth-last-child(2) {
  /* The "รวม" per-row total column - slight emphasis vs categories.
     :nth-last-child(2) hits the totals column whether editable adds a
     trailing actions column or not. */
  background: var(--surface-2);
  font-weight: 600;
}

/* Grand-total row - make it pop */
tr.lt-total td {
  font-weight: 800; font-size: 13.5px;
  padding-top: 16px; padding-bottom: 16px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--brand) 12%, var(--surface)) 0%,
    color-mix(in srgb, var(--brand-2) 9%, var(--surface)) 100%);
  border-top: 2px solid var(--brand);
  color: var(--text);
}
tr.lt-total:hover td { background: linear-gradient(
  90deg,
  color-mix(in srgb, var(--brand) 16%, var(--surface)),
  color-mix(in srgb, var(--brand-2) 12%, var(--surface))); }
tr.lt-total td.tot-label {
  text-transform: uppercase; letter-spacing: .07em;
  font-size: 11.5px; color: var(--brand); font-weight: 800;
}
tr.lt-total td.tot-grand {
  font-size: 16.5px; color: var(--brand); font-weight: 900;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--brand) 18%, var(--surface)) 0%,
    color-mix(in srgb, var(--brand-2) 15%, var(--surface)) 100%);
}
tr.lt-total td.tot-empty { background: transparent; border-top: 0; }
[data-theme="dark"] tr.lt-total td.tot-label,
[data-theme="dark"] tr.lt-total td.tot-grand { color: #a5b4fc; }

/* ── User profile pill (sidebar foot) ─────────────────────── */
.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}

/* ── Hero (denser) ────────────────────────────────────────── */
.hero-grid {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px;
  align-items: center;
}
.hero-right {
  color: rgba(255, 255, 255, .92); text-align: right;
  display: flex; flex-direction: column; gap: 4px;
}
.hero-right .label {
  color: rgba(255, 255, 255, .55); text-transform: uppercase;
  letter-spacing: .07em; font-size: 11px; font-weight: 600;
}
.hero-right .date {
  font-size: 22px; font-weight: 700; letter-spacing: -.01em;
}
.hero-right .meta { color: rgba(255, 255, 255, .68); font-size: 13px; }

/* ── Stat trend indicators ────────────────────────────────── */
.stat-foot.pos { color: var(--pos); font-weight: 600; }
.stat-foot.neg { color: var(--neg); font-weight: 600; }

/* ── Trend totals strip ───────────────────────────────────── */
.trend-totals {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; padding-top: 14px; margin-top: 12px;
  border-top: 1px solid var(--border);
}
.trend-totals > div {
  display: flex; flex-direction: column; gap: 2px;
}
.trend-totals .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-soft); font-weight: 600;
}
.trend-totals b { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }

/* ── Top clients widget ───────────────────────────────────── */
.topc {
  display: grid; grid-template-columns: 1fr 120px auto;
  gap: 14px; align-items: center; padding: 10px 0;
}
.topc + .topc { border-top: 1px solid var(--border); }
.topc-name {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600; min-width: 0;
}
.topc-name span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topc-bar {
  height: 7px; background: var(--surface-3);
  border-radius: 99px; overflow: hidden;
}
.topc-bar i {
  display: block; height: 100%; background: var(--gradient);
  border-radius: 99px;
}
.topc-val {
  font-size: 13.5px; font-weight: 700; color: var(--brand);
  white-space: nowrap;
}
[data-theme="dark"] .topc-val { color: #a5b4fc; }

/* ── Generic dropdown ─────────────────────────────────────── */
.dropdown { display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + 4px); left: 0;
  min-width: 220px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-md);
  padding: 6px; z-index: 50;
}
.dropdown-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--r-sm);
  cursor: pointer; font-size: 13.5px; color: var(--text);
}
.dropdown-row:hover { background: var(--surface-2); }

/* ── Forms tab (templates) ────────────────────────────────── */
.forms-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.form-tile {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border);
  text-align: left; cursor: pointer;
  transition: .14s var(--ease);
  font-family: inherit; color: var(--text);
}
.form-tile:hover {
  background: var(--surface-2);
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.form-tile .ft-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; box-shadow: var(--shadow-sm);
}
.form-tile .ft-body { min-width: 0; }
.form-tile .ft-body b {
  display: block; font-weight: 700; font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.form-tile .ft-arrow { color: var(--text-muted); }
.form-tile:hover .ft-arrow { color: var(--brand); }
.item-row {
  display: flex; gap: 6px; align-items: center;
}
.item-row .input { height: 36px; }

/* ── Contacts list (per-client) ───────────────────────────── */
.contacts-list { display: flex; flex-direction: column; gap: 6px;
  padding: 8px 14px 14px; }
.contact-row {
  display: grid;
  grid-template-columns: 38px 1fr auto 30px;
  gap: 14px; align-items: center;
  padding: 12px 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border);
  transition: .14s var(--ease);
}
.contact-row:hover { background: var(--surface-2);
  border-color: var(--border-strong); }
.cr-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.cr-main { min-width: 0; }
.cr-main b { font-weight: 700; }
.cr-meta {
  margin-top: 4px; font-size: 12px; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.cr-meta svg { vertical-align: -2px; margin-right: 4px;
  color: var(--text-soft); }
.cr-sep { color: var(--border-strong); margin: 0 2px; }
.cr-stats { text-align: right; }
.cr-amt { font-weight: 800; font-size: 14.5px;
  letter-spacing: -.01em; color: var(--text); }

/* ── Clients summary row ──────────────────────────────────── */
.clients-summary {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px; margin-bottom: 20px;
}

@media (max-width: 720px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-right { text-align: left; }
  .trend-totals, .clients-summary { grid-template-columns: 1fr; }
  .qrow { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1100px) {
  .qrow { grid-template-columns: repeat(2, 1fr); }
}

/* ── Splits ──────────────────────────────────────────────── */
.split-doc {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 14px 16px; background: var(--surface-2);
  border-radius: var(--r); margin-bottom: 14px;
}
.alloc-row { display: grid; grid-template-columns: 1.4fr .9fr .8fr 36px;
  gap: 9px; align-items: center; margin-bottom: 8px; }
.alloc-row .input, .alloc-row .select { height: 36px; }
.recon {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 15px; border-radius: var(--r-sm); font-weight: 700;
  margin-top: 6px;
}
.recon.ok { background: var(--pos-bg); color: var(--pos); }
.recon.off { background: var(--warn-bg); color: var(--warn); }

/* ── Summaries / AI ──────────────────────────────────────── */
.summary-card { padding: 0; overflow: hidden; }
.summary-card .sc-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.markdown { padding: 6px 18px 18px; line-height: 1.75; }
.markdown h2 { font-size: 16px; margin: 14px 0 8px; }
.markdown h3 { font-size: 14px; margin: 14px 0 6px; color: var(--brand); }
.markdown ul { padding-left: 4px; display: flex; flex-direction: column; gap: 4px; }
.markdown li { list-style: none; padding-left: 16px; position: relative; }
.markdown li::before { content: ""; position: absolute; left: 2px; top: 10px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--brand); }
.markdown strong { font-weight: 700; }
.markdown em { color: var(--text-muted); font-style: normal; font-size: 13px; }
.markdown p { margin: 6px 0; }

.anomaly { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px;
  border-radius: var(--r-sm); background: var(--surface-2); margin-bottom: 8px;
  font-size: 13px; }
.anomaly .ic { flex: none; width: 20px; height: 20px; }

.ask-box { display: flex; gap: 10px; }
.ask-msg { padding: 12px 15px; border-radius: var(--r); margin-bottom: 10px; }
.ask-msg.q { background: var(--gradient); color: #fff; margin-left: 36px; }
.ask-msg.a { background: var(--surface-2); margin-right: 36px;
  border: 1px solid var(--border); white-space: pre-wrap; }

/* utility */
.flex { display: flex; } .items-center { align-items: center; }
.between { justify-content: space-between; } .gap-8 { gap: 8px; }
.gap-12 { gap: 12px; } .mt-16 { margin-top: 16px; } .mb-12 { margin-bottom: 12px; }
.wrap { flex-wrap: wrap; } .grow { flex: 1; } .right { text-align: right; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.big-num { font-size: 21px; font-weight: 800; }

@media (max-width: 980px) {
  .stat-row { grid-template-columns: 1fr 1fr; }
  .dash-cols, .dash-cols-3, .doc-review { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .stat-row, .ledger-totals { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .alloc-row { grid-template-columns: 1fr 1fr; }
}

/* ── Login screen ─────────────────────────────────────────── */
.login-bg {
  position: fixed; inset: 0;
  background: linear-gradient(125deg, rgba(7,11,28,.78), rgba(28,21,72,.55) 65%),
    center / cover no-repeat url("/assets/background.png");
  display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: 380px; max-width: 100%;
  background: rgba(19, 25, 50, 0.78); backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-radius: var(--r-xl);
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 38px 90px rgba(0, 0, 0, .55);
  padding: 36px 32px 28px; color: #fff;
  animation: fvPop .28s var(--ease);
}
.login-card .lc-logo {
  width: 60px; height: 60px; margin: 0 auto 16px;
  border-radius: 18px; overflow: hidden;
  box-shadow: 0 10px 28px rgba(99, 102, 241, .45);
}
.login-card .lc-logo img { width: 100%; height: 100%; object-fit: cover; }
.login-card h1 { text-align: center; color: #fff; font-size: 22px; margin-bottom: 4px; }
.login-card .lc-sub {
  text-align: center; color: rgba(255, 255, 255, .68); font-size: 13px;
  margin-bottom: 22px;
}
.login-card .input {
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .18); color: #fff;
  margin-bottom: 12px;
}
.login-card .input::placeholder { color: rgba(255, 255, 255, .45); }
.login-card .input:focus { border-color: var(--brand); }
.login-card .btn-block { margin-top: 6px; }
.login-card .lc-hint {
  text-align: center; color: rgba(255, 255, 255, .55);
  margin-top: 18px; font-size: 12px; letter-spacing: .01em;
}
