/* سَكَن · لوحة إدارة المنصة — مطابقة لنظام التصميم (رمل، ورق، حبر، نخيل، طابوق، شمس، نحاس) */
:root {
  --sand: #F3ECE0;
  --paper: #FBF7F0;
  --ink: #1F2A24;
  --palm: #2F4A3F;
  --brick: #A3461F;
  --sun: #E9A15F;
  --copper: #C9A66B;
  --gray: #5E655C;
  --line: #E6DCCB;
  --line-soft: #EFE7DA;
  --muted: #8A8F86;
  --plum: #4B3F72;
  --ok-bg: #E3EDE6; --ok: #2F6B4F;
  --warn-bg: #F7E3CF; --warn: #A3461F;
  --bad-bg: #F6DCD6; --bad: #A12B1F;
  --info-bg: #E6E2F1; --info: #4B3F72;
  --radius: 18px;
  --font: 'Cairo', 'Readex Pro', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--sand); color: var(--ink); font-size: 14px; line-height: 1.6; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* ===== الهيكل ===== */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 264px; background: var(--ink); color: #E8E2D6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 24px 20px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand .logo { font-size: 26px; font-weight: 800; color: #fff; line-height: 1; }
.brand .logo-sub { font-size: 11px; color: #A9AFA5; }
.arch { width: 34px; height: 40px; border-radius: 17px 17px 4px 4px; background: var(--brick); flex-shrink: 0; display: grid; place-items: center; color: #fff; font-weight: 800; }
.arch.sm { width: 30px; height: 34px; border-radius: 15px 15px 4px 4px; font-size: 13px; }
.arch.palm { background: var(--palm); } .arch.copper { background: var(--copper); } .arch.sun { background: var(--sun); color: var(--ink); }
.arch.plum { background: var(--plum); } .arch.gray { background: var(--gray); } .arch.sand { background: #E4D8C4; color: var(--ink); }
.nav { padding: 18px 12px; flex: 1; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; color: #D9D3C7; margin-bottom: 4px; font-weight: 600; }
.nav a:hover { background: rgba(255,255,255,.05); }
.nav a.active { background: var(--palm); color: #fff; }
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.nav .badge { margin-inline-start: auto; background: var(--brick); color: #fff; border-radius: 999px; font-size: 11px; min-width: 22px; height: 20px; padding: 0 6px; display: grid; place-items: center; font-weight: 700; }
.nav .group { font-size: 11px; color: #858B82; padding: 16px 14px 6px; }
.me { display: flex; align-items: center; gap: 10px; padding: 18px 22px; border-top: 1px solid rgba(255,255,255,.07); }
.me .name { font-weight: 700; color: #fff; }
.me form { margin-inline-start: auto; }
.me button { background: none; border: 0; color: #A9AFA5; cursor: pointer; padding: 6px; }

.main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: flex-start; gap: 16px; padding: 22px 32px 18px; border-bottom: 1px solid var(--line); }
.topbar .titles { flex: 1; }
.topbar .sub { color: var(--gray); font-size: 13px; margin-top: 4px; }
.search { position: relative; width: 320px; }
.search input { width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 14px; padding: 10px 40px 10px 14px; }
.search svg { position: absolute; right: 14px; top: 12px; width: 16px; color: var(--muted); }
.icon-btn { width: 42px; height: 42px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper); display: grid; place-items: center; cursor: pointer; position: relative; }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 7px; height: 7px; background: var(--brick); border-radius: 50%; }
.content { padding: 24px 32px 40px; }

/* ===== المكوّنات ===== */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head .spacer { flex: 1; }
.flush .card-head { padding: 18px 20px 0; }
.grid { display: grid; gap: 18px; }
.g-5 { grid-template-columns: 1.25fr repeat(4, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: 1fr 1fr; }
.g-main-side { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.g-side-main-side { grid-template-columns: 300px minmax(0, 1fr) 280px; align-items: stretch; }
.mt { margin-top: 18px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row .spacer { flex: 1; }
.stack > * + * { margin-top: 10px; }

.stat .label { color: var(--gray); font-size: 13px; }
.stat .value { font-size: 30px; font-weight: 800; margin: 6px 0 4px; }
.stat .trend { font-size: 12px; }
.trend.up { color: var(--palm); } .trend.down { color: var(--bad); }
.card.dark .stat .label { color: #C9C3B6; }
.card.dark .trend.up { color: var(--sun); }
.stat-hero { position: relative; overflow: hidden; }
.stat-hero::before { content: ''; position: absolute; left: 22px; top: 22px; width: 64px; height: 80px; border-radius: 32px 32px 0 0; border: 2px solid rgba(255,255,255,.12); background: linear-gradient(transparent 55%, rgba(47,74,63,.9) 55%); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; padding: 9px 16px; font-weight: 700; border: 1px solid transparent; cursor: pointer; white-space: nowrap; background: var(--paper); }
.btn-primary { background: var(--brick); color: #fff; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-outline { border-color: var(--line); background: var(--paper); }
.btn-danger { border-color: #E8C3BA; color: var(--bad); background: var(--paper); }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 10px; }
.btn-link { background: none; border: 0; color: var(--brick); font-weight: 700; cursor: pointer; padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 12px; font-size: 12px; font-weight: 700; background: #EEE7DA; color: var(--gray); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.dark { background: var(--ink); color: #fff; }
.pill.sun { background: #F8E6D2; color: #9A5A1E; }
.tag-cash { background: var(--ok-bg); color: var(--ok); }
.tag-payments { background: #F8E3D0; color: #A3461F; }
.tag-installments { background: var(--info-bg); color: var(--info); }

.tabs { display: inline-flex; background: #ECE3D3; border-radius: 14px; padding: 4px; gap: 2px; }
.tabs a, .tabs button { padding: 7px 16px; border-radius: 11px; font-weight: 700; color: var(--gray); border: 0; background: none; cursor: pointer; }
.tabs .active { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 6px 12px; font-weight: 700; font-size: 13px; }
select.chip { appearance: none; padding-inline-end: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--gray) 50%), linear-gradient(135deg, var(--gray) 50%, transparent 50%); background-position: 14px 50%, 9px 50%; background-size: 5px 5px; background-repeat: no-repeat; }

table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: right; font-size: 12px; color: var(--gray); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--paper); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.selected td { background: #F1E9DB; }
.table tbody tr:hover td { background: #F7F1E6; }
.cell-strong { font-weight: 800; }
.cell-sub { font-size: 12px; color: var(--muted); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--gray); margin-bottom: 6px; font-weight: 600; }
.input, .field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px; }
.field textarea { min-height: 90px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(163,70,31,.25); border-color: var(--brick); }

.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #DCD2C1; border-radius: 999px; cursor: pointer; transition: .2s; }
.switch span::before { content: ''; position: absolute; width: 20px; height: 20px; right: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--palm); }
.switch input:checked + span::before { transform: translateX(-18px); }
.switch input:disabled + span { opacity: .55; cursor: not-allowed; }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .t { flex: 1; }
.toggle-row .t b { display: block; }
.toggle-row .t small { color: var(--muted); }

.list-item { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--line-soft); }
.list-item .body { flex: 1; min-width: 0; }
.list-item .title { font-weight: 800; }
.icon-tile { width: 36px; height: 36px; border-radius: 10px; background: #EFE7DA; display: grid; place-items: center; color: var(--gray); flex-shrink: 0; }
.icon-tile svg { width: 18px; height: 18px; }

.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.bad { background: var(--bad-bg); color: var(--bad); }

/* أعمدة المخطط */
.bars { display: flex; align-items: flex-end; gap: 18px; height: 170px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 6px; align-items: flex-end; height: 100%; }
.bars .bar { width: 26px; border-radius: 13px 13px 4px 4px; background: #DCCFB8; min-height: 6px; }
.bars .bar.b2 { background: #C9D3CB; }
.bars .bar.hl { background: var(--brick); } .bars .bar.hl2 { background: var(--palm); }
.bars .lbl { font-size: 12px; color: var(--gray); }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--gray); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.mix { display: flex; height: 12px; border-radius: 999px; overflow: hidden; }
.progress { height: 8px; border-radius: 999px; background: #ECE3D3; overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 999px; }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; align-items: start; }
.lane { background: #EBE1D0; border-radius: var(--radius); padding: 14px; }
.lane-head { display: flex; align-items: center; gap: 8px; font-weight: 800; margin-bottom: 12px; }
.lane-head .count { margin-inline-start: auto; background: var(--paper); border-radius: 999px; padding: 0 10px; font-size: 12px; }
.lane-head i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.kcard { background: var(--paper); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; border: 1px solid var(--line); }
.kcard .top { display: flex; align-items: center; gap: 8px; }
.kcard .name { font-weight: 800; flex: 1; }

/* المحادثات */
.chat-list { height: calc(100vh - 170px); display: flex; flex-direction: column; }
.chat-list .items { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--line-soft); cursor: pointer; }
.conv.active { background: #F1E9DB; }
.conv .body { flex: 1; min-width: 0; }
.conv .preview { color: var(--gray); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat { display: flex; flex-direction: column; height: calc(100vh - 170px); }
.chat .msgs { flex: 1; overflow-y: auto; padding: 18px; background: #F5EEE2; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 72%; padding: 10px 14px; border-radius: 16px; background: var(--paper); border: 1px solid var(--line); }
.bubble.mine { align-self: flex-start; background: var(--ink); color: #fff; border-color: var(--ink); }
.bubble.theirs { align-self: flex-end; }
.bubble.note { align-self: center; background: #E9E0CF; border: 0; font-size: 12px; color: var(--gray); max-width: 85%; }
.bubble time { display: block; font-size: 11px; opacity: .65; margin-top: 4px; }
.bubble.unit { border-style: dashed; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--paper); }
.composer input { flex: 1; }

/* صفحة الدخول */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth .art { background: var(--ink); color: #fff; display: flex; flex-direction: column; justify-content: flex-end; padding: 56px; position: relative; overflow: hidden; }
.auth .art::before { content: ''; position: absolute; top: 70px; right: 90px; width: 260px; height: 330px; border-radius: 130px 130px 0 0; background: #E9DCC6; }
.auth .art::after { content: ''; position: absolute; top: 140px; right: 140px; width: 70px; height: 70px; border-radius: 50%; background: var(--sun); }
.auth .art h1 { font-size: 40px; position: relative; }
.auth form { align-self: center; justify-self: center; width: 380px; }

.empty { text-align: center; color: var(--muted); padding: 32px; }
.pagination { display: flex; gap: 6px; padding: 14px 16px; align-items: center; }
.pagination a, .pagination span { min-width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--paper); font-weight: 700; padding: 0 8px; }
.pagination .active span { background: var(--ink); color: #fff; border-color: var(--ink); }
.pagination .disabled span { opacity: .4; }
.checkbox { width: 18px; height: 18px; accent-color: var(--palm); }
details.inline summary { list-style: none; cursor: pointer; }
details.inline summary::-webkit-details-marker { display: none; }
.modal-bg { position: fixed; inset: 0; background: rgba(31,42,36,.45); display: none; align-items: center; justify-content: center; z-index: 50; }
.modal-bg:target, .modal-bg.open { display: flex; }
.modal { background: var(--paper); border-radius: 22px; padding: 24px; width: 560px; max-height: 90vh; overflow-y: auto; }
.diff { font-size: 13px; }
.diff dt { color: var(--gray); font-weight: 700; margin-top: 8px; }
.diff dd { margin: 2px 0 0; }

@media (max-width: 1200px) {
  .g-5 { grid-template-columns: repeat(3, 1fr); }
  .g-main-side, .g-side-main-side { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr 1fr; }
}
.table td { white-space: nowrap; }
.table td.wrap-ok { white-space: normal; }
.table .row.wrap { flex-wrap: nowrap; }
.stat-hero::before { left: 18px; top: auto; bottom: -8px; width: 54px; height: 70px; }
