/* =========================================================
   Rival Studios — admin panel & client area
   ========================================================= */
:root {
  --blue: #0194ba; --blue-l: #3cc6ea; --green: #92c47b; --green-l: #b8e6a0;
  --red: #ff7d7d; --amber: #f5c26b;
  --ink: #070b15; --ink-2: #0d1322; --text: #e7eef6; --muted: #8e9cb0;
  --line: rgba(255, 255, 255, .09);
  --grad-btn: linear-gradient(120deg, #24b7da, #a5d88c);
  --radius: 18px; --ease: cubic-bezier(.2, .7, .2, 1);
  --font: 'Sora', system-ui, sans-serif;
  --sb-w: 250px;
}
*, *::before, *::after { box-sizing: border-box; }
body.panel { margin: 0; min-height: 100vh; background: var(--ink); color: var(--text); font-family: var(--font); font-size: 14.5px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
body.rtl { --font: 'Cairo', system-ui, sans-serif; font-size: 15px; }
a { color: var(--blue-l); text-decoration: none; }
a:hover { color: var(--green-l); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h3 { font-size: 1.02rem; font-weight: 600; margin-bottom: 14px; }
img { max-width: 100%; display: block; }
code { font-size: .85em; background: rgba(255, 255, 255, .06); padding: 2px 6px; border-radius: 6px; }
.ic { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.txt-red { color: var(--red) !important; }
.txt-green { color: var(--green-l) !important; }
button { font: inherit; color: inherit; cursor: pointer; }

.panel-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.panel-bg span { position: absolute; border-radius: 50%; filter: blur(110px); opacity: .22; }
.panel-bg span:first-child { width: 50vw; height: 50vw; background: var(--blue); top: -20vw; inset-inline-end: -10vw; }
.panel-bg span:last-child { width: 40vw; height: 40vw; background: #4f8a3a; bottom: -18vw; inset-inline-start: -8vw; }

.glass {
  background: linear-gradient(135deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .025));
  -webkit-backdrop-filter: blur(18px) saturate(140%); backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 20px 50px -30px rgba(0, 0, 0, .8);
}

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border-radius: 12px; border: 1px solid transparent; font-weight: 600; font-size: .9rem; transition: .3s var(--ease); white-space: nowrap; text-decoration: none; }
.btn-primary { background: var(--grad-btn); color: #04131b; box-shadow: 0 8px 24px -10px rgba(1, 148, 186, .7); }
.btn-primary:hover { color: #04131b; transform: translateY(-1px); box-shadow: 0 12px 30px -10px rgba(146, 196, 123, .6); }
.btn-ghost { background: rgba(255, 255, 255, .04); border-color: rgba(255, 255, 255, .14); color: var(--text); }
.btn-ghost:hover { border-color: var(--blue-l); color: #fff; background: rgba(60, 198, 234, .08); }
.btn-danger { background: rgba(255, 125, 125, .1); border-color: rgba(255, 125, 125, .3); color: var(--red); }
.btn-danger:hover { background: rgba(255, 125, 125, .2); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: .84rem; border-radius: 10px; }
.btn-block { width: 100%; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .03); color: var(--text); transition: .25s; }
.icon-btn:hover { border-color: var(--blue-l); color: var(--blue-l); }
.icon-btn.danger:hover { border-color: var(--red); color: var(--red); }
.icon-btn .ic { width: 16px; height: 16px; }
form { margin: 0; }

/* ---------- sidebar layout ---------- */
.sidebar { position: fixed; top: 14px; bottom: 14px; inset-inline-start: 14px; width: var(--sb-w); padding: 22px 14px; display: flex; flex-direction: column; z-index: 30; transition: transform .45s var(--ease); }
.sb-brand img { height: 30px; width: auto; margin: 0 8px; }
.sb-label { display: block; font-size: .7rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin: 12px 10px 18px; }
.sidebar nav { display: grid; gap: 3px; }
.sidebar nav a, .sb-foot a, .sb-foot button { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: #b6c3d2; font-weight: 500; border: 1px solid transparent; background: none; width: 100%; text-align: start; font-size: .92rem; transition: .25s; }
.sidebar nav a:hover, .sb-foot a:hover, .sb-foot button:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.sidebar nav a.active { background: linear-gradient(120deg, rgba(1, 148, 186, .25), rgba(146, 196, 123, .12)); border-color: rgba(60, 198, 234, .25); color: #fff; }
.sidebar nav a.active .ic { color: var(--green-l); }
.sidebar nav a span { flex: 1; }
.pill { font-style: normal; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--grad-btn); color: #04131b; }
.sb-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 3px; }

.main { margin-inline-start: calc(var(--sb-w) + 28px); padding: 14px 20px 40px 0; min-height: 100vh; }
[dir=rtl] .main { padding: 14px 0 40px 20px; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 14px 6px 20px; }
.topbar h1 { font-size: 1.45rem; font-weight: 700; flex: 1; letter-spacing: -.01em; }
.topbar-user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; }
.sb-toggle { display: none; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); place-items: center; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; background: linear-gradient(135deg, var(--blue), var(--green)); color: #04131b; font-weight: 700; flex: none; }
.avatar.sm { width: 32px; height: 32px; font-size: .85rem; }
.avatar.lg { width: 60px; height: 60px; font-size: 1.4rem; }
.content { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
/* grid children default to min-width:auto and can push past narrow screens */
.form-stack, .invoice-form, .form-grid { grid-template-columns: minmax(0, 1fr); }
.main { min-width: 0; }
.portal-main { grid-template-columns: minmax(0, 1fr); }
.link { display: inline-flex; align-items: center; min-height: 36px; }
.inv-qp { display: none; color: #7a8698; font-size: .85em; margin-top: 2px; }

/* ---------- alerts ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; font-size: .9rem; border: 1px solid; animation: slideIn .5s var(--ease); }
.alert-success { background: rgba(146, 196, 123, .1); border-color: rgba(146, 196, 123, .35); color: var(--green-l); }
.alert-error { background: rgba(255, 125, 125, .1); border-color: rgba(255, 125, 125, .35); color: #ffb3b3; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- cards / kpis ---------- */
.card { padding: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h3 { margin: 0; display: flex; align-items: center; gap: 8px; }
.link { font-size: .85rem; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; margin: 0; }
.all-clear { color: var(--green-l); display: flex; gap: 8px; align-items: center; justify-content: center; }
.welcome { padding: 24px 26px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: linear-gradient(120deg, rgba(1, 148, 186, .2), rgba(146, 196, 123, .08)); }
.welcome h2 { font-size: 1.35rem; margin-bottom: 4px; }
.welcome p { margin: 0; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpis.three { grid-template-columns: repeat(3, 1fr); }
.kpi { padding: 18px 20px; position: relative; display: flex; flex-direction: column; gap: 2px; animation: rise .6s var(--ease) both; }
.kpi:nth-child(2) { animation-delay: .06s; } .kpi:nth-child(3) { animation-delay: .12s; } .kpi:nth-child(4) { animation-delay: .18s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.kpi small { color: var(--muted); font-size: .8rem; }
.kpi strong { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; }
.kpi em { font-style: normal; font-size: .78rem; color: var(--muted); }
.kpi-ic { position: absolute; top: 16px; inset-inline-end: 16px; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, .06); color: #cfd8e3; }
.kpi-ic.blue { background: rgba(1, 148, 186, .2); color: var(--blue-l); }
.kpi-ic.green { background: rgba(146, 196, 123, .18); color: var(--green-l); }
.kpi-ic.red { background: rgba(255, 125, 125, .15); color: var(--red); }
.hero-kpi.owing { border-color: rgba(255, 125, 125, .3); }
.hero-kpi.clear { border-color: rgba(146, 196, 123, .3); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.note p { margin: 6px 0 0; color: #c9d4df; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: start; font-weight: 500; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rtl .table th { letter-spacing: 0; font-size: .85rem; }
.table td { padding: 12px; border-bottom: 1px solid rgba(255, 255, 255, .05); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .2s; }
.table tbody tr:hover { background: rgba(255, 255, 255, .025); }
.table td:first-child strong { white-space: nowrap; }
.table td small { display: block; color: var(--muted); font-size: .78rem; }
.table td a { color: var(--text); }
.table td a:hover { color: var(--blue-l); }
.actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.row-title { display: flex; align-items: center; gap: 12px; }
.mini-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(1, 148, 186, .18); color: var(--blue-l); }
.card { overflow-x: auto; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: .74rem; font-weight: 600; background: rgba(255, 255, 255, .08); color: #c9d4df; white-space: nowrap; }
.badge-paid { background: rgba(146, 196, 123, .16); color: var(--green-l); }
.badge-partial { background: rgba(60, 198, 234, .15); color: var(--blue-l); }
.badge-unpaid { background: rgba(245, 194, 107, .15); color: var(--amber); }
.badge-overdue { background: rgba(255, 125, 125, .16); color: var(--red); }
.badge-draft { background: rgba(255, 255, 255, .08); color: var(--muted); }
.badge-cancelled { background: rgba(255, 255, 255, .06); color: var(--muted); text-decoration: line-through; }

/* ---------- forms ---------- */
input, textarea, select { min-width: 0; width: 100%; padding: 11px 13px; border-radius: 11px; border: 1px solid var(--line); background: rgba(3, 6, 14, .45); color: var(--text); font: inherit; font-size: .92rem; outline: none; transition: border-color .25s, box-shadow .25s; }
input:focus, textarea:focus, select:focus { border-color: rgba(60, 198, 234, .6); box-shadow: 0 0 0 3px rgba(1, 148, 186, .15); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--blue); }
input[type=file] { padding: 9px; background: rgba(255, 255, 255, .03); }
input:disabled { opacity: .6; }
select option { background: #0d1322; }
textarea { resize: vertical; }
label { display: grid; gap: 6px; font-size: .85rem; color: #b8c5d3; }
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.form-stack { display: grid; gap: 14px; }
.form-grid { display: grid; gap: 0; padding: 6px 22px; }
.form-row { display: grid; grid-template-columns: 240px 1fr; gap: 24px; padding: 18px 0; border-bottom: 1px solid rgba(255, 255, 255, .05); align-items: start; }
.form-label strong { display: block; font-weight: 600; font-size: .92rem; }
.form-label small { display: block; color: var(--muted); font-size: .8rem; margin-top: 3px; }
.form-fields { display: grid; gap: 12px; }
.form-row.bi .form-fields { grid-template-columns: 1fr 1fr; }
.lang-field { position: relative; }
.lang-tag { font-size: .7rem; color: var(--green); font-weight: 600; letter-spacing: .05em; }
.form-actions { display: flex; gap: 10px; padding: 18px 0 8px; flex-wrap: wrap; align-items: center; }
.form-inline { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: end; }
.form-inline > label:not(.check) { min-width: 180px; }
.w-sm { width: 100px; }
.img-field { display: grid; gap: 10px; justify-items: start; }
.img-field img { max-height: 160px; border-radius: 12px; border: 1px solid var(--line); }
.pw-field { display: flex; gap: 8px; }
.search input { width: 260px; }
.typo-preview { position: relative; overflow: hidden; text-align: center; padding: 34px 20px 18px; border-radius: 16px; border: 1px solid var(--line);
  background: radial-gradient(ellipse at 50% 30%, rgba(1, 148, 186, .25), transparent 65%), radial-gradient(circle at 80% 90%, rgba(146, 196, 123, .15), transparent 50%), #050811; }
.tp-word { font-size: clamp(2.4rem, 5vw, 4.4rem); overflow-wrap: anywhere; line-height: .9; background: linear-gradient(100deg, #fff, #e6f7ff 30%, var(--blue-l) 50%, var(--green-l) 65%, #fff 85%); -webkit-background-clip: text; background-clip: text; color: transparent; padding: 0 .08em; }
.tp-line { margin-top: 14px; font-size: 1.3rem; color: #dfe8f2; }
.tp-ar { margin-top: 8px; }
.tp-info { display: block; margin-top: 18px; color: var(--muted); font-size: .76rem; }
.toggle-row span { color: var(--text); }
.slug-current { display: grid; gap: 2px; padding: 12px 14px; border-radius: 12px; background: rgba(1, 148, 186, .08); border: 1px solid rgba(60, 198, 234, .2); }
.slug-current a { font-weight: 600; word-break: break-all; }
.slug-input { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: rgba(3, 6, 14, .45); direction: ltr; }
.slug-input span { padding: 11px 4px 11px 13px; color: var(--muted); white-space: nowrap; font-size: .88rem; }
.slug-input input { border: 0; border-radius: 0; background: none; padding-inline-start: 0; min-width: 120px; }
.slug-input:focus-within { border-color: rgba(60, 198, 234, .6); box-shadow: 0 0 0 3px rgba(1, 148, 186, .15); }
.card h3 .ic { vertical-align: -3px; color: var(--green-l); }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.page-actions .spacer { flex: 1; }
.back-link { color: var(--muted); font-size: .88rem; justify-self: start; }
.back-link:hover { color: #fff; }

.tabs { display: flex; gap: 4px; padding: 5px; flex-wrap: wrap; border-radius: 14px; }
.tabs.inline { display: inline-flex; }
.tabs a { padding: 8px 16px; border-radius: 10px; color: var(--muted); font-size: .88rem; font-weight: 500; transition: .25s; }
.tabs a:hover { color: #fff; }
.tabs a.active { background: var(--grad-btn); color: #04131b; font-weight: 600; }

.switch { width: 42px; height: 24px; border-radius: 99px; border: 1px solid var(--line); background: rgba(255, 255, 255, .08); position: relative; padding: 0; transition: .3s; }
.switch span { position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #8d99aa; transition: .3s var(--ease); }
.switch.on { background: rgba(146, 196, 123, .35); border-color: rgba(146, 196, 123, .5); }
.switch.on span { inset-inline-start: 21px; background: var(--green-l); }

.icon-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-picker label { display: block; cursor: pointer; }
.icon-picker input { position: absolute; opacity: 0; }
.icon-picker span { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .03); transition: .25s; }
.icon-picker input:checked + span { background: linear-gradient(135deg, rgba(1, 148, 186, .45), rgba(146, 196, 123, .3)); border-color: var(--blue-l); color: #fff; }
.icon-picker .ic { width: 22px; height: 22px; }

.gallery-edit { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.gallery-edit label { width: 130px; }
.gallery-edit img { width: 130px; height: 90px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

/* ---------- portfolio admin ---------- */
.work-admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.work-admin { overflow: hidden; display: flex; flex-direction: column; padding: 0; transition: transform .35s var(--ease), border-color .3s; }
.work-admin:hover { transform: translateY(-3px); border-color: rgba(60, 198, 234, .3); }
.work-admin.off { opacity: .55; }
.wa-img { aspect-ratio: 16 / 10; background: radial-gradient(circle at 30% 20%, rgba(1, 148, 186, .4), transparent 60%), radial-gradient(circle at 80% 90%, rgba(146, 196, 123, .3), transparent 55%), #0b1424; position: relative; display: grid; place-items: center; color: var(--muted); }
.wa-img img { width: 100%; height: 100%; object-fit: cover; }
.wa-img span { display: flex; gap: 8px; align-items: center; font-size: .85rem; }
.wa-img .badge { position: absolute; top: 10px; inset-inline-start: 10px; }
.wa-body { padding: 14px 16px 6px; }
.wa-body strong { display: block; }
.wa-body small { color: var(--muted); }
.wa-actions { display: flex; gap: 6px; padding: 10px 16px 16px; justify-content: flex-end; align-items: center; }
.wa-actions form:first-child { margin-inline-end: auto; }

/* ---------- messages ---------- */
.msg-list { list-style: none; margin: 0; padding: 0; }
.msg-list a { display: flex; gap: 12px; align-items: center; padding: 12px 10px; border-radius: 12px; color: var(--text); transition: background .2s; }
.msg-list a:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.msg-body { flex: 1; min-width: 0; }
.msg-body strong { display: block; font-weight: 500; }
.msg-body em { font-style: normal; color: var(--green); font-weight: 400; font-size: .85rem; }
.msg-body small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-list time { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.msg-list li.unread strong { font-weight: 700; color: #fff; }
.msg-list li.unread a { background: rgba(1, 148, 186, .07); }
.msg-list li.unread .avatar { box-shadow: 0 0 0 3px rgba(60, 198, 234, .3); }
.message-view .mv-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.mv-head small { display: block; color: var(--muted); }
.mv-body { background: rgba(0, 0, 0, .2); border: 1px solid var(--line); border-radius: 14px; padding: 18px; white-space: normal; line-height: 1.7; }
.meta-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0 0 16px; font-size: .9rem; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; }

.client-head { display: flex; gap: 16px; align-items: center; padding: 20px 22px; flex-wrap: wrap; }
.ch-info { flex: 1; min-width: 200px; }
.ch-info h2 { font-size: 1.25rem; display: flex; gap: 10px; align-items: center; }
.ch-info p { margin: 4px 0; }

/* ---------- invoice form ---------- */
.invoice-form { display: grid; gap: 18px; }
.inv-form-top { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.inv-form-top .span-2 { grid-column: span 2; }
.items-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.items-table th { text-align: start; font-size: .76rem; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; padding: 0 6px; }
.items-table td { padding: 0 6px; vertical-align: top; }
.items-table textarea { min-height: 44px; }
.w-qty { width: 90px; } .w-price { width: 140px; } .w-amt { width: 130px; }
.items-table .amt { padding-top: 12px; font-weight: 600; text-align: end; white-space: nowrap; }
.inv-form-bottom { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.inv-form-bottom .grow { flex: 1; min-width: 260px; }
.totals-box { width: 320px; display: grid; gap: 10px; padding: 16px; border-radius: 14px; background: rgba(0, 0, 0, .2); border: 1px solid var(--line); }
.totals-box > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.totals-box input { width: 130px; text-align: end; }
.totals-box .grand { border-top: 1px solid var(--line); padding-top: 10px; font-size: 1.15rem; }
.totals-box .grand strong { flex: 1; text-align: end; }
.totals-box em { font-style: normal; color: var(--muted); font-size: .8rem; }

.invoice-layout { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.invoice-layout aside { display: grid; gap: 18px; position: sticky; top: 20px; }
.pay-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.pay-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .03); border: 1px solid rgba(255, 255, 255, .05); }
.pay-list small { display: block; color: var(--muted); font-size: .78rem; }

/* ---------- printable invoice ---------- */
.invoice-paper { background: #fff; color: #172030; border-radius: 16px; box-shadow: 0 30px 80px -40px rgba(0, 0, 0, .9); overflow: hidden; }
.invoice-doc { padding: 44px 48px; font-size: 14px; }
.invoice-doc[dir=rtl] { font-family: 'Cairo', sans-serif; }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 26px; border-bottom: 3px solid; border-image: linear-gradient(90deg, var(--blue), var(--green)) 1; }
.inv-logo { height: 76px; width: auto; }
.inv-title { text-align: end; display: grid; gap: 4px; justify-items: end; }
.inv-title h2 { font-size: 2rem; letter-spacing: .18em; text-transform: uppercase; color: var(--blue); font-weight: 700; }
.invoice-doc[dir=rtl] .inv-title h2 { letter-spacing: 0; }
.inv-title strong { font-size: 1.05rem; }
.invoice-doc .badge { background: #eef3f7; color: #445; }
.invoice-doc .badge-paid { background: #e6f4de; color: #3d7a26; }
.invoice-doc .badge-overdue { background: #fde6e6; color: #b42323; }
.invoice-doc .badge-partial { background: #e0f3f9; color: #016a86; }
.invoice-doc .badge-unpaid { background: #fdf1dc; color: #8a5a00; }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr auto; gap: 24px; padding: 26px 0; }
.inv-parties > div { display: grid; gap: 2px; align-content: start; }
.inv-parties small, .inv-notes small, .inv-payments small { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: #7a8698; font-weight: 600; margin-bottom: 4px; }
.inv-parties strong { font-size: 1.05rem; }
.inv-parties span { color: #4a5568; }
.inv-dates { gap: 12px !important; }
.inv-dates > div { display: grid; }
.inv-subject { font-size: 1.1rem; margin: 0 0 14px; }
.inv-items { width: 100%; border-collapse: collapse; }
.inv-items th { background: #f2f6f9; color: #5a6578; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; text-align: start; padding: 10px 12px; }
.inv-items td { padding: 12px; border-bottom: 1px solid #edf0f4; vertical-align: top; }
.inv-items th:nth-child(n+3), .inv-items td:nth-child(n+3) { text-align: end; white-space: nowrap; }
.inv-items th:first-child, .inv-items td:first-child { width: 36px; color: #98a2b3; }
.inv-bottom { display: flex; justify-content: space-between; gap: 30px; padding-top: 22px; flex-wrap: wrap; }
.inv-notes { flex: 1; min-width: 220px; display: grid; align-content: start; }
.inv-notes p { margin: 0 0 14px; color: #4a5568; }
.inv-totals { min-width: 300px; border-collapse: collapse; }
.inv-totals td { padding: 7px 0; }
.inv-totals td:last-child { text-align: end; font-weight: 600; white-space: nowrap; padding-inline-start: 30px; }
.inv-totals .grand td { border-top: 1px solid #e3e8ee; font-size: 1.05rem; padding-top: 12px; }
.inv-totals .due td { background: linear-gradient(90deg, rgba(1, 148, 186, .1), rgba(146, 196, 123, .12)); font-size: 1.15rem; font-weight: 700; color: #016a86; padding: 12px; }
.inv-payments { margin-top: 22px; display: grid; }
.inv-payments table { border-collapse: collapse; max-width: 480px; }
.inv-payments td { padding: 5px 16px 5px 0; color: #4a5568; }
.inv-foot { margin-top: 34px; padding-top: 16px; border-top: 1px solid #edf0f4; text-align: center; color: #7a8698; font-size: .85rem; }

/* ---------- updates ---------- */
.dropzone { position: relative; display: grid; place-items: center; gap: 6px; text-align: center; padding: 34px 20px; margin: 14px 0; border: 2px dashed rgba(60, 198, 234, .35); border-radius: 16px; background: rgba(1, 148, 186, .05); cursor: pointer; transition: .3s; }
.dropzone:hover, .dropzone.over { border-color: var(--green); background: rgba(146, 196, 123, .08); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dz-ic { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-btn); color: #04131b; }
.dz-ic .ic { width: 26px; height: 26px; }
.dz-sub { color: var(--muted); }
.steps-list { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 12px; }
.steps-list li { display: flex; gap: 12px; color: #c4d0dc; }
.steps-list span { width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; background: rgba(1, 148, 186, .25); color: var(--blue-l); }
.version-row { display: flex; align-items: center; justify-content: space-between; padding-top: 16px; border-top: 1px solid var(--line); }
.version-row strong { display: block; font-size: 1.3rem; }

/* ---------- auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px; }
.auth-card { width: min(420px, 100%); padding: 36px 32px; text-align: center; animation: rise .7s var(--ease) both; }
.auth-card .form-stack { text-align: start; margin-top: 22px; }
.auth-logo img { width: 130px; margin: 0 auto 18px; filter: drop-shadow(0 12px 30px rgba(1, 148, 186, .35)); }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 6px; }
.auth-card .alert { margin-top: 16px; text-align: start; }
.auth-links { display: flex; justify-content: space-between; margin-top: 20px; font-size: .85rem; }
.checks { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 6px; text-align: start; font-size: .85rem; }
.checks li { display: flex; gap: 8px; align-items: center; }
.checks .ok { color: var(--green-l); }
.checks .bad { color: var(--red); }

/* ---------- client portal ---------- */
.portal-top { position: sticky; top: 12px; z-index: 20; margin: 12px auto 0; width: min(1100px, calc(100% - 24px)); display: flex; align-items: center; gap: 18px; padding: 10px 14px 10px 20px; }
.portal-top nav { display: flex; gap: 4px; flex: 1; justify-content: center; }
.portal-top nav a { display: flex; gap: 8px; align-items: center; padding: 8px 14px; border-radius: 10px; color: #b6c3d2; font-weight: 500; }
.portal-top nav a:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.portal-top nav a.active { background: linear-gradient(120deg, rgba(1, 148, 186, .25), rgba(146, 196, 123, .12)); color: #fff; }
.pt-right { display: flex; gap: 8px; align-items: center; }
.lang-btn { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--text); font-weight: 700; font-family: 'Cairo', sans-serif; }
.portal-main { width: min(1100px, calc(100% - 24px)); margin: 24px auto 60px; display: grid; gap: 18px; }
.portal-h { font-size: 1.4rem; }
.help-links { display: flex; flex-wrap: wrap; gap: 8px; }
.pre { margin: 0; color: #c9d4df; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .invoice-layout { grid-template-columns: 1fr; }
  .invoice-layout aside { position: static; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(calc(-100% - 20px)); }
  [dir=rtl] .sidebar { transform: translateX(calc(100% + 20px)); }
  body.sb-open .sidebar { transform: none; background: rgba(10, 15, 28, .92); }
  .main { margin-inline-start: 0; padding: 10px 14px 40px !important; }
  .sb-toggle { display: grid; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; gap: 10px; }
  .form-row.bi .form-fields { grid-template-columns: 1fr; }
  .inv-form-top { grid-template-columns: 1fr 1fr; }
  .portal-top nav span { display: none; }
  .invoice-doc { padding: 28px 22px; }
  .inv-parties { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .kpis, .kpis.three { grid-template-columns: 1fr; }
  .topbar-user span:last-child { display: none; }
  .inv-form-top { grid-template-columns: 1fr; }
  .inv-form-top .span-2 { grid-column: auto; }
  .totals-box { width: 100%; }
  .search input { width: 100%; }
  .items-table thead { display: none; }
  .items-table tr { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; }
  .items-table td:first-child { grid-column: 1 / -1; }
  .items-table .amt { display: none; }
}

/* ---------- phones & tablets: tables become stacked cards, bigger tap targets ---------- */
.switch { position: relative; }
.switch::after { content: ''; position: absolute; inset: -8px; } /* larger invisible hit area */
@media (max-width: 900px), (pointer: coarse) {
  .card { padding: 16px; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 14px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .025); }
  .table tbody tr:hover { background: rgba(255, 255, 255, .025); }
  .table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border: 0; text-align: end; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; text-align: start; flex: none; }
  /* first cell is the row title: full width, no label */
  .table td:first-child { display: block; text-align: start; padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid rgba(255, 255, 255, .06); font-size: 1rem; }
  .table td:first-child::before { display: none; }
  .table td.actions { justify-content: flex-end; padding-top: 10px; }
  .table td.actions::before, .table td:empty { display: none; }
  .table td small { display: inline; }
  .table td:first-child small { display: block; }
  .page-actions { align-items: stretch; }
  .page-actions .tabs.inline { display: flex; flex-wrap: wrap; max-width: 100%; }
  .tabs a { white-space: nowrap; flex: 1 0 auto; text-align: center; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .inv-form-top { grid-template-columns: minmax(0, 1fr); }
  .back-link { display: inline-flex; align-items: center; min-height: 40px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  label.check { min-height: 40px; }
  .icon-btn { width: 42px; height: 42px; }
  .switch { width: 52px; height: 30px; }
  .switch span { width: 22px; height: 22px; }
  .switch.on span { inset-inline-start: 26px; }
  .slug-input { flex-wrap: wrap; }
  .slug-input span { width: 100%; padding: 10px 13px 0; white-space: normal; word-break: break-all; font-size: .8rem; }
  .slug-input input { padding-inline-start: 13px; }
  .slug-current a { display: block; padding: 8px 0; }
  .portal-top { padding: 8px 10px; gap: 6px; }
  .portal-top .sb-brand { display: inline-flex; align-items: center; min-height: 42px; }
  .portal-top .sb-brand img { height: 24px; margin: 0; }
  .portal-top nav a { min-width: 42px; min-height: 42px; justify-content: center; padding: 8px 10px; }
  .portal-top .lang-btn, .portal-top .icon-btn { width: 42px; height: 42px; }
  /* invoice lines: qty × price move under the description instead of their own columns */
  .inv-items th:nth-child(3), .inv-items td:nth-child(3), .inv-items th:nth-child(4), .inv-items td:nth-child(4) { display: none; }
  .inv-qp { display: block; }
  .invoice-doc { padding: 22px 16px; font-size: 13px; }
  .inv-head { flex-direction: column; align-items: flex-start; }
  .inv-title { text-align: start; justify-items: start; }
  .inv-logo { height: 60px; }
  .inv-items th:first-child, .inv-items td:first-child { display: none; }
  .inv-items th, .inv-items td { padding: 8px 6px; }
  .inv-totals { min-width: 0; width: 100%; }
  .welcome { padding: 18px; }
  .client-head .quick { width: 100%; }
}

/* ---------- print: only the invoice ---------- */
@media print {
  @page { margin: 12mm; }
  body.panel { background: #fff !important; color: #000; }
  .panel-bg, .sidebar, .topbar, .no-print, .alert, .portal-top, aside { display: none !important; }
  .main, .portal-main { margin: 0 !important; padding: 0 !important; width: auto !important; }
  .invoice-layout { display: block; }
  .invoice-paper { box-shadow: none; border-radius: 0; }
  .invoice-doc { padding: 0; }
  .inv-totals .due td, .inv-items th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
