:root {
    /* ── Brand: Arsan Law Firm (from images2/logo.png) ── */
    --color-gold: #b8974f;
    --color-gold-dark: #9a7d3f;
    --color-gold-light: #d4bc82;
    --color-gold-soft: #f5eed6;
    --color-gold-muted: #e8dcc0;

    --color-charcoal: #2b2b2b;
    --color-charcoal-light: #4a4a4a;
    --color-charcoal-muted: #6b6b6b;

    /* Semantic aliases */
    --color-primary: var(--color-gold);
    --color-primary-dark: var(--color-gold-dark);
    --color-primary-light: var(--color-gold-light);
    --color-secondary: var(--color-charcoal);
    --color-accent: var(--color-gold);
    --color-accent-soft: var(--color-gold-soft);

    --color-bg: #f5f3f0;
    --color-bg-warm: #fafaf9;
    --color-surface: #ffffff;
    --color-surface-muted: #f8f7f5;
    --color-border: #e8e4df;
    --color-border-strong: #d4cfc8;
    --color-text: var(--color-charcoal);
    --color-text-muted: var(--color-charcoal-muted);
    --color-text-light: #9a9590;

    --color-success: #0d9488;
    --color-success-soft: #e8f6f4;
    --color-warning: #d97706;
    --color-warning-soft: #fffbeb;
    --color-danger: #dc2626;
    --color-danger-soft: #fef2f2;
    --color-info: #2563eb;
    --color-info-soft: #eef4fc;

    /* Dashboard pastel card backgrounds */
    --pastel-gold: #fbf5e6;
    --pastel-blue: #eef4fc;
    --pastel-purple: #f3eef8;
    --pastel-teal: #e8f6f4;
    --pastel-coral: #fdf0ed;
    --pastel-sand: #f7f3ed;
    --pastel-gray: #f3f4f6;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(43, 43, 43, 0.05);
    --shadow-md: 0 4px 12px rgba(43, 43, 43, 0.07);
    --shadow-lg: 0 8px 24px rgba(43, 43, 43, 0.09);
    --sidebar-width: 248px;
    --header-height: 68px;
    --font-family: 'Noto Kufi Arabic', 'Segoe UI', Tahoma, sans-serif;
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-family);
    background: var(--color-bg-warm);
    color: var(--color-text);
    margin: 0;
    direction: rtl;
    line-height: 1.65;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-gold-dark); text-decoration: none; }
a:hover { color: var(--color-gold); text-decoration: underline; }

/* ── Shell ── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-guest .app-main {
    max-width: 100%;
}

.app-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 1.5rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.app-header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-charcoal);
}

.app-header-brand img {
    height: 36px;
    width: auto;
    object-fit: contain;
}

.app-header-user {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.app-header-user strong {
    color: var(--color-text);
    font-weight: 600;
}

.app-content {
    flex: 1;
    padding: var(--space-lg);
    max-width: 1200px;
    width: 100%;
}

.app-guest-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--header-height));
    padding: 2rem 1rem;
}

/* ── Sidebar: white/light, gold active, dark text ── */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    color: var(--color-charcoal);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-left: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.app-sidebar-brand {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.app-sidebar-brand img {
    max-width: 100%;
    height: auto;
    max-height: 72px;
    object-fit: contain;
    margin-bottom: 0.5rem;
    display: block;
}

.app-sidebar-brand-text {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--color-charcoal);
    line-height: 1.4;
}

.app-sidebar-brand small {
    display: block;
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.app-sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0.75rem 0;
    flex: 1;
}

