/*
 * Warde CRM — presentation layer only
 * Brand-led light/dark design system. No workflow or application logic lives here.
 */

:root,
[data-bs-theme="light"] {
    color-scheme: light;
    --crm-primary: #981830;
    --crm-primary-hover: #781025;
    --crm-primary-soft: #f8e9ed;
    --crm-primary-rgb: 152, 24, 48;
    --crm-secondary: #6d5d53;
    --crm-dark: #211b18;
    --crm-light: #fbf8f3;
    --crm-bg: #f4f0ea;
    --crm-surface: #fffdf9;
    --crm-surface-raised: #ffffff;
    --crm-surface-muted: #f7f2ec;
    --crm-card-border: #e5ddd4;
    --crm-border-strong: #d2c6bb;
    --crm-text: #302824;
    --crm-text-soft: #71665f;
    --crm-text-faint: #958981;
    --crm-success: #2f7557;
    --crm-warning: #a86416;
    --crm-danger: #b4233d;
    --crm-info: #376f79;
    --crm-plum: #74566e;
    --crm-wood: #a67b4c;
    --crm-sidebar: #171210;
    --crm-sidebar-raised: #211816;
    --crm-sidebar-text: #f3eae2;
    --crm-sidebar-muted: #b9aaa0;
    --crm-shadow-sm: 0 2px 8px rgba(37, 24, 18, 0.045);
    --crm-shadow-md: 0 16px 44px rgba(47, 27, 20, 0.08);
    --crm-shadow-lg: 0 30px 80px rgba(34, 18, 13, 0.14);
    --crm-radius-sm: 10px;
    --crm-radius-md: 16px;
    --crm-radius-lg: 22px;
    --crm-sidebar-width: 286px;
    --crm-motion-fast: 160ms;
    --crm-motion: 240ms;
    --crm-ease: cubic-bezier(.2, .75, .25, 1);

    --bs-primary: #981830;
    --bs-primary-rgb: 152, 24, 48;
    --bs-secondary: #71665f;
    --bs-secondary-rgb: 113, 102, 95;
    --bs-success: #2f7557;
    --bs-success-rgb: 47, 117, 87;
    --bs-warning: #a86416;
    --bs-warning-rgb: 168, 100, 22;
    --bs-danger: #b4233d;
    --bs-danger-rgb: 180, 35, 61;
    --bs-info: #376f79;
    --bs-info-rgb: 55, 111, 121;
    --bs-body-color: #302824;
    --bs-body-bg: #f4f0ea;
    --bs-border-color: #e5ddd4;
    --bs-link-color: #981830;
    --bs-link-hover-color: #781025;
    --bs-focus-ring-color: rgba(152, 24, 48, .22);
}

html[data-theme="dark"],
[data-bs-theme="dark"] {
    color-scheme: dark;
    --crm-primary: #d3516c;
    --crm-primary-hover: #e16b82;
    --crm-primary-soft: rgba(211, 81, 108, .14);
    --crm-primary-rgb: 211, 81, 108;
    --crm-secondary: #c1b3aa;
    --crm-dark: #f7f0e9;
    --crm-light: #191513;
    --crm-bg: #110e0d;
    --crm-surface: #1b1715;
    --crm-surface-raised: #221d1a;
    --crm-surface-muted: #27211e;
    --crm-card-border: #3a302b;
    --crm-border-strong: #51423b;
    --crm-text: #f1e9e2;
    --crm-text-soft: #c0b3aa;
    --crm-text-faint: #998b82;
    --crm-success: #68b28e;
    --crm-warning: #dca552;
    --crm-danger: #ef7086;
    --crm-info: #74b3bd;
    --crm-plum: #b896b0;
    --crm-wood: #c79a68;
    --crm-sidebar: #0d0a09;
    --crm-sidebar-raised: #18110f;
    --crm-sidebar-text: #f8eee7;
    --crm-sidebar-muted: #b9aaa0;
    --crm-shadow-sm: 0 3px 12px rgba(0, 0, 0, .2);
    --crm-shadow-md: 0 18px 48px rgba(0, 0, 0, .28);
    --crm-shadow-lg: 0 32px 90px rgba(0, 0, 0, .38);

    --bs-primary: #d3516c;
    --bs-primary-rgb: 211, 81, 108;
    --bs-secondary: #c0b3aa;
    --bs-secondary-rgb: 192, 179, 170;
    --bs-success: #68b28e;
    --bs-success-rgb: 104, 178, 142;
    --bs-warning: #dca552;
    --bs-warning-rgb: 220, 165, 82;
    --bs-danger: #ef7086;
    --bs-danger-rgb: 239, 112, 134;
    --bs-info: #74b3bd;
    --bs-info-rgb: 116, 179, 189;
    --bs-body-color: #f1e9e2;
    --bs-body-bg: #110e0d;
    --bs-border-color: #3a302b;
    --bs-link-color: #e16b82;
    --bs-link-hover-color: #ef8ca0;
    --bs-focus-ring-color: rgba(211, 81, 108, .3);
}

@view-transition {
    navigation: auto;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--crm-bg);
    scroll-behavior: smooth;
    scrollbar-color: var(--crm-border-strong) transparent;
    scrollbar-width: thin;
}

