/* ==========================================================================
   Square Ibis — money & network views: finance, merchants, drivers, hubs, pricing
   ========================================================================== */

/* ---------- shared bits ---------- */

.tc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 16px 12px; border-bottom: 1px solid var(--border); }
.tc-head .card-title { font-size: 14px; }
.tc-head .card-title svg { width: 16px; height: 16px; color: var(--accent); }
.tc-head > .muted { font-size: 12.5px; }
.tc-head .select.sm { width: auto; min-width: 170px; }
.tc-filter { display: flex; gap: 6px; padding: 10px 16px 0; }
.chip-x { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-inline-end: -4px; border-radius: 50%; color: inherit; opacity: .7; }
.chip-x:hover { opacity: 1; background: var(--surface-3); }
.chip-x svg { width: 11px; height: 11px; }
.table-card.flat { box-shadow: none; animation: none; border-radius: 16px; }

.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who > div { min-width: 0; }

.back-link { display: inline-flex; align-items: center; gap: 6px; width: fit-content; font-size: 13px; color: var(--text-3); text-decoration: none; margin-bottom: -6px; }
.back-link:hover { color: var(--text); text-decoration: none; }
.back-link svg { width: 15px; height: 15px; }

.entity-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; animation: fadeUp .5s var(--ease-out) both; }
.entity-head > .grow { min-width: 220px; }
.entity-meta { margin-top: 6px; font-size: 13px; gap: 8px 10px; }
.entity-meta a { color: var(--text-2); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; align-items: start; }
.detail-grid > .card { gap: 18px; }

.link-list { display: flex; flex-direction: column; gap: 2px; }
.link-list a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text-2); font-size: 13.5px; text-decoration: none; transition: background .2s, color .2s; }
.link-list a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.link-list svg { width: 16px; height: 16px; color: var(--text-3); }

.success-panel { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 0 6px; text-align: center; }
.success-panel h3 { font-size: 30px; font-weight: 600; letter-spacing: -.03em; font-family: var(--mono); }
.success-panel > .kv-list { width: 100%; margin-top: 12px; text-align: start; }
.sp-check { width: 62px; height: 62px; border-radius: 20px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #10b981, #22c55e); box-shadow: 0 14px 34px -12px rgba(16, 185, 129, .8), inset 0 1px 0 rgba(255, 255, 255, .25); animation: popIn .6s var(--spring) both; margin-bottom: 6px; }
.sp-check svg { width: 28px; height: 28px; stroke-width: 2.4; }

.creds-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.creds-title svg { width: 16px; height: 16px; color: var(--accent); }
.creds .btn { align-self: flex-start; }
.creds .field-hint { margin: 2px 0 0; }

tr.is-dirty td { background: color-mix(in srgb, var(--amber) 7%, transparent); }
tr.is-dirty td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
:root[dir="rtl"] tr.is-dirty td:first-child { box-shadow: inset -3px 0 0 var(--amber); }

/* ---------- finance ---------- */

.fin-body { gap: 16px; }
.cashflow { display: grid; grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr) 28px minmax(0, 1fr) 28px minmax(0, 1fr); align-items: stretch; gap: 6px; }
.cf-node {
  --h: 262;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 14px 13px;
  border-radius: 16px;
  background: linear-gradient(160deg, hsl(var(--h) 85% 60% / .1), var(--surface) 60%);
  border: 1px solid hsl(var(--h) 85% 62% / .22);
  animation: fieldIn .55s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 90ms);
  min-width: 0;
}
.cf-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; color: hsl(var(--h) 85% var(--chip-l)); background: hsl(var(--h) 85% 60% / var(--chip-bg-a)); border: 1px solid hsl(var(--h) 85% 62% / var(--chip-bd-a)); margin-bottom: 4px; }
.cf-icon svg { width: 17px; height: 17px; }
.cf-label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
:root[lang="ar"] .cf-label { letter-spacing: 0; font-size: 13px; }
.cf-amount { font-size: 21px; font-weight: 500; letter-spacing: -.02em; }
.cf-sub { font-size: 12px; color: var(--text-3); line-height: 1.4; flex: 1; }
.cf-node .btn { margin-top: 8px; align-self: flex-start; }
.cf-arrow { display: grid; place-items: center; color: var(--text-3); }
.cf-arrow svg { width: 20px; height: 20px; animation: cfNudge 2.4s var(--ease) infinite; }
@keyframes cfNudge { 0%, 100% { transform: translateX(0); opacity: .55; } 50% { transform: translateX(3px); opacity: 1; } }
:root[dir="rtl"] .cf-arrow svg { animation-name: cfNudgeRtl; }
@keyframes cfNudgeRtl { 0%, 100% { transform: scaleX(-1) translateX(0); opacity: .55; } 50% { transform: scaleX(-1) translateX(3px); opacity: 1; } }