.app-sidebar-nav li a,
.app-sidebar-nav li button.sidebar-logout {
    display: block;
    width: 100%;
    color: var(--color-charcoal-light);
    padding: 0.7rem 1.25rem;
    text-decoration: none;
    font-size: 0.875rem;
    border: none;
    background: none;
    text-align: right;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.app-sidebar-nav li a:hover,
.app-sidebar-nav li button.sidebar-logout:hover {
    background: var(--color-bg);
    color: var(--color-charcoal);
    text-decoration: none;
}

.app-sidebar-nav li.active a {
    background: var(--color-gold-soft);
    color: var(--color-charcoal);
    font-weight: 600;
    border-right: 3px solid var(--color-gold);
}

.app-sidebar-nav li.nav-divider {
    border-top: 1px solid var(--color-border);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
}

.app-sidebar-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.app-sidebar-top .app-sidebar-brand {
    border-bottom: none;
    flex: 1;
}

.app-sidebar-close {
    display: none;
    border: none;
    background: transparent;
    color: var(--color-charcoal-muted);
    font-size: 1.75rem;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
}

.app-sidebar-user-panel {
    display: none;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-muted);
}

.app-sidebar-user-panel strong {
    display: block;
    font-size: 0.9375rem;
    color: var(--color-charcoal);
}

.app-sidebar-user-role {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.125rem;
}

.app-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.app-sidebar-section {
    border: none;
    margin: 0 0 0.25rem;
}

.app-sidebar-section-title {
    list-style: none;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: none;
    padding: 0.625rem 1.25rem 0.375rem;
    user-select: none;
}

.app-sidebar-section-title::-webkit-details-marker {
    display: none;
}

.app-sidebar-section-items {
    padding-top: 0 !important;
    padding-bottom: 0.25rem !important;
}

.app-sidebar-section-items .app-sidebar-nav li a,
.app-sidebar-section-items .app-sidebar-nav li button.sidebar-logout {
    padding-top: 0.8125rem;
    padding-bottom: 0.8125rem;
    font-size: 0.9375rem;
}

.app-sidebar-footer {
    border-top: 1px solid var(--color-border);
    padding: 0.75rem 1.25rem 1rem;
    background: var(--color-surface-muted);
}

.app-sidebar-footer .sidebar-logout {
    display: block;
    width: 100%;
    text-align: right;
    border: none;
    background: none;
    color: var(--color-danger);
    padding: 0.75rem 0;
    font-family: inherit;
    font-size: 0.9375rem;
    cursor: pointer;
}

.app-sidebar-footer-link {
    display: block;
    padding: 0.5rem 0 0;
    font-size: 0.8125rem;
    color: var(--color-charcoal-muted);
    text-decoration: none;
}

.app-sidebar-backdrop {
    display: none;
}

.mobile-nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-nav-toggle-bar {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--color-charcoal);
    border-radius: 1px;
}

/* ── Page header ── */
.page-header {
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-charcoal);
    margin: 0 0 0.375rem;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin: 0;
}

/* Legacy title aliases */
.MidTitle01 { font-size: 1.375rem; font-weight: 700; color: var(--color-text); margin: 0 0 0.25rem; }
.MidTitle02 { font-size: 0.875rem; color: var(--color-text-muted); margin: 0 0 1rem; }

/* ── Cards ── */
.ui-card,
.ClientCard,
.CaseCard,
.PaymentCard,
.GeneralCard,
.SearchBox {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.ui-card-title,
.ClientCard .title,
.CaseCardHader,
.CaseCard .title,
.SearchBox .title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-charcoal);
    margin: 0 0 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--color-gold-muted);
}

/* ── Login ── */
.login-page {
    width: 100%;
    max-width: 440px;
}

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-xl);
    border: 1px solid var(--color-border);
}

.login-card-logo {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.login-card-logo img {
    max-width: 220px;
    height: auto;
    margin: 0 auto 1rem;
    display: block;
}

.login-card-logo h1 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-charcoal);
    margin: 0 0 0.25rem;
}

.login-card-logo p {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin: 0;
}

.loginbox { display: none; }

.login-form-group {
    margin-bottom: 1rem;
}

.login-form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.375rem;
}

.login-form-group input {
    width: 100%;
}

