/* Just Creativity — Agency CRM & Client Portal
   One family (Readex Pro) for Arabic + Latin. Navy base, purple for action, gold for money that works. */

:root {
  --night: #0e1028;
  --deck: #151834;
  --raised: #1d2142;
  --hover: #232850;
  --line: #2a2f55;
  --line-soft: #20244a;
  --text: #ecedf8;
  --muted: #8f94b8;
  --faint: #6b7097;
  --purple: #7b1fff;
  --purple-hi: #9455ff;
  --purple-ink: #b694ff;
  --purple-wash: rgba(123, 31, 255, 0.14);
  --gold: #c9a84c;
  --gold-wash: rgba(201, 168, 76, 0.12);
  --good: #3fd08f;
  --bad: #f2707a;
  --warn: #e7b551;
  --r-panel: 14px;
  --r-ctl: 9px;
  --font: "Readex Pro", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.6;
  background: var(--night);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--purple-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 600; }
h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line-soft); margin: 1.2rem 0; }
.ico { flex: none; display: block; }
:focus-visible { outline: 2px solid var(--purple-hi); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.86rem; }
.tiny { font-size: 0.75rem; }
.good-txt { color: var(--good); }
.bad-txt { color: var(--bad); }
.warn-txt { color: var(--warn); }
.gold-txt { color: var(--gold); }
.spacer { flex: 1; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dim { opacity: 0.5; }

/* ---------------------------------------------------------- controls */
.btn {
  font: inherit; font-size: 0.9rem; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  height: 38px; padding: 0 0.95rem; border-radius: var(--r-ctl);
  border: 1px solid var(--line); background: var(--raised); color: var(--text);
  cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn.primary:hover { background: var(--purple-hi); border-color: var(--purple-hi); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--raised); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #1a0a0d; }
.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--bad); }
.btn.danger-ghost:hover { background: rgba(242, 112, 122, 0.1); }
.btn.good { background: rgba(63, 208, 143, 0.12); border-color: rgba(63, 208, 143, 0.4); color: var(--good); }
.btn.sm { height: 32px; padding: 0 0.7rem; font-size: 0.84rem; }
.btn.block { width: 100%; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy .ico { visibility: hidden; }
.btn.busy::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff6; border-top-color: #fff; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  font: inherit; display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: var(--r-ctl); border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.danger:hover { color: var(--bad); }

input, select, textarea {
  font: inherit; color: var(--text); width: 100%;
  background: var(--night); border: 1px solid var(--line); border-radius: var(--r-ctl);
  padding: 0.55rem 0.75rem; min-height: 40px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--purple-hi); box-shadow: 0 0 0 3px var(--purple-wash); }
select option { background: var(--deck); }
input[type="date"], input[type="month"] { color-scheme: dark; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }
.field small { display: block; color: var(--faint); font-size: 0.78rem; margin-top: 0.3rem; }
.req { color: var(--bad); }
.check { display: flex; align-items: center; gap: 0.6rem; margin: 0.3rem 0 0.9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--purple); }
.file-drop {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem; padding: 1.2rem; cursor: pointer;
  border: 1px dashed var(--line); border-radius: var(--r-ctl); color: var(--muted); text-align: center;
}
.file-drop:hover { border-color: var(--purple-hi); color: var(--text); }
.file-drop input { min-height: 0; border: 0; padding: 0; background: none; font-size: 0.8rem; }

/* segmented control (filters) */
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--deck); border: 1px solid var(--line-soft); border-radius: 11px; }
.seg button {
  font: inherit; font-size: 0.84rem; border: 0; background: transparent; color: var(--muted);
  height: 30px; padding: 0 0.8rem; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 0.35rem;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--raised); color: var(--text); }
.seg .count { font-size: 0.72rem; color: var(--faint); }

