@font-face {
    font-family: "IBM Plex Sans Arabic";
    src: url("../fonts/IBMPlexSansArabic-Regular.ttf") format("truetype");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Sans Arabic";
    src: url("../fonts/IBMPlexSansArabic-SemiBold.ttf") format("truetype");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Sans Arabic";
    src: url("../fonts/IBMPlexSansArabic-Bold.ttf") format("truetype");
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

:root {
    --bg: #f7f9fc;
    --surface: #ffffff;
    --surface-soft: #fbfcfe;
    --border: #dce4ef;
    --border-strong: #cbd7e5;
    --text: #142033;
    --muted: #708098;
    --muted-light: #9caac0;
    --primary: #07966f;
    --primary-dark: #047857;
    --primary-soft: #ecfdf5;
    --teal: #0f9d92;
    --teal-soft: #ebfffb;
    --blue: #3b82f6;
    --blue-soft: #eff6ff;
    --indigo: #4f46e5;
    --indigo-soft: #eef2ff;
    --amber: #d97706;
    --amber-soft: #fff8e6;
    --red: #ef3340;
    --red-soft: #fff1f2;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 12px 34px rgba(20, 32, 51, .10);
    --radius-sm: 7px;
    --radius: 12px;
    --radius-lg: 16px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

[hidden] {
    display: none !important;
}

.btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 8px 17px;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 600;
    transition: border-color .15s ease, background .15s ease, color .15s ease, transform .15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(59, 130, 246, .2);
    outline-offset: 2px;
}

.btn-primary {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-light {
    background: #f8fafc;
    border-color: var(--border);
    color: #42526a;
}

.btn-light:hover {
    background: #eef2f7;
}

.btn-teal {
    background: var(--teal);
    color: #fff;
}

.btn-red {
    background: #e94355;
    color: #fff;
}

.btn-green {
    background: var(--primary);
    color: #fff;
}

.btn-outline-danger {
    color: var(--red);
    border-color: #fda4af;
    background: #fff;
}

.btn-lg {
    min-height: 46px;
    padding-inline: 22px;
    font-size: 15px;
}

.btn-block {
    width: 100%;
}

.icon-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    color: var(--muted);
    cursor: pointer;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 12px;
    color: #fff;
    background: var(--primary);
    font-size: 21px;
}

.brand-mark.large {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    font-size: 27px;
    background: #fff;
    color: var(--primary);
}

.eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
}

.eyebrow.light {
    color: #baf5e2;
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 13px;
    font-size: 13px;
}

.alert-danger {
    color: #a3122a;
    border-color: #fecdd3;
    background: var(--red-soft);
}

.alert-warning {
    color: #8a4b05;
    border-color: #fed7aa;
    background: #fff8ed;
}

.alert-success {
    color: #087654;
    border-color: #a7f3d0;
    background: var(--primary-soft);
}

/* Authentication and installer */
.auth-body {
    background: #f4f7fb;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(420px, 46%) minmax(420px, 54%);
    direction: ltr;
}

.auth-aside {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 60px clamp(42px, 6vw, 96px);
    overflow: hidden;
    color: #fff;
    background: #08785f;
    direction: rtl;
}

.auth-aside::before,
.auth-aside::after {
    position: absolute;
    content: "";
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 50%;
}

.auth-aside::before {
    width: 420px;
    height: 420px;
    left: -180px;
    bottom: -120px;
}

.auth-aside::after {
    width: 270px;
    height: 270px;
    right: -110px;
    top: -90px;
}

.auth-visual {
    position: relative;
    z-index: 1;
    max-width: 520px;
}

.auth-visual h1 {
    margin: 20px 0 14px;
    font-size: clamp(34px, 4vw, 54px);
    line-height: 1.25;
    letter-spacing: -.7px;
}

.auth-visual > p {
    max-width: 450px;
    margin: 0;
    color: #d9f7ed;
    font-size: 17px;
    line-height: 1.9;
}

.auth-features {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 36px;
}

.auth-features span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
    font-size: 12px;
}

.auth-panel {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    direction: rtl;
}

.auth-card {
    width: min(100%, 430px);
    padding: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--shadow-md);
}

.auth-card h2,
.auth-card h1 {
    margin: 4px 0 5px;
    font-size: 27px;
}

.auth-card > p {
    margin: 0 0 24px;
    color: var(--muted);
}