.login-card .btn-login {
    width: 100%;
    padding: 0.625rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.login-footer {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.8125rem;
}

.login-intro {
    max-width: 480px;
    margin: 0 auto 2rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9375rem;
    line-height: 1.7;
}

/* ── Forms ── */
.form-group,
.ui-form-row {
    margin-bottom: 1rem;
}

.form-group label,
.ui-form-row label,
p > label:first-child {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.375rem;
}

.FormatControl,
.form-control,
.form-select {
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.875rem;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.FormatControl:focus,
.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-gold);
    box-shadow: 0 0 0 3px rgba(184, 151, 79, 0.18);
}

.FormatControl.centered { text-align: center; }
.FormatControl.righted { text-align: right; }

textarea.FormatControl {
    width: 100%;
    max-width: 100%;
    resize: vertical;
    min-height: 80px;
}

.hijri-date-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.hijri-date-group input {
    width: 3rem;
    text-align: center;
}

.hijri-date-group input.hijri-year {
    width: 4.5rem;
}

.hijri-date-sep {
    color: var(--color-text-light);
    font-size: 0.875rem;
}

.gregorian-preview {
    display: inline-block;
    padding: 0.5rem 0.75rem;
    background: var(--color-bg);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 0.875rem;
    min-width: 120px;
}

.description {
    color: var(--color-text-light);
    font-size: 0.75rem;
    font-style: normal;
}

/* ── Buttons ── */
.btn {
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    transition: background 0.15s, transform 0.1s;
}

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

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

.btn-secondary {
    background: var(--color-charcoal-light);
    border-color: var(--color-charcoal-light);
    color: #fff;
}

.btn-secondary:hover {
    background: var(--color-charcoal);
    border-color: var(--color-charcoal);
    color: #fff;
}

.btn-success { background: var(--color-success); border-color: var(--color-success); color: #fff; }
.btn-danger { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8125rem; }

.btn-default {
    background: var(--color-gold);
    color: #fff;
    border: none;
}

/* ── Alerts ── */
.alert {
    border-radius: var(--radius-md);
    border: none;
    padding: 0.875rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
}

.alert-success {
    background: var(--color-success-soft);
    color: #115e59;
    border-right: 4px solid var(--color-success);
}

.alert-danger {
    background: var(--color-danger-soft);
    color: #991b1b;
    border-right: 4px solid var(--color-danger);
}

.alert-warning {
    background: var(--color-warning-soft);
    color: #92400e;
    border-right: 4px solid var(--color-warning);
}

.alert-info {
    background: var(--color-info-soft);
    color: #1e40af;
    border-right: 4px solid var(--color-info);
}

.alert ul { margin: 0.5rem 0 0; padding-right: 1.25rem; }

/* ── Tables ── */
.legacy-table,
.ui-table,
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.legacy-table th,
.ui-table th,
.table thead th {
    background: var(--color-surface-muted);
    color: var(--color-charcoal);
    font-weight: 600;
    text-align: right;
    padding: 0.875rem 1rem;
    border-bottom: 2px solid var(--color-gold-muted);
    font-size: 0.8125rem;
}

.legacy-table td,
.ui-table td,
.table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

.legacy-table tr:hover td,
.ui-table tbody tr:hover td {
    background: var(--color-gold-soft);
}

.legacy-table td.right { text-align: right; }

.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

/* ── Dashboard ── */
.dashboard-header { margin-bottom: 1.5rem; }

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.dashboard-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.375rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s, transform 0.15s;
}