/* period picker */
.range-picker { display: inline-flex; align-items: center; gap: 0.4rem; height: 38px; padding-inline: 0.75rem 0.3rem; background: var(--deck); border: 1px solid var(--line); border-radius: var(--r-ctl); color: var(--muted); }
.range-picker select { width: auto; min-height: 0; height: 34px; border: 0; background: transparent; padding: 0 0.3rem; color: var(--text); }
.range-picker select:focus { box-shadow: none; }
.range-dates { display: inline-flex; align-items: center; gap: 0.35rem; }
.range-dates input { width: auto; min-height: 0; height: 30px; padding: 0 0.4rem; font-size: 0.84rem; }

/* ---------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art {
  position: relative; overflow: hidden; background: var(--deck); border-inline-end: 1px solid var(--line-soft);
  display: flex; flex-direction: column; justify-content: space-between; padding: 2.5rem;
}
.orbit { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.orbit .ring { fill: none; stroke: var(--line); stroke-width: 1; }
.orbit .sat { fill: var(--gold); }
.orbit .sat.p { fill: var(--purple-hi); }
.orbit .spin { transform-box: view-box; transform-origin: 80% 30%; animation: orbit 80s linear infinite; }
.orbit .spin.rev { animation-duration: 120s; animation-direction: reverse; }
@keyframes orbit { to { transform: rotate(360deg); } }
.login-art .claim { position: relative; max-width: 16em; }
[dir="rtl"] .orbit { transform: scaleX(-1); }
.login-art .claim h2 { font-size: 2.2rem; font-weight: 400; line-height: 1.25; letter-spacing: -0.01em; }
.login-art .claim p { color: var(--muted); margin-top: 0.9rem; max-width: 36ch; font-size: 0.98rem; }
.login-art .brand, .login-art .claim { z-index: 1; }
.login-form { display: grid; place-items: center; padding: 2rem 1.25rem; position: relative; }
.login-form form { width: min(380px, 100%); }
.login-form h1 { font-size: 1.5rem; margin-bottom: 0.35rem; }
.login-form .sub { color: var(--muted); margin-bottom: 1.6rem; }
.login-form .lang-btn { position: absolute; top: 1.25rem; inset-inline-end: 1.25rem; }
.alert { display: flex; gap: 0.5rem; align-items: flex-start; background: rgba(242, 112, 122, 0.08); border: 1px solid rgba(242, 112, 122, 0.35); color: #ffc9ce; padding: 0.65rem 0.8rem; border-radius: var(--r-ctl); margin-bottom: 1rem; font-size: 0.9rem; }

/* ---------------------------------------------------------- brand */
.brand { display: flex; align-items: center; gap: 0.7rem; }
.mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--purple); color: #fff; font-weight: 700; font-size: 1.05rem; position: relative;
}
.mark::after { content: ""; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); top: -3px; inset-inline-end: -3px; box-shadow: 0 0 0 2px var(--deck); }
.brand b { display: block; font-weight: 600; font-size: 0.98rem; }
.brand small { display: block; color: var(--muted); font-size: 0.76rem; }