.mobile-brand {
    display: none;
    margin-bottom: 18px;
}

.login-form {
    display: grid;
    gap: 17px;
    margin-top: 18px;
}

.security-note {
    display: flex;
    justify-content: center;
    gap: 7px;
    margin-top: 20px;
    color: var(--muted-light);
}

.input-icon {
    position: relative;
}

.input-icon > i {
    position: absolute;
    top: 50%;
    right: 13px;
    transform: translateY(-50%);
    color: #8da0b8;
}

.input-icon input {
    width: 100%;
    padding-right: 40px !important;
    padding-left: 42px !important;
}

.password-toggle {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.installer-body {
    display: grid;
    place-items: center;
    padding: 34px;
}

.install-card {
    width: min(1050px, 100%);
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--shadow-md);
}

.install-header {
    display: flex;
    gap: 15px;
    align-items: center;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.install-header h1 {
    margin: 0;
    font-size: 25px;
}

.install-header p,
.section-heading p {
    margin: 2px 0 0;
    color: var(--muted);
}

.install-form {
    display: grid;
    gap: 20px;
    padding-top: 22px;
}

.form-section {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.section-heading {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 18px;
}

.section-heading h2 {
    margin: 0;
    font-size: 17px;
}

.section-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 10px;
    font-size: 18px;
}

.section-icon.green {
    color: var(--primary);
    background: var(--primary-soft);
}

.section-icon.blue {
    color: var(--blue);
    background: var(--blue-soft);
}

.success-state {
    display: grid;
    justify-items: center;
    padding: 60px 20px 30px;
    text-align: center;
}

.success-state > span {
    color: var(--primary);
    font-size: 55px;
}

.success-state h2 {
    margin: 8px 0 3px;
}

.success-state p {
    margin: 0 0 20px;
    color: var(--muted);
}

.error-card {
    margin: 15vh auto;
    text-align: center;
}

.error-card .brand-mark {
    margin: auto;
}

/* App shell */
.app-header {
    position: relative;
    z-index: 30;
    top: 0;
    height: 84px;
    border-top: 5px solid #f0f4f8;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, .97);
}

.header-inner {
    width: min(1275px, calc(100% - 48px));
    height: 100%;
    display: flex;
    align-items: center;
    gap: 18px;
    margin: auto;
    direction: ltr;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 385px;
    margin-right: auto;
    direction: ltr;
}

.brand-copy {
    display: grid;
    line-height: 1.35;
    direction: rtl;
    text-align: left;
}

.brand-title-row {
    display: flex;
    align-items: center;
    gap: 9px;
    direction: ltr;
}

.brand-copy strong {
    font-size: 18px;
    letter-spacing: -.1px;
    direction: rtl;
}

.brand-copy small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.count-pill {
    display: inline-flex;
    align-items: center;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    padding: 2px 8px;
    color: #08785f;
    background: var(--primary-soft);
    font-size: 11px;
    font-style: normal;
    font-weight: 600;
}

.main-nav,
.view-tabs {
    display: inline-flex;
    align-items: center;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #f1f5f9;
    direction: rtl;
}

.main-nav a,
.view-tabs button {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 0;
    border-radius: 7px;
    padding: 6px 13px;
    color: #43536a;
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.main-nav a.active,
.view-tabs button.active {
    color: var(--text);
    background: #fff;
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.view-tabs button i,
.main-nav a i {
    color: #2eaa8d;
    font-size: 14px;
}

.header-view-tabs {
    margin-inline: 0;
}

.header-add {
    min-height: 40px;
    padding-inline: 15px;
    direction: rtl;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    padding-right: 6px;
    border-right: 1px solid var(--border);
    direction: rtl;
}

.account-menu {
    position: relative;
}

.account-menu > summary {
    list-style: none;
}

.account-menu > summary::-webkit-details-marker {
    display: none;
}

.account-menu-panel {
    position: absolute;
    z-index: 80;
    top: 46px;
    left: 0;
    width: 235px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 7px;
    background: #fff;
    box-shadow: var(--shadow-md);
    direction: rtl;
}

.account-identity {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 6px;
    padding: 9px;
    border-bottom: 1px solid var(--border);
}

.account-identity > span:not(.avatar) {
    min-width: 0;
    display: grid;
}

.account-identity strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.account-identity small {
    color: var(--muted);
    font-size: 9px;
}

.account-menu-panel a,
.account-menu-panel form button {
    width: 100%;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 7px;
    padding: 7px 9px;
    color: #46566d;
    background: transparent;
    cursor: pointer;
    text-align: right;
    font-size: 11px;
}

.account-menu-panel a:hover,
.account-menu-panel form button:hover {
    color: var(--primary);
    background: var(--primary-soft);
}

.user-chip {
    display: none;
    align-items: center;
    gap: 8px;
}

.user-chip > span:not(.avatar) {
    display: grid;
    line-height: 1.35;
}

.user-chip strong {
    max-width: 100px;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chip small {
    color: var(--muted);
    font-size: 9px;
}

.avatar {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 9px;
    color: #155e75;
    background: #cffafe;
    font-weight: 700;
}

.avatar.admin {
    color: #4f46e5;
    background: var(--indigo-soft);
}

.toast {
    position: fixed;
    z-index: 200;
    top: 96px;
    left: 24px;
    min-width: 290px;
    max-width: 460px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid;
    border-radius: 10px;
    padding: 11px 13px;
    box-shadow: var(--shadow-md);
    animation: toast-in .2s ease-out;
}

.toast button {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: auto;
    border: 0;
    background: transparent;
    cursor: pointer;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Dashboard */
.dashboard-page,
.users-page {
    width: min(1275px, calc(100% - 48px));
    margin: 0 auto;
    padding: 25px 0 56px;
}

.stats-grid {
    display: grid;
    grid-template-columns: .96fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    min-height: 137px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.stat-card small {
    display: block;
    margin: 6px 0 14px;
    color: var(--muted);
}

.stat-card strong {
    display: block;
    font-size: 27px;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.stat-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 9px;
    font-size: 17px;
}

.stat-icon.amber {
    color: var(--amber);
    background: var(--amber-soft);
}

.stat-icon.teal {
    color: var(--teal);
    background: var(--teal-soft);
}

.stat-icon.green {
    color: var(--primary);
    background: var(--primary-soft);
}

.stat-icon.blue {
    color: var(--blue);
    background: var(--blue-soft);
}

.total-stat p {
    display: flex;
    gap: 18px;
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.total-stat p em {
    color: #c2410c;
    font-style: normal;
}

.progress-stat .stat-main {
    flex: 1;
}

.progress-stat p {
    display: flex;
    align-items: baseline;
    gap: 7px;
    margin: 0 0 13px;
}

.progress-stat p strong {
    display: inline;
    color: #0f8276;
}

.progress-stat p span {
    color: var(--muted);
    font-size: 11px;
}

.progress-track {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #e6edf4;
    direction: ltr;
}

.progress-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: #12968e;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) repeat(4, minmax(120px, auto)) auto;
    gap: 9px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    background: #fff;
    direction: ltr;
}

.filter-bar > * {
    direction: rtl;
}

.filter-bar select,
.field input,
.field select,
.field textarea,
.search-field,
.assignment-search {
    border: 1px solid var(--border);
    border-radius: 8px;
    color: #35445a;
    background: #fff;
}

.filter-bar select {
    min-height: 38px;
    padding: 6px 12px 6px 30px;
    cursor: pointer;
}

.search-field,
.assignment-search {
    position: relative;
    min-height: 38px;
    display: flex;
    align-items: center;
}

.search-field i,
.assignment-search i {
    position: absolute;
    right: 13px;
    color: #92a3b8;
}

.search-field input,
.assignment-search input {
    width: 100%;
    height: 36px;
    border: 0;
    outline: 0;
    padding: 7px 40px 7px 12px;
    color: var(--text);
    background: transparent;
}

.search-field input::placeholder,
.field input::placeholder,
.field textarea::placeholder {
    color: #a3afc1;
}

.btn-filter {
    color: #365068;
    border-color: var(--border);
    background: #f8fafc;
}

.table-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 12px 4px;
    color: var(--muted);
    font-size: 11px;
}

.table-meta strong {
    color: #73829a;
    font-weight: 500;
}

.data-table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    direction: ltr;
}

.data-table th,
.data-table td {
    height: 52px;
    padding: 9px 15px;
    border-bottom: 1px solid #e8edf3;
    text-align: right;
    vertical-align: middle;
    direction: rtl;
}

.data-table th {
    height: 48px;
    color: #334155;
    background: #f8fafc;
    font-size: 12px;
    font-weight: 600;
}

.data-table th i {
    margin-right: 4px;
    color: #9aa9bd;
    font-size: 10px;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover td {
    background: #fbfdff;
}

.data-table tbody tr.is-paid td {
    background: rgba(236, 253, 245, .56);
}

.data-table tbody tr.is-paid:hover td {
    background: rgba(226, 250, 240, .72);
}

.data-table .check-col {
    width: 46px;
    text-align: center;
}

.data-table .number-col {
    width: 54px;
    color: #8ca0b7;
    text-align: center;
    font-size: 11px;
    direction: ltr;
}

.data-table th:nth-last-child(1) {
    width: 130px;
}

.data-table th:nth-last-child(2) {
    width: 175px;
}

.data-table th:nth-last-child(3) {
    width: 120px;
}

.data-table th:nth-last-child(4) {
    width: 175px;
}

.data-table th:nth-last-child(5) {
    width: 155px;
}

.data-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #1685ee;
}

.company-name strong {
    display: block;
    overflow: hidden;
    color: #182235;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.company-name small {
    display: none;
    color: var(--muted);
}

.badge {
    min-height: 27px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 11px;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
}

.badge i {
    font-size: 12px;
}

.status-delivered,
.payment-paid,
.active-badge {
    color: #087654;
    border-color: #9cebc9;
    background: #e9fff5;
}

.status-submitted,
.payment-unpaid {
    color: #a54c09;
    border-color: #fed7aa;
    background: #fff8ed;
}

.status-in_progress,
.payment-partial {
    color: #1d64c8;
    border-color: #bfdbfe;
    background: var(--blue-soft);
}

.auth-badge {
    color: #4a42dd;
    border-color: #c7d2fe;
    background: var(--indigo-soft);
}

.role-admin {
    color: #4a42dd;
    border-color: #c7d2fe;
    background: var(--indigo-soft);
}

.role-client {
    color: #036782;
    border-color: #a5f3fc;
    background: #ecfeff;
}

.inactive-badge {
    color: #64748b;
    border-color: #dbe2ea;
    background: #f1f5f9;
}

.active-badge i,
.inactive-badge i {
    font-size: 6px;
}

.muted-dash {
    color: #cbd5e1;
}

.fee-value {
    color: #28364b;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    direction: ltr;
}

.row-actions form {
    display: contents;
}

.row-actions button {
    width: 27px;
    height: 27px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 6px;
    color: #8ba0b9;
    background: transparent;
    cursor: pointer;
}

.row-actions button:hover {
    color: var(--primary);
    background: var(--primary-soft);
}

.row-actions form button:hover {
    color: var(--red);
    background: var(--red-soft);
}

.empty-state {
    min-height: 230px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}

.empty-state i {
    margin-bottom: 8px;
    font-size: 30px;
}

.empty-state strong {
    color: var(--text);
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 18px;
}

.pagination a {
    min-width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    background: #fff;
}

.pagination a.active {
    color: #fff;
    border-color: var(--primary);
    background: var(--primary);
}

.pagination a.disabled {
    pointer-events: none;
    opacity: .45;
}

/* Selection summary */
.selection-summary {
    margin-bottom: 16px;
    border: 2px solid #0db57e;
    border-radius: var(--radius);
    padding: 14px 16px 16px;
    background: #fff;
    box-shadow: 0 10px 25px rgba(13, 181, 126, .08);
}

.selection-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
}

.selection-count {
    width: 37px;
    height: 37px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: #fff;
    background: var(--primary);
    font-size: 19px;
    font-weight: 700;
}

.selection-heading > div {
    display: grid;
    line-height: 1.35;
}

.selection-heading strong {
    font-size: 13px;
}

.selection-heading small {
    color: var(--muted);
    font-size: 10px;
}

.summary-chip {
    border: 1px solid #a7f3d0;
    border-radius: 999px;
    padding: 3px 10px;
    color: #087654;
    background: var(--primary-soft);
    font-size: 10px;
}

.summary-chip.muted {
    color: #526177;
    border-color: var(--border);
    background: #f4f7fa;
}

.selection-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0 12px;
    border-top: 1px solid #e8edf2;
}

.selection-actions .btn {
    min-height: 34px;
    padding: 6px 12px;
    font-size: 11px;
}

.selection-breakdown {
    display: grid;
    grid-template-columns: repeat(10, minmax(85px, 1fr));
    gap: 8px;
    direction: ltr;
}

.breakdown-item {
    min-height: 58px;
    display: grid;
    place-items: center;
    align-content: center;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 5px;
    color: #164e63;
    background: #f0f9ff;
}

.breakdown-item small {
    max-width: 100%;
    overflow: hidden;
    font-size: 9px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.breakdown-item b {
    color: #0369a1;
    font-size: 15px;
}

.breakdown-item.indigo {
    color: #312e81;
    border-color: #c7d2fe;
    background: var(--indigo-soft);
}

.breakdown-item.amber {
    color: #7c2d12;
    border-color: #fde68a;
    background: var(--amber-soft);
}

.breakdown-item.teal,
.breakdown-item.type {
    color: #0f766e;
    border-color: #99f6e4;
    background: #f0fdfa;
}

/* Dialogs and forms */
.app-dialog {
    width: min(1040px, calc(100vw - 28px));
    max-width: none;
    max-height: calc(100vh - 24px);
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 16px;
    color: var(--text);
    background: #fff;
    box-shadow: 0 24px 80px rgba(15, 23, 42, .25);
}

.app-dialog::backdrop {
    background: rgba(42, 51, 65, .58);
    backdrop-filter: blur(1px);
}

.company-dialog {
    width: min(1230px, calc(100vw - 12px));
    max-height: calc(100vh - 12px);
}

.dialog-shell {
    max-height: inherit;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dialog-header {
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex: 0 0 auto;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    background: #fbfcfe;
}

.dialog-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dialog-title h2 {
    margin: 0;
    font-size: 18px;
}

.dialog-title p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 10px;
}

.dialog-icon {
    width: 35px;
    height: 35px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    color: #fff;
    background: var(--primary);
    font-size: 18px;
}

.dialog-close {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    color: #93a4b9;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
}

.dialog-close:hover {
    color: var(--text);
    background: #edf2f7;
}

.dialog-footer {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    flex: 0 0 auto;
    padding: 12px 24px;
    border-top: 1px solid var(--border);
    background: #fbfcfe;
}

.company-form-grid {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    padding: 18px 22px;
    overflow: auto;
    direction: rtl;
}

.form-card,
.detail-card {
    align-self: start;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    background: #fff;
}

.form-card h3,
.detail-card h3 {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 0 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.form-card h3 i,
.detail-card h3 i {
    color: var(--primary);
}

.form-card h4 {
    margin: 15px 0 8px;
    font-size: 12px;
}

.field {
    display: grid;
    gap: 6px;
}

.field > span {
    color: #344054;
    font-size: 12px;
    font-weight: 600;
}

.field > span b {
    color: var(--red);
}

.field > span small {
    color: var(--muted);
    font-size: 9px;
    font-weight: 400;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    outline: 0;
}

.field textarea {
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-field:focus-within,
.assignment-search:focus-within {
    border-color: #65bfa7;
    box-shadow: 0 0 0 3px rgba(7, 150, 111, .08);
}

.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid.two {
    grid-template-columns: 1fr 1fr;
}

.form-grid.three {
    grid-template-columns: repeat(3, 1fr);
}

.form-grid .span-2 {
    grid-column: span 2;
}

.type-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 14px 0;
    padding: 0;
    border: 0;
}

.type-selector legend {
    grid-column: 1 / -1;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 600;
}

.type-selector label {
    cursor: pointer;
}

.type-selector input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.type-selector span {
    min-height: 58px;
    display: grid;
    place-items: center;
    align-content: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
}

.type-selector strong {
    font-size: 13px;
}

.type-selector small {
    color: var(--primary);
    font-size: 10px;
    font-weight: 700;
}

.type-selector input:checked + span {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 2px rgba(7, 150, 111, .09);
}

.service-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.simple-services-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-bottom: 10px;
}

.simple-service-option {
    cursor: pointer;
}

.simple-service-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.simple-service-option span {
    min-height: 35px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 6px 9px;
    background: #fff;
}

.simple-service-option strong {
    overflow: hidden;
    color: #425168;
    font-size: 9px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.simple-service-option b {
    color: #087654;
    font-size: 9px;
    direction: ltr;
}

.simple-service-option input:checked + span {
    color: #086c51;
    border-color: #79d9b8;
    background: var(--primary-soft);
    box-shadow: 0 0 0 2px rgba(7, 150, 111, .07);
}

.service-card {
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 9px;
    background: #fff;
}

.service-card:has(input:not([value="0"])) {
    border-color: #b5e6d5;
}

.service-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.service-card header > div {
    min-width: 0;
    display: grid;
}

.service-card header strong {
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.service-card header small {
    color: var(--muted);
    font-size: 9px;
}

.service-card output {
    border: 1px solid #99f6e4;
    border-radius: 4px;
    padding: 2px 7px;
    color: #087654;
    background: var(--primary-soft);
    font-size: 10px;
    font-weight: 700;
}

.quantity-control {
    display: flex;
    align-items: stretch;
    gap: 5px;
    margin-top: 8px;
    direction: ltr;
}

.quantity-control > button {
    width: 28px;
    border: 0;
    border-radius: 5px;
    color: #526177;
    background: #f0f4f8;
    cursor: pointer;
}

.quantity-control > input {
    width: 38px;
    border: 1px solid var(--border);
    border-radius: 5px;
    text-align: center;
}

.quantity-presets {
    display: flex;
    flex: 1;
    gap: 4px;
}

.quantity-presets button {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: #334155;
    background: #f8fafc;
    cursor: pointer;
    font-size: 9px;
    line-height: 1.2;
}

.quantity-presets small {
    font-size: 8px;
}

.timeline-card {
    display: grid;
    gap: 14px;
}

.timeline-card h3 {
    margin-bottom: 0;
}

.form-divider {
    height: 1px;
    margin: 2px 0;
    background: var(--border);
}

.form-grid.compact {
    gap: 8px;
}

.fee-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #a7f3d0;
    border-radius: 9px;
    padding: 10px 12px;
    color: #086c51;
    background: var(--primary-soft);
}

.fee-preview strong {
    font-size: 18px;
    font-variant-numeric: tabular-nums;
}

.fee-preview small {
    margin-right: auto;
    color: #43816f;
    font-size: 9px;
}

/* Details */
.details-dialog {
    width: min(1025px, calc(100vw - 24px));
}

.details-grid {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    padding: 24px;
    overflow: auto;
}

.detail-card h4 {
    margin: 15px 0 7px;
    font-size: 11px;
}

.company-identity {
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 16px;
}

.company-identity > small {
    display: block;
    color: var(--muted-light);
    font-size: 9px;
}

.company-identity > strong {
    display: block;
    margin: 6px 0 12px;
    font-size: 17px;
}

.company-identity > div {
    display: flex;
    gap: 7px;
}

.total-fees-box,
.auth-box,
.notes-box {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid #9ee9ca;
    border-radius: 8px;
    padding: 9px 12px;
    color: #086c51;
    background: #dff9ed;
}

.total-fees-box span {
    font-size: 11px;
    font-weight: 600;
}

.total-fees-box strong {
    direction: ltr;
    font-size: 16px;
}

.auth-box {
    color: #4540a4;
    border-color: #d4d7ff;
    background: #f0f2ff;
}

.notes-box {
    min-height: 42px;
    justify-content: flex-start;
    color: #344b74;
    border-color: #c8ddfa;
    background: #edf5ff;
    font-size: 11px;
}

.date-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.date-grid > div {
    min-height: 60px;
    display: grid;
    align-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
}

.date-grid span {
    color: #4d5f75;
    font-size: 10px;
}

.date-grid strong {
    font-size: 11px;
}

.date-grid > div:nth-child(2) {
    border-color: #fde68a;
    background: #fffbeb;
}

.date-grid > div:nth-child(3) {
    border-color: #c7d2fe;
    background: var(--indigo-soft);
}

.date-grid > div:nth-child(4) {
    border-color: #99f6e4;
    background: #f0fdfa;
}

.selected-services-title {
    display: flex;
    justify-content: space-between;
    margin: 14px 0 8px;
    font-size: 11px;
}

.selected-services-title > span {
    border: 1px solid #a7f3d0;
    border-radius: 4px;
    padding: 2px 7px;
    color: #087654;
    background: var(--primary-soft);
    font-size: 9px;
}

.selected-services {
    display: grid;
    gap: 7px;
}

.selected-service {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid #9ee9ca;
    border-radius: 7px;
    padding: 8px 10px;
    color: #0c5d49;
    background: #effdf7;
    font-size: 11px;
}

.selected-service strong {
    direction: ltr;
}

.general-notes {
    margin-top: 12px;
    color: var(--muted);
    font-size: 10px;
}

/* Kanban and finance */
.section-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-intro h2,
.page-heading h1 {
    margin: 0;
    font-size: 24px;
}

.section-intro p,
.page-heading p {
    margin: 3px 0 0;
    color: var(--muted);
}

.kanban-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.kanban-column {
    min-height: 560px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    background: #f2f5f9;
}

.kanban-column > header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 3px 13px;
}

.kanban-column > header b {
    min-width: 24px;
    margin-right: auto;
    border-radius: 999px;
    padding: 2px 7px;
    color: var(--muted);
    background: #e2e8f0;
    text-align: center;
    font-size: 10px;
}

.kanban-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--amber);
}

.kanban-dot.in_progress {
    background: var(--blue);
}

.kanban-dot.delivered {
    background: var(--primary);
}

.kanban-list {
    display: grid;
    gap: 9px;
}

.kanban-card {
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 12px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.kanban-card > strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kanban-card > span {
    color: var(--muted);
    font-size: 10px;
}

.kanban-card footer {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 9px;
    border-top: 1px solid #edf1f5;
}

.kanban-card em {
    color: var(--primary);
    font-style: normal;
    font-weight: 700;
}

.kanban-card small,
.kanban-empty {
    color: var(--muted);
    font-size: 9px;
}

.kanban-empty {
    display: grid;
    place-items: center;
    min-height: 120px;
}

.financial-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.financial-grid article {
    min-height: 145px;
    display: grid;
    align-content: center;
    justify-items: start;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    background: #fff;
}

.financial-grid article small {
    color: var(--muted);
}

.financial-grid article strong {
    font-size: 27px;
}

.finance-breakdown {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    background: #fff;
}

.finance-breakdown h3 {
    margin: 0 0 20px;
    font-size: 15px;
}

.finance-row {
    display: grid;
    grid-template-columns: 160px 1fr 50px;
    align-items: center;
    gap: 14px;
    margin-top: 14px;
}

.finance-row > span {
    display: flex;
    justify-content: space-between;
    color: #43536a;
}

.finance-row > div {
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #edf2f6;
}

.finance-row i {
    display: block;
    height: 100%;
    background: var(--primary);
}

.finance-row i.partial {
    background: var(--blue);
}

.finance-row i.unpaid {
    background: var(--amber);
}

.finance-row em {
    color: var(--muted);
    font-style: normal;
}

/* Users */
.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.permission-note {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    border: 1px solid #b7ead7;
    border-radius: var(--radius);
    padding: 14px 16px;
    color: #145e4c;
    background: #f1fcf7;
}

.permission-note strong {
    font-size: 13px;
}

.permission-note p {
    margin: 2px 0 0;
    color: #4c7469;
    font-size: 11px;
}

.users-table-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.users-table-card .data-table-wrap {
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
}

.card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
}

.card-heading h2 {
    margin: 0;
    font-size: 16px;
}

.card-heading p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 10px;
}