.dashboard-cards > .dashboard-card:nth-child(7n+1),
.dashboard-cards > a.dashboard-card:nth-child(7n+1) { background: var(--pastel-gold); }
.dashboard-cards > .dashboard-card:nth-child(7n+2),
.dashboard-cards > a.dashboard-card:nth-child(7n+2) { background: var(--pastel-blue); }
.dashboard-cards > .dashboard-card:nth-child(7n+3),
.dashboard-cards > a.dashboard-card:nth-child(7n+3) { background: var(--pastel-purple); }
.dashboard-cards > .dashboard-card:nth-child(7n+4),
.dashboard-cards > a.dashboard-card:nth-child(7n+4) { background: var(--pastel-teal); }
.dashboard-cards > .dashboard-card:nth-child(7n+5),
.dashboard-cards > a.dashboard-card:nth-child(7n+5) { background: var(--pastel-coral); }
.dashboard-cards > .dashboard-card:nth-child(7n+6),
.dashboard-cards > a.dashboard-card:nth-child(7n+6) { background: var(--pastel-sand); }
.dashboard-cards > .dashboard-card:nth-child(7n+7),
.dashboard-cards > a.dashboard-card:nth-child(7n+7) { background: var(--pastel-gray); }

.dashboard-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.dashboard-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.dashboard-card-link:hover { text-decoration: none; color: inherit; }

.dashboard-card-label {
    display: block;
    font-size: 0.8125rem;
    color: var(--color-charcoal-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.dashboard-card-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-charcoal);
    line-height: 1.2;
}

.dashboard-card-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-light);
    margin-top: 0.5rem;
    line-height: 1.4;
}

.dashboard-card-informational {
    cursor: default;
}

.dashboard-card-informational:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

.dashboard-table-block {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.dashboard-table-title {
    font-weight: 700;
    color: var(--color-charcoal);
    margin-bottom: 1rem;
    font-size: 0.9375rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--color-gold-muted);
}

/* ── Status badges ── */
.badge-status {
    display: inline-block;
    padding: 0.2rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-open { background: var(--color-info-soft); color: #1e40af; }
.badge-closed { background: var(--pastel-gray); color: var(--color-charcoal-muted); }
.badge-success { background: var(--color-success-soft); color: #115e59; }
.badge-warning { background: var(--color-warning-soft); color: #92400e; }
.badge-danger { background: var(--color-danger-soft); color: #991b1b; }
.badge-info { background: var(--color-info-soft); color: #1e40af; }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--color-text-muted);
}

.empty-state-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

.empty-state-title {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

/* ── Toolbar / search ── */
.toolbar-search {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.toolbar-search .SearchBox {
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    flex: 1;
    min-width: 200px;
}

.toolbar-search .SearchBox .title { display: none; }

/* ── Case card sections ── */
.CaseCardTable td:first-child {
    color: var(--color-text-muted);
    font-weight: 600;
    width: 35%;
    font-size: 0.8125rem;
}

.internal-note {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
}

.CardOption a,
.CardOption button {
    font-size: 0.8125rem;
    margin-left: 0.5rem;
}

.centered { text-align: center; }

/* ── Phase 2: legacy cleanup ── */
.IndexLeftCard02, .IndexLeftCard03, .IndexLeftCard04, .IndexLeftCard05 { display: none !important; }

.page-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.page-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.ui-form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    max-width: 720px;
}

.ui-form-card .FormatControl[type="text"],
.ui-form-card .FormatControl[type="email"],
.ui-form-card .FormatControl[type="number"],
.ui-form-card .FormatControl[type="password"],
.ui-form-card .FormatControl[type="file"],
.ui-form-card select.FormatControl,
.ui-form-card textarea.FormatControl,
.ui-form-card .form-control,
.ui-form-card .form-select {
    width: 100%;
    max-width: 480px;
}

.ui-form-card .hijri-date-group .FormatControl { width: auto; max-width: none; }

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.filter-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.filter-panel-title {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--color-charcoal);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-gold-muted);
}

.detail-table td:first-child {
    color: var(--color-text-muted);
    font-weight: 600;
    width: 38%;
    font-size: 0.8125rem;
    white-space: nowrap;
}

.detail-table .text-muted { color: var(--color-text-light) !important; font-size: 0.8125rem; }

.section-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.section-card-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-charcoal);
    margin: 0;
}

.section-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--color-gold-muted);
}