/* ---------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.topbar { display: none; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1.2rem;
  padding: 1.25rem 0.85rem 1rem; background: var(--deck); border-inline-end: 1px solid var(--line-soft);
}
.sidebar > .brand { padding: 0 0.45rem; }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding-inline-end: 0.2rem; }
.side-top .brand { padding: 0 0.45rem; min-width: 0; }
.side-top .brand b, .side-top .brand small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-top .brand b { font-size: 0.93rem; }
#nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; margin: 0 -0.2rem; padding: 0 0.2rem; }
.nav-link {
  display: flex; align-items: center; gap: 0.7rem; min-height: 38px; padding: 0 0.65rem; border-radius: var(--r-ctl);
  color: var(--muted); font-size: 0.92rem;
}
.nav-link:hover { background: var(--raised); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--raised); color: var(--text); }
.nav-link.active .ico { color: var(--purple-ink); }
.nav-link .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-sep { height: 1px; background: var(--line-soft); margin: 0.75rem 0.4rem; }
.nav-title { font-size: 0.78rem; color: var(--faint); padding: 0 0.65rem 0.35rem; }
.client-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none; margin: 0 5px; }
.client-dot.ok { background: var(--good); }
.client-dot.bad { background: var(--bad); }
.nav-badge { background: var(--bad); color: #1a0a0d; font-size: 0.7rem; font-weight: 600; border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px; display: grid; place-items: center; }
.nav-client { display: flex; align-items: center; gap: 0.6rem; padding: 0.2rem 0.65rem 0.9rem; font-weight: 500; }
.nav-client img { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; }
.me { display: flex; align-items: center; gap: 0.5rem; padding: 0.8rem 0.45rem 0; border-top: 1px solid var(--line-soft); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--raised); display: grid; place-items: center; font-weight: 600; color: var(--gold); flex: none; }
.me-txt { flex: 1; min-width: 0; }
.me-txt b { display: block; font-size: 0.88rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-txt small { color: var(--muted); font-size: 0.76rem; }
.lang-btn { font: inherit; font-size: 0.78rem; font-weight: 600; height: 30px; min-width: 38px; padding: 0 0.5rem; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 0.35rem; }
.lang-btn:hover { color: var(--text); border-color: var(--muted); }
.main { min-width: 0; }
.scrim { display: none; }

.page { padding: 2rem clamp(1rem, 3.2vw, 2.6rem) 4rem; max-width: 1320px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 1rem 1.5rem; margin-bottom: 1.6rem; }
.page-head .sub { color: var(--muted); margin-top: 0.25rem; }
.head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.section { margin-top: 2.2rem; }
.section > h2 { margin-bottom: 0.9rem; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1.1rem; }
.status-line { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.84rem; color: var(--muted); }
.status-line.bad { color: var(--bad); }

/* ---------------------------------------------------------- client header + tabs */
.client-head { display: flex; align-items: center; gap: 0.9rem; }
.client-head img, .logo-ph { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex: none; }
.logo-ph { display: grid; place-items: center; background: var(--raised); border: 1px solid var(--line); font-weight: 600; font-size: 1.2rem; color: var(--purple-ink); }
.logo-ph.sm { width: 38px; height: 38px; border-radius: 10px; font-size: 1rem; }
.tabs { display: flex; gap: 0.2rem; border-bottom: 1px solid var(--line-soft); margin: 0 0 1.6rem; overflow-x: auto; scrollbar-width: none; }
.tab {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.7rem 0.85rem; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 0.93rem;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); border-bottom-color: var(--purple); }
.tab.active .ico { color: var(--purple-ink); }

/* ---------------------------------------------------------- ledger (signature KPI strip) */
.ledger {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  background: var(--deck); border: 1px solid var(--line-soft); border-radius: var(--r-panel); overflow: hidden; margin-bottom: 1.25rem;
}
.ledger .cell { padding: 1rem 1.15rem 1.05rem; border-inline-end: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); margin-bottom: -1px; margin-inline-end: -1px; }
.ledger .lbl { display: block; font-size: 0.8rem; color: var(--muted); }
.ledger .val { display: block; font-size: 1.45rem; font-weight: 500; margin-top: 0.15rem; letter-spacing: -0.01em; white-space: nowrap; }
.ledger .note { display: block; font-size: 0.76rem; color: var(--faint); margin-top: 0.1rem; }
.ledger .cell.big { grid-column: span 2; background: linear-gradient(180deg, var(--gold-wash), transparent 85%); }
.ledger.tall { grid-template-columns: minmax(200px, 1.4fr) repeat(4, minmax(0, 1fr)); }
.ledger.tall .cell.big { grid-column: auto; grid-row: span 2; display: flex; flex-direction: column; justify-content: center; }
.ledger .cell.big .val { font-size: 2.7rem; font-weight: 300; line-height: 1.1; margin-top: 0.35rem; color: var(--gold); }
.ledger .cell.gold .val { color: var(--gold); }
.ledger .cell.bad .val { color: var(--bad); }
.ledger .cell.good .val { color: var(--good); }

