/* Friends Traders — black and orange theme on top of Bootstrap 5 */
:root {
  --ft-ink: #0F0F10;
  --ft-ink-2: #1A1A1C;
  --ft-ink-line: #2B2B2E;
  --ft-on-ink: #EDEAE4;
  --ft-on-ink-muted: #9B978F;
  --ft-orange: #F07A1A;
  --ft-orange-hover: #DB6A0E;
  --ft-orange-text: #B4530F;
  --ft-orange-soft: #FDF3EA;
  --ft-orange-line: #E3A36B;
  --ft-peach: #F5B27A;
  --ft-bg: #F5F3EF;
  --ft-surface: #FFFFFF;
  --ft-line: #E4E0D8;
  --ft-line-soft: #EFEBE4;
  --ft-text: #1A1A1C;
  --ft-muted: #6B665E;
  --ft-green: #1F6B45;
  --ft-green-bg: #E3F2EA;
  --ft-red: #A12016;
  --ft-red-bg: #FDE8E6;
  --bs-body-font-family: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-link-color: var(--ft-orange-text);
  --bs-link-hover-color: #8A3E0A;
  --bs-link-color-rgb: 180, 83, 15;
  --bs-link-hover-color-rgb: 138, 62, 10;
}

body { background: var(--ft-bg); color: var(--ft-text); font-size: 14px; }
.num, .table .num { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.text-muted-ft { color: var(--ft-muted) !important; }

/* ---------- layout ---------- */
.ft-shell { display: flex; min-height: 100vh; }
.ft-sidebar {
  width: 240px; flex-shrink: 0; background: var(--ft-ink); color: var(--ft-on-ink);
  display: flex; flex-direction: column; gap: 16px; padding: 18px 14px; overflow-y: auto;
}
@media (min-width: 992px) { .ft-sidebar { position: sticky; top: 0; height: 100vh; } }
.ft-mobilebar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--ft-ink); color: var(--ft-on-ink); position: sticky; top: 0; z-index: 1020; }
.ft-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; color: var(--ft-on-ink); text-decoration: none; }
.ft-brand:hover { color: var(--ft-on-ink); }
.ft-mark {
  width: 38px; height: 38px; border-radius: 9px; background: var(--ft-orange); color: #111;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px;
}
.ft-brand small { display: block; font-size: 11px; color: var(--ft-on-ink-muted); }
.ft-nav-label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: #8A867E; font-weight: 700; padding: 0 10px 6px; }
.ft-nav a {
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px; border-radius: 7px;
  font-size: 13.5px; font-weight: 600; color: #D6D2CA; text-decoration: none;
}
.ft-nav a:hover { background: var(--ft-ink-2); color: #fff; }
.ft-nav a.active { background: var(--ft-orange); color: #111; font-weight: 700; }
.ft-user { margin-top: auto; padding: 12px; border-radius: 10px; background: var(--ft-ink-2); font-size: 13px; }
.ft-user small { display: block; color: var(--ft-on-ink-muted); font-size: 11px; }
.ft-user a { color: var(--ft-peach); font-size: 12px; font-weight: 700; text-decoration: none; }
.ft-main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.ft-topbar {
  height: 64px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 28px; background: var(--ft-surface); border-bottom: 1px solid var(--ft-line);
}
.ft-topbar h1 { margin: 0; font-size: 20px; font-weight: 800; }
.ft-crumb { font-size: 12px; color: var(--ft-muted); font-weight: 600; }
.ft-content { padding: 22px 28px 40px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- surfaces ---------- */
.ft-card { background: var(--ft-surface); border: 1px solid var(--ft-line); border-radius: 10px; }
.ft-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; }
.ft-card-head h2 { margin: 0; font-size: 16px; font-weight: 800; }
.ft-card-body { padding: 16px; }
.ft-kpi { padding: 16px 18px; border-radius: 10px; background: var(--ft-surface); border: 1px solid var(--ft-line); display: flex; flex-direction: column; gap: 6px; }
.ft-kpi .label { font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.ft-kpi .value { font-size: 22px; font-weight: 600; }
.ft-kpi .sub { font-size: 12px; opacity: .8; }
.ft-kpi.dark { background: var(--ft-ink-2); border-color: var(--ft-ink-2); color: var(--ft-peach); }

/* ---------- tables ---------- */
.table { --bs-table-bg: transparent; margin: 0; font-size: 13px; }
.table > thead th {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ft-muted); font-weight: 700;
  background: #FAF8F5; border-bottom: 1px solid var(--ft-line); padding: 10px 12px; white-space: nowrap;
}
.table > tbody td { padding: 10px 12px; border-color: var(--ft-line-soft); vertical-align: middle; }
.table .r, .r { text-align: right; }
.table td.num, .table td.r, .table th.r { white-space: nowrap; }
.row-type td { background: var(--ft-ink-2) !important; color: var(--ft-peach); font-size: 11px; letter-spacing: .1em; font-weight: 800; }
.row-group td { background: #FAF8F5; font-weight: 700; }
.row-total td { font-weight: 800; border-top: 2px solid var(--ft-text); }

/* ---------- badges ---------- */
.ft-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.b-post, .b-posted, .b-pass, .b-ok { background: var(--ft-green-bg); color: var(--ft-green); }
.b-draft, .b-signoff { background: #EDEBE7; color: #4A463F; }
.b-warn, .b-pending, .b-soft_closed { background: #FDEBDD; color: #8A3E0A; }
.b-err, .b-fail, .b-failed { background: var(--ft-red-bg); color: var(--ft-red); }
.b-cur, .b-closed { background: var(--ft-ink-2); color: var(--ft-peach); }
.b-open { background: var(--ft-green-bg); color: var(--ft-green); }

/* ---------- buttons & forms ---------- */
.btn { font-weight: 600; border-radius: 8px; }
.btn-ft { background: var(--ft-orange); border-color: var(--ft-orange); color: #111; }
.btn-ft:hover, .btn-ft:focus { background: var(--ft-orange-hover); border-color: var(--ft-orange-hover); color: #111; }
.btn-outline-ft { border-color: #D6D1C7; color: var(--ft-text); background: #fff; }
.btn-outline-ft:hover { background: var(--ft-bg); color: var(--ft-text); }
.btn-warn-ft { border-color: var(--ft-orange-line); color: #8A3E0A; background: #fff; }
.btn-warn-ft:hover { background: var(--ft-orange-soft); color: #8A3E0A; }
.form-label { font-size: 12px; font-weight: 700; color: #4A463F; margin-bottom: 4px; }
.form-control, .form-select { font-size: 13.5px; border-color: #D6D1C7; border-radius: 7px; }
.form-control:focus, .form-select:focus { border-color: var(--ft-orange); box-shadow: 0 0 0 .2rem rgba(240, 122, 26, .2); }
.form-control:disabled, .form-select:disabled, .form-control[readonly] { background: #F0EDE8; color: var(--ft-muted); }
.calc { background: var(--ft-orange-soft) !important; border: 1px dashed var(--ft-orange-line) !important; text-align: right; }

/* ---------- journal form ---------- */
.jv-lines .jv-head, .jv-lines .jv-row {
  display: grid; grid-template-columns: 240px minmax(140px, 1fr) 52px 72px 130px 92px 130px 130px 72px;
  gap: 8px; align-items: center; padding: 8px 14px;
}
.jv-lines .jv-head { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ft-muted); font-weight: 700; background: #FAF8F5; border-bottom: 1px solid var(--ft-line); }
.jv-block { border-bottom: 1px solid var(--ft-line-soft); }
.jv-block.pnl { background: #FDF6EF; }
.jv-deal { display: flex; align-items: center; gap: 8px; padding: 0 14px 10px 262px; font-size: 12.5px; color: #4A463F; }
.jv-deal .form-control, .jv-deal .form-select { height: 32px; padding-top: 2px; padding-bottom: 2px; }
.jv-foot { display: grid; grid-template-columns: 1fr 130px 130px 72px; gap: 8px; align-items: center; padding: 12px 14px; background: #FAF8F5; }
.ib { width: 32px; height: 34px; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--ft-muted); display: inline-flex; align-items: center; justify-content: center; }
.ib:hover { background: var(--ft-bg); color: var(--ft-text); }
.ib.on { background: var(--ft-ink-2); color: var(--ft-peach); }

.ft-feedback-btn {
  position: fixed; right: 18px; bottom: 18px; z-index: 1030; border: 0; border-radius: 999px;
  background: var(--ft-ink-2); color: var(--ft-peach); font-weight: 700; font-size: 13px; padding: 10px 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}
.ft-feedback-btn:hover { background: #000; color: #fff; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; }
.auth-side { width: 52%; background: var(--ft-ink); color: var(--ft-on-ink); padding: 56px 64px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { font-size: 48px; line-height: 1.05; font-weight: 800; letter-spacing: -.02em; }
.auth-side h1 span { color: var(--ft-orange); }
.auth-side p { color: #B8B3AA; font-size: 16px; line-height: 1.6; max-width: 520px; }
.auth-rates { background: var(--ft-ink-2); border: 1px solid var(--ft-ink-line); border-radius: 12px; padding: 16px 18px; }
.auth-rates .cell { background: #111112; border-radius: 8px; padding: 10px 12px; flex: 1; }
.auth-rates .code { font-size: 12px; font-weight: 800; color: var(--ft-peach); }
.auth-form { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 440px; }

/* ---------- report paper & print ---------- */
.paper { background: #fff; border: 1px solid var(--ft-line); box-shadow: 0 6px 24px rgba(20, 20, 20, .06); padding: 28px 34px; }
.paper .table > thead th { background: #fff; color: var(--ft-text); border-bottom: 1px solid var(--ft-text); border-top: 1px solid var(--ft-text); }
.paper-title { display: flex; justify-content: space-between; border-bottom: 2px solid var(--ft-text); padding-bottom: 10px; margin-bottom: 14px; }
.flash-area .alert { margin: 0; }

@media print {
  .ft-sidebar, .ft-topbar .no-print, .no-print, .flash-area { display: none !important; }
  body, .ft-content { background: #fff !important; padding: 0 !important; }
  .ft-topbar { border: 0; height: auto; padding: 0 0 8px; }
  .paper { border: 0; box-shadow: none; padding: 0; }
  .ft-card { border: 0; }
  @page { size: A4 portrait; margin: 10mm; }
  /* reports print at full page width and are never cut off by a scroll box */
  .ft-shell, .ft-main { display: block !important; width: 100% !important; margin: 0 !important; }
  .ft-main:has(.paper) .ft-topbar, .ft-mobilebar, .ft-feedback-btn { display: none !important; }
  .table-responsive { overflow: visible !important; }
  .paper { max-width: none !important; width: 100% !important; }
  .paper table { width: 100% !important; }
  .paper thead { display: table-header-group; }
  .paper tfoot { display: table-row-group; }  /* totals print once, straight after the rows */
  .paper tr { break-inside: avoid; }
  /* compact layout (trial balance): 9pt, tight rows, so a normal chart fits one A4 page */
  .paper-compact { font-size: 8.5pt; }
  .paper-compact .paper-title { padding-bottom: 4px; margin-bottom: 6px; }
  .paper-compact .paper-title .fs-5 { font-size: 11pt !important; }
  .paper-compact .table { margin-bottom: 4px; }
  .paper-compact .table > :not(caption) > * > * { padding: 1px 4px !important; font-size: 8.5pt; line-height: 1.25; }
  .paper-compact .table td.pt-3 { padding-top: 4px !important; }
  .paper-compact .small { font-size: 7.5pt; }
  .paper-compact a { text-decoration: none; }
  /* wide reports (ledger with FC columns) print on landscape pages */
  .paper-wide { page: wide; }
}
@page wide { size: A4 landscape; margin: 10mm; }

/* ---------- tablet & phone ---------- */
.jv-row .cell::before { display: none; }
@media (max-width: 991.98px) {
  .ft-sidebar.offcanvas-lg { --bs-offcanvas-width: 270px; background: var(--ft-ink); }
  .auth-side { display: none; }
  .ft-content { padding: 14px; gap: 14px; }
  .ft-topbar { height: auto; min-height: 56px; padding: 10px 14px; flex-wrap: wrap; }
  .ft-topbar h1 { font-size: 18px; }
  .paper { padding: 16px; overflow-x: auto; }
  .ft-kpi .value { font-size: 18px; }
  .ft-feedback-btn { right: 12px; bottom: 12px; padding: 8px 12px; }
}
@media (max-width: 1199.98px) {
  /* voucher lines become cards: account + currency, narration, then Dr/Cr · amount · rate, then PKR */
  .jv-lines .jv-head { display: none; }
  .jv-lines .jv-row { grid-template-columns: repeat(6, minmax(0, 1fr)); row-gap: 10px; padding: 12px 14px; }
  .jv-row > .cell:nth-child(1) { grid-column: span 4; }
  .jv-row > .cell:nth-child(2) { grid-column: span 6; grid-row: 2; }
  .jv-row > .cell:nth-child(3) { grid-column: span 1; }
  .jv-row > .cell:nth-child(4), .jv-row > .cell:nth-child(5), .jv-row > .cell:nth-child(6) { grid-column: span 2; }
  .jv-row > .cell:nth-child(7), .jv-row > .cell:nth-child(8) { grid-column: span 3; }
  .jv-row > .cell:nth-child(9) { grid-column: 6; grid-row: 1; }
  .jv-row > .cell:nth-child(1) { grid-row: 1; }
  .jv-row > .cell:nth-child(3) { grid-row: 1; }
  .jv-row .cell::before { display: block; content: attr(data-label); font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ft-muted); margin-bottom: 3px; }
  .jv-row .cell[data-label=""]::before { display: none; }
  .jv-deal { padding: 0 14px 12px; flex-wrap: wrap; }
  .jv-foot { grid-template-columns: 1fr 1fr; }
  .jv-foot > div:first-child { grid-column: 1 / -1; }
  .jv-foot > span:last-child { display: none; }
}
@media (max-width: 575.98px) {
  .jv-row > .cell:nth-child(1) { grid-column: span 5; }
  .jv-row > .cell:nth-child(3) { grid-column: 1 / span 2; grid-row: 3; }
  .jv-row > .cell:nth-child(4) { grid-column: 3 / span 4; grid-row: 3; }
  .jv-row > .cell:nth-child(5), .jv-row > .cell:nth-child(6) { grid-column: span 3; }
  .jv-row > .cell:nth-child(9) { grid-column: 6; }
  .ft-topbar .no-print { width: 100%; flex-wrap: wrap; }
}
.jv-row .f-rate.rate-auto { background: var(--ft-orange-soft); }

/* Help (user guide inside the app) */
.help-toc { position: sticky; top: 16px; }
.help-toc a { color: var(--ft-text); text-decoration: none; }
.help-toc a:hover { color: var(--ft-orange-text); }
.help-body { line-height: 1.6; max-width: 900px; }
.help-body h2 { font-size: 1.25rem; font-weight: 800; margin: 2rem 0 .75rem; padding-top: .5rem; border-top: 1px solid var(--ft-line-soft); scroll-margin-top: 16px; }
.help-body h2:first-of-type { border-top: 0; margin-top: 0; }
.help-body h3 { font-size: 1.05rem; font-weight: 700; margin: 1.5rem 0 .5rem; scroll-margin-top: 16px; }
.help-body img { max-width: 100%; height: auto; border: 1px solid var(--ft-line); border-radius: 8px; margin: .5rem 0 1rem; }
.help-body code { color: var(--ft-orange-text); }
.help-body .help-target { background: var(--ft-orange-soft); border-radius: 6px; padding: .25rem .5rem; }
.ft-help-btn { color: var(--ft-orange-text); font-weight: 700; }
@media print { .help-body { max-width: none; } }