.section-card-link {
    font-size: 0.8125rem;
    margin-bottom: 0.75rem;
    display: inline-block;
}

.item-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-sm);
}

.item-card-meta {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    min-width: 100px;
}

.item-card-meta .hijri-primary {
    font-weight: 700;
    color: var(--color-text);
    font-size: 0.9375rem;
}

.item-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-card-label { font-size: 0.75rem; color: var(--color-text-muted); margin-bottom: 0.25rem; }
.stat-card-value { font-weight: 700; color: var(--color-charcoal); font-size: 1.125rem; }

.ui-nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.ui-nav-tile {
    display: block;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    color: inherit;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.ui-nav-tile:hover {
    text-decoration: none;
    border-color: var(--color-gold-light);
    box-shadow: var(--shadow-md);
    color: inherit;
}

.ui-nav-tile-title { font-weight: 700; color: var(--color-charcoal); margin-bottom: 0.375rem; }
.ui-nav-tile-desc { font-size: 0.8125rem; color: var(--color-text-muted); margin: 0; }

.ui-nav-tile-muted {
    cursor: default;
    background: var(--color-surface-muted);
    border-style: dashed;
}

.ui-nav-tile-muted:hover {
    box-shadow: none;
    border-color: var(--color-border);
    color: inherit;
}

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

.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
}

.btn-delete {
    background: transparent;
    border: 1px solid var(--color-danger);
    color: var(--color-danger);
    padding: 0.25rem 0.625rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
}

.btn-delete:hover { background: var(--color-danger); color: #fff; }

.CardOption .btn-delete,
.item-card-actions .btn-delete { margin: 0; }

.placeholder-card {
    max-width: 560px;
    margin: 0 auto;
    text-align: center;
    padding: 2rem;
}

.client-actions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.security-note {
    background: var(--color-gold-soft);
    border-right: 3px solid var(--color-gold);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
}

.temp-password-box {
    background: var(--pastel-gold);
    border: 1px solid var(--color-gold-muted);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    max-width: 480px;
}

.temp-password-value {
    font-family: ui-monospace, monospace;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-charcoal);
    letter-spacing: 0.05em;
    margin: 0.5rem 0;
}

/* Form row spacing inside legacy <p> tags */
.ui-form-card form > p,
.section-card form > p {
    margin-bottom: 1rem;
}

.ui-form-card form > p > label,
.section-card form > p > label {
    display: block;
    margin-bottom: 0.375rem;
}

/* ── Hide legacy layout chrome ── */
#main, #content_mid, #content_header, #right_bg, #content_mid_footer,
#footer01, #footer02, .content-mid-banner { all: unset; display: contents; }

.HeaderText { display: none; }

/* ── Responsive ── */
@media (min-width: 993px) {
    .app-sidebar-section-title {
        pointer-events: none;
    }

    .app-sidebar-section[open] .app-sidebar-section-title::after {
        content: none;
    }
}