/* ---------------------------------------------------------- panels */
.panel { background: var(--deck); border: 1px solid var(--line-soft); border-radius: var(--r-panel); padding: 1.15rem 1.25rem; margin-bottom: 1.25rem; }
.panel.flush { padding: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.panel.flush .panel-head { padding: 1.05rem 1.25rem 0.2rem; }
.panel-head h3 { display: flex; align-items: center; gap: 0.5rem; }
.panel-head h3 .ico { color: var(--muted); }
.panel-head .sub { color: var(--muted); font-size: 0.84rem; }
.panel.alert-edge { border-color: rgba(242, 112, 122, 0.35); }
.panel.alert-edge .panel-head h3 .ico { color: var(--bad); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 1.25rem; margin-bottom: 1.25rem; }
.grid-2.even { grid-template-columns: 1fr 1fr; }
.grid-2 > .panel { margin-bottom: 0; }
details.panel > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 0.5rem; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary .chev { transition: transform 0.2s; color: var(--muted); }
details.panel[open] > summary .chev { transform: rotate(90deg); }
[dir="rtl"] details.panel > summary .chev { transform: scaleX(-1); }
[dir="rtl"] details.panel[open] > summary .chev { transform: scaleX(-1) rotate(90deg); }
details.panel[open] > summary { margin-bottom: 0.9rem; }

/* ---------------------------------------------------------- client cards (home) */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.client-card { display: block; background: var(--deck); border: 1px solid var(--line-soft); border-radius: var(--r-panel); padding: 1.05rem 1.15rem; color: var(--text); transition: border-color 0.15s; }
.client-card:hover { border-color: var(--line); text-decoration: none; }
.cc-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.cc-head img { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; }
.cc-head .grow { flex: 1; min-width: 0; }
.cc-head b { display: block; font-weight: 500; }
.cc-head small { display: flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--muted); }
.cc-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; padding-top: 0.85rem; border-top: 1px solid var(--line-soft); }
.cc-stats small { display: block; color: var(--faint); font-size: 0.74rem; }
.cc-stats b { font-weight: 500; font-size: 0.95rem; white-space: nowrap; }

/* ---------------------------------------------------------- chart + funnel */
.chart-wrap { position: relative; height: 290px; }
.funnel { display: flex; flex-direction: column; gap: 0.95rem; }
.f-row .f-top { display: flex; justify-content: space-between; font-size: 0.88rem; }
.f-row .f-top b { font-weight: 500; }
.f-bar { height: 6px; background: var(--raised); border-radius: 999px; overflow: hidden; margin: 0.35rem 0 0.2rem; }
.f-bar span { display: block; height: 100%; background: var(--purple); border-radius: 999px; }
.f-row:last-child .f-bar span { background: var(--gold); }
.f-row small { font-size: 0.76rem; color: var(--faint); }

/* ---------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: start; color: var(--faint); font-weight: 400; font-size: 0.8rem; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.table td { padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #ffffff04; }
.table .num { text-align: end; white-space: nowrap; }
.panel.flush .table th:first-child, .panel.flush .table td:first-child { padding-inline-start: 1.25rem; }
.panel.flush .table th:last-child, .panel.flush .table td:last-child { padding-inline-end: 1.25rem; }
.row-actions { display: flex; gap: 0.25rem; justify-content: flex-end; align-items: center; white-space: nowrap; }
.item-cell { display: flex; align-items: center; gap: 0.7rem; min-width: 220px; }
.item-cell .thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; flex: none; background: var(--raised); display: grid; place-items: center; color: var(--faint); }
.item-cell b { display: block; font-weight: 500; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-cell small { display: block; font-size: 0.78rem; color: var(--muted); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------- tags */
.tag { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.76rem; height: 22px; padding: 0 0.55rem; border-radius: 6px; background: var(--raised); color: var(--muted); white-space: nowrap; }
.tag.good { background: rgba(63, 208, 143, 0.12); color: var(--good); }
.tag.warn { background: rgba(231, 181, 81, 0.12); color: var(--warn); }
.tag.bad { background: rgba(242, 112, 122, 0.12); color: var(--bad); }
.tag.gold { background: var(--gold-wash); color: var(--gold); }
.tag.purple { background: var(--purple-wash); color: var(--purple-ink); }

