:root {
  color-scheme: light;
  --bg: #f4f3ef; --surface: #ffffff; --surface-2: #faf9f7; --line: #e6e4de; --line-2: #d6d3cb;
  --text: #0b0b0b; --text-2: #52514e; --muted: #8a8983;
  --ink: #0b0b0c; --ink-text: #f2f0eb;
  --series-1: #2a78d6; --series-1-wash: rgba(42,120,214,.10); --series-prev: #b9b7b0;
  --series-2: #eb6834; --series-3: #1baf7a;
  --seq-0: #eef4fc; --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #5598e7; --seq-4: #256abf; --seq-5: #0d366b;
  --good: #1a7f45; --good-bg: #e6f4ec; --warn: #9a6500; --warn-bg: #fdf3dc; --bad: #c43a3a; --bad-bg: #fbe9e9; --info-bg: #eaf1fb;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px -12px rgba(0,0,0,.12);
  --side-w: 248px;
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a19; --surface-2: #1f1f1e; --line: #2c2c2a; --line-2: #3a3a37;
    --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8e86;
    --ink: #f2f0eb; --ink-text: #0b0b0c;
    --series-1: #3987e5; --series-1-wash: rgba(57,135,229,.14); --series-prev: #5b5a55;
    --series-2: #d95926; --series-3: #199e70;
    --seq-0: #1d2430; --seq-1: #104281; --seq-2: #1c5cab; --seq-3: #2a78d6; --seq-4: #5598e7; --seq-5: #9ec5f4;
    --good: #4cc27f; --good-bg: #16291e; --warn: #e2b04a; --warn-bg: #2d2412; --bad: #ef7171; --bad-bg: #321717; --info-bg: #17212f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 14.5px; line-height: 1.55; -webkit-font-smoothing: antialiased; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
svg { display: block; }
.num, .ltr { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-mark { width: 56px; color: var(--text); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ------------------------------------------------ login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: #0b0b0c center/cover; position: relative; color: #f2f0eb; display: flex; flex-direction: column; justify-content: flex-end; padding: 48px; overflow: hidden; }
.login-art::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, #000d 10%, #0003 60%, #0000); }
.login-art > * { position: relative; }
.login-art h1 { font-family: Oswald, sans-serif; font-weight: 500; font-size: 42px; letter-spacing: .06em; line-height: 1; }
.login-art p { opacity: .7; margin-top: 10px; max-width: 36ch; }
.login-form { display: grid; place-items: center; padding: 32px; }
.login-form form { width: min(380px, 100%); display: grid; gap: 16px; }
.login-form .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.login-form .brand svg { width: 40px; }
.login-form h2 { font-size: 24px; }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login-art { min-height: 220px; padding: 28px; } .login-art h1 { font-size: 30px; } }

/* ------------------------------------------------ layout */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side { background: #0b0b0c; color: #d9d7d0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px; gap: 6px; }
.side .brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; color: #f2f0eb; text-decoration: none; }
.side .brand svg { width: 34px; }
.side .brand b { font-family: Oswald, sans-serif; font-weight: 500; letter-spacing: .14em; font-size: 17px; display: block; }
.side .brand small { font-size: 11px; opacity: .55; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: #bdbbb3; border: 0; background: none; width: 100%; text-align: start; font-weight: 500; position: relative; }
.nav-item svg { width: 20px; height: 20px; flex: none; }
.nav-item:hover { background: #ffffff0f; color: #fff; }
.nav-item.on { background: #f2f0eb; color: #0b0b0c; }
.nav-item .badge { margin-inline-start: auto; background: #e34948; color: #fff; font-size: 11px; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; }
.side .spacer { flex: 1; }
.side .foot { display: grid; gap: 4px; border-top: 1px solid #ffffff14; padding-top: 12px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar .grow { flex: 1; }
.page { padding: 24px 28px 64px; display: grid; gap: 20px; max-width: 1480px; width: 100%; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: auto 0 0 0; height: auto; z-index: 50; flex-direction: row; padding: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); overflow-x: auto; gap: 2px; }
  .side .brand, .side .spacer, .side .foot { display: none; }
  .nav-item { flex-direction: column; gap: 2px; font-size: 11px; padding: 8px 10px; min-width: 64px; align-items: center; text-align: center; }
  .nav-item .badge { position: absolute; top: 2px; inset-inline-end: 6px; margin: 0; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .page { padding: 16px 14px 110px; }
}

/* ------------------------------------------------ primitives */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card-h h3 { font-size: 15px; font-weight: 700; }
.card-h .sub { color: var(--muted); font-size: 12.5px; }
.card-h .grow { flex: 1; }
.grid { display: grid; gap: 20px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1200px) { .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .g-2, .g-3 { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; }
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.btn-primary:hover { background: var(--ink); opacity: .88; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 36px; padding: 0; height: 36px; }
.btn:disabled { opacity: .45; pointer-events: none; }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.seg button.on { background: var(--ink); color: var(--ink-text); }

.live { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--good-bg); color: var(--good); font-weight: 600; font-size: 13px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: ping 1.8s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 50%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }

.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 12px; background: var(--warn-bg); color: var(--warn); font-weight: 500; }
.banner .grow { flex: 1; }
.banner.info { background: var(--info-bg); color: var(--series-1); }

/* ------------------------------------------------ KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1350px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 620px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { padding: 16px 16px 12px; display: grid; gap: 4px; }
.kpi .label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 700; line-height: 1.15; letter-spacing: -.01em; }
.kpi .delta { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.kpi .delta.up { color: var(--good); } .kpi .delta.down { color: var(--bad); } .kpi .delta.flat { color: var(--muted); }
.kpi .delta span { color: var(--muted); font-weight: 400; }
.kpi svg.spark { width: 100%; height: 30px; margin-top: 4px; }
.kpi.hero .value { font-size: 40px; }

/* ------------------------------------------------ charts */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-t { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.prev { stroke: var(--series-prev); stroke-width: 1.5; }
.chart .area { fill: var(--series-1-wash); }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--line-2); stroke-width: 1; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-inline-end: 6px; border-radius: 2px; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow); border-radius: 10px; padding: 8px 12px; font-size: 12.5px; white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity .12s; z-index: 5; }
.tip.on { opacity: 1; }
.tip b { font-weight: 700; }
.tip .row { display: flex; align-items: center; gap: 8px; }
.tip .sw { width: 10px; height: 10px; border-radius: 3px; }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; font-size: 13.5px; }
.bar-row .k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-row .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-row .track { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--seq-0); overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; transition: width .6s cubic-bezier(.2,.7,.2,1); }
[dir=rtl] .bar-row .fill { border-radius: 4px 0 0 4px; margin-inline-start: 0; }
.bar-row .k svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.empty { color: var(--muted); padding: 20px 0; text-align: center; font-size: 13px; }

.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut-wrap svg { width: 130px; height: 130px; flex: none; }
.donut-legend { display: grid; gap: 8px; font-size: 13.5px; flex: 1; }
.donut-legend div { display: flex; align-items: center; gap: 8px; }
.donut-legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.donut-legend .v { margin-inline-start: auto; font-weight: 600; }

.heat { display: grid; grid-template-columns: 56px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 10.5px; color: var(--muted); }
.heat .c { aspect-ratio: 1; border-radius: 3px; background: var(--seq-0); position: relative; }
.heat .c:hover { outline: 2px solid var(--text); outline-offset: 0; z-index: 2; }
.heat .h { text-align: center; direction: ltr; }
.heat .d { align-self: center; font-size: 11.5px; }
.heat-scale { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); margin-top: 10px; }
.heat-scale i { width: 16px; height: 10px; border-radius: 2px; display: inline-block; }

.insights { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.insight { display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.insight .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--info-bg); color: var(--series-1); }
.insight .ic svg { width: 18px; height: 18px; }
.insight.good .ic { background: var(--good-bg); color: var(--good); }
.insight.warn .ic { background: var(--warn-bg); color: var(--warn); }
.insight h4 { font-size: 14px; font-weight: 700; }
.insight p { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.insight button { margin-top: 8px; }

.feed { display: grid; gap: 2px; max-height: 360px; overflow: auto; }
.feed div { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.feed .t { color: var(--muted); font-size: 12px; }
.feed .tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.feed .tag.lead { background: var(--good-bg); color: var(--good); border-color: transparent; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: start; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); }
.tbl td.n { text-align: end; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ------------------------------------------------ forms */
.field { display: grid; gap: 6px; }
.field > label, .field > .lbl { font-weight: 600; font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.input, .field input[type=text], .field input[type=url], .field input[type=number], .field input[type=password], .field input[type=email], .field select, .field textarea {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.field textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 12%, transparent); }
.i18n { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 720px) { .i18n { grid-template-columns: 1fr; } }
.i18n .lang { position: relative; }
.i18n .lang::before { content: attr(data-l); position: absolute; top: 9px; inset-inline-end: 10px; font-size: 10.5px; font-weight: 700; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; pointer-events: none; z-index: 1; }
.i18n .lang[data-l="EN"]::before { inset-inline-end: auto; right: 10px; }
.i18n .lang input, .i18n .lang textarea { padding-inline-end: 44px; }
.i18n .lang[data-l="EN"] input, .i18n .lang[data-l="EN"] textarea { padding-right: 44px; padding-left: 12px; }
.form-grid { display: grid; gap: 18px; }
.form-grid.cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid.cols { grid-template-columns: 1fr; } }
.group-title { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .02em; padding-top: 6px; border-top: 1px dashed var(--line); margin-top: 6px; }

.switch { position: relative; width: 44px; height: 26px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 999px; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0003; transition: transform .2s; }
.switch input:checked + span { background: var(--good); }
[dir=rtl] .switch input:checked + span::after { transform: translateX(-18px); }
[dir=ltr] .switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.toggle-row { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 13.5px; }

.img-field { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.thumb { width: 120px; aspect-ratio: 4/3; border-radius: 10px; background: var(--surface-2) center/cover no-repeat; border: 1px solid var(--line); flex: none; display: grid; place-items: center; color: var(--muted); font-size: 12px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery { display: flex; gap: 10px; flex-wrap: wrap; }
.gallery .g { position: relative; }
.gallery .g .thumb { width: 110px; }
.gallery .g .ops { position: absolute; inset: auto 4px 4px 4px; display: flex; gap: 4px; justify-content: center; opacity: 0; transition: opacity .15s; }
.gallery .g:hover .ops, .gallery .g:focus-within .ops { opacity: 1; }
.gallery .g .ops button { width: 26px; height: 26px; border-radius: 7px; border: 0; background: #000b; color: #fff; display: grid; place-items: center; }
.gallery .g .ops svg { width: 14px; height: 14px; }
.icon-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-pick button { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); display: grid; place-items: center; }
.icon-pick button svg { width: 20px; height: 20px; }
.icon-pick button.on { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }

.list-field { display: grid; gap: 8px; }
.li { border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.li > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.li > summary::-webkit-details-marker { display: none; }
.li > summary .n { width: 24px; height: 24px; border-radius: 7px; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; font-size: 11px; color: var(--muted); flex: none; }
.li > summary .ttl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li > summary .ops { display: flex; gap: 2px; }
.li > .body { padding: 4px 14px 16px; display: grid; gap: 14px; border-top: 1px solid var(--line); padding-top: 14px; }

/* ------------------------------------------------ sections manager */
.sec-list { display: grid; gap: 10px; }
.sec { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); transition: opacity .2s, transform .2s, box-shadow .2s; }
.sec.off { opacity: .55; }
.sec.drag { opacity: .4; }
.sec.over { box-shadow: 0 0 0 2px var(--series-1); }
.sec .handle { cursor: grab; color: var(--muted); display: grid; place-items: center; width: 24px; }
.sec .ic { width: 42px; height: 42px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; }
.sec .ic svg { width: 20px; height: 20px; }
.sec h4 { font-size: 15px; }
.sec .meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; }
.sec .reach { display: inline-flex; align-items: center; gap: 6px; }
.sec .reach i { display: inline-block; width: 60px; height: 6px; background: var(--seq-0); border-radius: 3px; overflow: hidden; }
.sec .reach i b { display: block; height: 100%; background: var(--series-1); }
.sec .acts { display: flex; gap: 6px; align-items: center; }
@media (max-width: 720px) { .sec { grid-template-columns: auto 1fr; } .sec .ic { display: none; } .sec .acts { grid-column: 1 / -1; justify-content: flex-end; } }

/* ------------------------------------------------ editor drawer */
.drawer-bg { position: fixed; inset: 0; background: #0006; z-index: 60; opacity: 0; animation: fade .2s forwards; }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(760px, 100%); background: var(--bg); z-index: 61; display: flex; flex-direction: column; box-shadow: -20px 0 60px -20px #0005; animation: slide .28s cubic-bezier(.2,.7,.2,1); }
[dir=rtl] .drawer { animation-name: slide-rtl; }
@keyframes fade { to { opacity: 1; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes slide-rtl { from { transform: translateX(-40px); opacity: 0; } }
.drawer-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.drawer-h h3 { font-size: 17px; flex: 1; }
.drawer-b { flex: 1; overflow: auto; padding: 20px; display: grid; gap: 18px; align-content: start; }
.drawer-f { display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.drawer-f .grow { flex: 1; }

/* ------------------------------------------------ projects */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.proj { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform .2s, box-shadow .2s; }
.proj:hover { transform: translateY(-2px); }
.proj.drag { opacity: .4; } .proj.over { box-shadow: 0 0 0 2px var(--series-1); }
.proj .cv { aspect-ratio: 16/10; background: var(--surface-2) center/cover; position: relative; cursor: pointer; }
.proj .cv .flags { position: absolute; top: 8px; inset-inline-start: 8px; display: flex; gap: 6px; }
.chip { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text-2); }
.chip.dark { background: #000a; color: #fff; border-color: transparent; backdrop-filter: blur(6px); }
.chip.star { background: #f5c451; color: #3d2c00; border-color: transparent; }
.proj .bd { padding: 12px 14px; display: grid; gap: 2px; flex: 1; }
.proj h4 { font-size: 15px; }
.proj .ft { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
.proj .ft .grow { flex: 1; }
.proj.off .cv { filter: grayscale(1); opacity: .6; }

/* ------------------------------------------------ media */
.drop { border: 2px dashed var(--line-2); border-radius: 14px; padding: 28px; text-align: center; color: var(--text-2); transition: border-color .2s, background .2s; cursor: pointer; }
.drop.on { border-color: var(--series-1); background: var(--info-bg); }
.drop svg { width: 32px; height: 32px; margin: 0 auto 8px; color: var(--muted); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-item { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.media-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.media-item .cap { font-size: 11px; color: var(--muted); padding: 6px 8px; direction: ltr; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item button.pick { position: absolute; inset: 0; border: 0; background: transparent; }
.media-item.sel { outline: 3px solid var(--series-1); }
.media-item .del { position: absolute; top: 6px; inset-inline-end: 6px; width: 28px; height: 28px; border-radius: 8px; border: 0; background: #000b; color: #fff; display: grid; place-items: center; opacity: 0; transition: opacity .15s; }
.media-item:hover .del { opacity: 1; }
.media-item .del svg { width: 14px; height: 14px; }
.progress { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--series-1); width: 0; transition: width .2s; }

/* ------------------------------------------------ messages */
.msgs { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .msgs { grid-template-columns: 1fr; } }
.msg-list { display: grid; gap: 6px; }
.msg-item { text-align: start; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px; display: grid; gap: 2px; }
.msg-item.unread { border-inline-start: 3px solid var(--series-1); }
.msg-item.unread b { font-weight: 700; }
.msg-item.on { border-color: var(--ink); }
.msg-item .row { display: flex; gap: 8px; align-items: center; }
.msg-item .row .t { margin-inline-start: auto; font-size: 12px; color: var(--muted); }
.msg-item p { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-detail dl { display: grid; grid-template-columns: 120px 1fr; gap: 10px; margin: 16px 0; }
.msg-detail dt { color: var(--muted); font-size: 13px; }
.msg-detail dd { margin: 0; font-weight: 500; }
.msg-detail .body { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; line-height: 1.8; }
.msg-detail .acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* ------------------------------------------------ themes */
.themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 1100px) { .themes { grid-template-columns: 1fr; } }
.theme { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.theme.on { box-shadow: 0 0 0 3px var(--ink), var(--shadow); }
.theme .pv { position: relative; aspect-ratio: 16/11; overflow: hidden; background: var(--surface-2); }
.theme .pv iframe { position: absolute; top: 0; left: 0; width: 1440px; height: 990px; border: 0; transform-origin: 0 0; pointer-events: none; }
.theme .pv .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.theme .bd { padding: 16px 18px; display: grid; gap: 8px; }
.theme h3 { font-size: 18px; display: flex; align-items: center; gap: 10px; }
.theme h3 small { font-family: Oswald, sans-serif; font-weight: 500; letter-spacing: .12em; font-size: 12px; color: var(--muted); }
.theme .sw { display: flex; gap: 6px; }
.theme .sw i { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-2); }
.theme .ft { display: flex; gap: 8px; padding: 0 18px 18px; flex-wrap: wrap; }

/* ------------------------------------------------ modal + toasts */
.modal-bg { position: fixed; inset: 0; z-index: 80; background: #0007; display: grid; place-items: center; padding: 16px; animation: fade .2s forwards; opacity: 0; }
.modal { background: var(--bg); border-radius: 18px; width: min(980px, 100%); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 30px 80px -20px #000a; }
.modal.sm { width: min(460px, 100%); }
.modal .drawer-b { max-height: 70vh; }
#toasts { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; pointer-events: none; }
[dir=rtl] #toasts { transform: translateX(50%); }
.toast { background: var(--ink); color: var(--ink-text); padding: 10px 18px; border-radius: 12px; font-weight: 600; box-shadow: 0 10px 30px -10px #0008; animation: toast .3s cubic-bezier(.2,.7,.2,1); display: flex; gap: 8px; align-items: center; }
.toast.err { background: var(--bad); color: #fff; }
@keyframes toast { from { transform: translateY(12px); opacity: 0; } }
@media (max-width: 900px) { #toasts { bottom: 90px; } }

.savebar { position: sticky; bottom: 16px; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--ink-text); box-shadow: 0 16px 40px -12px #0008; animation: toast .3s; }
.savebar .grow { flex: 1; }
.savebar .btn { border-color: transparent; }
.savebar .btn-primary { background: var(--ink-text); color: var(--ink); }
@media (max-width: 900px) { .savebar { bottom: 84px; } }

.kbd-hint { font-size: 12px; color: var(--muted); }
.tabs-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; }

/* ------------------------------------------------ team links (embedded) */
.tl-page { max-width: none; }
.tl-wrap { padding: 0; overflow: hidden; }
.tl-kpis .banner { grid-column: 1 / -1; }
.tl-frame { display: block; width: 100%; height: calc(100vh - 230px); min-height: 640px; border: 0; background: var(--surface); }
@media (max-width: 900px) { .tl-frame { height: calc(100vh - 250px); min-height: 560px; } .tl-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