.fin-hero { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.fin-hero b { font-size: 34px; font-weight: 600; letter-spacing: -.03em; }
.fin-hero span { color: var(--text-2); font-size: 13px; }

.cash-summary { display: flex; flex-direction: column; gap: 1px; padding: 12px 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); }
.cs-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 13px; color: var(--text-2); }
.cs-row b { color: var(--text); font-weight: 500; }
.cs-row.muted { font-size: 12.5px; color: var(--text-3); }
.cs-diff { padding-top: 8px; margin-top: 3px; border-top: 1px dashed var(--border-strong); }
.cs-total { padding-top: 10px; margin-top: 4px; border-top: 1px dashed var(--border-strong); color: var(--text); font-weight: 600; font-size: 14px; }
.cs-total b { font-size: 22px; font-weight: 600; letter-spacing: -.02em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.receive-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
.receive-side { position: sticky; top: 0; }
.big-input { height: 50px !important; font-size: 20px !important; font-family: var(--mono); font-weight: 500; }

.fin-steps { margin: 0; padding-inline-start: 0; list-style: none; counter-reset: fs; display: flex; flex-direction: column; gap: 12px; }
.fin-steps li { position: relative; padding-inline-start: 36px; font-size: 13.5px; color: var(--text-2); line-height: 1.5; counter-increment: fs; }
.fin-steps li::before { content: counter(fs); position: absolute; inset-inline-start: 0; top: -1px; width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: #fff; background: var(--grad); box-shadow: 0 4px 12px -4px rgba(var(--a0-rgb), .8); }
.fin-steps b { color: var(--text); }

/* ---------- merchants ---------- */

.approvals { border-color: color-mix(in srgb, var(--amber) 32%, var(--border)); background: linear-gradient(160deg, color-mix(in srgb, var(--amber) 8%, transparent), var(--surface) 60%); }
.approval-list { display: flex; flex-direction: column; gap: 8px; }
.approval-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.approval-row > .grow { min-width: 180px; }

.rate-cell { display: flex; align-items: center; gap: 10px; min-width: 120px; }
.rate-cell .meter { flex: 1; min-width: 60px; }
.rate-cell .meter-track { height: 5px; }
.rate-cell .num { font-size: 12px; color: var(--text-2); min-width: 34px; text-align: end; }

.fee-cell { display: flex; flex-direction: column; gap: 2px; }
.fee-cell small { font-size: 10.5px; }
.fee-input { width: 108px !important; font-family: var(--mono); text-align: end; }
.fee-input::placeholder { font-family: var(--font); font-size: 12px; text-align: start; }

/* ---------- drivers ---------- */

.driver-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.driver-grid.is-empty, .hub-grid.is-empty { display: block; }
.driver-grid .skel.block, .hub-grid .skel.block { height: 170px; border-radius: 20px; }
.driver-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--highlight);
  color: inherit;
  text-decoration: none;
  transition: transform .3s var(--ease-out), border-color .3s;
  animation: fieldIn .5s var(--ease-out) both;
}
.driver-card:hover { transform: translateY(-2px); border-color: var(--border-strong); text-decoration: none; }
.driver-card.is-off { opacity: .6; }
.dc-head { display: flex; align-items: center; gap: 11px; min-width: 0; }
.dc-head > .grow { min-width: 0; }
.dc-avatar { position: relative; flex: none; }
.dc-online { position: absolute; inset-inline-end: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--gray); border: 2px solid var(--bg-2); }
.dc-online.on { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent); }
.dc-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dc-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dc-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.dc-stats > div { display: flex; flex-direction: column; gap: 1px; padding: 8px 9px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.dc-stats b { font-size: 17px; font-weight: 500; }
.dc-stats span { font-size: 10.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dc-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dc-seen { font-size: 11.5px; }

.zones-picker { display: flex; flex-direction: column; gap: 10px; }
.zones-picker .input.sm { max-width: 220px; }
.zone-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 220px; overflow-y: auto; padding: 2px; }

/* ---------- hubs ---------- */

.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.hub-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--highlight);
  animation: fieldIn .5s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 45ms);
  transition: border-color .3s;
}
.hub-card:hover { border-color: var(--border-strong); }
.hub-card.is-off { opacity: .6; }
.hc-head { display: flex; align-items: center; gap: 12px; }
.hc-head > .grow { min-width: 0; }
.hc-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-sub { font-size: 12px; color: var(--text-3); }
.hc-lines { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.hc-lines > div { display: flex; align-items: flex-start; gap: 8px; }
.hc-lines svg { width: 15px; height: 15px; color: var(--text-3); margin-top: 2px; }
.hc-stock { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 10px 12px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: 12.5px; text-decoration: none; transition: background .2s, border-color .2s; }
.hc-stock:hover { background: var(--surface-3); border-color: var(--border-strong); text-decoration: none; }
.hc-stock b { font-size: 18px; font-weight: 500; color: var(--text); }
.hc-stock span { flex: 1; }
.hc-stock svg { width: 15px; height: 15px; }

/* ---------- pricing ---------- */

.bulk-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bulk-row .select.sm { width: auto; }
.bulk-scope { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex-basis: 100%; }
.bulk-scope .select.sm { width: auto; }
.dirty-note { font-size: 12.5px; color: var(--amber); }
.zone-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; background: var(--zc); box-shadow: 0 0 10px var(--zc); }
.zone-1 { --zc: var(--violet); } .zone-2 { --zc: var(--indigo); } .zone-3 { --zc: var(--cyan); }
.zone-4 { --zc: var(--amber); } .zone-5 { --zc: var(--orange); } .zone-6 { --zc: var(--rose); }
.tag.zone-1, .tag.zone-2, .tag.zone-3, .tag.zone-4, .tag.zone-5, .tag.zone-6 { color: var(--zc); border-color: color-mix(in srgb, var(--zc) 30%, transparent); background: color-mix(in srgb, var(--zc) 10%, transparent); }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .cashflow { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .cf-arrow { display: none; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .receive-grid { grid-template-columns: minmax(0, 1fr); }
  .receive-side { position: static; }
}

@media (max-width: 640px) {
  .cashflow { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .cf-arrow { display: grid; height: 20px; }
  .cf-arrow svg { transform: rotate(90deg); animation: none; }
  :root[dir="rtl"] .cf-arrow svg { transform: rotate(90deg); }
  .driver-grid, .hub-grid { grid-template-columns: minmax(0, 1fr); }
  .dc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entity-head .page-actions { width: 100%; }
  .tc-head { padding: 12px 14px 10px; }
  .tc-head .select.sm { min-width: 0; flex: 1; }
  .fee-input { width: 86px !important; }
  .approval-row .btn { flex: 1; }
  .bulk-row .btn { flex: 1; }
}
