/* Top Laser Invoicing — RTL-first stylesheet using logical properties (works for ar/rtl and en/ltr).
 * Plain CSS, no build step: deploys as-is to shared hosting. */
@font-face { font-family: "Noto Sans Arabic"; src: url("../fonts/noto-sans-arabic-arabic-400.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-089F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Noto Sans Arabic"; src: url("../fonts/noto-sans-arabic-arabic-700.woff2") format("woff2"); font-weight: 600 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-089F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Noto Sans"; src: url("../fonts/noto-sans-latin-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Noto Sans"; src: url("../fonts/noto-sans-latin-700.woff2") format("woff2"); font-weight: 600 700; font-display: swap; }

:root {
    /* Brand: Top Laser navy + laser yellow */
    --navy-950: #0b1628;
    --navy-900: #0f1f38;
    --navy-800: #16294a;
    --navy-700: #1f3a5f;
    --navy-600: #2a4c7a;
    --navy-500: #3b6299;
    --gold: #f2b705;
    --gold-soft: #fff6d6;

    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef2f7;
    --border: #e3e8ef;
    --border-strong: #cfd7e2;
    --text: #0f1b2d;
    --text-2: #334155;
    --muted: #64748b;
    --primary: var(--navy-700);
    --primary-600: var(--navy-600);
    --primary-50: #edf3fb;
    --primary-100: #dbe6f4;
    --success: #12805c;
    --success-50: #e7f6ef;
    --warning: #a15c07;
    --warning-50: #fef5e3;
    --danger: #c0262d;
    --danger-50: #fdeced;
    --info: #1f62b3;
    --info-50: #e8f1fc;
    --violet: #6d4fc2;
    --violet-50: #f1edfc;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-xs: 0 1px 2px rgba(15, 27, 45, .05);
    --shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 4px 14px -6px rgba(15, 27, 45, .10);
    --shadow-lg: 0 12px 40px -12px rgba(15, 27, 45, .25);
    --ring: 0 0 0 4px rgba(59, 98, 153, .16);
    --sidebar-w: 264px;
    --topbar-h: 64px;
    --font: "Noto Sans Arabic", "Noto Sans", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
    --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--primary-600); text-decoration: none; }
a:hover { color: var(--navy-500); }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5rem; color: var(--text); letter-spacing: -.005em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.06rem; font-weight: 700; }
h3 { font-size: .98rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.ltr, [dir="ltr"] { unicode-bidi: isolate; }
.num { direction: ltr; unicode-bidi: isolate; text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sr-only:focus { position: fixed; inset-block-start: .5rem; inset-inline-start: .5rem; width: auto; height: auto; clip: auto; z-index: 100; background: #fff; padding: .5rem .9rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
:focus-visible { outline: 2px solid var(--navy-500); outline-offset: 2px; }
::selection { background: var(--primary-100); }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
    background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%);
    color: #c9d5e6; padding: 1.1rem .8rem 1rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent;
}
.brand { display: flex; align-items: center; gap: .7rem; padding: .3rem .45rem 1.1rem; margin-bottom: .35rem; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand img { height: 42px; width: auto; max-width: 92px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px 6px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.brand .brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand span, .brand .brand-title { font-weight: 700; font-size: .92rem; color: #fff; line-height: 1.35; }
.brand .brand-tag { font-size: .72rem; color: #8ea3c0; font-weight: 400; }
.nav { flex: 1; }
.nav-group { margin: 1.05rem 0 .3rem; padding-inline-start: .75rem; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #6f86a6; }
.nav a { position: relative; display: flex; align-items: center; gap: .65rem; padding: .52rem .75rem; margin: 1px 0; border-radius: 10px; color: #c9d5e6; font-size: .92rem; transition: background .15s var(--ease), color .15s var(--ease); }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(242,183,5,.16), rgba(242,183,5,.04)); color: #fff; font-weight: 700; }
[dir="rtl"] .nav a.active { background: linear-gradient(270deg, rgba(242,183,5,.16), rgba(242,183,5,.04)); }
.nav a.active::before { content: ""; position: absolute; inset-inline-start: -.8rem; inset-block: .45rem; width: 4px; border-radius: 0 4px 4px 0; background: var(--gold); }
[dir="rtl"] .nav a.active::before { border-radius: 4px 0 0 4px; }
.nav a.active svg { color: var(--gold); opacity: 1; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.sidebar-foot { margin-top: 1rem; padding: .75rem .55rem 0; border-top: 1px solid rgba(255,255,255,.07); font-size: .72rem; color: #6f86a6; display: flex; align-items: center; gap: .45rem; }
.sidebar-foot .dot { margin-top: 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: .75rem; padding: 0 1.6rem; min-height: var(--topbar-h);
    background: rgba(255,255,255,.86); -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-weight: 700; font-size: 1.1rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.topbar .user-chip { display: inline-flex; align-items: center; gap: .55rem; padding: .25rem .35rem; padding-inline-end: .75rem; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--text-2); font-size: .88rem; }
.topbar .user-chip:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; background: linear-gradient(135deg, var(--navy-600), var(--navy-800)); color: #fff; font-size: .8rem; font-weight: 700; flex: none; }
.content { padding: 1.6rem; max-width: 1440px; width: 100%; margin-inline: auto; }
.menu-toggle { display: none; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: .45rem .55rem; cursor: pointer; color: var(--text-2); }
.menu-toggle svg { width: 20px; height: 20px; display: block; }
.overlay { display: none; }
.page-footer-app { padding: 0 1.6rem 1.4rem; color: var(--muted); font-size: .78rem; }

@media (max-width: 1024px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(84vw, 300px); z-index: 50; transform: translateX(100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); }
    [dir="ltr"] .sidebar { transform: translateX(-100%); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .overlay { display: block; position: fixed; inset: 0; background: rgba(11,22,40,.45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); z-index: 40; }
    .menu-toggle { display: inline-flex; }
    .content { padding: 1rem; }
    .topbar { padding: 0 1rem; gap: .5rem; }
    .page-footer-app { padding: 0 1rem 1rem; }
}
@media (max-width: 640px) {
    .hide-sm { display: none !important; }
    .topbar .title { font-size: 1rem; }
    .topbar .user-chip { padding-inline-end: .35rem; }
}

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-header h2, .card-header h3 { margin: 0; }
.card-body { padding: 1.25rem; }
.card-body.flush { padding: 0; }
.card > .table-wrap:last-child, .card > .card-body.flush:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); overflow: hidden; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: .2rem 0 0; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .55rem 1.05rem; min-height: 2.45rem;
    border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
    font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; line-height: 1.3; white-space: nowrap;
    box-shadow: var(--shadow-xs); transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:hover { background: var(--surface-2); border-color: #b9c4d3; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: linear-gradient(180deg, var(--navy-600), var(--navy-700)); border-color: var(--navy-700); color: #fff; box-shadow: 0 1px 2px rgba(15,31,56,.25), inset 0 1px 0 rgba(255,255,255,.08); }
.btn-primary:hover { background: linear-gradient(180deg, var(--navy-500), var(--navy-600)); border-color: var(--navy-600); color: #fff; }
.btn-success { background: linear-gradient(180deg, #179a6f, var(--success)); border-color: var(--success); color: #fff; }
.btn-success:hover { background: var(--success); border-color: var(--success); color: #fff; filter: brightness(1.06); }
.btn-danger { background: var(--surface); border-color: #f1c0c2; color: var(--danger); }
.btn-danger:hover { background: var(--danger-50); border-color: #e9a1a5; color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-sm { padding: .32rem .7rem; min-height: 2rem; font-size: .82rem; border-radius: 8px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-link { background: none; border: none; color: var(--primary-600); padding: 0; cursor: pointer; font: inherit; font-weight: 600; }
.btn-link:hover { color: var(--navy-500); text-decoration: underline; }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .16rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 700; border: 1px solid transparent; white-space: nowrap; line-height: 1.5; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.badge-neutral { background: #f1f4f8; color: #475569; border-color: #e2e8f0; }
.badge-success { background: var(--success-50); color: var(--success); border-color: #c4e8d8; }
.badge-warning { background: var(--warning-50); color: var(--warning); border-color: #f5dcaa; }
.badge-danger { background: var(--danger-50); color: var(--danger); border-color: #f5c6c8; }
.badge-info { background: var(--info-50); color: var(--info); border-color: #c9ddf6; }
.badge-primary { background: var(--primary-50); color: var(--primary); border-color: var(--primary-100); }
.mode-badge { font-size: .74rem; }
.mode-badge::before { animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.alert { position: relative; padding: .85rem 1.1rem; padding-inline-start: 1.25rem; border-radius: var(--radius); margin-bottom: 1.1rem; border: 1px solid; overflow: hidden; }
.alert::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: currentColor; opacity: .55; }
.alert-success { background: var(--success-50); border-color: #c4e8d8; color: #0d5a40; }
.alert-danger { background: var(--danger-50); border-color: #f5c6c8; color: #86191e; }
.alert-warning { background: var(--warning-50); border-color: #f5dcaa; color: #6f3f05; }
.alert-info { background: var(--info-50); border-color: #c9ddf6; color: #154680; }
.alert ul { margin: .3rem 0 0; padding-inline-start: 1.2rem; }
.alert .badge { margin: .15rem 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.table th { text-align: start; font-weight: 700; color: var(--muted); font-size: .76rem; letter-spacing: .02em; background: var(--surface-2); padding: .7rem .9rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .72rem .9rem; border-bottom: 1px solid #eef2f6; vertical-align: middle; color: var(--text-2); }
.table td a { font-weight: 600; }
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover td { background: #f7f9fc; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border-strong); color: var(--text); }
.table .num { text-align: end; }
.table th.num { text-align: end; }
.table-compact td, .table-compact th { padding: .45rem .6rem; }
.empty { padding: 2.6rem 1rem; text-align: center; color: var(--muted); }
.empty::before { content: ""; display: block; width: 44px; height: 44px; margin: 0 auto .7rem; border-radius: 12px; background: var(--surface-3) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z'/%3E%3Cpath d='M14 3v6h6'/%3E%3C/svg%3E") center / 22px no-repeat; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem 1.1rem; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid .span-2 { grid-column: auto; } }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field label { font-size: .84rem; font-weight: 700; color: var(--text-2); }
.field .req { color: var(--danger); }
.field .help { font-size: .79rem; color: var(--muted); }
.field .error { font-size: .8rem; color: var(--danger); font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=tel], input[type=url], input[type=file], select, textarea {
    width: 100%; padding: .55rem .75rem; border: 1px solid var(--border-strong); border-radius: 10px; background: #fff; font: inherit; color: var(--text); min-height: 2.6rem;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
input[type=file] { padding: .4rem; }
input::placeholder, textarea::placeholder { color: #9aa7b8; }
input:hover, select:hover, textarea:hover { border-color: #b5c1d1; }
textarea { min-height: 5rem; resize: vertical; }
select { -webkit-appearance: none; appearance: none; padding-inline-end: 2.2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-size: 16px; background-position: right .7rem center; }
[dir="rtl"] select { background-position: left .7rem center; }
input:focus, select:focus, textarea:focus { border-color: var(--navy-500); box-shadow: var(--ring); outline: none; }
input[disabled], select[disabled], textarea[disabled], input[readonly] { background: var(--surface-2); color: var(--muted); }
.is-invalid { border-color: var(--danger) !important; background-color: #fffafa !important; }
.is-invalid:focus { box-shadow: 0 0 0 4px rgba(192,38,45,.12) !important; }
input[dir="ltr"], .input-ltr { direction: ltr; text-align: left; }
[dir="rtl"] input[dir="ltr"] { text-align: right; }
.check { display: flex; align-items: center; gap: .55rem; font-size: .9rem; color: var(--text-2); cursor: pointer; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--navy-600); }
input[type=radio], input[type=checkbox] { accent-color: var(--navy-600); }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; padding-top: .75rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem 1.1rem; margin: 0 0 1.1rem; background: var(--surface); }
legend { font-weight: 700; padding: 0 .5rem; color: var(--primary); font-size: .92rem; }

.filters { display: flex; flex-wrap: wrap; gap: .7rem; align-items: flex-end; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.card > .filters:first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.filters .field { min-width: 150px; flex: 1 1 150px; max-width: 260px; }
.filters .field label { font-size: .75rem; color: var(--muted); }
.filters input, .filters select { min-height: 2.35rem; padding-block: .4rem; background-color: #fff; }

/* KPI cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.05rem 1.15rem; box-shadow: var(--shadow); overflow: hidden; transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.stat:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(15,27,45,.04), 0 12px 24px -10px rgba(15,27,45,.18); }
.stat .stat-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.stat .label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.stat .icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary-600); flex: none; }
.stat .icon svg { width: 19px; height: 19px; }
.stat .value { font-size: 1.5rem; font-weight: 700; margin-top: .35rem; direction: ltr; unicode-bidi: isolate; text-align: start; font-variant-numeric: tabular-nums; color: var(--text); letter-spacing: -.01em; }
.stat .value .cur { font-size: .78rem; color: var(--muted); font-weight: 600; margin-inline-start: .25rem; }
[dir="rtl"] .stat .value { text-align: right; }
.stat .sub { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.stat.tone-green .icon { background: var(--success-50); color: var(--success); }
.stat.tone-amber .icon { background: var(--warning-50); color: var(--warning); }
.stat.tone-red .icon { background: var(--danger-50); color: var(--danger); }
.stat.tone-violet .icon { background: var(--violet-50); color: var(--violet); }
.stat.tone-gold .icon { background: var(--gold-soft); color: #9a7300; }
.stat.warn .value { color: var(--warning); }
.stat.danger .value { color: var(--danger); }
.stat.danger { border-color: #f3cfd1; }

.hero { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1.35rem 1.5rem; margin-bottom: 1.25rem; border-radius: var(--radius-lg); color: #fff; overflow: hidden;
    background: radial-gradient(120% 140% at 100% 0%, rgba(242,183,5,.22) 0%, rgba(242,183,5,0) 45%), linear-gradient(135deg, var(--navy-700) 0%, var(--navy-900) 100%); box-shadow: var(--shadow); }
[dir="rtl"] .hero { background: radial-gradient(120% 140% at 0% 0%, rgba(242,183,5,.22) 0%, rgba(242,183,5,0) 45%), linear-gradient(225deg, var(--navy-700) 0%, var(--navy-900) 100%); }
.hero h1 { color: #fff; margin: 0 0 .2rem; font-size: 1.35rem; }
.hero p { margin: 0; color: #c3d1e5; font-size: .9rem; }
.hero .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.hero .btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); color: #fff; box-shadow: none; }
.hero .btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.hero .btn-primary { background: var(--gold); border-color: var(--gold); color: var(--navy-950); }
.hero .btn-primary:hover { background: #ffc61a; color: var(--navy-950); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 1.25rem; }
.grid-2 > *, .grid-3 > *, .stats > * { min-width: 0; }

dl.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: .55rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .86rem; }
dl.kv dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; color: var(--text); }
dl.kv dd.num, dl.kv .num { white-space: normal; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); padding: 0 .9rem; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: .8rem .95rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-size: .9rem; font-weight: 600; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--gold); }

.totals-panel { width: 100%; max-width: 440px; margin-inline-start: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem 1rem; }
.totals-panel .row { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px dashed var(--border); }
.totals-panel .row:last-child { border-bottom: 0; }
.totals-panel .row.grand { font-size: 1.12rem; font-weight: 700; color: var(--primary); border-bottom: 0; border-top: 2px solid var(--primary); margin-top: .25rem; padding-top: .65rem; }

details.inline-form summary { cursor: pointer; list-style: none; }
details.inline-form summary::-webkit-details-marker { display: none; }
details.inline-form[open] .panel { margin-top: .6rem; padding: .9rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); min-width: min(360px, 80vw); box-shadow: var(--shadow); }

/* Invoice editor */
.line-table input, .line-table select { min-height: 2.2rem; padding: .35rem .5rem; font-size: .88rem; border-radius: 8px; }
.line-table td { padding: .45rem .35rem; }
.line-table .col-desc { min-width: 230px; }
.line-table .col-num { min-width: 92px; }
.line-table .col-sm { min-width: 70px; }
.suggest { position: relative; }
.suggest-list { position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 30; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; display: none; padding: .25rem; }
.suggest-list.open { display: block; }
.suggest-list button { display: block; width: 100%; text-align: start; padding: .5rem .65rem; border: 0; border-radius: 8px; background: none; font: inherit; cursor: pointer; color: var(--text-2); }
.suggest-list button:hover, .suggest-list button.active { background: var(--primary-50); color: var(--text); }

.theme-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.1rem; }
.theme-card { border: 2px solid var(--border); border-radius: var(--radius-lg); padding: .8rem; background: #fff; transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease); }
.theme-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.theme-card.selected { border-color: var(--navy-600); box-shadow: 0 0 0 4px rgba(42,76,122,.12); }
.theme-card img { width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; display: block; background: #fff; }
.preview-frame { width: 100%; height: 75vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }

.chart { width: 100%; height: auto; }
.chart text { font-family: var(--font); fill: var(--muted); font-size: 11px; }
.bar-list .item { display: grid; grid-template-columns: minmax(90px, 35%) 1fr auto; align-items: center; gap: .7rem; padding: .4rem 0; font-size: .87rem; color: var(--text-2); }
.bar-list .track { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar-list .fill { height: 100%; background: linear-gradient(90deg, var(--navy-500), var(--navy-700)); border-radius: 99px; }
[dir="rtl"] .bar-list .fill { background: linear-gradient(270deg, var(--navy-500), var(--navy-700)); }

.lang-switch { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-3); }
.lang-switch button { border: 0; background: transparent; padding: .28rem .7rem; cursor: pointer; font: inherit; font-size: .82rem; font-weight: 600; color: var(--muted); border-radius: 7px; }
.lang-switch button:hover:not([disabled]) { color: var(--text); }
.lang-switch button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-xs); cursor: default; }
.user-menu { position: relative; }

/* ---------- Auth (split screen) ---------- */
.auth-split { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--bg); }
.auth-brand {
    position: relative; overflow: hidden; color: #fff; padding: 3rem clamp(2rem, 5vw, 4.5rem); display: flex; flex-direction: column; justify-content: space-between;
    background: radial-gradient(90% 70% at 85% 10%, rgba(242,183,5,.20) 0%, rgba(242,183,5,0) 55%), radial-gradient(70% 60% at 0% 100%, rgba(59,98,153,.45) 0%, rgba(59,98,153,0) 60%), linear-gradient(160deg, var(--navy-800) 0%, var(--navy-950) 100%);
}
.auth-brand::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 44px 44px; -webkit-mask-image: linear-gradient(180deg, #000, transparent 85%); mask-image: linear-gradient(180deg, #000, transparent 85%); pointer-events: none; }
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand .mark { display: inline-flex; align-items: center; gap: .9rem; }
.auth-brand .mark img { height: 58px; width: auto; background: #fff; border-radius: 14px; padding: 6px 10px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.auth-brand .mark strong { font-size: 1.05rem; display: block; }
.auth-brand .mark span { font-size: .8rem; color: #9fb2cc; }
.auth-brand h2 { color: #fff; font-size: clamp(1.6rem, 2.6vw, 2.25rem); line-height: 1.3; margin: 0 0 .8rem; max-width: 30ch; }
.auth-brand h2 em { font-style: normal; color: var(--gold); }
.auth-brand p.lead { color: #b9c8dc; max-width: 46ch; margin-bottom: 1.6rem; }
.auth-features { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; max-width: 460px; }
.auth-features li { display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); color: #dbe5f2; font-size: .9rem; }
.auth-features svg { width: 20px; height: 20px; color: var(--gold); flex: none; }
.auth-brand .foot { font-size: .78rem; color: #7f93b0; }
.auth-panel { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.auth-card { width: 100%; max-width: 430px; background: #fff; border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 2rem 1.9rem; }
.auth-card .logo { display: block; height: 64px; width: auto; margin: 0 auto 1.1rem; }
.auth-card h1 { text-align: center; font-size: 1.4rem; margin-bottom: .3rem; }
.auth-card .btn-primary { min-height: 2.9rem; font-size: .98rem; }
.auth-top { display: flex; justify-content: flex-end; margin-bottom: .75rem; }
.auth-copy { text-align: center; margin-top: 1.25rem; font-size: .76rem; color: var(--muted); }
@media (max-width: 920px) {
    .auth-split { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .auth-panel { min-height: 100vh; background: radial-gradient(80% 50% at 50% 0%, var(--primary-50), transparent 70%), var(--bg); }
}

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: .6rem 0; padding-inline-start: 1.2rem; border-bottom: 1px solid #eef2f6; font-size: .88rem; display: flex; justify-content: space-between; gap: .75rem; color: var(--text-2); }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 0; top: 1.05rem; width: 7px; height: 7px; border-radius: 50%; background: var(--navy-500); box-shadow: 0 0 0 3px var(--primary-50); }
.timeline li:last-child { border-bottom: 0; }
.timeline li.muted::before { display: none; }
.checklist li { padding: .4rem 0; list-style: none; display: flex; gap: .55rem; align-items: flex-start; }
.checklist { padding: 0; margin: 0; }
.dot { width: .62rem; height: .62rem; border-radius: 50%; display: inline-block; margin-top: .5rem; flex: none; }
.dot.ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-50); }
.dot.no { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-50); }
.dot.opt { background: #a7b2c0; box-shadow: 0 0 0 3px var(--surface-3); }
.pagination { display: flex; gap: .3rem; flex-wrap: wrap; padding: .9rem 1.25rem; align-items: center; border-top: 1px solid var(--border); }
.pagination a, .pagination span { min-width: 2.1rem; text-align: center; padding: .32rem .65rem; border: 1px solid var(--border); border-radius: 8px; font-size: .86rem; background: #fff; color: var(--text-2); }
.pagination a:hover { border-color: var(--border-strong); background: var(--surface-2); }
.pagination .active span { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled span { color: #a6b0bc; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
    .sidebar, .topbar, .no-print, .filters, .page-head .actions, .pagination, .hero .actions, .page-footer-app { display: none !important; }
    .app { display: block; }
    body { background: #fff; }
    .card, .stat { box-shadow: none; border-color: #ddd; }
    .hero { background: #fff !important; color: #000; border: 1px solid #ddd; }
    .hero h1, .hero p { color: #000; }
}

/* Wide tables scroll sideways on small screens instead of crushing columns. */
.table-wrap > table.table { min-width: 820px; }
.table-wrap > table.table-compact { min-width: 560px; }
.table td:first-child a, .table td .num, .table td[dir="ltr"] { white-space: nowrap; }

/* Password fields: show/hide (eye) toggle, placed on the inline-end side in both RTL and LTR. */
.pw-wrap { position: relative; }
.pw-wrap input { padding-inline-end: 2.8rem; }
[dir="rtl"] .pw-wrap input[dir="ltr"] { text-align: right; padding-right: .75rem; padding-left: 2.8rem; }
[dir="ltr"] .pw-wrap input { padding-right: 2.8rem; }
.pw-toggle { position: absolute; top: 50%; transform: translateY(-50%); right: .4rem; width: 2.1rem; height: 2.1rem; display: grid; place-items: center;
    border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
[dir="rtl"] .pw-toggle { right: auto; left: .4rem; }
.pw-toggle:hover { background: var(--surface-3); color: var(--text); }
.pw-toggle:focus-visible { outline: none; box-shadow: var(--ring); }
.pw-toggle .eye-closed, .pw-toggle.is-visible .eye-open { display: none; }
.pw-toggle.is-visible .eye-closed { display: block; }
/* Row action buttons (invoice list) */
.row-actions { display: inline-flex; gap: .25rem; }
.icon-btn { width: 2rem; height: 2rem; display: inline-grid; place-items: center; border-radius: 8px; color: var(--muted); border: 1px solid transparent; }
.icon-btn:hover { background: var(--primary-50); color: var(--primary); border-color: var(--primary-100); }
.icon-btn svg { width: 17px; height: 17px; }

/* Print page */
.print-page { margin: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface-3); }
.print-bar { display: flex; align-items: center; gap: .9rem; padding: .6rem 1rem; background: #fff; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.print-bar-actions { margin-inline-start: auto; display: flex; gap: .4rem; }
.print-frame { flex: 1; width: 100%; border: 0; background: #fff; }
@media print { .print-bar { display: none; } }

.table td.col-wide { min-width: 170px; }