@media (max-width: 992px) {
    .app-shell { flex-direction: column; }

    .mobile-nav-toggle {
        display: inline-flex;
    }

    .app-header-user {
        font-size: 0.8125rem;
        max-width: 52vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        width: min(88vw, 320px);
        height: 100vh;
        height: 100dvh;
        z-index: 1100;
        transform: translateX(100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-lg);
    }

    body.nav-open .app-sidebar {
        transform: translateX(0);
    }

    body.nav-open {
        overflow: hidden;
    }

    .app-sidebar-close {
        display: block;
    }

    .app-sidebar-user-panel {
        display: block;
    }

    .app-sidebar-brand {
        border-bottom: none;
        padding-bottom: 0;
    }

    .app-sidebar-top .app-sidebar-brand {
        padding: 1rem 0 0 1rem;
    }

    .app-sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(43, 43, 43, 0.45);
        z-index: 1050;
    }

    body.nav-open .app-sidebar-backdrop {
        display: block;
    }

    .app-sidebar-section-title::after {
        content: '▾';
        float: left;
        font-size: 0.75rem;
        color: var(--color-text-light);
    }

    .app-sidebar-section:not([open]) .app-sidebar-section-title::after {
        content: '◂';
    }

    .app-content { padding: 1rem; }

    .toolbar-search {
        margin-bottom: 0.75rem;
    }

    .dashboard-cards {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

.btn-outline-primary {
    color: var(--color-gold-dark);
    border-color: var(--color-gold);
    background: transparent;
}

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

.btn-outline-secondary {
    color: var(--color-charcoal-light);
    border-color: var(--color-border-strong);
}

.btn-outline-secondary:hover {
    background: var(--color-charcoal-light);
    border-color: var(--color-charcoal-light);
    color: #fff;
}

.report-link-grid .dashboard-card-value { font-size: 1rem !important; }

/* ── Pagination (Bootstrap RTL, compact) ── */
.ui-pagination {
    display: flex;
    justify-content: center;
}

.ui-pagination nav {
    display: block;
}

.ui-pagination .pagination,
.ui-pagination ul.pagination {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.125rem;
}

.ui-pagination .page-item {
    display: inline-flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

.ui-pagination .page-item::before,
.ui-pagination .page-item::marker {
    content: none;
    display: none;
}

.ui-pagination .page-link {
    display: inline-block;
    font-size: 0.8125rem;
    line-height: 1.25;
    padding: 0.3rem 0.55rem;
    color: var(--color-charcoal);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 0.25rem);
    background: var(--color-surface, #fff);
    min-width: 2rem;
    text-align: center;
    text-decoration: none;
}

.ui-pagination .page-item.active .page-link {
    background: var(--color-gold);
    border-color: var(--color-gold);
    color: #fff;
}

.ui-pagination .page-item.disabled .page-link {
    color: var(--color-text-muted);
    background: var(--color-surface-muted, #f8f9fa);
    cursor: default;
}

.ui-pagination .page-link:hover:not(.disabled) {
    background: var(--pastel-gold, #f5f0e6);
    border-color: var(--color-gold);
    color: var(--color-charcoal);
}

.ui-pagination svg {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* ── Case list cards: limit long text ── */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.case-contract-card .detail-table td.right {
    word-break: break-word;
    max-width: 42rem;
}

/* ── Branded error pages ── */
.error-page-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--color-bg-warm);
}

.error-page-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.error-page-logo {
    max-width: 120px;
    height: auto;
    margin-bottom: 1rem;
}

.error-page-code {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-gold);
    margin: 0 0 0.5rem;
}

.error-page-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
    color: var(--color-charcoal);
}

.error-page-message {
    color: var(--color-text-muted);
    margin: 0 0 1.25rem;
    font-size: 0.875rem;
}

.error-page-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

@media (max-width: 576px) {
    .hijri-date-group input { width: 2.75rem; }
    .login-card { padding: 1.5rem; }
}

/* ── Office calendar print ── */
.office-calendar-print-only {
    display: none;
}

.office-calendar-print-header {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--color-gold);
}

.office-calendar-print-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.office-calendar-print-brand img {
    max-height: 64px;
    width: auto;
}

.office-calendar-print-firm {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.office-calendar-print-title {
    font-size: 1.375rem;
    margin: 0 0 0.75rem;
    color: var(--color-charcoal);
}

.office-calendar-print-meta {
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--color-charcoal-light);
}

.office-calendar-print-table th,
.office-calendar-print-table td {
    font-size: 0.8125rem;
    vertical-align: middle;
    box-sizing: border-box;
}

.office-calendar-print-table th {
    white-space: normal !important;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.35;
    vertical-align: middle;
    text-align: center;
    padding: 5px 4px;
    overflow: hidden;
}

