/* ============================================================
   Sabahi Portfolio — Blue & White theme
   ============================================================ */

:root {
  --blue-900: #0b2a6b;
  --blue-800: #133a8a;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-300: #93c5fd;
  --blue-100: #dbeafe;
  --blue-50:  #eff5ff;

  --ink:      #0f1b33;
  --muted:    #5b6b86;
  --line:     #e3e9f2;
  --bg:       #f4f7fc;
  --white:    #ffffff;

  --green:    #16a34a;
  --green-bg: #e7f7ec;
  --amber:    #d97706;
  --amber-bg: #fdf0db;
  --red:      #dc2626;
  --red-bg:   #fdeaea;
  --gray:     #6b7280;
  --gray-bg:  #eef1f6;

  --shadow:   0 1px 2px rgba(15,27,51,.06), 0 6px 20px rgba(15,27,51,.06);
  --shadow-lg:0 10px 40px rgba(15,27,51,.14);
  --radius:   14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--blue-700); }

/* ── Top brand bar ───────────────────────────────────────── */
.appbar {
  background: linear-gradient(120deg, var(--blue-800), var(--blue-600));
  color: #fff;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow);
}
.appbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px;
  border-radius: 11px;
  background: #fff;
  color: var(--blue-700);
  font-weight: 800;
  font-size: 22px;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: .3px; }
.brand-name .ar { font-weight: 700; opacity: .85; margin-left: 8px; font-size: 17px; }
.brand-sub { font-size: 12.5px; opacity: .82; }

.appbar-spacer { flex: 1; }
.appbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.conn-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 99px;
  background: rgba(255,255,255,.14);
  white-space: nowrap;
}
.conn-badge.conn-ok { background: rgba(255,255,255,.14); color: #d7ffe6; }
.conn-badge.conn-bad { background: #fff; color: var(--red); }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 70px;
  z-index: 30;
}
.tabs-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 14px;
  display: flex;
  gap: 2px;
  overflow-x: auto;
}
.tab {
  border: none;
  background: none;
  padding: 14px 16px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--blue-700); }
.tab.active { color: var(--blue-700); border-bottom-color: var(--blue-600); }

/* ── Layout ──────────────────────────────────────────────── */
.wrap { max-width: 1240px; margin: 0 auto; padding: 24px; }
.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 26px 0 12px; }
.section-title:first-child { margin-top: 0; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: .15s;
}
.btn:hover { border-color: var(--blue-300); background: var(--blue-50); }
.btn-primary { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
.btn-ghost-light { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); color: #fff; }
.btn-ghost-light:hover { background: rgba(255,255,255,.24); }
.btn-danger { color: var(--red); border-color: var(--red-bg); background: var(--red-bg); }
.btn-danger:hover { background: #fbdada; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { padding: 6px 9px; }

/* ── Welcome + quick guide (dashboard) ───────────────────── */
.welcome {
  background: linear-gradient(120deg, var(--blue-700), var(--blue-500));
  color: #fff;
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.welcome-title { font-size: 20px; font-weight: 800; }
.welcome-text { font-size: 14.5px; opacity: .95; margin-top: 6px; max-width: 760px; line-height: 1.55; }
.welcome .btn-primary { background: #fff; color: var(--blue-700); border-color: #fff; }
.welcome .btn-primary:hover { background: var(--blue-50); }

.guide-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue-500);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}
.guide-title { font-size: 15px; font-weight: 800; color: var(--blue-800); margin-bottom: 10px; }
.guide-steps { margin: 0; padding-left: 22px; }
.guide-steps li { margin: 8px 0; font-size: 14px; line-height: 1.5; }

.progress.big { height: 16px; }

/* ── KPI cards ───────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 800; margin-top: 6px; color: var(--blue-800); }
.kpi-value.small { font-size: 22px; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi.accent { background: linear-gradient(120deg, var(--blue-700), var(--blue-500)); border: none; color: #fff; }
.kpi.accent .kpi-label, .kpi.accent .kpi-sub { color: rgba(255,255,255,.85); }
.kpi.accent .kpi-value { color: #fff; }

/* progress bar */
.progress { height: 9px; background: var(--blue-100); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress > span { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.kpi.accent .progress { background: rgba(255,255,255,.28); }
.kpi.accent .progress > span { background: #fff; }

/* ── Generic card ────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 14px; font-size: 15px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ── Charts (pure SVG / CSS) ─────────────────────────────── */
.bar-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; }
.bar-label { width: 150px; font-size: 13px; color: var(--ink); flex-shrink: 0; text-align: right; }
.bar-track { flex: 1; background: var(--blue-50); border-radius: 8px; height: 22px; position: relative; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--blue-500), var(--blue-700)); border-radius: 8px; min-width: 2px; transition: width .4s ease; }
.bar-val { width: 92px; font-size: 13px; font-weight: 700; color: var(--blue-800); text-align: right; flex-shrink: 0; }

.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut-legend { display: flex; flex-direction: column; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.legend-dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }

/* ── Insight (best seller / top lead) ────────────────────── */
.insight { display: flex; align-items: flex-start; gap: 14px; }
.insight-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 22px;
  background: var(--blue-50); color: var(--blue-700);
}
.insight-main { font-size: 18px; font-weight: 800; color: var(--blue-800); }
.insight-sub { font-size: 13px; color: var(--muted); }
.rank-list { list-style: none; margin: 12px 0 0; padding: 0; }
.rank-list li { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.rank-list li span:last-child { font-weight: 700; color: var(--blue-800); }

/* ── Alerts ──────────────────────────────────────────────── */
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.alert-list li:first-child { border-top: none; }
.alert-tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.tag-overdue { background: var(--red-bg); color: var(--red); }
.tag-soon { background: var(--amber-bg); color: var(--amber); }
.tag-follow { background: var(--blue-100); color: var(--blue-700); }
.empty-line { color: var(--muted); font-size: 13.5px; padding: 6px 0; }

/* ── Table ───────────────────────────────────────────────── */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.input, .select, textarea.input {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--ink);
  width: 100%;
  font-family: inherit;
}
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100); }