body.warde-ui {
    --crm-module: var(--crm-primary);
    --crm-module-rgb: var(--crm-primary-rgb);
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    margin: 0;
    overflow-x: hidden;
    color: var(--crm-text);
    background:
        radial-gradient(circle at 100% 0%, rgba(var(--crm-primary-rgb), .055), transparent 31rem),
        radial-gradient(circle at 0% 100%, rgba(166, 123, 76, .045), transparent 28rem),
        var(--crm-bg);
    font-family: var(--warde-font, "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif);
    font-size: .95rem;
    line-height: 1.6;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

body[data-page="customers"] {
    --crm-module: #356f65;
    --crm-module-rgb: 53, 111, 101;
}

body[data-page="products"],
body[data-page="booking"],
body[data-page="project_edit"] {
    --crm-module: #8a6338;
    --crm-module-rgb: 138, 99, 56;
}

body[data-page="after_sales"] {
    --crm-module: #47697a;
    --crm-module-rgb: 71, 105, 122;
}

body[data-page="appointments"] {
    --crm-module: #585d7e;
    --crm-module-rgb: 88, 93, 126;
}

body[data-page="admin_users"] {
    --crm-module: #69566a;
    --crm-module-rgb: 105, 86, 106;
}

body[data-page="settings"] {
    --crm-module: #60636a;
    --crm-module-rgb: 96, 99, 106;
}

html[dir="rtl"] body.warde-ui {
    --warde-font: "Cairo", system-ui, sans-serif;
    letter-spacing: 0;
}

body.warde-ui::before {
    position: fixed;
    z-index: -1;
    inset: 0;
    pointer-events: none;
    content: "";
    opacity: .38;
    background-image: linear-gradient(rgba(var(--crm-primary-rgb), .018) 1px, transparent 1px), linear-gradient(90deg, rgba(var(--crm-primary-rgb), .018) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: linear-gradient(to bottom, #000, transparent 72%);
}

::selection {
    color: #fff;
    background: rgba(152, 24, 48, .82);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background: var(--crm-border-strong);
    background-clip: padding-box;
}

a {
    text-underline-offset: .2em;
}

.min-w-0 {
    min-width: 0;
}

/* Logo frames keep configured company artwork intact. The source-frame modifier
   crops only the supplied Warde PNG's transparent canvas, without altering it. */
.warde-logo-frame {
    position: relative;
    display: inline-block;
    overflow: hidden;
    aspect-ratio: 1.52 / 1;
}

.warde-logo-frame > img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.warde-logo-source-frame > img {
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: 0;
    display: block;
    width: 100%;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    object-fit: initial !important;
    transform: translateY(-10.2%);
}

.font-monospace {
    direction: ltr;
    unicode-bidi: isolate;
}

.warde-logo-frame-sidebar {
    width: min(174px, 100%);
}

.warde-logo-frame-mobile {
    width: 78px;
    flex: 0 0 78px;
}

.warde-logo-frame-public {
    width: 92px;
}

.warde-logo-frame-login {
    width: min(280px, 100%);
}

.warde-logo-frame-login-mobile {
    width: min(180px, 72%);
}

a,
button,
input,
select,
textarea,
.card,
.modal-content,
.accordion-item,
.nav-link {
    transition-duration: var(--crm-motion-fast);
    transition-timing-function: var(--crm-ease);
}

:focus-visible {
    outline: 3px solid rgba(var(--crm-primary-rgb), .28) !important;
    outline-offset: 3px;
}

.warde-skip-link {
    position: fixed;
    z-index: 5000;
    inset-block-start: 12px;
    inset-inline-start: 12px;
    padding: .7rem 1rem;
    border-radius: 999px;
    color: #fff;
    background: var(--crm-primary);
    box-shadow: var(--crm-shadow-md);
    transform: translateY(-180%);
}

.warde-skip-link:focus {
    color: #fff;
    transform: translateY(0);
}

.warde-route-line {
    position: fixed;
    z-index: 4500;
    inset-block-start: 0;
    inset-inline-start: 0;
    width: 0;
    height: 3px;
    pointer-events: none;
    background: linear-gradient(90deg, var(--crm-primary), #d48291, var(--crm-wood));
    box-shadow: 0 0 18px rgba(var(--crm-primary-rgb), .4);
    animation: warde-route-load .72s var(--crm-ease) forwards;
}

@keyframes warde-route-load {
    0% { width: 0; opacity: 1; }
    75% { width: 86%; opacity: 1; }
    100% { width: 100%; opacity: 0; }
}

/* Application shell */
.warde-app-shell {
    min-height: 100vh;
}

.warde-sidebar {
    --bs-offcanvas-width: var(--crm-sidebar-width);
    position: sticky;
    z-index: 1035;
    inset-block-start: 0;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    color: var(--crm-sidebar-text);
    border: 0 !important;
    background:
        radial-gradient(circle at 18% 9%, rgba(152, 24, 48, .3), transparent 15rem),
        linear-gradient(160deg, rgba(255, 255, 255, .025), transparent 36%),
        var(--crm-sidebar) !important;
    box-shadow: 12px 0 45px rgba(22, 12, 8, .1);
}

html[dir="rtl"] .warde-sidebar {
    box-shadow: -12px 0 45px rgba(22, 12, 8, .1);
}

.warde-sidebar::after {
    position: absolute;
    z-index: 0;
    inset-inline-end: -72px;
    inset-block-end: -95px;
    width: 260px;
    height: 260px;
    content: "";
    pointer-events: none;
    border: 1px solid rgba(211, 81, 108, .11);
    border-radius: 44% 56% 62% 38%;
    transform: rotate(28deg);
}

.warde-sidebar .offcanvas-header,
.warde-sidebar .offcanvas-body {
    position: relative;
    z-index: 1;
}

.warde-sidebar .offcanvas-body {
    min-height: 0;
    overflow-y: auto;
}

.warde-sidebar-close {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    color: var(--crm-sidebar-text);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 50%;
    background: rgba(255, 255, 255, .06);
}

.warde-brand-panel {
    position: relative;
    margin: .85rem .85rem 1rem;
    padding: 1.1rem 1rem 1rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, .075);
    border-radius: var(--crm-radius-lg);
    background: linear-gradient(145deg, rgba(255, 255, 255, .065), rgba(255, 255, 255, .015));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045);
}

.warde-brand-mark {
    display: grid;
    min-height: 102px;
    margin-inline: auto;
    place-items: center;
}

.warde-brand-mark img {
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .24));
}

.warde-brand-name {
    margin: .15rem 0 0;
    overflow: hidden;
    color: #fff;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.08rem;
    font-weight: 600;
    letter-spacing: .055em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

html[dir="rtl"] .warde-brand-name {
    font-family: "Cairo", sans-serif;
    letter-spacing: 0;
}

.warde-brand-kicker {
    display: block;
    margin-block-start: .15rem;
    color: var(--crm-sidebar-muted);
    font-size: .66rem;
    font-weight: 600;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.warde-sidebar-tools {
    display: flex;
    justify-content: center;
    gap: .5rem;
    margin-block-start: .85rem;
}

.warde-sidebar-tool {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .45rem .72rem;
    color: var(--crm-sidebar-muted);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 999px;
    background: rgba(255, 255, 255, .035);
    font-size: .75rem;
    text-decoration: none;
}

.warde-sidebar-tool:hover,
.warde-sidebar-tool:focus-visible {
    color: #fff;
    border-color: rgba(211, 81, 108, .48);
    background: rgba(152, 24, 48, .22);
}

.warde-nav-label {
    margin: .35rem 1.4rem .55rem;
    color: #8f7f75;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.warde-sidebar-nav {
    padding-inline: .85rem;
}

.warde-sidebar-nav .nav-item + .nav-item {
    margin-block-start: .18rem;
}

.warde-sidebar-nav .nav-link,
.warde-sidebar-nav button.nav-link {
    position: relative;
    display: flex;
    width: 100%;
    min-height: 46px;
    align-items: center;
    gap: .75rem;
    padding: .68rem .8rem !important;
    overflow: hidden;
    color: var(--crm-sidebar-muted) !important;
    border: 1px solid transparent !important;
    border-radius: 13px;
    background: transparent;
    font-size: .86rem;
    font-weight: 500;
    text-align: start;
    text-decoration: none;
    transition-property: color, background-color, border-color, transform;
}

.warde-sidebar-nav .nav-link i {
    display: inline-grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    place-items: center;
    color: #a89285;
    border-radius: 9px;
    background: rgba(255, 255, 255, .04);
    font-size: 1rem;
}

.warde-sidebar-nav .nav-link:hover,
.warde-sidebar-nav .nav-link:focus-visible {
    color: #fff !important;
    border-color: rgba(255, 255, 255, .065) !important;
    background: rgba(255, 255, 255, .055);
    transform: translateX(2px);
}

html[dir="rtl"] .warde-sidebar-nav .nav-link:hover,
html[dir="rtl"] .warde-sidebar-nav .nav-link:focus-visible {
    transform: translateX(-2px);
}

.warde-sidebar-nav .nav-link.active {
    color: #fff !important;
    border-color: rgba(var(--crm-module-rgb), .35) !important;
    background: linear-gradient(90deg, rgba(var(--crm-module-rgb), .38), rgba(var(--crm-module-rgb), .12));
    box-shadow: inset 3px 0 0 var(--crm-module), 0 10px 26px rgba(0, 0, 0, .12);
    font-weight: 600;
}

html[dir="rtl"] .warde-sidebar-nav .nav-link.active {
    background: linear-gradient(-90deg, rgba(var(--crm-module-rgb), .38), rgba(var(--crm-module-rgb), .12));
    box-shadow: inset -3px 0 0 var(--crm-module), 0 10px 26px rgba(0, 0, 0, .12);
}

.warde-sidebar-nav .nav-link.active i {
    color: #fff;
    background: rgba(var(--crm-module-rgb), .24);
}

.warde-nav-divider {
    margin-block: .65rem !important;
    padding-block-start: .65rem !important;
    border-color: rgba(255, 255, 255, .07) !important;
}

.warde-sidebar-nav .warde-logout {
    color: #df8395 !important;
}

.warde-sidebar-nav .warde-logout:hover {
    color: #fff !important;
    border-color: rgba(211, 81, 108, .18) !important;
    background: rgba(152, 24, 48, .18);
}

.warde-user-panel {
    display: flex;
    align-items: center;
    gap: .72rem;
    margin: auto .85rem .9rem;
    padding: .75rem;
    border: 1px solid rgba(255, 255, 255, .075);
    border-radius: 15px;
    background: rgba(255, 255, 255, .035);
}

.warde-user-avatar {
    display: inline-grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 12px;
    background: linear-gradient(145deg, rgba(211, 81, 108, .9), rgba(120, 16, 37, .92));
    box-shadow: 0 8px 18px rgba(0, 0, 0, .2);
}

.warde-user-name {
    max-width: 150px;
    overflow: hidden;
    color: #fff;
    font-size: .82rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.warde-user-role {
    color: var(--crm-sidebar-muted);
    font-size: .66rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.warde-main {
    position: relative;
    min-width: 0;
    min-height: 100vh;
    padding: 0 !important;
}

.warde-commandbar {
    position: sticky;
    z-index: 1020;
    inset-block-start: 0;
    display: flex;
    min-height: 76px;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem clamp(1rem, 2.4vw, 2.25rem);
    border-block-end: 1px solid rgba(159, 139, 126, .18);
    background: color-mix(in srgb, var(--crm-bg) 84%, transparent);
    box-shadow: 0 8px 26px rgba(42, 24, 17, .035);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.warde-page-context {
    min-width: 0;
}

.warde-context-kicker {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin: 0 0 .05rem;
    color: var(--crm-text-faint);
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.warde-context-kicker::before {
    width: 18px;
    height: 2px;
    content: "";
    border-radius: 99px;
    background: var(--crm-module);
}

.warde-context-title {
    max-width: min(720px, 58vw);
    margin: 0;
    overflow: hidden;
    color: var(--crm-dark);
    font-size: clamp(1.08rem, 1.6vw, 1.35rem);
    font-weight: 650;
    letter-spacing: -.018em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

html[dir="rtl"] .warde-context-title {
    letter-spacing: 0;
}

.warde-command-actions {
    display: flex;
    align-items: center;
    gap: .65rem;
}

.warde-icon-button {
    display: inline-grid;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    place-items: center;
    color: var(--crm-text-soft);
    border: 1px solid var(--crm-card-border);
    border-radius: 13px;
    background: var(--crm-surface);
    box-shadow: var(--crm-shadow-sm);
}

.warde-icon-button:hover,
.warde-icon-button:focus-visible {
    color: var(--crm-primary);
    border-color: rgba(var(--crm-primary-rgb), .32);
    background: var(--crm-primary-soft);
    transform: translateY(-1px);
}

.warde-command-user {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: .55rem;
    padding: .35rem .72rem .35rem .4rem;
    color: var(--crm-text);
    border: 1px solid var(--crm-card-border);
    border-radius: 14px;
    background: var(--crm-surface);
    box-shadow: var(--crm-shadow-sm);
}

html[dir="rtl"] .warde-command-user {
    padding: .35rem .4rem .35rem .72rem;
}

.warde-command-user .warde-user-avatar {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    border-radius: 10px;
}

.warde-command-user-name {
    max-width: 150px;
    overflow: hidden;
    font-size: .78rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.warde-command-user-role {
    display: block;
    color: var(--crm-text-faint);
    font-size: .61rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.warde-page {
    width: 100%;
    max-width: 1680px;
    margin-inline: auto;
    padding: clamp(1rem, 2.4vw, 2.25rem);
    animation: warde-page-in .48s var(--crm-ease) both;
}

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

.warde-mobilebar {
    position: sticky;
    z-index: 1025;
    inset-block-start: 0;
    display: flex;
    min-height: 66px;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .6rem .8rem;
    border-block-end: 1px solid rgba(255, 255, 255, .08);
    background: rgba(18, 13, 11, .96);
    box-shadow: 0 12px 35px rgba(20, 10, 7, .2);
    backdrop-filter: blur(16px);
}

.warde-mobile-brand {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: .6rem;
    color: #fff;
    text-decoration: none;
}

.warde-mobile-brand img {
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, .22));
}

.warde-mobile-brand span {
    max-width: 120px;
    overflow: hidden;
    font-family: Georgia, "Times New Roman", serif;
    font-size: .95rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.warde-mobile-actions {
    display: flex;
    gap: .42rem;
}

.warde-mobile-actions .warde-icon-button {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    color: #eee4dd;
    border-color: rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .055);
    box-shadow: none;
}

/* Public shell */
.warde-public-nav {
    min-height: 74px;
    margin: 0 !important;
    border: 0;
    border-block-end: 1px solid var(--crm-card-border);
    background: color-mix(in srgb, var(--crm-surface) 88%, transparent);
    box-shadow: 0 8px 26px rgba(42, 24, 17, .04);
    backdrop-filter: blur(18px) saturate(140%);
}

.warde-public-brand {
    display: flex;
    align-items: center;
    gap: .72rem;
    color: var(--crm-dark) !important;
    text-decoration: none;
}

.warde-public-logo {
    flex: 0 0 92px;
}

.warde-public-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}

.warde-public-brand-name {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: .04em;
}

.warde-public-brand-subtitle {
    margin-block-start: .25rem;
    color: var(--crm-text-faint);
    font-family: var(--warde-font, "Outfit", sans-serif);
    font-size: .58rem;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.warde-public-main {
    position: relative;
    width: 100%;
    flex: 1 0 auto;
    padding-block: clamp(1.5rem, 4vw, 3.75rem);
}

.warde-public-main::before {
    position: absolute;
    z-index: -1;
    inset-block-start: 5%;
    inset-inline-end: -8rem;
    width: 30rem;
    height: 30rem;
    content: "";
    border: 1px solid rgba(var(--crm-primary-rgb), .07);
    border-radius: 44% 56% 61% 39%;
    transform: rotate(23deg);
}

/* Typography and page headings */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--crm-dark);
    font-weight: 650;
    letter-spacing: -.018em;
}

html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3,
html[dir="rtl"] h4,
html[dir="rtl"] h5,
html[dir="rtl"] h6 {
    letter-spacing: 0;
}

.warde-page > .row:first-child h1,
.warde-page > .row:first-child h2,
.warde-page > .d-flex:first-child h1,
.warde-page > .d-flex:first-child h2 {
    position: relative;
}

.warde-page > .row:first-child h1::after,
.warde-page > .row:first-child h2::after,
.warde-page > .d-flex:first-child h1::after,
.warde-page > .d-flex:first-child h2::after {
    display: block;
    width: 44px;
    height: 3px;
    margin-block-start: .55rem;
    content: "";
    border-radius: 99px;
    background: linear-gradient(90deg, var(--crm-module), var(--crm-wood));
}

.text-dark { color: var(--crm-dark) !important; }
.text-secondary { color: var(--crm-text-soft) !important; }
.text-muted { color: var(--crm-text-faint) !important; }
.text-primary { color: var(--crm-primary) !important; }
.bg-white { background-color: var(--crm-surface) !important; }
.bg-light { background-color: var(--crm-surface-muted) !important; }
.border { border-color: var(--crm-card-border) !important; }

/* Cards */
.card {
    overflow: clip;
    color: var(--crm-text);
    border: 1px solid var(--crm-card-border) !important;
    border-radius: var(--crm-radius-md);
    background: var(--crm-surface);
    box-shadow: var(--crm-shadow-sm);
    transition-property: border-color, box-shadow, transform, background-color;
}

.card.shadow-sm,
.card.shadow {
    box-shadow: var(--crm-shadow-sm) !important;
}

.card.shadow-lg {
    box-shadow: var(--crm-shadow-lg) !important;
}

.card-header {
    min-height: 58px;
    padding: 1rem 1.2rem;
    color: var(--crm-dark);
    border-block-end: 1px solid var(--crm-card-border);
    background: linear-gradient(180deg, color-mix(in srgb, var(--crm-surface) 94%, #fff), var(--crm-surface)) !important;
    font-weight: 650;
}

.card-header > span:first-child,
.card-header > h5:first-child {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}

.card-header i.text-primary {
    display: inline-grid;
    width: 30px;
    height: 30px;
    place-items: center;
    margin-inline-end: .4rem !important;
    border-radius: 9px;
    color: var(--crm-module) !important;
    background: rgba(var(--crm-module-rgb), .1);
}

.card-footer {
    border-block-start: 1px solid var(--crm-card-border);
    background: var(--crm-surface-muted);
}

.warde-page a.card:hover,
.warde-page .card.interactive:hover {
    border-color: color-mix(in srgb, var(--crm-card-border) 55%, var(--crm-primary)) !important;
    box-shadow: var(--crm-shadow-md) !important;
    transform: translateY(-2px);
}

/* Buttons */
.btn {
    min-height: 40px;
    padding: .56rem 1rem;
    border-radius: 11px;
    font-weight: 600;
    letter-spacing: .005em;
    transition-property: color, background-color, border-color, box-shadow, transform;
}

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

.btn:active:not(:disabled) {
    transform: translateY(0) scale(.985);
}

.btn-sm {
    min-height: 34px;
    padding: .38rem .7rem;
    border-radius: 9px;
    font-size: .78rem;
}

.btn-lg {
    min-height: 48px;
    padding: .72rem 1.25rem;
    border-radius: 13px;
}

.btn-primary {
    color: #fff !important;
    border-color: var(--crm-primary) !important;
    background: linear-gradient(145deg, color-mix(in srgb, var(--crm-primary) 88%, #fff), var(--crm-primary-hover)) !important;
    box-shadow: 0 8px 18px rgba(120, 16, 37, .16);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    color: #fff !important;
    border-color: var(--crm-primary-hover) !important;
    background: var(--crm-primary-hover) !important;
    box-shadow: 0 10px 25px rgba(120, 16, 37, .24), 0 0 0 .22rem rgba(var(--crm-primary-rgb), .14) !important;
}

.btn-outline-primary {
    color: var(--crm-primary);
    border-color: rgba(var(--crm-primary-rgb), .36);
    background: transparent;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus-visible {
    color: #fff;
    border-color: var(--crm-primary);
    background: var(--crm-primary);
}

.btn-outline-secondary {
    color: var(--crm-text-soft);
    border-color: var(--crm-border-strong);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus-visible {
    color: var(--crm-dark);
    border-color: var(--crm-text-soft);
    background: var(--crm-surface-muted);
}

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

.btn-outline-purple {
    color: var(--crm-plum) !important;
    border-color: var(--crm-plum) !important;
}

.btn-check:checked + .btn-outline-purple,
.btn-outline-purple:hover {
    color: #fff !important;
    background: var(--crm-plum) !important;
}

/* Forms */
.form-label,
.col-form-label {
    margin-block-end: .45rem;
    color: var(--crm-text-soft) !important;
    font-size: .76rem;
    font-weight: 650 !important;
    letter-spacing: .02em;
}

.form-control,
.form-select,
.input-group-text {
    min-height: 44px;
    color: var(--crm-text);
    border: 1px solid var(--crm-card-border);
    border-radius: 11px;
    background-color: var(--crm-surface-raised);
    box-shadow: inset 0 1px 1px rgba(33, 21, 16, .025);
    transition-property: border-color, box-shadow, background-color;
}

.input-group > .form-control,
.input-group > .form-select,
.input-group > .input-group-text,
.input-group > .btn {
    border-radius: 0;
}

.input-group > :first-child {
    border-start-start-radius: 11px !important;
    border-end-start-radius: 11px !important;
}

.input-group > :last-child {
    border-start-end-radius: 11px !important;
    border-end-end-radius: 11px !important;
}

.form-control:hover,
.form-select:hover {
    border-color: var(--crm-border-strong);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    color: var(--crm-text);
    border-color: rgba(var(--crm-primary-rgb), .62);
    background-color: var(--crm-surface-raised);
    box-shadow: 0 0 0 .23rem rgba(var(--crm-primary-rgb), .11);
}

.form-control::placeholder {
    color: var(--crm-text-faint);
    opacity: .78;
}

.form-control:disabled,
.form-select:disabled,
.form-control[readonly] {
    color: var(--crm-text-faint);
    background-color: var(--crm-surface-muted);
    opacity: .85;
}

textarea.form-control {
    min-height: 96px;
}

.form-check-input {
    width: 1.05rem;
    height: 1.05rem;
    border-color: var(--crm-border-strong);
    background-color: var(--crm-surface-raised);
}

.form-check-input:checked {
    border-color: var(--crm-primary);
    background-color: var(--crm-primary);
}

input[type="file"]::file-selector-button {
    color: var(--crm-text);
    border: 0;
    border-inline-end: 1px solid var(--crm-card-border);
    background: var(--crm-surface-muted);
    font-weight: 600;
}

.form-text {
    color: var(--crm-text-faint);
}

/* Tables */
.table-responsive {
    position: relative;
    border-radius: inherit;
    scrollbar-color: var(--crm-border-strong) transparent;
    scrollbar-width: thin;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--crm-text);
    --bs-table-border-color: var(--crm-card-border);
    --bs-table-hover-bg: rgba(var(--crm-primary-rgb), .035);
    --bs-table-hover-color: var(--crm-text);
    margin-block-end: 0;
    color: var(--crm-text);
    vertical-align: middle;
}

.table > :not(caption) > * > * {
    padding: .88rem .92rem;
    border-block-end-color: var(--crm-card-border);
}

.table thead th {
    color: var(--crm-text-soft);
    background: var(--crm-surface-muted) !important;
    font-size: .68rem;
    font-weight: 750;
    letter-spacing: .065em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody tr:last-child > * {
    border-block-end: 0;
}

.table-hover > tbody > tr:hover > * {
    color: var(--crm-text);
    background-color: rgba(var(--crm-primary-rgb), .035);
}

.table-light {
    --bs-table-bg: var(--crm-surface-muted);
    --bs-table-color: var(--crm-text-soft);
}

/* Badges and semantic states */
.badge {
    padding: .42em .7em;
    border-radius: 999px;
    font-weight: 650;
    letter-spacing: .01em;
}

.badge-admin {
    color: var(--crm-primary);
    background: var(--crm-primary-soft);
}

.badge-manager {
    color: var(--crm-warning);
    background: rgba(168, 100, 22, .12);
}

.badge-staff {
    color: var(--crm-info);
    background: rgba(55, 111, 121, .12);
}

.style-preproject {
    color: #fff !important;
    background: var(--crm-plum) !important;
}

/* Alerts */
.alert {
    padding: .9rem 1rem;
    color: var(--crm-text);
    border-width: 1px;
    border-radius: 13px;
    background: var(--crm-surface);
    box-shadow: var(--crm-shadow-sm);
}

.alert-danger {
    color: var(--crm-danger);
    border-color: color-mix(in srgb, var(--crm-danger) 32%, transparent);
    background: color-mix(in srgb, var(--crm-danger) 8%, var(--crm-surface));
}

.alert-success {
    color: var(--crm-success);
    border-color: color-mix(in srgb, var(--crm-success) 32%, transparent);
    background: color-mix(in srgb, var(--crm-success) 8%, var(--crm-surface));
}

.alert-warning {
    color: var(--crm-warning);
    border-color: color-mix(in srgb, var(--crm-warning) 32%, transparent);
    background: color-mix(in srgb, var(--crm-warning) 8%, var(--crm-surface));
}

/* Accordion, modals, dropdowns */
.accordion-item {
    overflow: hidden;
    color: var(--crm-text);
    border-color: var(--crm-card-border);
    background: var(--crm-surface);
}

.accordion-button {
    color: var(--crm-text);
    background: var(--crm-surface);
    box-shadow: none !important;
    font-weight: 600;
}

.accordion-button:not(.collapsed) {
    color: var(--crm-primary);
    background: var(--crm-primary-soft);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1060 !important;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050 !important;
}

.modal-dialog {
    position: relative;
    z-index: 1065 !important;
}

.modal-content {
    overflow: hidden;
    color: var(--crm-text);
    border: 1px solid var(--crm-card-border) !important;
    border-radius: var(--crm-radius-lg);
    background: var(--crm-surface);
    box-shadow: var(--crm-shadow-lg) !important;
}

.modal-header,
.modal-footer {
    border-color: var(--crm-card-border);
    background: var(--crm-surface) !important;
}

.modal-backdrop.show {
    opacity: .58;
    backdrop-filter: blur(2px);
}

.dropdown-menu {
    padding: .5rem;
    color: var(--crm-text);
    border-color: var(--crm-card-border);
    border-radius: 13px;
    background: var(--crm-surface-raised);
    box-shadow: var(--crm-shadow-md);
}

.dropdown-item {
    min-height: 38px;
    border-radius: 9px;
}

.dropdown-item:hover,
.dropdown-item:focus {
    color: var(--crm-primary);
    background: var(--crm-primary-soft);
}

/* Timeline */
.timeline {
    position: relative;
    margin: 0;
    padding-inline-start: 27px;
    list-style: none;
    border-inline-start: 2px solid var(--crm-card-border);
}

.timeline-item {
    position: relative;
    margin-block-end: 1.35rem;
}

.timeline-item:last-child {
    margin-block-end: 0;
}

.timeline-marker {
    position: absolute;
    inset-block-start: 3px;
    inset-inline-start: -36px;
    width: 16px;
    height: 16px;
    border: 3px solid var(--crm-surface);
    border-radius: 50%;
    background: var(--crm-border-strong);
    box-shadow: 0 0 0 2px var(--crm-card-border);
    transition-property: background-color, box-shadow, transform;
}

.timeline-item.active .timeline-marker {
    background: var(--crm-primary);
    box-shadow: 0 0 0 3px rgba(var(--crm-primary-rgb), .18);
    transform: scale(1.08);
}

.timeline-item.completed .timeline-marker {
    background: var(--crm-success);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--crm-success) 32%, transparent);
}

/* FullCalendar */
.fc {
    --fc-border-color: var(--crm-card-border);
    --fc-page-bg-color: var(--crm-surface);
    --fc-neutral-bg-color: var(--crm-surface-muted);
    --fc-list-event-hover-bg-color: var(--crm-primary-soft);
    --fc-today-bg-color: rgba(var(--crm-primary-rgb), .065);
    color: var(--crm-text);
}

.fc .fc-toolbar-title {
    color: var(--crm-dark);
    font-size: 1.15rem;
    font-weight: 700;
}

.fc .fc-button-primary {
    border-color: var(--crm-primary) !important;
    background: var(--crm-primary) !important;
    box-shadow: none !important;
}

.fc .fc-button-primary:hover,
.fc .fc-button-primary:not(:disabled).fc-button-active {
    border-color: var(--crm-primary-hover) !important;
    background: var(--crm-primary-hover) !important;
}

.fc-theme-standard td,
.fc-theme-standard th,
.fc-theme-standard .fc-scrollgrid {
    border-color: var(--crm-card-border);
}

.fc .fc-col-header-cell-cushion,
.fc .fc-daygrid-day-number {
    color: var(--crm-text-soft);
    text-decoration: none;
}

.fc .fc-event {
    border: 0;
    border-radius: 7px;
    box-shadow: 0 4px 10px rgba(33, 18, 13, .12);
}

/* Login and public tracker */
body[data-page="login"] .warde-public-main,
body[data-page="track"] .warde-public-main {
    display: flex;
    align-items: center;
}

body[data-page="login"] .warde-public-main > .container,
body[data-page="track"] .warde-public-main > .container {
    width: 100%;
}

body[data-page="login"] .card {
    position: relative;
    overflow: hidden;
    border-radius: var(--crm-radius-lg);
    box-shadow: var(--crm-shadow-lg) !important;
}

body[data-page="login"] .card::before {
    position: absolute;
    inset-block-start: 0;
    inset-inline: 0;
    height: 4px;
    content: "";
    background: linear-gradient(90deg, var(--crm-primary), #c44c65, var(--crm-wood));
}

.warde-login-stage {
    min-height: min(720px, calc(100dvh - 170px));
}

.warde-login-card {
    overflow: hidden;
}

.warde-login-brand-pane {
    position: relative;
    min-height: 560px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #f8eee7;
    background:
        radial-gradient(circle at 22% 15%, rgba(152, 24, 48, .5), transparent 16rem),
        linear-gradient(150deg, rgba(255, 255, 255, .035), transparent 43%),
        #171210;
}

.warde-login-brand-pane::before,
.warde-login-brand-pane::after {
    position: absolute;
    content: "";
    pointer-events: none;
    border: 1px solid rgba(211, 81, 108, .14);
    border-radius: 44% 56% 62% 38%;
}

.warde-login-brand-pane::before {
    inset-inline-end: -7rem;
    inset-block-start: -7rem;
    width: 25rem;
    height: 25rem;
    transform: rotate(24deg);
}

.warde-login-brand-pane::after {
    inset-inline-start: -8rem;
    inset-block-end: -9rem;
    width: 28rem;
    height: 28rem;
    transform: rotate(-18deg);
}

.warde-login-brand-content {
    position: relative;
    z-index: 1;
    width: min(320px, 78%);
    text-align: center;
}

.warde-login-brand-content img {
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, .32));
}

.warde-login-kicker,
.warde-form-eyebrow {
    display: block;
    margin: 1.1rem 0 .35rem;
    color: #cdbdb3;
    font-size: .67rem;
    font-weight: 750;
    letter-spacing: .17em;
    text-transform: uppercase;
}

.warde-login-brand-content h2 {
    margin: 0;
    color: #fff;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.6rem, 3vw, 2.15rem);
    letter-spacing: .03em;
}

html[dir="rtl"] .warde-login-brand-content h2 {
    font-family: "Cairo", sans-serif;
    letter-spacing: 0;
}

.warde-login-capabilities {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .45rem;
    margin-block-start: 1.65rem;
}

.warde-login-capabilities span {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .62rem;
    color: #cdbdb3;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 999px;
    background: rgba(255, 255, 255, .035);
    font-size: .68rem;
}

.warde-login-capabilities i {
    color: #d3516c;
}

.warde-login-form-pane {
    display: flex;
    min-height: 560px;
    flex-direction: column;
    justify-content: center;
    background: var(--crm-surface);
}

.warde-form-eyebrow {
    margin: 0 0 .35rem;
    color: var(--crm-primary);
}

.warde-login-track-link {
    border-color: var(--crm-card-border) !important;
}

body[data-page="track"] .uppercase-input {
    text-transform: uppercase;
}

/* Footer */
.warde-footer {
    flex-shrink: 0;
    padding: 1rem clamp(1rem, 2.4vw, 2.25rem);
    color: var(--crm-text-faint);
    border-block-start: 1px solid rgba(159, 139, 126, .17);
    background: transparent;
    font-size: .72rem;
}

.warde-footer-inner {
    display: flex;
    max-width: 1680px;
    margin-inline: auto;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.warde-footer-mark {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
}

.warde-footer-mark::before {
    width: 18px;
    height: 2px;
    content: "";
    border-radius: 99px;
    background: var(--crm-primary);
}

/* Dark-mode repairs for Bootstrap's fixed utility colors */
html[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(180%);
}

html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="datetime-local"] {
    color-scheme: dark;
}

html[data-theme="dark"] .shadow-sm,
html[data-theme="dark"] .shadow,
html[data-theme="dark"] .shadow-lg {
    box-shadow: var(--crm-shadow-sm) !important;
}

html[data-theme="dark"] .border-primary-subtle,
html[data-theme="dark"] .border-success-subtle,
html[data-theme="dark"] .border-warning-subtle,
html[data-theme="dark"] .border-danger-subtle {
    border-color: var(--crm-card-border) !important;
}

html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
    transition-property: color, background-color, border-color, box-shadow !important;
    transition-duration: 220ms !important;
}

/* Responsive behavior */
@media (min-width: 768px) {
    .warde-sidebar.col-md-3 {
        width: var(--crm-sidebar-width);
        flex: 0 0 var(--crm-sidebar-width);
    }

    .warde-main.col-md-9 {
        width: calc(100% - var(--crm-sidebar-width));
        flex: 0 0 calc(100% - var(--crm-sidebar-width));
        margin-inline-start: 0 !important;
    }
}

@media (max-width: 991.98px) {
    :root { --crm-sidebar-width: 258px; }
    .warde-command-user { display: none; }
    .warde-page { padding: 1.25rem; }
}

@media (max-width: 767.98px) {
    body.warde-ui::before { opacity: .2; }

    .warde-sidebar {
        position: fixed;
        z-index: 1045;
        height: 100dvh;
        min-height: 100dvh;
    }

    .warde-commandbar {
        position: relative;
        min-height: 65px;
        padding: .7rem 1rem;
    }

    .warde-command-actions .warde-icon-button {
        display: none;
    }

    .warde-context-title {
        max-width: 72vw;
        font-size: 1rem;
    }

    .warde-context-kicker {
        font-size: .6rem;
    }

    .warde-page {
        padding: 1rem .78rem 1.5rem;
    }

    .warde-page > .row:first-child,
    .warde-page > .d-flex:first-child {
        row-gap: .75rem;
    }

    .warde-page > .row:first-child .btn,
    .warde-page > .d-flex:first-child .btn {
        min-height: 42px;
    }

    .card {
        border-radius: 14px;
    }

    .card-header,
    .card-body {
        padding-inline: 1rem !important;
    }

    .table > :not(caption) > * > * {
        padding: .78rem .72rem;
    }

    .modal-dialog {
        margin: .65rem;
    }

    .modal-content {
        max-height: calc(100dvh - 1.3rem);
    }

    .modal-body {
        overflow-y: auto;
    }

    .warde-footer-inner {
        flex-direction: column;
        text-align: center;
    }

    .fc .fc-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: .6rem;
    }

    .fc .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
    }
}

@media (max-width: 420px) {
    .warde-mobile-brand span { display: none; }
    .warde-public-brand-text { display: none; }
    .warde-public-logo { width: 76px; flex-basis: 76px; }
    .warde-public-nav .btn { padding-inline: .65rem; }
    .warde-public-nav .btn span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

@media print {
    :root,
    html[data-theme="dark"] {
        color-scheme: light;
        --crm-bg: #fff;
        --crm-surface: #fff;
        --crm-surface-raised: #fff;
        --crm-surface-muted: #f6f2ed;
        --crm-card-border: #d8d0c9;
        --crm-text: #181412;
        --crm-dark: #181412;
        --crm-text-soft: #514a45;
    }

    body.warde-ui {
        color: #181412 !important;
        background: #fff !important;
    }

    body.warde-ui::before,
    .warde-sidebar,
    .warde-mobilebar,
    .warde-commandbar,
    .warde-footer,
    .warde-route-line,
    .btn,
    .no-print {
        display: none !important;
    }

    .warde-main,
    .warde-page {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .card,
    .table-responsive {
        overflow: visible !important;
        break-inside: avoid;
        box-shadow: none !important;
    }
}