.users-table {
    table-layout: auto;
}

.users-table th:last-child {
    width: 100px;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-cell > div {
    display: grid;
}

.user-cell small,
.muted-cell {
    color: var(--muted);
    font-size: 10px;
}

.all-access {
    color: var(--primary);
    font-weight: 600;
}

.user-dialog {
    width: min(770px, calc(100vw - 24px));
}

.user-form-body {
    min-height: 0;
    display: grid;
    gap: 17px;
    padding: 22px;
    overflow: auto;
}

.switch-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.switch-row > input {
    position: absolute;
    opacity: 0;
}

.switch-row > span {
    position: relative;
    width: 42px;
    height: 23px;
    border-radius: 999px;
    background: #cbd5e1;
}

.switch-row > span::after {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #fff;
    content: "";
    transition: transform .15s ease;
}

.switch-row > input:checked + span {
    background: var(--primary);
}

.switch-row > input:checked + span::after {
    transform: translateX(-19px);
}

.switch-row > div {
    display: grid;
}

.switch-row small {
    color: var(--muted);
    font-size: 9px;
}

.company-assignment {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
}

.assignment-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 12px;
}

.assignment-heading h3 {
    margin: 0;
    font-size: 13px;
}

.assignment-heading p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 9px;
}

.assignment-heading > label {
    color: var(--primary);
    font-size: 10px;
    font-weight: 600;
}