/* ---------------------------------------------------------- creatives */
.creative-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.creative { background: var(--deck); border: 1px solid var(--line-soft); border-radius: var(--r-panel); overflow: hidden; display: flex; flex-direction: column; }
.creative.winner { border-color: rgba(201, 168, 76, 0.55); }
.creative .media { position: relative; aspect-ratio: 4 / 5; background: #0a0c20; display: grid; place-items: center; color: var(--faint); }
.creative .media img, .creative .media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.creative .media > a { display: block; width: 100%; height: 100%; }
.creative .media .ext-link { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.4rem; color: var(--purple-ink); }
.creative .corner { position: absolute; top: 10px; inset-inline-start: 10px; display: flex; gap: 0.3rem; }
.creative .corner .tag { background: rgba(14, 16, 40, 0.85); }
.creative .body { padding: 0.85rem 0.95rem 0.95rem; display: flex; flex-direction: column; gap: 0.55rem; flex: 1; }
.creative .title { font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.creative .meta { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.78rem; color: var(--muted); min-width: 0; }
.creative .meta > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.creative .stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.45rem 0.5rem; padding: 0.55rem 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.creative .stats small { display: block; font-size: 0.7rem; color: var(--faint); }
.creative .stats b { font-size: 0.86rem; font-weight: 500; white-space: nowrap; }
.creative .notes { font-size: 0.84rem; color: var(--muted); }
.creative .actions { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-top: auto; align-items: center; }

/* ---------------------------------------------------------- plan */
.plan-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; width: 100%; }
.plan-head .when { color: var(--muted); font-size: 0.84rem; display: flex; gap: 0.9rem; flex-wrap: wrap; margin-top: 0.15rem; }
.progress { display: flex; align-items: center; gap: 0.6rem; min-width: 180px; }
.progress .bar { flex: 1; height: 6px; background: var(--raised); border-radius: 999px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; background: var(--purple); }
.progress b { font-weight: 500; font-size: 0.86rem; white-space: nowrap; }
.plan-goal { border-inline-start: 2px solid var(--gold); padding: 0.2rem 0.9rem; margin: 0.2rem 0 1rem; }
.plan-goal small { color: var(--gold); font-size: 0.78rem; }
.items { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 0; border-bottom: 1px solid var(--line-soft); }
.item:last-child { border-bottom: 0; }
.item .txt { flex: 1; min-width: 0; }
.item .txt b { display: block; font-weight: 500; }
.item .txt small { display: block; color: var(--muted); font-size: 0.82rem; }
.item.done .txt b { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.status-btn { font: inherit; display: inline-flex; align-items: center; gap: 0.35rem; height: 26px; padding: 0 0.6rem; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 0.78rem; cursor: pointer; white-space: nowrap; min-width: 96px; justify-content: center; }
.status-btn:disabled { cursor: default; }
.status-btn.doing { color: var(--warn); border-color: rgba(231, 181, 81, 0.4); }
.status-btn.done { color: var(--good); border-color: rgba(63, 208, 143, 0.4); }
.status-btn.blocked { color: var(--bad); border-color: rgba(242, 112, 122, 0.4); }
.plan-foot { display: flex; gap: 0.4rem; flex-wrap: wrap; padding-top: 0.9rem; margin-top: 0.4rem; border-top: 1px solid var(--line-soft); }

/* ---------------------------------------------------------- lists */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.6rem 1.4rem; margin: 0; }
.dl dt { color: var(--muted); font-size: 0.86rem; }
.dl dd { margin: 0; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line-soft); }
.rows li:last-child { border-bottom: 0; }
.rows .grow { flex: 1; min-width: 0; }
.rows .grow b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .grow small { display: block; color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .end { text-align: end; white-space: nowrap; }
.rows .end b { display: block; font-weight: 500; }
.rows .end small { display: block; color: var(--muted); font-size: 0.78rem; }
.rank { width: 22px; text-align: center; color: var(--gold); font-weight: 600; font-size: 0.86rem; flex: none; }
.pill-qty { display: inline-flex; align-items: center; height: 26px; padding: 0 0.6rem; border-radius: 6px; background: var(--purple-wash); color: var(--purple-ink); font-weight: 500; white-space: nowrap; }
.sizes { display: flex; flex-wrap: wrap; gap: 0.25rem; max-width: 380px; }
.size { font-size: 0.74rem; padding: 0.05rem 0.45rem; border-radius: 5px; background: var(--raised); color: var(--muted); white-space: nowrap; }
.size b { color: var(--text); font-weight: 500; }
.size.out, .size.now { background: rgba(242, 112, 122, 0.14); color: #ffb3ba; }
.size.soon { background: rgba(231, 181, 81, 0.14); color: #f4d48f; }
.size.dead { opacity: 0.5; }
.inv-thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; flex: none; background: var(--raised); }
.inv-search { width: min(260px, 100%); min-height: 34px; padding: 0.3rem 0.75rem; }

/* ---------------------------------------------------------- comments */
.comments { max-height: 52vh; overflow-y: auto; display: flex; flex-direction: column; gap: 0.7rem; }
.comment { max-width: 86%; padding: 0.6rem 0.85rem; border-radius: 12px; background: var(--raised); align-self: flex-end; }
.comment.mine { background: var(--purple-wash); align-self: flex-start; }
.comment .c-head { display: flex; gap: 0.7rem; justify-content: space-between; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.15rem; }
.comment .c-head b { color: var(--text); font-weight: 500; }
.comment-form { align-items: flex-end; }
.comment-form textarea { flex: 1; min-height: 44px; }
.cred { background: var(--night); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 0.9rem; white-space: pre-wrap; font-family: var(--font); font-size: 0.9rem; user-select: all; margin-top: 0.8rem; }

/* ---------------------------------------------------------- modal / toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(6, 7, 20, 0.72); display: grid; place-items: center; padding: 1rem; z-index: 50; animation: fade 0.15s; }
.modal { width: min(520px, 100%); max-height: 90vh; display: flex; flex-direction: column; background: var(--deck); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45); }
.modal.small { width: min(400px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1.1rem 1.25rem 0.4rem; }
.modal-body { padding: 0.9rem 1.25rem; overflow-y: auto; }
.modal-foot { display: flex; gap: 0.5rem; justify-content: flex-end; align-items: center; padding: 0.85rem 1.25rem 1.1rem; border-top: 1px solid var(--line-soft); }
.confirm-text { font-size: 1rem; }
@keyframes fade { from { opacity: 0; } }
.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translate(-50%, 16px); opacity: 0; z-index: 100;
  display: flex; align-items: center; gap: 0.55rem; max-width: calc(100vw - 2rem);
  background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem 1rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4); transition: 0.22s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok .ico { color: var(--good); }
.toast-err { border-color: rgba(242, 112, 122, 0.5); }
.toast-err .ico { color: var(--bad); }

/* ---------------------------------------------------------- empty / loading */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.7rem; padding: 3rem 1rem; color: var(--muted); }
.empty .ico { color: var(--faint); }
.empty p { max-width: 46ch; }
.loading { display: flex; gap: 6px; justify-content: center; padding: 3.5rem; }
.loading span { width: 7px; height: 7px; border-radius: 50%; background: var(--purple-hi); animation: pulse 1s infinite ease-in-out; }
.loading span:nth-child(2) { animation-delay: 0.15s; }
.loading span:nth-child(3) { animation-delay: 0.3s; background: var(--gold); }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.7); } 40% { opacity: 1; transform: scale(1); } }
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }

