/* css/style.css */
/* CFO Cash Flow Intelligence — Professional Executive Design (Navy / Green) */

:root {
  --color-navy: #0a192f;
  --color-navy-light: #112240;
  --color-navy-lighter: #1a365d;
  --color-green: #2d6a4f;
  --color-green-light: #40916c;
  --color-green-pale: #d8f3dc;
  --color-red: #c53030;
  --color-orange: #dd6b20;

  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;

  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: all .2s ease;

  --font-ar: "Cairo", sans-serif;
  --font-en: "Inter", sans-serif;
  --font-mono: "SF Mono", "Fira Code", monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-en);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
html[lang="ar"] body { font-family: var(--font-ar); }
a { color: var(--color-navy-lighter); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--color-green); }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.3; color: var(--color-navy); }
h1 { font-size: 2rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.25rem; }
p { margin-bottom: 1rem; color: var(--color-text-secondary); }

.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 1.5rem; }
main { flex: 1; padding: 2rem 0; }

/* Header */
#main-header { background: var(--color-navy); color: #fff; position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow-md); }
#main-header .container { display: flex; align-items: center; justify-content: space-between; height: 64px; flex-wrap: wrap; }
.nav-brand { display: flex; align-items: center; gap: .75rem; }
.nav-logo { background: var(--color-green); color: #fff; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); font-weight: 800; font-size: .75rem; }
.nav-title { font-weight: 700; font-size: 1rem; color: #fff; }
.nav-links { display: flex; gap: .4rem; flex-wrap: wrap; }
.nav-link { color: rgba(255,255,255,.8); padding: .5rem .875rem; border-radius: var(--radius-sm); font-size: .875rem; font-weight: 500; transition: var(--transition); }
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(255,255,255,.1); }
.lang-toggle { background: transparent; border: 1px solid rgba(255,255,255,.3); color: #fff; padding: .4rem .875rem; border-radius: var(--radius-sm); font-size: .875rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.lang-toggle:hover { background: rgba(255,255,255,.15); }
.mobile-menu-btn { display: none; background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .625rem 1.25rem; border-radius: var(--radius-sm); font-size: .9375rem; font-weight: 600; cursor: pointer; border: none; transition: var(--transition); font-family: inherit; }
.btn-primary { background: var(--color-green); color: #fff; }
.btn-primary:hover { background: var(--color-green-light); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--color-navy-lighter); color: #fff; }
.btn-secondary:hover { background: var(--color-navy); }
.btn-outline { background: transparent; border: 1.5px solid var(--color-border); color: var(--color-text); }
.btn-outline:hover { border-color: var(--color-green); color: var(--color-green); }
.btn-danger { background: var(--color-red); color: #fff; }
.btn-danger:hover { background: #9b2c2c; }
.btn-group { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1.5rem 0; }
.btn-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); border: none; background: var(--color-bg); color: var(--color-text-secondary); cursor: pointer; font-size: 1.1rem; }
.btn-icon:hover { background: var(--color-border); color: var(--color-red); }

/* Cards */
.card { background: var(--color-surface); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); border: 1px solid var(--color-border); padding: 1.5rem; }

input:disabled, select:disabled { background: var(--color-bg); color: var(--color-text-muted); cursor: not-allowed; opacity: .7; }

/* Forms */
.input-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.input-group { display: flex; flex-direction: column; gap: .375rem; }
.input-group label { font-size: .8125rem; font-weight: 600; color: var(--color-text-secondary); }
.input-group input, .input-group select { padding: .625rem .875rem; border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); font-size: .9375rem; font-family: inherit; background: var(--color-surface); color: var(--color-text); }
.input-group input:focus, .input-group select:focus { outline: none; border-color: var(--color-green); box-shadow: 0 0 0 3px rgba(45,106,79,.1); }
.section-title { font-size: 1.0625rem; font-weight: 700; color: var(--color-navy); margin: 1.5rem 0 1rem; padding-bottom: .5rem; border-bottom: 2px solid var(--color-green-pale); }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }
.kpi-card { background: var(--color-surface); border-radius: var(--radius-md); padding: 1.25rem; border: 1px solid var(--color-border); box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.kpi-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.kpi-card.healthy::before { background: var(--color-green); }
.kpi-card.attention::before { background: var(--color-orange); }
.kpi-card.critical::before { background: var(--color-red); }
.kpi-value { font-size: 1.6rem; font-weight: 800; color: var(--color-navy); font-family: var(--font-mono); margin-bottom: .25rem; }
.kpi-label { font-size: .8125rem; color: var(--color-text-secondary); font-weight: 500; }

/* Dynamic period table — the core "Gantt-style" wide table (Prompt §28: horizontal
   scroll on mobile, never collapse into cards) */
.period-table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
table.period-table { border-collapse: collapse; width: 100%; min-width: 720px; font-size: .8125rem; }
table.period-table th, table.period-table td { padding: .5rem .75rem; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--color-border); border-inline-start: 1px solid var(--color-border); }
table.period-table th:first-child, table.period-table td:first-child { border-inline-start: none; position: sticky; inset-inline-start: 0; background: var(--color-surface); text-align: start; font-weight: 600; z-index: 2; }
table.period-table thead th { background: var(--color-navy); color: #fff; position: sticky; top: 0; z-index: 3; }
table.period-table thead th:first-child { z-index: 4; }
table.period-table tbody tr:nth-child(even) td { background: var(--color-bg); }
table.period-table tbody tr:nth-child(even) td:first-child { background: var(--color-bg); }
table.period-table td.section-row { text-align: start; font-weight: 700; color: var(--color-navy); background: var(--color-green-pale) !important; }
table.period-table td input { width: 90px; padding: .3rem .4rem; border: 1px solid var(--color-border); border-radius: 4px; font-size: .8125rem; text-align: center; font-family: var(--font-mono); }
table.period-table td.total-row { font-weight: 700; }
table.period-table td.negative { color: var(--color-red); }
table.period-table td.status-cell.healthy { color: var(--color-green); font-weight: 700; }
table.period-table td.status-cell.attention { color: var(--color-orange); font-weight: 700; }
table.period-table td.status-cell.critical { color: var(--color-red); font-weight: 700; }

/* Insights (shared visual language with CFO Intelligence) */
.insights-list { display: flex; flex-direction: column; gap: 1rem; }
.insight-card { background: var(--color-surface); border-radius: var(--radius-md); padding: 1.5rem; border: 1px solid var(--color-border); box-shadow: var(--shadow-sm); }
.insight-card.critical { border-inline-start: 4px solid var(--color-red); background: #fff5f5; }
.insight-card.attention { border-inline-start: 4px solid var(--color-orange); background: #fffaf0; }
.insight-card.healthy { border-inline-start: 4px solid var(--color-green); background: #f0fff4; }
.insight-header { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; flex-wrap: wrap; }
.insight-severity { font-size: .75rem; font-weight: 700; text-transform: uppercase; padding: .25rem .625rem; border-radius: var(--radius-sm); }
.insight-severity.critical { background: #fed7d7; color: #742a2a; }
.insight-severity.attention { background: #feebc8; color: #7c2d12; }
.insight-severity.healthy { background: #c6f6d5; color: #22543d; }
.insight-title { font-size: 1.0625rem; font-weight: 700; color: var(--color-navy); }
.insight-action { background: rgba(255,255,255,.6); border-radius: var(--radius-sm); padding: 1rem; border: 1px solid var(--color-border); margin-top: .75rem; }
.insight-action strong { color: var(--color-navy); font-size: .8125rem; text-transform: uppercase; }
.no-insights { text-align: center; padding: 3rem; color: var(--color-text-muted); font-size: 1.0625rem; }

/* Gap analysis summary */
.gap-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.gap-stat { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 1rem; text-align: center; }
.gap-stat .value { font-size: 1.375rem; font-weight: 800; color: var(--color-navy); font-family: var(--font-mono); }
.gap-stat .label { font-size: .75rem; color: var(--color-text-secondary); margin-top: .25rem; }

/* Scenario cards */
.scenario-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; }
.scenario-card { background: var(--color-surface); border: 1.5px solid var(--color-border); border-radius: var(--radius-md); padding: 1.25rem; }
.scenario-card.base { border-color: var(--color-navy-lighter); }
.scenario-card.optimistic { border-color: var(--color-green); }
.scenario-card.stress { border-color: var(--color-red); }
.scenario-card h3 { margin-bottom: .75rem; }
.scenario-assumption-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.scenario-assumption-row label { flex: 1; font-size: .8125rem; color: var(--color-text-secondary); }
.scenario-assumption-row input { width: 70px; padding: .35rem; border: 1px solid var(--color-border); border-radius: 4px; text-align: center; }

/* Hero / Home */
.hero { text-align: center; padding: 3.5rem 1rem; background: linear-gradient(135deg, var(--color-navy) 0%, var(--color-navy-light) 100%); color: #fff; border-radius: var(--radius-lg); margin-bottom: 2rem; }
.hero h1 { font-size: 2.25rem; color: #fff; margin-bottom: 1rem; }
.hero p { font-size: 1.0625rem; color: rgba(255,255,255,.85); max-width: 620px; margin: 0 auto 2rem; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; margin-top: 2rem; }
.feature-card { display: block; background: var(--color-surface); border-radius: var(--radius-md); padding: 1.5rem; text-align: center; border: 1px solid var(--color-border); transition: var(--transition); text-decoration: none; color: inherit; cursor: pointer; }
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--color-green); }
.feature-icon { width: 48px; height: 48px; background: var(--color-green-pale); color: var(--color-green); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem; font-size: 1.5rem; }
.feature-card h3 { font-size: 1.0625rem; margin-bottom: .5rem; color: var(--color-navy); }
.feature-card p { font-size: .875rem; margin: 0; }
.demo-disclaimer { display: inline-block; margin-top: 1rem; font-size: .8125rem; color: var(--color-orange); background: #fffaf0; border: 1px solid #feebc8; padding: .4rem .875rem; border-radius: var(--radius-sm); }

/* Integrity / info banners */
.integrity-banner { border-radius: var(--radius-md); padding: 1rem 1.5rem; margin-bottom: 1.5rem; }
.integrity-banner.warning { background: #fff5f5; border: 1px solid #feb2b2; color: #742a2a; }
.integrity-banner.info { background: var(--color-navy); color: #fff; }
.integrity-banner strong { display: block; margin-bottom: .25rem; }

footer { background: var(--color-navy); color: rgba(255,255,255,.6); text-align: center; padding: 1.5rem; font-size: .875rem; margin-top: auto; }

.text-center { text-align: center; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none; }

/* Itemized/expandable cell */
.cell-expand { background: var(--color-green-pale); border: 1.5px dashed var(--color-green); border-radius: 4px; padding: .3rem .5rem; font-family: var(--font-mono); font-size: .8125rem; cursor: pointer; color: var(--color-navy); }
.cell-expand:hover { background: var(--color-green-light); color: #fff; }
.cell-expand small { opacity: .75; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,25,47,.6); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1rem; }
.modal-box { background: var(--color-surface); border-radius: var(--radius-md); padding: 1.5rem; max-width: 900px; width: 100%; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-table input, .modal-table select { width: 100%; }

@media (max-width: 768px) {
  .nav-links { display: none; position: absolute; top: 64px; inset-inline: 0; background: var(--color-navy); flex-direction: column; padding: 1rem; }
  .nav-links.open { display: flex; }
  .mobile-menu-btn { display: block; }
  .lang-toggle { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .btn-group { flex-direction: column; }
  .btn { width: 100%; }
  .hero h1 { font-size: 1.625rem; }
  .modal-box { padding: 1rem; }
}