.office-calendar-print-table.legacy-table th,
.office-calendar-print-table.ui-table th {
    padding: 5px 4px;
    text-align: center;
}

.office-calendar-print-table {
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
}

.office-calendar-print-table .col-serial,
.office-calendar-print-table col.col-serial {
    width: 4%;
}

.office-calendar-print-table .col-type,
.office-calendar-print-table col.col-type {
    width: 11%;
}

.office-calendar-print-table .col-date,
.office-calendar-print-table col.col-date {
    width: 25%;
}

.office-calendar-print-table .col-time,
.office-calendar-print-table col.col-time {
    width: 9%;
}

.office-calendar-print-table th:nth-child(5),
.office-calendar-print-table td:nth-child(5),
.office-calendar-print-table .col-case,
.office-calendar-print-table col.col-case {
    width: 10%;
    min-width: 10%;
    max-width: 10%;
}

.office-calendar-print-table th:nth-child(6),
.office-calendar-print-table td:nth-child(6),
.office-calendar-print-table .col-client,
.office-calendar-print-table col.col-client {
    width: 16%;
    min-width: 16%;
    max-width: 16%;
}

.office-calendar-print-table .col-details,
.office-calendar-print-table col.col-details {
    width: 25%;
}

.office-calendar-print-table td.col-time,
.office-calendar-print-table td.col-case {
    white-space: nowrap;
}

.office-calendar-print-table .col-serial {
    text-align: center;
}

.office-calendar-print-table .col-details {
    word-break: break-word;
}

.office-calendar-print-date {
    display: block;
}

.office-calendar-print-date-line {
    display: block;
    line-height: 1.4;
}

.office-calendar-print-date-line + .office-calendar-print-date-line {
    margin-top: 0.15rem;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 12mm;
    }

    body {
        background: #fff !important;
        font-size: 11pt;
    }

    .app-sidebar,
    .app-sidebar-backdrop,
    .mobile-nav-toggle,
    .app-header,
    .toolbar-search,
    .page-header,
    .no-print,
    .office-calendar-screen-only,
    .item-card-actions,
    .alert {
        display: none !important;
    }

    .app-shell,
    .app-main,
    .app-content {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .office-calendar-print-only {
        display: block !important;
    }

    .office-calendar-print-table {
        width: 100%;
        border-collapse: collapse;
        table-layout: fixed;
    }

    .office-calendar-print-table th,
    .office-calendar-print-table td {
        border: 1px solid #ccc;
        padding: 5px 4px;
        font-size: 9pt;
        line-height: 1.35;
        vertical-align: middle;
        box-sizing: border-box;
    }

    .office-calendar-print-table th {
        white-space: normal !important;
        overflow-wrap: anywhere;
        word-break: normal;
        text-align: center;
        overflow: hidden;
    }

    .office-calendar-print-table.legacy-table th,
    .office-calendar-print-table.ui-table th {
        padding: 5px 4px;
        text-align: center;
    }

    .office-calendar-print-table th:nth-child(5),
    .office-calendar-print-table td:nth-child(5),
    .office-calendar-print-table .col-case,
    .office-calendar-print-table col.col-case {
        width: 10%;
        min-width: 10%;
        max-width: 10%;
    }

    .office-calendar-print-table th:nth-child(6),
    .office-calendar-print-table td:nth-child(6),
    .office-calendar-print-table .col-client,
    .office-calendar-print-table col.col-client {
        width: 16%;
        min-width: 16%;
        max-width: 16%;
    }

    .office-calendar-print-table td.col-time,
    .office-calendar-print-table td.col-case {
        white-space: nowrap;
    }

    .office-calendar-print-table .col-details,
    .office-calendar-print-table .col-client,
    .office-calendar-print-table .col-type {
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .office-calendar-print-table thead {
        display: table-header-group;
    }

    .office-calendar-print-table tr {
        break-inside: avoid;
    }

    a[href]::after {
        content: none !important;
    }
}