/* ---------------------------------------------------------- connect (Shopify) */
.connect-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.connect-opt { border: 1px solid var(--line-soft); border-radius: 12px; padding: 1rem 1.1rem; }
.connect-opt h4 { font-size: 0.95rem; margin-bottom: 0.6rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.connect-form { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.9rem; }
.steps { margin: 0.3rem 0; padding-inline-start: 1.2rem; display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.88rem; color: var(--muted); }
.steps b { color: var(--text); font-weight: 500; }
code { font-family: var(--font); background: var(--night); border: 1px solid var(--line); border-radius: 5px; padding: 0.05rem 0.35rem; font-size: 0.82rem; word-break: break-all; color: var(--text); }
code.copy { cursor: pointer; }
code.copy:hover { border-color: var(--purple-hi); }

/* ---------------------------------------------------------- brand home (space) */
[dir="rtl"] .flip, [dir="rtl"] .flip-r { transform: scaleX(-1); }
.cosmos {
  position: relative; overflow: hidden; min-height: 440px; margin: -0.4rem 0 1.4rem;
  border-radius: 20px; border: 1px solid var(--line-soft);
  background: radial-gradient(120% 90% at 50% 0%, #1a1745 0%, #0d0f27 55%, #080a1d 100%);
  display: flex; align-items: center;
}
.cosmos-sky { position: absolute; inset: 0; width: 100%; height: 100%; }
.cosmos-copy { position: relative; z-index: 1; padding: 2.6rem clamp(1.4rem, 4vw, 3.2rem); max-width: 560px; }
.cosmos .hello { color: var(--purple-ink); font-size: 0.95rem; margin-bottom: 0.7rem; animation: rise 0.8s 0.1s both ease-out; }
.cosmos .headline { font-size: clamp(1.6rem, 3.1vw, 2.45rem); font-weight: 300; line-height: 1.3; letter-spacing: -0.01em; animation: rise 0.9s 0.25s both ease-out; }
.cosmos .headline span { font-weight: 600; }
.cosmos .headline b { font-weight: 500; color: var(--gold); white-space: nowrap; }
.cosmos .lede { color: var(--muted); margin-top: 0.9rem; max-width: 40ch; animation: rise 0.9s 0.4s both ease-out; }
.cosmos-stats { display: flex; gap: 2.2rem; flex-wrap: wrap; margin-top: 1.8rem; animation: rise 0.9s 0.45s both ease-out; }
.cosmos-stats > div { display: flex; flex-direction: column; gap: 0.1rem; }
.cosmos-stats span { font-size: 0.8rem; color: var(--muted); }
.cosmos-stats b { font-size: 1.5rem; font-weight: 500; white-space: nowrap; }
.orbit-key { display: flex; align-items: center; gap: 0.45rem; margin-top: 1.8rem; font-size: 0.8rem; color: var(--faint); animation: rise 0.9s 0.6s both ease-out; }
.delta { font-style: normal; font-size: 0.76rem; color: var(--muted); white-space: nowrap; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.astronaut {
  position: absolute; z-index: 1; width: 128px; bottom: 6%; inset-inline-end: 5%;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.45)); animation: drift 9s ease-in-out infinite;
}
[dir="rtl"] .astronaut { transform: scaleX(-1); animation-name: drift-rtl; }
@keyframes drift { 0%, 100% { transform: translate(0, 0) rotate(-8deg); } 50% { transform: translate(-10px, -16px) rotate(6deg); } }
@keyframes drift-rtl { 0%, 100% { transform: scaleX(-1) translate(0, 0) rotate(-8deg); } 50% { transform: scaleX(-1) translate(-10px, -16px) rotate(6deg); } }

.mission-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
.mission { display: flex; flex-direction: column; margin-bottom: 0; }
.mission .block-link { margin-top: auto; align-self: flex-start; }
.mission .block-link .ico { opacity: 0.6; }
.rows.compact li { padding: 0.5rem 0; gap: 0.6rem; }
.rows.compact li > b { font-weight: 500; white-space: nowrap; }
.rows.compact li small { color: var(--muted); font-size: 0.85rem; }
.rows.compact { margin-bottom: 1rem; }
.spark { width: 100%; height: 64px; display: block; margin: 0.2rem 0 0.6rem; overflow: visible; }
.spark-line { stroke-dasharray: 600; stroke-dashoffset: 600; animation: draw 1.6s 0.3s forwards ease-out; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.hero-creative { display: flex; gap: 0.85rem; align-items: center; color: var(--text); margin-bottom: 1rem; }
.hero-creative:hover { text-decoration: none; }
.hc-media { position: relative; width: 108px; aspect-ratio: 4 / 5; border-radius: 10px; overflow: hidden; background: #0a0c20; display: grid; place-items: center; color: var(--faint); flex: none; border: 1px solid rgba(201, 168, 76, 0.45); }
.hc-media img { width: 100%; height: 100%; object-fit: cover; }
.hc-media .tag { position: absolute; bottom: 6px; inset-inline-start: 6px; font-size: 0.66rem; height: 18px; padding: 0 0.35rem; background: rgba(14, 16, 40, 0.88); }
.hc-body b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 500; }
.hc-stats { display: flex; gap: 0.9rem; flex-wrap: wrap; margin-top: 0.4rem; font-size: 0.84rem; color: var(--muted); }
.ring-wrap { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.9rem; }
.ring-wrap > div { display: flex; flex-direction: column; }
.big-num { font-size: 1.25rem; font-weight: 500; }
.ring-fill { animation: ring 1.4s 0.3s both ease-out; }
@keyframes ring { from { stroke-dashoffset: var(--c); } }
.mini-title { font-size: 0.8rem; color: var(--faint); margin-bottom: 0.2rem; }
.dot-st { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.dot-st.doing { background: var(--warn); }
.dot-st.blocked { background: var(--bad); }

/* ---------------------------------------------------------- mobile */
@media (max-width: 1180px) {
  .ledger.tall { grid-template-columns: minmax(170px, 1.2fr) repeat(4, minmax(0, 1fr)); }
  .ledger .val { font-size: 1.25rem; }
}
@media (max-width: 1050px) {
  .grid-2, .grid-2.even { grid-template-columns: 1fr; }
  .mission-grid { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-art { min-height: 230px; border-inline-end: 0; border-bottom: 1px solid var(--line-soft); padding: 1.5rem; }
  .login-art .claim h2 { font-size: 1.5rem; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar {
    display: flex; align-items: center; gap: 0.6rem; position: sticky; top: 0; z-index: 30;
    padding: 0.6rem 1rem; background: rgba(14, 16, 40, 0.94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-soft);
  }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 280px; z-index: 40; transition: transform 0.25s; transform: translateX(-105%); }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  .menu-open .sidebar { transform: none !important; }
  .menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 35; }
  .page { padding-top: 1.25rem; }
  h1 { font-size: 1.4rem; }
  .ledger { grid-template-columns: repeat(2, 1fr); }
  .ledger .val { font-size: 1.2rem; }
  .ledger .cell.big .val { font-size: 2.1rem; }
  .cc-stats { grid-template-columns: repeat(2, 1fr); }
  .creative-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
  .ledger.tall { grid-template-columns: repeat(2, 1fr); }
  .ledger.tall .cell.big { grid-column: span 2; grid-row: auto; }
  .chart-wrap { height: 230px; }
  .connect-grid { grid-template-columns: 1fr; }
  .item { flex-wrap: wrap; }
  .cosmos { min-height: 560px; align-items: flex-end; }
  .cosmos-copy { padding: 1.5rem 1.25rem 1.6rem; }
  .cosmos-stats { gap: 1.4rem; }
  .astronaut { width: 84px; top: 4%; bottom: auto; inset-inline-end: 4%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
