/* Watermelon Capitalio layout and base-component styles adapted for Persian RTL.
 * Copyright (c) 2026 Watermelon Platform Contributors. MIT, LICENSE.txt included.
 * Product-specific layout, charts and financial workflow: Takvin app.
 */
:root {
  --ink: #17342e;
  --muted: #697873;
  --green: #13785a;
  --mint: #eaf5ee;
  --line: #e2e8e4;
  --paper: #f6f8f6;
  --sidebar: 280px;
}
.watermelon-theme {
  --wm-primary: #13785a;
  --wm-ring: #13785a;
}
body {
  font-size: 15px;
  line-height: 1.7;
}
[hidden] {
  display: none !important;
}
button,
input,
select,
textarea {
  font-family: Takvin, Tahoma, sans-serif;
}
button {
  touch-action: manipulation;
}
.primary,
.secondary,
.confirm-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
}
.primary {
  background: var(--wm-primary);
  box-shadow: 0 1px 2px #00000012;
}
.secondary {
  background: var(--wm-card);
  border-color: var(--wm-border);
}
.primary:focus-visible,
.secondary:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #9bd0b9;
}
.confirm-button:disabled {
  opacity: 1;
  background: #e4f4e9;
  color: #176e4f;
  cursor: default;
}
.brand-icon {
  font: 700 19px Arial;
  transform: none;
  background: #167457;
  width: 43px;
  height: 43px;
  box-shadow: inset 0 0 0 1px #ffffff40;
}
.brand b {
  font-size: 20px;
}
.brand small {
  font-size: 11px;
}
.sidebar {
  background: var(--wm-sidebar);
  color: var(--wm-sidebar-foreground);
  border-left: 1px solid var(--line);
  padding: 24px 16px 12px;
}
.sidebar .brand {
  padding: 0 8px 22px;
  border-color: var(--line);
}
.sidebar .brand b {
  font-size: 20px;
}
.sidebar .brand-icon {
  background: #167457;
  color: white;
}
.sidebar .brand small,
.sidebar-label,
.back-projects {
  color: #73817b;
}
.back-projects {
  font-size: 13px;
  padding: 16px 8px;
}
.sidebar-label {
  padding: 10px 8px 6px;
  font-size: 12px;
}
#stage-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf8;
  padding: 8px 12px;
  font-size: 13px;
  margin: 4px 0 12px;
}
.sidebar nav {
  scrollbar-color: #d2dbd4 transparent;
}
.nav-step {
  gap: 8px;
  color: #52645b;
  padding: 10px;
  min-height: 43px;
  margin: 3px 0;
}
.nav-step span {
  font-size: 12px;
  width: 22px;
  flex-shrink: 0;
}
.nav-step b {
  font-size: 13px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-step-sum {
  margin-inline-start: auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: 4px;
  background: #eef5f0;
  color: #157653;
  white-space: nowrap;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  border: 1px solid #d4e6db;
}
.nav-step-sum small {
  font-size: 9px;
  color: #52645b;
}
.nav-step.active .nav-step-sum {
  background: #ffffff;
  color: #0f513a;
  border-color: #bad3c3;
}
.nav-step:hover:not(.active) .nav-step-sum {
  background: #e2ede5;
}
.nav-step:hover:not(.active) {
  background: var(--wm-sidebar-accent);
  color: var(--ink);
}
.nav-step.active {
  background: #e9f4ec;
  color: #126548;
  box-shadow: inset 0 0 0 1px #cde3d5;
}
.nav-step i {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #157653;
  background: #dcf1e3;
  font-size: 12px;
  flex-shrink: 0;
}
.sidebar-footer {
  border-color: var(--line);
  color: #718078;
  font-size: 11px;
}
.topbar {
  background: #fff;
  min-height: 82px;
  gap: 10px;
  padding: 14px 32px;
}
.top-actions {
  flex-wrap: wrap;
  gap: 8px;
}
.saved {
  white-space: nowrap;
  font-size: 12px;
}
.breadcrumbs {
  font-size: 13px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.workspace {
  min-width: 0;
}
.page-content {
  padding: 32px;
  max-width: 1500px;
}
.page-heading {
  gap: 18px;
}
.page-heading h1 {
  font-size: 29px;
  letter-spacing: -0.5px;
}
.page-heading p {
  font-size: 14px;
}
.eyebrow {
  letter-spacing: 1.2px;
  color: #648274;
}
.progress-mini {
  border: 1px solid var(--line);
  background: white;
  min-width: 106px;
  flex-shrink: 0;
}
.progress-mini > span {
  font-size: 12px;
}
.panel {
  border-radius: 12px;
  background: var(--wm-card);
  border-color: var(--wm-border);
  box-shadow: 0 1px 3px #163b2410;
  padding: 24px;
}
.section-heading h2 {
  font-size: 19px;
  font-weight: 700;
}
.section-heading p,
.muted {
  font-size: 13px;
}
.field > span {
  font-size: 14px;
  color: #465e52;
}
.input-wrap {
  border-color: #dce3dd;
  background: white;
}
.input-wrap input {
  min-height: 45px;
  font-size: 15px;
}
.input-wrap small {
  font-size: 12px;
  color: #67796e;
}
table {
  font-size: 14px;
}
th {
  color: #5e7266;
  font-weight: 700;
  background: #f5f8f5;
  font-size: 12px;
}
td {
  line-height: 1.8;
}
.table-scroll {
  max-width: 100%;
  scrollbar-width: thin;
}
.line-picker {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.line-picker article {
  background: #f7faf7;
}
.line-picker h3 {
  font-size: 16px;
  min-height: 68px;
}
.line-picker small {
  font-size: 12px;
}

.notice,
.validation,
.warnings {
  font-size: 14px;
}
.review-grid > div {
  font-size: 14px;
}
.review-grid button {
  font-size: 13px;
}
.page-footer {
  background: #ffffffed;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  gap: 12px;
}
.footer-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}
.dashboard {
  max-width: 1350px;
  padding: 30px 40px;
}
.dashboard > header {
  padding-bottom: 24px;
}
.local-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #637b6c;
}
.local-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #379b6e;
}
.welcome {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 28px;
  padding: 40px 0 22px;
}
.welcome h1 {
  font-size: 32px;
  margin-bottom: 10px;
}
.welcome p {
  font-size: 14px;
  max-width: 650px;
}
.welcome .row-tools {
  flex-shrink: 0;
}
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 6px 0 36px;
}
.stat-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--wm-border);
  background: var(--wm-card);
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 1px 2px #172f2010;
}
.stat-card > span {
  font-size: 14px;
  color: #586c60;
}
.stat-card strong {
  font-size: 31px;
  color: #193c2c;
  line-height: 1.65;
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
  overflow-wrap: anywhere;
}
.stat-card small {
  font-size: 12px;
  color: #7c8b81;
}
.project-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 36px;
}
.project-card {
  padding: 22px;
  border-color: var(--wm-border);
  box-shadow: 0 1px 2px #172f200a;
}
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.project-monogram {
  background: #eaf4ec;
  color: #2d754a;
}
.status-badge {
  font-size: 11px;
  border: 1px solid #e1e8e2;
  background: #f7f9f6;
  border-radius: 20px;
  padding: 3px 9px;
  color: #6a786c;
}
.status-badge.approved {
  background: #e6f3e9;
  border-color: #c9e3d0;
  color: #246d40;
}
.project-card h3 {
  margin: 20px 0 8px;
  font-size: 18px;
  line-height: 1.9;
  overflow-wrap: anywhere;
}
.project-card p {
  font-size: 13px;
}
.thin-progress {
  height: 5px;
  background: #edf1ec;
  border-radius: 5px;
  overflow: hidden;
  margin: 14px 0;
}
.thin-progress span {
  display: block;
  background: #398e64;
  height: 100%;
  border-radius: 5px;
  transition: width 0.25s;
}
.project-card > .project-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
}
.project-actions button {
  font-size: 12px;
  padding: 7px 10px;
  min-height: 38px;
}
.project-actions .danger-link {
  margin-inline-start: auto;
}
#project-search {
  width: 240px;
  max-width: 100%;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 14px;
}
.comparison-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
}
.comparison-picker .check {
  padding: 10px 14px;
  background: #f7faf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}
.comparison-picker input {
  accent-color: var(--green);
  width: 17px;
  height: 17px;
}
#comparison-result:not(:empty) {
  border-top: 1px solid var(--line);
  margin-top: 26px;
  padding-top: 22px;
}
.overview-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 0;
  margin-bottom: 22px;
}
.overview-stats .stat-card {
  padding: 20px;
}
.overview-stats strong {
  font-size: 27px;
}
.overview-columns {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
}
.capital-bars > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 14px;
  margin-bottom: 17px;
  font-size: 13px;
}
.capital-bars strong {
  font-size: 14px;
  font-weight: 400;
}
.capital-bars > div > div {
  grid-column: 1/-1;
  height: 8px;
  background: #edf2ed;
  border-radius: 4px;
  overflow: hidden;
}
.capital-bars i {
  height: 100%;
  display: block;
  background: #478666;
  border-radius: 4px;
}
.capital-bars .bar-1 {
  background: #84ab8a;
}
.capital-bars .bar-2 {
  background: #a6bea5;
}
.capital-bars .bar-3 {
  background: #3b7182;
}
.capital-bars .bar-4 {
  background: #c1ad7c;
}
.review-summary > strong {
  font-size: 40px;
  color: var(--green);
}
.review-summary strong small {
  font-size: 15px;
  color: var(--muted);
  font-weight: 400;
}
.review-summary p {
  font-size: 14px;
}
.review-summary .thin-progress {
  margin-bottom: 26px;
}
.onboarding-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin: 24px 0;
}
.onboarding-grid p {
  font-size: 14px;
  margin-top: 10px;
}
.sensitivity-controls {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin: 24px 0 12px;
  flex-wrap: wrap;
}
.sensitivity-controls .field {
  max-width: 320px;
  margin-bottom: 0;
}
.sensitivity-controls button {
  min-height: 47px;
}
.sensitivity-bars {
  display: grid;
  gap: 12px;
  margin: 24px 0 30px;
}
.sensitivity-bars > div {
  display: grid;
  grid-template-columns: 210px 1fr 100px;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}
