:root {
    --primary: #087f5b;
    --primary-dark: #066546;
    --primary-soft: #e8f7f1;
    --accent: #f59f00;
    --accent-soft: #fff4d6;
    --danger: #e03131;
    --danger-soft: #fff0f0;
    --warning: #e67700;
    --warning-soft: #fff4e6;
    --info: #1971c2;
    --info-soft: #e7f5ff;
    --ink: #17232d;
    --muted: #667784;
    --line: #dce3e8;
    --surface: #ffffff;
    --background: #f5f7f9;
    --shadow: 0 12px 34px rgba(19, 36, 50, .08);
    --shadow-sm: 0 4px 14px rgba(19, 36, 50, .07);
    --radius: 20px;
    --radius-sm: 13px;
    --sidebar: 285px;
}

* { box-sizing: border-box; }
html { font-size: 18px; scroll-behavior: smooth; max-width: 100%; overflow-x: hidden; }
body {
    margin: 0;
    background: var(--background);
    color: var(--ink);
    font-family: "Tajawal", "Noto Kufi Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    max-width: 100%;
    overflow-x: hidden;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { font-size: clamp(1.55rem, 3vw, 2.15rem); line-height: 1.35; }
h2 { font-size: clamp(1.3rem, 2.5vw, 1.7rem); line-height: 1.4; }
h3 { font-size: 1.14rem; }
small { display: block; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--primary); }
.text-warning { color: var(--warning); }
.ltr { direction: ltr; text-align: left; }
.nowrap { white-space: nowrap; }
.w-full { width: 100%; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: .6rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mb-0 { margin-bottom: 0 !important; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; width: 100%; overflow-x: clip; }
.sidebar {
    position: fixed;
    inset: 0 0 0 auto;
    width: var(--sidebar);
    background: #082f26;
    color: #fff;
    z-index: 40;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 30px rgba(0,0,0,.08);
}
.sidebar-brand {
    min-height: 108px;
    padding: 1.15rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand strong { display: block; font-size: 1rem; line-height: 1.45; }
.sidebar-brand small { color: rgba(255,255,255,.64); font-size: .73rem; }
.brand-mark {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    flex: 0 0 50px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #19b47e, var(--primary));
    color: #fff;
    font-size: 1.4rem;
    font-weight: 900;
    box-shadow: 0 9px 20px rgba(8,127,91,.28);
}
.brand-mark-lg { width: 72px; height: 72px; border-radius: 22px; font-size: 2rem; }
.brand-mark.brand-logo { padding: 5px; overflow: hidden; background: #fff; }
.brand-mark.brand-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.settings-logo-preview { width: max-content; max-width: 100%; margin: .55rem 0; padding: .65rem; display: flex; align-items: center; gap: .7rem; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.settings-logo-preview img { width: 110px; height: 75px; object-fit: contain; }
.settings-logo-preview small { color: var(--muted); font-weight: 800; }
.sidebar-close { display: none; margin-right: auto; color: #fff; background: transparent; border: 0; font-size: 1.7rem; }
.sidebar-nav { padding: .85rem; overflow-y: auto; flex: 1; }
.sidebar-nav a {
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .75rem;
    margin-bottom: .24rem;
    color: rgba(255,255,255,.78);
    border-radius: 13px;
    font-weight: 700;
    font-size: .94rem;
    transition: .18s ease;
}
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.sidebar-nav a.active { color: #063b2e; background: #fff; box-shadow: var(--shadow-sm); }
.nav-icon { width: 30px; height: 30px; display: grid; place-items: center; font-size: 1.25rem; font-weight: 400; }
.sidebar-footer {
    padding: .9rem 1rem;
    margin: .7rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    border-radius: 14px;
    background: rgba(255,255,255,.08);
}
.sidebar-footer strong { font-size: .86rem; }
.sidebar-footer small { color: rgba(255,255,255,.6); font-size: .72rem; }
.logout-link { margin-right: auto; color: #ffb7b7; font-weight: 800; font-size: .8rem; }

.app-main { margin-right: var(--sidebar); min-height: 100vh; min-width: 0; }
.topbar {
    min-height: 92px;
    position: sticky;
    top: 0;
    z-index: 25;
    padding: .75rem clamp(1rem, 3vw, 2rem);
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(220,227,232,.9);
}
.menu-toggle { display: none; }
.topbar-logo { display: none; }
.icon-btn {
    width: 48px;
    height: 48px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}
.topbar-title { display: flex; flex-direction: column; min-width: 0; }
.topbar-title strong { font-size: 1.25rem; line-height: 1.35; }
.eyebrow { color: var(--primary); font-weight: 800; font-size: .72rem; letter-spacing: .02em; }
.eyebrow.light { color: #8ff0ce; }
.topbar-user { margin-right: auto; display: flex; align-items: center; gap: .65rem; }
.topbar-user strong { display: block; font-size: .86rem; }
.topbar-user small { font-size: .69rem; color: var(--muted); }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 900; }
.page-content { padding: clamp(1rem, 3vw, 2rem); max-width: 1550px; margin: 0 auto; }
.app-footer { min-height: 66px; margin: 0 clamp(1rem,3vw,2rem); padding: 1rem 0; border-top: 1px solid var(--line); color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: .75rem; }
.system-update-banner { margin: 1rem clamp(1rem,3vw,2rem) 0; padding: .7rem .9rem; border: 1px solid #ffd8a8; border-radius: 13px; background: var(--warning-soft); color: #8a4800; display: flex; align-items: center; justify-content: space-between; gap: .7rem; font-weight: 800; font-size: .82rem; }
.mobile-overlay { display: none; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.35rem; min-width: 0; }
.page-header > div { min-width: 0; }
.page-header h1 { margin-bottom: .2rem; }
.page-header p { color: var(--muted); margin: 0; }
.representative-line { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .65rem; margin-top: .45rem; color: var(--primary); font-size: .72rem; font-weight: 800; }
.header-actions { display: flex; flex-wrap: wrap; gap: .55rem; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card {
    min-height: 160px;
    padding: 1.15rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    position: relative;
}
.stat-card::after { content: ""; position: absolute; width: 90px; height: 90px; border-radius: 50%; inset: auto auto -35px -35px; background: var(--stat-soft, var(--primary-soft)); }
.stat-top { display: flex; align-items: center; gap: .65rem; color: var(--muted); font-weight: 700; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--stat-soft, var(--primary-soft)); color: var(--stat-color, var(--primary)); font-size: 1.15rem; }
.stat-value { font-size: clamp(1.45rem, 3vw, 2.05rem); font-weight: 900; line-height: 1.2; color: var(--stat-color, var(--ink)); position: relative; z-index: 1; }
.stat-note { position: relative; z-index: 1; color: var(--muted); font-size: .68rem; }
.stat-card.green { --stat-color: var(--primary); --stat-soft: var(--primary-soft); }
.stat-card.orange { --stat-color: var(--warning); --stat-soft: var(--warning-soft); }
.stat-card.red { --stat-color: var(--danger); --stat-soft: var(--danger-soft); }
.stat-card.blue { --stat-color: var(--info); --stat-soft: var(--info-soft); }

.content-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 1rem; align-items: start; }
.content-grid > * { min-width: 0; }
.content-grid.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    min-width: 0;
}
.card-header { padding: 1.05rem 1.15rem; display: flex; align-items: center; justify-content: space-between; gap: .7rem; border-bottom: 1px solid var(--line); }
.card-header h2, .card-header h3 { margin: 0; }
.card-header p { margin: .15rem 0 0; color: var(--muted); font-size: .84rem; }
.card-body { padding: 1.15rem; }
.card-footer { padding: .9rem 1.15rem; border-top: 1px solid var(--line); background: #fbfcfd; border-radius: 0 0 var(--radius) var(--radius); }
.section-title { color: var(--primary); font-weight: 900; font-size: 1rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); margin: .3rem 0 .8rem; }

.btn {
    min-height: 48px;
    padding: .55rem 1rem;
    border: 1px solid transparent;
    border-radius: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    cursor: pointer;
    font-weight: 800;
    font-size: .91rem;
    transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-lg { min-height: 58px; padding-inline: 1.35rem; font-size: 1rem; }
.btn-sm { min-height: 39px; padding: .38rem .7rem; font-size: .78rem; border-radius: 10px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(8,127,91,.18); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #352000; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { border-color: var(--line); color: var(--ink); background: #fff; }
.btn-soft { background: var(--primary-soft); color: var(--primary-dark); }
.btn-link { color: var(--primary); background: transparent; padding-inline: .35rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.actions-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

label { display: flex; flex-direction: column; gap: .35rem; color: var(--ink); font-weight: 800; font-size: .88rem; }
label .hint { color: var(--muted); font-size: .7rem; font-weight: 500; }
input, select, textarea {
    width: 100%;
    min-height: 53px;
    padding: .68rem .82rem;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    outline: 0;
    transition: border .15s ease, box-shadow .15s ease;
    font-size: .95rem;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(8,127,91,.1); }
input::placeholder, textarea::placeholder { color: #9aa7b0; }
input[readonly] { background: #f3f7f5; color: var(--primary-dark); font-weight: 900; cursor: default; }
input[type="checkbox"], input[type="radio"] { width: 22px; min-height: 22px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.stack-form { display: flex; flex-direction: column; gap: .9rem; }
.inline-form { display: flex; gap: .55rem; align-items: end; flex-wrap: wrap; }
.inline-form > label { flex: 1; min-width: 170px; }
.check-row { min-height: 52px; flex-direction: row; align-items: center; gap: .55rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 12px; }
.choice-switch { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .65rem; }
.choice-option { min-height: 82px; padding: .75rem .85rem; flex-direction: row; align-items: center; gap: .7rem; border: 1.5px solid var(--line); border-radius: 15px; background: #fff; cursor: pointer; transition: border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.choice-option:hover { border-color: #91cdbb; }
.choice-option.is-active,.choice-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(8,127,91,.08); }
.choice-option:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.choice-option input { flex: 0 0 22px; margin: 0; }
.choice-option span { min-width: 0; display: grid; gap: .12rem; }
.choice-option strong { font-size: .86rem; }
.choice-option small { color: var(--muted); font-size: .68rem; font-weight: 600; }
.password-wrap { position: relative; }
.password-wrap input { padding-left: 80px; }
.password-wrap button { position: absolute; left: .5rem; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--primary); font-weight: 800; cursor: pointer; }
.input-group { display: flex; }
.input-group input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-addon { min-width: 58px; display: grid; place-items: center; border: 1.5px solid var(--line); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: #f8fafb; color: var(--muted); font-weight: 800; }
.file-drop { border: 2px dashed #ccd5da; border-radius: 15px; padding: 1rem; background: #fbfcfd; text-align: center; }

.filters { padding: 1rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; box-shadow: var(--shadow-sm); }
.filters-grid { display: grid; grid-template-columns: 2fr repeat(3, minmax(140px, 1fr)) auto; gap: .65rem; align-items: end; }
.search-wrap { position: relative; }
.search-wrap input { padding-right: 2.55rem; }
.search-wrap::before { content: "⌕"; position: absolute; right: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 1.3rem; z-index: 1; }

.table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; overscroll-behavior-inline: contain; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: .82rem .75rem; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: .76rem; background: #fafbfc; white-space: nowrap; }
td { font-size: .87rem; }
tbody tr:hover { background: #fbfdfc; }
tbody tr:last-child td { border-bottom: 0; }
.table-title { font-weight: 900; }
.table-subtitle { color: var(--muted); font-size: .73rem; }
.table-actions { display: flex; gap: .35rem; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; gap: .25rem; border-radius: 999px; padding: .25rem .58rem; font-size: .72rem; font-weight: 900; white-space: nowrap; }
.badge-success { background: var(--primary-soft); color: var(--primary-dark); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-muted { background: #edf1f3; color: var(--muted); }
.badge-blue { background: var(--info-soft); color: var(--info); }

.list-cards { display: grid; gap: .8rem; }
.entity-card { border: 1px solid var(--line); border-radius: 17px; padding: 1rem; background: #fff; box-shadow: var(--shadow-sm); }
.entity-head { display: flex; gap: .65rem; justify-content: space-between; align-items: flex-start; }
.entity-head h3 { margin-bottom: .15rem; }
.entity-meta { display: flex; flex-wrap: wrap; gap: .45rem 1rem; color: var(--muted); font-size: .8rem; margin-top: .7rem; }
.entity-values { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; padding: .8rem; margin-top: .8rem; border-radius: 13px; background: #f8fafb; }
.entity-values small { color: var(--muted); font-size: .7rem; }
.entity-values strong { display: block; font-size: .95rem; margin-top: .12rem; }

.detail-hero { padding: 1.25rem; color: #fff; background: linear-gradient(135deg, #075a45, #0aa175); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1rem; }
.detail-hero .eyebrow { color: #9af1d3; }
.detail-hero h1 { margin: .2rem 0 .5rem; }
.detail-hero p { color: rgba(255,255,255,.8); margin-bottom: 0; }
.detail-hero-grid { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: .75rem; align-items: center; }
.hero-metric { padding: .75rem; border-radius: 13px; background: rgba(255,255,255,.1); }
.hero-metric small { color: rgba(255,255,255,.72); }
.hero-metric strong { font-size: 1.15rem; }
.info-list { display: grid; gap: .6rem; }
.info-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding-bottom: .6rem; border-bottom: 1px solid var(--line); }
.info-row:last-child { border-bottom: 0; padding-bottom: 0; }
.info-row span { color: var(--muted); font-size: .8rem; }
.info-row strong { text-align: left; }
.info-row strong,.info-row a { min-width: 0; overflow-wrap: anywhere; }
.progress { height: 13px; border-radius: 99px; background: #e9eef1; overflow: hidden; }
.progress > span { height: 100%; display: block; background: linear-gradient(90deg, var(--primary), #19b985); border-radius: inherit; }

.timeline { display: grid; gap: .7rem; }
.timeline-item { position: relative; padding: .8rem 1rem .8rem .8rem; margin-right: .6rem; border-right: 3px solid var(--line); background: #fbfcfd; border-radius: 12px 0 0 12px; }
.timeline-item::before { content: ""; position: absolute; right: -7px; top: 1rem; width: 11px; height: 11px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; }
.timeline-item p { margin: .2rem 0; }
.timeline-item small { color: var(--muted); }

.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; }
.quick-action { min-height: 115px; padding: .85rem; border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .45rem; font-weight: 800; background: #fff; }
.quick-action span { font-size: 1.5rem; color: var(--primary); }
.quick-action:hover { border-color: var(--primary); background: var(--primary-soft); }

.alert, .toast { padding: .72rem .9rem; border-radius: 12px; font-weight: 700; font-size: .85rem; margin-bottom: .75rem; border: 1px solid transparent; }
.alert-success { background: var(--primary-soft); color: var(--primary-dark); border-color: #b7e6d5; }
.alert-error { background: var(--danger-soft); color: #a61e1e; border-color: #ffc9c9; }
.alert-warning { background: var(--warning-soft); color: #a65300; border-color: #ffd8a8; }
.alert-info { background: var(--info-soft); color: #145b99; border-color: #a5d8ff; }
.toast { position: fixed; top: 105px; left: 1rem; z-index: 100; width: min(420px, calc(100vw - 2rem)); box-shadow: var(--shadow); animation: toastIn .25s ease both; }
.toast button { float: left; border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; color: inherit; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }

dialog { width: min(720px, calc(100vw - 1.2rem)); max-height: calc(100vh - 1.2rem); padding: 0; border: 0; border-radius: 22px; box-shadow: 0 25px 70px rgba(0,0,0,.25); color: var(--ink); }
dialog::backdrop { background: rgba(7,19,26,.62); backdrop-filter: blur(3px); }
.dialog-header { padding: 1rem 1.15rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: #fff; z-index: 2; }
.dialog-header h2 { margin: 0; }
.dialog-close { border: 0; background: #f1f3f5; width: 42px; height: 42px; border-radius: 12px; font-size: 1.3rem; cursor: pointer; }
.dialog-body { padding: 1.15rem; overflow-y: auto; }
.dialog-footer { padding: .9rem 1.15rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: .55rem; background: #fafbfc; }

.tabs { display: flex; gap: .4rem; padding: .35rem; border-radius: 14px; background: #edf1f3; margin-bottom: 1rem; overflow-x: auto; }
.tabs a, .tabs button { flex: 1; min-width: 120px; min-height: 44px; padding: .45rem .65rem; border: 0; border-radius: 11px; background: transparent; font-weight: 800; color: var(--muted); cursor: pointer; }
.tabs .active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: .45rem; }
.calendar-day { min-height: 105px; padding: .55rem; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.calendar-day.today { border-color: var(--primary); background: var(--primary-soft); }
.calendar-day strong { display: block; }
.calendar-count { display: inline-flex; margin-top: .4rem; padding: .15rem .4rem; border-radius: 99px; background: var(--warning-soft); color: var(--warning); font-size: .68rem; font-weight: 900; }

.empty-state { min-height: 290px; padding: 2rem 1rem; border: 1px dashed #c9d2d8; border-radius: var(--radius); background: #fff; text-align: center; display: grid; place-items: center; align-content: center; }
.empty-icon { font-size: 2.4rem; color: var(--primary); margin-bottom: .5rem; }
.empty-state p { color: var(--muted); max-width: 520px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: .3rem; padding-top: .9rem; }
.pagination a, .pagination span { min-width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: .8rem; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

.auth-body { background: #edf3f0; min-height: 100vh; }
.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 1fr) minmax(420px, 520px); }
.auth-welcome { padding: clamp(2rem, 7vw, 6rem); color: #fff; background: radial-gradient(circle at 15% 20%, rgba(58,211,157,.35), transparent 28%), linear-gradient(145deg, #063d30, #087f5b); display: flex; flex-direction: column; justify-content: center; }
.auth-welcome h1 { font-size: clamp(2rem, 5vw, 3.7rem); margin: .4rem 0 .8rem; max-width: 800px; }
.auth-welcome p { color: rgba(255,255,255,.8); font-size: 1.1rem; max-width: 650px; }
.welcome-points { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1rem; }
.welcome-points span { padding: .45rem .75rem; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); border-radius: 99px; font-size: .82rem; }
.auth-card { padding: clamp(1.3rem, 5vw, 3rem); background: #fff; display: flex; flex-direction: column; justify-content: center; }
.auth-card h2 { font-size: 2rem; margin: .2rem 0; }
.mobile-login-brand { display: none; }
.login-footer { color: var(--muted); text-align: center; margin-top: 1.2rem; }
.installer-wrap { min-height: 100vh; padding: 2rem 1rem; display: grid; place-items: center; }
.installer-card { width: min(780px, 100%); padding: clamp(1.2rem, 4vw, 2rem); background: #fff; border-radius: 24px; box-shadow: var(--shadow); }
.installer-card > .brand-mark { margin-bottom: 1rem; }

.receipt { width: min(820px, 100%); margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.receipt-head { padding: 1.4rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; color: #fff; background: var(--primary); }
.receipt-body { padding: 1.4rem; }
.receipt-total { padding: 1rem; margin: 1rem 0; border-radius: 14px; background: var(--primary-soft); display: flex; justify-content: space-between; align-items: center; }
.receipt-total strong { color: var(--primary); font-size: 1.5rem; }
.receipt-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
.receipt-box { padding: .7rem; border: 1px solid var(--line); border-radius: 12px; }
.receipt-box small { color: var(--muted); }
.print-only { display: none; }
.filters-grid.compact-filters { grid-template-columns: 2fr minmax(180px,1fr) auto; }

.document { position: relative; width: min(980px,100%); margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); overflow: hidden; }
.document-head { min-height: 145px; padding: 1.35rem 1.55rem; display: flex; align-items: center; justify-content: space-between; gap: 1.2rem; color: #fff; background: linear-gradient(135deg,var(--primary-dark),var(--primary)); }
.document-brand { min-width: 0; display: flex; align-items: center; gap: .9rem; }
.document-brand img { width: 82px; height: 82px; object-fit: contain; border-radius: 16px; padding: .35rem; background: #fff; }
.document-brand h2 { margin: 0 0 .15rem; font-size: 1.45rem; }
.document-brand p { margin: 0; color: rgba(255,255,255,.76); font-size: .8rem; }
.document-id { flex: 0 0 auto; min-width: 210px; padding: .75rem .9rem; border: 1px solid rgba(255,255,255,.2); border-radius: 15px; background: rgba(255,255,255,.1); text-align: center; }
.document-id span,.document-id small { display: block; color: rgba(255,255,255,.72); font-size: .72rem; }
.document-id strong { display: block; margin: .2rem 0; font-size: .95rem; text-align: center; }
.document-body { padding: 1.55rem; }
.document-customer { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .65rem; margin-bottom: 1.1rem; }
.document-customer > div { min-width: 0; padding: .8rem; border: 1px solid var(--line); border-radius: 13px; background: #fafcfc; }
.document-customer small,.document-summary small { color: var(--muted); font-size: .7rem; }
.document-customer strong { display: block; margin-top: .12rem; overflow-wrap: anywhere; }
.document-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .65rem; margin: 1rem 0 1.35rem; }
.document-summary > div { min-width: 0; padding: .85rem; border-radius: 14px; background: #f3f6f7; }
.document-summary strong { display: block; margin-top: .15rem; font-size: 1.05rem; }
.document-summary .is-due { background: var(--danger-soft); color: var(--danger); }
.document-summary .is-paid { background: var(--primary-soft); color: var(--primary-dark); }
.document-section-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.35rem 0 .65rem; padding-bottom: .55rem; border-bottom: 2px solid var(--primary-soft); }
.document-section-title h3 { margin: 0; color: var(--primary-dark); }
.document-section-title > span:not(.badge) { color: var(--muted); font-size: .75rem; }
.document-table { min-width: 760px; }
.document-table th { color: var(--primary-dark); background: var(--primary-soft); }
.document-table td { font-size: .78rem; }
.document-table td small { color: var(--muted); }
.document-table tr.is-voided { opacity: .56; text-decoration: line-through; }
.document-note { margin-top: 1rem; padding: .75rem .9rem; border-right: 4px solid var(--primary); border-radius: 10px; color: var(--muted); background: #f8fafb; font-size: .78rem; }
.document-footer { min-height: 64px; padding: .85rem 1.55rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--muted); background: #f7f9fa; border-top: 1px solid var(--line); font-size: .68rem; }
.receipt-amount { margin: -.2rem 0 1rem; padding: 1.1rem; border: 1px solid #b7e6d5; border-radius: 17px; background: linear-gradient(135deg,#f0fcf7,var(--primary-soft)); text-align: center; }
.receipt-amount span,.receipt-amount small { display: block; color: var(--muted); }
.receipt-amount strong { display: block; color: var(--primary-dark); font-size: 2rem; line-height: 1.35; }
.payment-details { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.payment-details > div { min-width: 0; padding: .75rem .9rem; display: flex; justify-content: space-between; gap: .7rem; border-bottom: 1px solid var(--line); }
.payment-details > div:nth-child(odd) { border-left: 1px solid var(--line); }
.payment-details > div:nth-last-child(-n+2) { border-bottom: 0; }
.payment-details span { color: var(--muted); font-size: .76rem; }
.payment-details strong { text-align: left; overflow-wrap: anywhere; }
.signature-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 2rem; margin: 4rem 0 1rem; }
.signature-row > div { min-height: 42px; border-top: 1px solid #7c878e; text-align: center; }
.signature-row span { display: block; padding-top: .45rem; color: var(--muted); font-size: .75rem; }
.document-watermark { position: absolute; inset: 45% auto auto 50%; z-index: 4; transform: translate(-50%,-50%) rotate(-20deg); color: rgba(224,49,49,.18); border: 8px solid rgba(224,49,49,.14); border-radius: 16px; padding: .4rem 1.6rem; font-size: 5rem; font-weight: 900; pointer-events: none; }
.clearance-body { text-align: center; padding-block: 2rem; }
.certificate-mark { width: 68px; height: 68px; margin: 0 auto .7rem; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--primary); font-size: 2rem; box-shadow: 0 10px 25px rgba(8,127,91,.22); }
.clearance-body > h1 { margin: .25rem 0 1rem; }
.certificate-text { max-width: 820px; margin: 0 auto 1.35rem; font-size: 1.08rem; line-height: 2.15; }
.clearance-body .document-customer,.clearance-body .document-summary { text-align: right; }
.clearance-signatures { grid-template-columns: repeat(2,1fr); max-width: 650px; margin-inline: auto; margin-top: 4rem; }

@media (max-width: 1180px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-hero-grid { grid-template-columns: repeat(3, 1fr); }
    .detail-hero-grid > :first-child { grid-column: span 3; }
    .filters-grid { grid-template-columns: repeat(2, 1fr); }
    .filters-grid > :first-child { grid-column: span 2; }
}

@media (max-width: 900px) {
    html { font-size: 17px; }
    body.menu-open { overflow: hidden; }
    .sidebar { position: fixed; top: 0; right: 0; bottom: 0; left: auto; margin: 0; height: 100vh; height: 100dvh; max-width: 100%; transform: translate3d(105%,0,0); transition: transform .22s ease; width: min(290px,78vw); box-shadow: -14px 0 42px rgba(0,0,0,.24); }
    body.menu-open .sidebar { transform: translate3d(0,0,0); }
    .sidebar-close { display: block; flex: 0 0 42px; width: 42px; height: 42px; }
    .sidebar-brand { min-height: 94px; padding: .85rem; }
    .sidebar-nav { padding: .65rem; overscroll-behavior: contain; }
    .sidebar-nav a { min-height: 48px; padding: .45rem .6rem; }
    .mobile-overlay { position: fixed; inset: 0; z-index: 35; background: rgba(7,19,26,.56); }
    body.menu-open .mobile-overlay { display: block; }
    .app-main { margin-right: 0; }
    .menu-toggle { display: inline-grid; place-items: center; }
    .topbar-logo { width: 42px; height: 42px; flex-basis: 42px; display: grid; border-radius: 12px; }
    .topbar { min-height: 78px; }
    .topbar-user > div:not(.avatar) { display: none; }
    .page-content { padding: 1rem; width: 100%; min-width: 0; }
    .app-footer { margin-inline: 1rem; }
    .system-update-banner { margin: .75rem 1rem 0; }
    .content-grid, .content-grid.equal { grid-template-columns: 1fr; }
    .auth-layout { grid-template-columns: 1fr; }
    .auth-welcome { display: none; }
    .mobile-login-brand { display: block; margin-bottom: 1.2rem; }
    .auth-card { min-height: 100vh; max-width: 600px; width: 100%; margin: auto; }
}

@media (max-width: 650px) {
    html { font-size: 17px; }
    .page-header { flex-direction: column; }
    .header-actions, .header-actions .btn { width: 100%; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
    .stat-card { min-height: 132px; padding: .85rem; }
    .stat-top { font-size: .76rem; align-items: flex-start; }
    .stat-icon { width: 34px; height: 34px; flex: 0 0 34px; }
    .stat-value { font-size: 1.25rem; }
    .stat-note { font-size: .62rem; }
    .form-grid, .form-grid.three { grid-template-columns: 1fr; }
    .choice-switch { grid-template-columns: 1fr; }
    .span-2, .span-3 { grid-column: span 1; }
    .filters-grid { grid-template-columns: 1fr; }
    .filters-grid > :first-child { grid-column: span 1; }
    .filters-grid .btn { width: 100%; }
    .entity-values { grid-template-columns: repeat(2, 1fr); }
    .detail-hero-grid { grid-template-columns: 1fr 1fr; }
    .detail-hero-grid > :first-child { grid-column: span 2; }
    .quick-actions { grid-template-columns: repeat(2, 1fr); }
    .topbar-title .eyebrow { display: none; }
    .topbar-title strong { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-user .avatar { width: 40px; height: 40px; }
    .card-header { align-items: flex-start; }
    .entity-head { flex-direction: column; }
    .receipt-grid { grid-template-columns: 1fr; }
    .document { border-radius: 17px; }
    .document-head { min-height: 0; padding: 1rem; flex-direction: column; align-items: stretch; text-align: center; }
    .document-brand { justify-content: center; flex-direction: column; }
    .document-brand img { width: 70px; height: 70px; }
    .document-brand h2 { font-size: 1.25rem; }
    .document-id { min-width: 0; width: 100%; }
    .document-body { padding: .85rem; }
    .document-customer,.document-summary { grid-template-columns: repeat(2,minmax(0,1fr)); gap: .5rem; }
    .document-customer > div,.document-summary > div { padding: .65rem; }
    .document-summary strong { font-size: .88rem; overflow-wrap: anywhere; }
    .receipt-amount strong { font-size: 1.65rem; }
    .payment-details { grid-template-columns: 1fr; }
    .payment-details > div,.payment-details > div:nth-child(odd),.payment-details > div:nth-last-child(-n+2) { border-left: 0; border-bottom: 1px solid var(--line); }
    .payment-details > div:last-child { border-bottom: 0; }
    .signature-row { grid-template-columns: 1fr; gap: 2.4rem; margin-top: 3rem; }
    .clearance-signatures { grid-template-columns: 1fr; }
    .certificate-text { font-size: .95rem; line-height: 2; }
    .document-footer,.app-footer { flex-direction: column; text-align: center; }
    .system-update-banner { flex-direction: column; align-items: stretch; text-align: center; }
    .document-watermark { font-size: 3.2rem; }
    .filters-grid.compact-filters { grid-template-columns: 1fr; }
    .calendar-days { grid-template-columns: repeat(2, 1fr); }
    .calendar-day { min-height: 90px; }
}

@media print {
    @page { size: A4; margin: 10mm; }
    body { background: #fff; font-size: 13px; }
    .sidebar, .topbar, .no-print, .toast, .mobile-overlay { display: none !important; }
    .app-main { margin: 0; }
    .page-content { padding: 0; max-width: none; }
    .print-only { display: block; }
    .card, .receipt, .document { box-shadow: none; border-color: #bbb; }
    .receipt { width: 100%; }
    .document { width: 100%; border-radius: 0; }
    .document-head,.receipt-amount,.document-summary .is-paid,.document-summary .is-due { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .document-body { padding: 8mm; }
    .document-footer { padding: 4mm 8mm; }
    .document-table { min-width: 0; }
    .document-table th,.document-table td { padding: 2.2mm; font-size: 10px; }
    table { min-width: 0; }
}

/* بوابة العميل — الإصدار 1.3.2 */
.portal-body { min-height: 100vh; background: radial-gradient(circle at 8% 0, rgba(8,127,91,.08), transparent 30%), var(--background); }
.portal-shell { min-height: 100vh; display: flex; flex-direction: column; }
.portal-topbar { min-height: 86px; padding: .75rem clamp(1rem,4vw,3rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: #073f32; color: #fff; box-shadow: 0 8px 24px rgba(5,43,34,.14); }
.portal-brand { min-width: 0; display: flex; align-items: center; gap: .75rem; }
.portal-brand .brand-mark { width: 50px; height: 50px; flex-basis: 50px; }
.portal-brand strong,.portal-user strong { display: block; line-height: 1.4; }
.portal-brand small,.portal-user small { color: rgba(255,255,255,.66); font-size: .72rem; }
.portal-user { display: flex; align-items: center; gap: .8rem; text-align: left; }
.portal-user .btn-outline { color: #fff; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.2); }
.portal-nav { position: sticky; top: 0; z-index: 22; width: min(820px,calc(100% - 2rem)); margin: 1rem auto 0; padding: .35rem; display: grid; grid-template-columns: repeat(4,1fr); gap: .35rem; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.94); backdrop-filter: blur(14px); box-shadow: var(--shadow-sm); }
.portal-nav a { min-height: 52px; display: flex; align-items: center; justify-content: center; gap: .45rem; border-radius: 13px; color: var(--muted); font-size: .86rem; }
.portal-nav a span { font-size: 1.2rem; }
.portal-nav a.active { color: #fff; background: var(--primary); box-shadow: 0 7px 16px rgba(8,127,91,.2); }
.portal-content { flex: 1; width: min(1360px,100%); margin: 0 auto; padding: clamp(1rem,3vw,2rem); min-width: 0; }
.portal-footer { min-height: 66px; padding: 1rem clamp(1rem,4vw,3rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--muted); background: #fff; border-top: 1px solid var(--line); font-size: .75rem; }
.portal-footer a { color: var(--primary); font-weight: 800; }
.portal-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin: .5rem 0 1.2rem; }
.portal-page-head > div { min-width: 0; }
.portal-page-head h1 { margin: .12rem 0 .18rem; }
.portal-page-head p { margin: 0; color: var(--muted); }
.back-link { display: block; width: max-content; margin-bottom: .4rem; color: var(--primary); font-size: .8rem; font-weight: 900; }
.portal-alert { padding: 1rem 1.1rem; font-size: .92rem; border-radius: 15px; }
.portal-summary-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .9rem; margin-bottom: 1rem; }
.portal-summary-grid.compact { grid-template-columns: repeat(3,minmax(0,1fr)); }
.portal-metric { min-width: 0; min-height: 154px; padding: 1rem; display: flex; flex-direction: column; justify-content: center; border: 1px solid var(--line); border-radius: 19px; background: #fff; box-shadow: var(--shadow-sm); overflow: hidden; position: relative; }
.portal-metric::after { content: ""; position: absolute; width: 84px; height: 84px; left: -36px; bottom: -38px; border-radius: 50%; background: #edf2f4; }
.portal-metric.primary { color: #fff; border-color: var(--primary); background: linear-gradient(145deg,var(--primary-dark),var(--primary)); }
.portal-metric.success { background: linear-gradient(145deg,#fff,var(--primary-soft)); border-color: #b7e6d5; }
.portal-metric.accent { background: linear-gradient(145deg,#fff,var(--accent-soft)); border-color: #ffe3a3; }
.portal-metric span { color: var(--muted); font-size: .79rem; font-weight: 800; }
.portal-metric strong { margin: .25rem 0; font-size: clamp(1.25rem,2.5vw,1.85rem); line-height: 1.3; overflow-wrap: anywhere; }
.portal-metric small { color: var(--muted); font-size: .7rem; }
.portal-metric.primary span,.portal-metric.primary small { color: rgba(255,255,255,.72); }
.portal-section { min-width: 0; margin-bottom: 1rem; padding: clamp(.9rem,2vw,1.25rem); border: 1px solid var(--line); border-radius: 21px; background: #fff; box-shadow: var(--shadow-sm); }
.portal-section-head,.portal-contract-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; margin-bottom: .85rem; }
.portal-section-head h2,.portal-contract-head h2,.portal-contract-head h3 { margin: 0; }
.portal-section-head p,.portal-contract-head p { margin: .12rem 0 0; color: var(--muted); font-size: .8rem; }
.portal-contracts { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .85rem; }
.portal-contract-card { min-width: 0; padding: 1rem; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(180deg,#fff,#fbfdfc); }
.portal-contract-head h3 { margin: .15rem 0 0; overflow-wrap: anywhere; }
.portal-contract-values { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .55rem; margin: .8rem 0; }
.portal-contract-values > div,.portal-contract-meta > div { min-width: 0; padding: .65rem; border-radius: 12px; background: #f5f8f8; }
.portal-contract-values small,.portal-contract-meta small { color: var(--muted); font-size: .67rem; }
.portal-contract-values strong,.portal-contract-meta strong { display: block; margin-top: .1rem; font-size: .86rem; overflow-wrap: anywhere; }
.progress-caption { display: flex; justify-content: space-between; gap: .6rem; margin: .35rem 0 .8rem; color: var(--muted); font-size: .7rem; font-weight: 700; }
.portal-contract-overview > .progress { margin-top: .8rem; }
.portal-contract-meta { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .55rem; margin-top: .85rem; }
.portal-installments { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .75rem; }
.portal-installment-card { min-width: 0; padding: .85rem; border: 1px solid var(--line); border-right: 5px solid #adb5bd; border-radius: 16px; background: #fff; }
.portal-installment-card.status-success { border-right-color: var(--primary); background: linear-gradient(145deg,#fff,#f1fbf7); }
.portal-installment-card.status-danger { border-right-color: var(--danger); background: linear-gradient(145deg,#fff,#fff4f4); }
.portal-installment-card.status-warning { border-right-color: var(--warning); background: linear-gradient(145deg,#fff,#fff8ed); }
.portal-installment-head,.portal-installment-due { display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.portal-installment-head > div { display: flex; align-items: baseline; gap: .35rem; }
.portal-installment-head span,.portal-installment-due span { color: var(--muted); font-size: .72rem; }
.portal-installment-head strong { font-size: 1.15rem; }
.portal-installment-due { margin: .55rem 0; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.portal-installment-values { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .4rem; }
.portal-installment-values > div { min-width: 0; }
.portal-installment-values small { color: var(--muted); font-size: .64rem; }
.portal-installment-values strong { display: block; font-size: .8rem; overflow-wrap: anywhere; }
.portal-payment-list { display: grid; gap: .65rem; }
.portal-payment-item { min-width: 0; padding: .8rem; display: flex; align-items: center; justify-content: space-between; gap: .8rem; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.portal-payment-item.is-voided { opacity: .65; background: #fafafa; }
.portal-payment-item h3,.portal-payment-item p { margin: .1rem 0; }
.portal-payment-item p,.portal-payment-item small { color: var(--muted); font-size: .73rem; }
.portal-payment-main { min-width: 0; display: flex; align-items: center; gap: .75rem; }
.portal-payment-icon { width: 46px; height: 46px; flex: 0 0 46px; display: grid; place-items: center; border-radius: 13px; color: var(--primary); background: var(--primary-soft); font-size: 1.15rem; font-weight: 900; }
.portal-filter { display: flex; flex-wrap: wrap; gap: .3rem; padding: .25rem; border-radius: 12px; background: #edf2f4; }
.portal-filter a { padding: .38rem .7rem; border-radius: 9px; color: var(--muted); font-size: .74rem; font-weight: 800; }
.portal-filter a.active { color: #fff; background: var(--primary); }
.portal-empty { min-height: 220px; display: grid; place-items: center; align-content: center; text-align: center; }
.portal-empty h2,.portal-empty h3 { margin-bottom: .2rem; }
.portal-empty p { max-width: 520px; margin: 0; color: var(--muted); }
.portal-help { padding: 1rem 1.15rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-radius: 18px; color: #fff; background: linear-gradient(145deg,#073f32,var(--primary)); }
.portal-help h3 { margin: 0; }
.portal-help p { margin: .12rem 0 0; color: rgba(255,255,255,.72); font-size: .78rem; }
.portal-help .btn-soft { background: #fff; }
.portal-profile-grid { display: grid; grid-template-columns: minmax(0,1.05fr) minmax(320px,.95fr); gap: 1rem; align-items: start; }
.portal-profile-details { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .6rem; }
.portal-profile-details > div,.account-status-line { min-width: 0; padding: .75rem; border: 1px solid var(--line); border-radius: 13px; background: #fafcfc; }
.portal-profile-details small,.account-status-line span { color: var(--muted); font-size: .7rem; }
.portal-profile-details strong { display: block; overflow-wrap: anywhere; }
.account-status-line { display: flex; justify-content: space-between; gap: .7rem; margin-bottom: .55rem; }
.portal-security-card .stack-form { margin-top: .9rem; }
.clearance-unavailable { min-height: 430px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.clearance-state-icon { width: 68px; height: 68px; display: grid; place-items: center; margin-bottom: .7rem; border-radius: 50%; color: #fff; background: var(--warning); font-size: 2rem; font-weight: 900; }
.clearance-unavailable > strong { margin: .25rem 0; color: var(--danger); font-size: 2rem; }
.clearance-unavailable > p { max-width: 650px; color: var(--muted); }

.customer-auth-body { background: #edf4f1; }
.customer-auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(420px,1fr) minmax(420px,560px); }
.customer-auth-hero { padding: clamp(2rem,7vw,6rem); display: flex; flex-direction: column; justify-content: center; color: #fff; background: radial-gradient(circle at 12% 16%,rgba(55,220,161,.28),transparent 30%),linear-gradient(145deg,#052f26,#087f5b); }
.customer-auth-hero h1 { max-width: 760px; margin: .55rem 0 .8rem; font-size: clamp(2rem,5vw,3.8rem); }
.customer-auth-hero > p { max-width: 680px; color: rgba(255,255,255,.78); font-size: 1.05rem; }
.customer-login-card { min-height: 100vh; padding: clamp(1.4rem,5vw,3.2rem); }
.customer-login-card .stack-form { margin-top: .8rem; }
.login-help { margin-top: 1rem; padding: .85rem; border-radius: 14px; background: #f5f8f8; text-align: center; }
.login-help p { margin-bottom: .55rem; color: var(--muted); font-size: .76rem; }
.customer-service-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .55rem; }
.customer-service-actions .btn { min-width: 0; }
.login-footer a,.app-footer a,.document-footer a { color: var(--primary); font-weight: 800; }

@media (max-width: 1000px) {
    .portal-summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .portal-summary-grid.compact { grid-template-columns: repeat(3,minmax(0,1fr)); }
    .portal-profile-grid { grid-template-columns: 1fr; }
    .customer-auth-layout { grid-template-columns: minmax(0,1fr) minmax(380px,46%); }
}

@media (max-width: 760px) {
    .portal-body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
    .portal-topbar { min-height: 72px; padding: .6rem .85rem; }
    .portal-brand .brand-mark { width: 44px; height: 44px; flex-basis: 44px; border-radius: 13px; }
    .portal-brand strong { max-width: 42vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9rem; }
    .portal-brand small,.portal-user > span { display: none; }
    .portal-user { margin-right: auto; }
    .portal-nav { position: fixed; inset: auto 0 0; z-index: 60; width: 100%; margin: 0; padding: .35rem .45rem calc(.35rem + env(safe-area-inset-bottom)); gap: .18rem; border: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(19,36,50,.12); }
    .portal-nav a { min-height: 60px; flex-direction: column; gap: .06rem; font-size: .65rem; }
    .portal-nav a span { font-size: 1.25rem; line-height: 1; }
    .portal-content { padding: .85rem; }
    .portal-footer { display: none; }
    .portal-page-head { flex-direction: column; }
    .portal-page-head .header-actions,.portal-page-head .header-actions .btn { width: 100%; }
    .portal-summary-grid.compact { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .portal-contracts,.portal-installments { grid-template-columns: 1fr; }
    .portal-contract-meta { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .portal-help { align-items: stretch; flex-direction: column; }
    .portal-help .btn { width: 100%; }
    .customer-auth-layout { display: block; min-height: 100vh; }
    .customer-auth-hero { min-height: 245px; padding: 1.4rem; justify-content: flex-end; }
    .customer-auth-hero .brand-mark { width: 54px; height: 54px; }
    .customer-auth-hero h1 { margin: .35rem 0; font-size: 1.65rem; }
    .customer-auth-hero > p { margin: 0; font-size: .85rem; }
    .customer-auth-hero .welcome-points { display: none; }
    .customer-login-card { min-height: auto; margin: -.35rem .65rem 1rem; padding: 1.1rem; border-radius: 20px; box-shadow: var(--shadow); position: relative; z-index: 2; }
    .customer-login-card .mobile-login-brand { display: none; }
}

@media (max-width: 520px) {
    .portal-summary-grid,.portal-summary-grid.compact { grid-template-columns: 1fr; }
    .portal-metric { min-height: 132px; }
    .portal-contract-values { grid-template-columns: 1fr 1fr; }
    .portal-contract-values > div:last-child { grid-column: span 2; }
    .portal-installment-values { grid-template-columns: repeat(2,minmax(0,1fr)); gap: .55rem; }
    .portal-payment-item { align-items: stretch; flex-direction: column; }
    .portal-payment-item > .btn { width: 100%; }
    .portal-payment-main { align-items: flex-start; }
    .portal-section-head { flex-direction: column; }
    .portal-filter { width: 100%; }
    .portal-filter a { flex: 1; text-align: center; }
    .portal-profile-details { grid-template-columns: 1fr; }
    .progress-caption { flex-direction: column; gap: .05rem; }
    .customer-service-actions { grid-template-columns: 1fr; }
}

@media print {
    .portal-body { padding: 0; background: #fff; }
    .portal-shell,.portal-content { display: block; width: 100%; max-width: none; margin: 0; padding: 0; }
    .portal-topbar,.portal-nav,.portal-footer { display: none !important; }
    .portal-body .document { width: 100%; max-width: none; }
}