.assignment-search {
    margin-bottom: 10px;
}

.company-check-list {
    max-height: 220px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    overflow: auto;
}

.company-check-list > label {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
}

.company-check-list > label:has(input:checked) {
    border-color: #9ee9ca;
    background: var(--primary-soft);
}

.company-check-list input {
    accent-color: var(--primary);
}

.company-check-list span {
    min-width: 0;
    display: grid;
}

.company-check-list strong {
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.company-check-list small {
    color: var(--muted);
    font-size: 8px;
}

.assignment-empty {
    grid-column: 1 / -1;
    padding: 20px;
    color: var(--muted);
    text-align: center;
}

/* Responsive */
@media (max-width: 1180px) {
    .header-inner,
    .dashboard-page,
    .users-page {
        width: calc(100% - 28px);
    }

    .brand {
        min-width: 300px;
    }

    .brand-copy strong {
        font-size: 15px;
    }

    .brand-copy small,
    .user-chip > span:not(.avatar) {
        display: none;
    }

    .filter-bar {
        grid-template-columns: minmax(280px, 1fr) repeat(2, minmax(140px, auto));
    }

    .selection-breakdown {
        grid-template-columns: repeat(5, minmax(82px, 1fr));
    }
}

@media (max-width: 900px) {
    .app-header {
        height: auto;
        position: relative;
    }

    .header-inner {
        min-height: 76px;
        flex-wrap: wrap;
        padding: 10px 0;
    }

    .brand {
        min-width: 0;
        flex: 1;
    }

    .header-view-tabs,
    .main-nav {
        order: 5;
        width: 100%;
        overflow: auto;
    }

    .header-view-tabs button,
    .main-nav a {
        flex: 1;
    }

    .header-actions {
        border: 0;
    }

    .stats-grid,
    .financial-grid {
        grid-template-columns: 1fr 1fr;
    }

    .progress-stat {
        grid-column: 1 / -1;
    }

    .filter-bar {
        grid-template-columns: 1fr 1fr;
    }

    .search-field {
        grid-column: 1 / -1;
    }

    .company-form-grid,
    .details-grid {
        grid-template-columns: 1fr;
    }

    .service-grid {
        grid-template-columns: 1fr 1fr;
    }

    .kanban-board {
        grid-template-columns: 1fr;
    }

    .kanban-column {
        min-height: 280px;
    }

    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-aside {
        display: none;
    }

    .mobile-brand {
        display: inline-flex;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 13px;
    }

    .dashboard-page,
    .users-page {
        width: calc(100% - 20px);
        padding-top: 15px;
    }

    .header-inner {
        width: calc(100% - 20px);
    }

    .brand-copy .count-pill,
    .header-actions .avatar {
        display: none;
    }

    .header-add {
        width: 40px;
        overflow: hidden;
        padding: 0;
        font-size: 0;
    }

    .header-add i {
        font-size: 16px;
    }

    .view-tabs button,
    .main-nav a {
        min-width: max-content;
    }

    .stats-grid,
    .financial-grid {
        grid-template-columns: 1fr;
    }

    .progress-stat {
        grid-column: auto;
    }

    .stat-card {
        min-height: 110px;
    }

    .filter-bar,
    .form-grid.two,
    .form-grid.three,
    .type-selector,
    .service-grid,
    .simple-services-grid,
    .date-grid,
    .company-check-list {
        grid-template-columns: 1fr;
    }

    .filter-bar > *,
    .search-field,
    .form-grid .span-2 {
        grid-column: auto;
    }

    .selection-heading {
        flex-wrap: wrap;
    }

    .selection-breakdown {
        grid-template-columns: repeat(3, minmax(75px, 1fr));
    }

    .app-dialog,
    .company-dialog,
    .details-dialog,
    .user-dialog {
        width: 100vw;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }

    .dialog-header,
    .dialog-footer {
        padding-inline: 14px;
    }

    .company-form-grid,
    .details-grid,
    .user-form-body {
        padding: 13px;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .finance-row {
        grid-template-columns: 110px 1fr 38px;
        gap: 8px;
    }

    .auth-panel,
    .installer-body {
        padding: 18px;
    }

    .auth-card,
    .install-card {
        padding: 24px 19px;
    }
}