.table-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 11px 14px; text-align: left; white-space: nowrap; }
table.data thead th {
  background: var(--blue-50);
  color: var(--blue-800);
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none;
}
table.data thead th.no-sort { cursor: default; }
table.data tbody tr { border-bottom: 1px solid var(--line); }
table.data tbody tr:last-child { border-bottom: none; }
table.data tbody tr:hover { background: var(--blue-50); }
table.data td.num, table.data th.num { text-align: right; }
table.data .muted { color: var(--muted); }
.wrap-cell { white-space: normal; min-width: 200px; max-width: 280px; }

/* gate badges */
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.g0 { background: var(--gray-bg); color: var(--gray); }
.g1 { background: #e6efff; color: #2b5dc6; }
.g2 { background: var(--blue-100); color: var(--blue-700); }
.g3 { background: var(--amber-bg); color: var(--amber); }
.g4 { background: #dde9ff; color: var(--blue-700); }
.g5 { background: var(--green-bg); color: var(--green); }
.ghold { background: var(--amber-bg); color: var(--amber); }
.gcancel { background: var(--red-bg); color: var(--red); }

.wa-link { color: var(--green); text-decoration: none; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.wa-link:hover { text-decoration: underline; }

.row-actions { display: flex; gap: 6px; }

/* ── Pipeline board (Kanban) ─────────────────────────────── */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.board-col {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 250px; flex-shrink: 0;
  display: flex; flex-direction: column;
  max-height: 70vh;
}
.board-col.drag-over { border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100); }
.board-col-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--white); border-radius: var(--radius) var(--radius) 0 0; }
.board-col-head .name { font-weight: 700; font-size: 13.5px; }
.board-col-head .count { font-size: 12px; color: var(--muted); }
.board-col-sum { padding: 6px 14px; font-size: 12px; color: var(--blue-700); font-weight: 700; border-bottom: 1px solid var(--line); background: var(--blue-50); }
.board-col-body { padding: 10px; overflow-y: auto; flex: 1; min-height: 60px; }
.pcard {
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue-500);
  border-radius: 10px;
  padding: 11px 12px;
  margin-bottom: 9px;
  box-shadow: var(--shadow);
  cursor: grab;
}
.pcard:active { cursor: grabbing; }
.pcard.dragging { opacity: .5; }
.pcard .pc-client { font-weight: 700; font-size: 13.5px; }
.pcard .pc-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pcard .pc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.pcard .pc-val { font-weight: 800; color: var(--blue-800); font-size: 13px; }
.pcard .pc-lead { font-size: 11.5px; color: var(--muted); }
.pc-controls { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 7px; }
.pc-stage-label { font-size: 11.5px; color: var(--muted); font-weight: 600; display: flex; flex-direction: column; gap: 3px; }
.pc-stage { padding: 6px 8px; font-size: 12.5px; cursor: pointer; }
.pc-edit { width: 100%; justify-content: center; }
.pcard[draggable="true"] { cursor: default; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,27,51,.5);
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 100; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); border-radius: 16px; width: 100%; max-width: 680px;
  box-shadow: var(--shadow-lg); animation: pop .2s ease;
}
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.close-x { border: none; background: none; font-size: 24px; line-height: 1; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.close-x:hover { background: var(--bg); color: var(--ink); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }

/* ── misc ────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .big { font-size: 40px; margin-bottom: 10px; }
.pill { font-size: 12px; background: var(--blue-50); color: var(--blue-700); padding: 4px 10px; border-radius: 99px; font-weight: 600; }
.note-banner { background: var(--blue-50); border: 1px solid var(--blue-100); color: var(--blue-800); border-radius: 12px; padding: 12px 16px; font-size: 13.5px; margin-bottom: 18px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow-lg); z-index: 200; opacity: 0;
  pointer-events: none; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.file-input { display: none; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .tabs { top: 64px; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .wrap { padding: 16px; }
  .bar-label { width: 110px; }
}