.sensitivity-bars b {
  margin-inline-start: 10px;
  font-size: 12px;
}
.sensitivity-bars > div > div {
  height: 14px;
  background: #f0f3f0;
  border-radius: 4px;
}
.sensitivity-bars i {
  height: 100%;
  display: block;
  min-width: 1px;
  border-radius: 4px;
}
.bar-gain {
  background: #438963;
}
.bar-loss {
  background: #c77862;
}
.sensitivity-bars strong {
  text-align: left;
  font-size: 13px;
}
@media (max-width: 1200px) {
  :root {
    --sidebar: 245px;
  }
  .page-content {
    padding: 26px 22px;
  }
  .topbar {
    padding-inline: 22px;
  }
  .overview-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .welcome {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 800px) {
  :root {
    --sidebar: 0px;
  }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-left: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px;
  }
  .sidebar nav {
    margin-top: 12px;
  }
  #stage-search {
    display: none;
  }
  .nav-step b {
    font-size: 13px;
  }
  .topbar {
    padding: 12px 16px;
  }
  .top-actions button {
    font-size: 12px;
    padding: 7px 10px;
  }
  .breadcrumbs {
    max-width: 100%;
    width: 100%;
  }
  .page-content {
    padding: 22px 16px;
  }
  .page-heading h1 {
    font-size: 25px;
  }
  .panel {
    padding: 19px 16px;
  }
  .overview-columns,
  .onboarding-grid {
    grid-template-columns: 1fr;
  }
  .line-picker {
    grid-template-columns: 1fr;
  }
  .line-picker h3 {
    min-height: 0;
  }
  .dashboard {
    padding: 22px 18px;
  }
  .dashboard-stats {
    gap: 10px;
  }
  .stat-card {
    padding: 16px;
  }
  .stat-card strong {
    font-size: 25px;
  }
  .local-status {
    display: none;
  }
  .welcome h1 {
    font-size: 27px;
  }
  .section-heading.horizontal {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }
  .sensitivity-bars > div {
    grid-template-columns: 160px 1fr 70px;
    gap: 8px;
    font-size: 12px;
  }
  .footer-actions button {
    font-size: 12px;
  }
  .footer-actions {
    flex-direction: row;
  }
}
@media (max-width: 520px) {
  .project-grid,
  .dashboard-stats {
    grid-template-columns: 1fr;
  }
  .overview-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .overview-stats .stat-card {
    padding: 14px;
  }
  .stat-card > span {
    font-size: 13px;
  }
  .overview-stats strong {
    font-size: 21px;
  }
  .sensitivity-bars > div {
    grid-template-columns: 1fr 70px;
  }
  .sensitivity-bars > div > span {
    grid-column: 1/-1;
  }
  .page-footer {
    align-items: flex-start;
    flex-wrap: wrap;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

.equipment-table {
  min-width: 900px;
}
.equipment-table td:first-child {
  min-width: 170px;
}
.equipment-table td:nth-child(3) {
  min-width: 240px;
}
.equipment-table .field {
  margin-bottom: 6px;
}
.equipment-table .field > span {
  font-size: 11px;
}
.equipment-table .field input {
  width: 100%;
  min-width: 70px;
}
.equipment-table td:nth-child(2) {
  width: 110px;
}
.equipment-table select {
  width: 100%;
  font-size: 12px;
}
.equipment-table .equipment-source,
.equipment-original small {
  display: block;
  margin-top: 6px;
}
.equipment-original b {
  font-size: 15px;
}
.equipment-table td:last-child {
  min-width: 90px;
}

/* --- UNIDO COMFAR III Accounting Typography & Financial Statements Suite --- */
.accounting-number {
  direction: ltr !important;
  unicode-bidi: isolate !important;
  display: inline-block;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
}
.accounting-number.negative {
  color: #dc2626 !important;
  font-weight: 600;
}

.reconciled-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 9999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #a7f3d0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.reconciled-badge.unbalanced {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.solvency-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 9999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #bfdbfe;
}
.solvency-badge.deficit {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.statement-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.statement-pill {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--color-border, #d1d5db);
  background: var(--bg-card, #ffffff);
  color: var(--color-ink, #374151);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}
.statement-pill.active {
  background: var(--color-primary, #1e3a5f);
  color: #ffffff;
  border-color: var(--color-primary, #1e3a5f);
}

.financial-table {
  width: 100%;
  border-collapse: collapse;
}
.financial-table th:first-child,
.financial-table td:first-child {
  position: sticky;
  right: 0;
  background: var(--bg-surface, #ffffff);
  z-index: 2;
  font-weight: 600;
  min-width: 200px;
  box-shadow: -2px 0 4px rgba(0,0,0,0.04);
}
.financial-table tr:hover td:first-child {
  background: var(--bg-hover, #f3f4f6);
}
.financial-table .total-row td {
  font-weight: 700;
  border-top: 2px solid var(--color-border, #cbd5e1);
  border-bottom: 2px solid var(--color-border, #cbd5e1);
  background: #f8fafc;
}
.financial-table .subtotal-row td {
  font-weight: 600;
  background: #fdfdfd;
}

/* --- Spider Chart & Tornado Chart --- */
.spider-chart-box {
  background: #ffffff;
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 8px;
  padding: 18px;
  margin: 16px 0;
}
.spider-chart-svg {
  width: 100%;
  height: auto;
  max-height: 380px;
  display: block;
}
.spider-legend {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 12px;
  font-weight: 500;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.legend-badge {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.tornado-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}
.tornado-item {
  display: grid;
  grid-template-columns: 140px 1fr 140px;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}
.tornado-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
}
.tornado-bar-outer {
  height: 26px;
  background: #f1f5f9;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.tornado-bar-inner {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* --- Interactive Risk Simulator --- */
.risk-simulator-panel {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 20px;
  margin: 20px 0;
}
.risk-sliders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin: 18px 0;
}
.risk-slider-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.risk-slider-card label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
}
.risk-slider-card input[type="range"] {
  width: 100%;
  cursor: pointer;
  accent-color: #0d9488;
}
.risk-live-outcome {
  background: #ffffff;
  border: 1px solid #0d9488;
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.risk-metric-cell span {
  display: block;
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
}
.risk-metric-cell strong {
  font-size: 20px;
  font-weight: 700;
}

/* --- Capex & Opex Ledgers --- */
.ledger-table .field {
  margin-bottom: 0;
}
.ledger-table input,
.ledger-table select {
  font-size: 12px;
  padding: 4px 8px;
}
.ledger-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

