:root {
    --ewa-primary: #00626e;
    --ewa-primary-2: #007d8c;
    --ewa-secondary: #9c4400;
    --ewa-bg: #f8fafa;
    --ewa-surface: #ffffff;
    --ewa-surface-soft: #f2f4f4;
    --ewa-surface-mid: #e6e8e8;
    --ewa-text: #191c1d;
    --ewa-muted: #3e494b;
    --ewa-outline: rgba(189, 200, 203, 0.35);
}

html, body {
    min-height: 100%;
    overflow-x: hidden;
}

body {
    background: radial-gradient(circle at top right, rgba(0, 125, 140, 0.07), transparent 28%), var(--ewa-bg);
    color: var(--ewa-text);
    font-family: "Century Gothic", "Tajawal", sans-serif;
}

.font-headline {
    font-family: "Century Gothic", "Tajawal", sans-serif;
}

.text-primary {
    color: var(--ewa-primary) !important;
}

.text-secondary {
    color: var(--ewa-secondary) !important;
}

.bg-primary {
    background-color: var(--ewa-primary) !important;
}

.bg-secondary {
    background-color: var(--ewa-secondary) !important;
}

.border-primary {
    border-color: var(--ewa-primary) !important;
}

html[data-theme="dark"] {
    --ewa-primary: #2fc0cc;
    --ewa-primary-2: #128f9e;
    --ewa-secondary: #ff9d4c;
    --ewa-bg: #071417;
    --ewa-surface: #102126;
    --ewa-surface-soft: #172b31;
    --ewa-surface-mid: #203a42;
    --ewa-text: #eef8fa;
    --ewa-muted: #b6c6ca;
    --ewa-outline: rgba(158, 185, 191, 0.28);
}

html[data-theme="dark"] body {
    background: radial-gradient(circle at top right, rgba(47, 192, 204, 0.13), transparent 28%),
        radial-gradient(circle at bottom left, rgba(255, 157, 76, 0.1), transparent 24%),
        var(--ewa-bg);
}

html[data-theme="dark"] .bg-background,
html[data-theme="dark"] .bg-surface {
    background-color: var(--ewa-bg) !important;
}

html[data-theme="dark"] .bg-white {
    background-color: var(--ewa-surface) !important;
}

html[data-theme="dark"] .bg-surface-low {
    background-color: var(--ewa-surface-soft) !important;
}

html[data-theme="dark"] .bg-surface-high {
    background-color: var(--ewa-surface-mid) !important;
}

html[data-theme="dark"] .text-textmain {
    color: var(--ewa-text) !important;
}

html[data-theme="dark"] .text-muted {
    color: var(--ewa-muted) !important;
}

html[data-theme="dark"] .border-outline,
html[data-theme="dark"] .border-outline\/40 {
    border-color: var(--ewa-outline) !important;
}

.glass-panel {
    background: rgba(248, 250, 250, 0.8);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

html[data-theme="dark"] .glass-panel {
    background: rgba(16, 33, 38, 0.82);
}

.topbar-shell {
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(189, 200, 203, 0.35);
    box-shadow: 0 18px 60px -32px rgba(8, 31, 35, 0.35);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

html[data-theme="dark"] .topbar-shell {
    background: rgba(16, 33, 38, 0.9);
    border-color: var(--ewa-outline);
    box-shadow: 0 18px 60px -32px rgba(0, 0, 0, 0.75);
}

.ewa-card {
    background: var(--ewa-surface);
    border-radius: 1.5rem;
    box-shadow: 0 10px 40px -8px rgba(25, 28, 29, 0.06);
    max-width: 100%;
}

html[data-theme="dark"] .ewa-card {
    border: 1px solid var(--ewa-outline);
    box-shadow: 0 18px 48px -34px rgba(0, 0, 0, 0.9);
}

.ewa-soft {
    background: var(--ewa-surface-soft);
    border-radius: 1.25rem;
}

.ewa-pill {
    border-radius: 999px;
}

.ghost-field {
    background: rgba(225, 227, 227, 0.75);
    border: 1px solid var(--ewa-outline);
    border-radius: 1rem;
}

html[data-theme="dark"] .ghost-field {
    background: rgba(23, 43, 49, 0.95);
    color: var(--ewa-text);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    color: var(--ewa-text);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: rgba(182, 198, 202, 0.72);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.badge-primary {
    background: rgba(0, 98, 110, 0.1);
    color: var(--ewa-primary);
}

.badge-secondary {
    background: rgba(156, 68, 0, 0.12);
    color: var(--ewa-secondary);
}

.badge-muted {
    background: rgba(62, 73, 75, 0.08);
    color: var(--ewa-muted);
}

html[data-theme="dark"] .badge-muted {
    background: rgba(238, 248, 250, 0.08);
}

.btn-gradient {
    background: linear-gradient(135deg, var(--ewa-primary), var(--ewa-primary-2));
    color: white;
}

.btn-secondary {
    background: var(--ewa-secondary);
    color: white;
}

.btn-tertiary {
    color: var(--ewa-primary);
    background: rgba(0, 98, 110, 0.08);
}

.table-shell table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.75rem;
    min-width: 42rem;
}

.table-shell {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-shell thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ewa-muted);
    text-align: left;
    padding: 0 1rem 0.25rem;
}

html[dir="rtl"] .table-shell thead th {
    text-align: right;
}

.table-shell tbody tr {
    background: var(--ewa-surface);
}

.table-shell tbody td {
    padding: 1rem;
    vertical-align: top;
}

.table-shell tbody tr td:first-child {
    border-top-left-radius: 1rem;
    border-bottom-left-radius: 1rem;
}

.table-shell tbody tr td:last-child {
    border-top-right-radius: 1rem;
    border-bottom-right-radius: 1rem;
}

html[dir="rtl"] .table-shell tbody tr td:first-child {
    border-radius: 0 1rem 1rem 0;
}

html[dir="rtl"] .table-shell tbody tr td:last-child {
    border-radius: 1rem 0 0 1rem;
}

.project-tabs a {
    border-radius: 999px;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--ewa-muted);
}

.project-tabs a.active {
    background: white;
    color: var(--ewa-primary);
    box-shadow: 0 10px 30px -12px rgba(25, 28, 29, 0.12);
}

.status-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
    display: inline-block;
}

.status-open { background: #00626e; }
.status-pending { background: #fd7613; }
.status-closed { background: #4e5b61; }
.status-danger { background: #ba1a1a; }

.editorial-grid {
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .editorial-grid {
        grid-template-columns: repeat(12, minmax(0, 1fr));
    }
}

.empty-state {
    border: 2px dashed rgba(189, 200, 203, 0.5);
    background: rgba(255, 255, 255, 0.65);
    border-radius: 1.5rem;
}

html[data-theme="dark"] .empty-state {
    background: rgba(16, 33, 38, 0.78);
    border-color: var(--ewa-outline);
}

.app-main-shell {
    position: relative;
    width: 100%;
    min-width: 0;
}

img,
video,
canvas,
svg {
    max-width: 100%;
}

input,
select,
textarea,
button {
    max-width: 100%;
}

.login-shell,
.login-card {
    min-width: 0;
}

.context-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: rgba(0, 98, 110, 0.08);
    color: var(--ewa-primary);
    font-size: 0.78rem;
    font-weight: 700;
}

.page-hero {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.page-hero p {
    color: var(--ewa-muted);
    max-width: 60rem;
}

.filter-toolbar {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    margin-bottom: 2rem;
}

.metric-strip {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-tile {
    background: rgba(242, 244, 244, 0.9);
    border: 1px solid rgba(189, 200, 203, 0.28);
    border-radius: 1.25rem;
    padding: 1rem;
}

html[data-theme="dark"] .metric-tile {
    background: rgba(23, 43, 49, 0.9);
    border-color: var(--ewa-outline);
}

.metric-tile .metric-label {
    color: var(--ewa-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.metric-tile .metric-value {
    color: var(--ewa-primary);
    font-family: "Century Gothic", "Tajawal", sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.1;
    margin-top: 0.45rem;
}

.progress-track {
    height: 0.55rem;
    border-radius: 999px;
    background: rgba(189, 200, 203, 0.35);
    overflow: hidden;
}

.progress-track > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--ewa-primary), var(--ewa-primary-2));
}

.workspace-hero {
    display: grid;
    gap: 1.25rem;
}

.workspace-panel {
    border: 1px solid rgba(189, 200, 203, 0.22);
}

.message-stream {
    display: grid;
    gap: 1rem;
}

.chat-bubble {
    border-radius: 1.5rem;
    padding: 1rem 1.1rem;
    background: rgba(242, 244, 244, 0.94);
    border: 1px solid rgba(189, 200, 203, 0.22);
}

html[data-theme="dark"] .chat-bubble {
    background: rgba(23, 43, 49, 0.95);
    border-color: var(--ewa-outline);
}

.chat-bubble.self {
    background: rgba(0, 98, 110, 0.08);
    border-color: rgba(0, 98, 110, 0.16);
}

.sidebar-link {
    border-radius: 1rem;
    color: var(--ewa-muted);
    font-weight: 600;
    transition: all 160ms ease;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(255, 255, 255, 0.96);
    color: var(--ewa-primary);
    box-shadow: 0 12px 32px -24px rgba(8, 31, 35, 0.6);
}

html[data-theme="dark"] .sidebar-link:hover,
html[data-theme="dark"] .sidebar-link.active {
    background: rgba(238, 248, 250, 0.08);
    box-shadow: none;
}

.project-tab-shell {
    position: sticky;
    top: 6.5rem;
    z-index: 20;
    scrollbar-width: none;
}

.project-tab-shell::-webkit-scrollbar {
    display: none;
}

.project-tab-link {
    white-space: nowrap;
    border-radius: 999px;
    padding: 0.85rem 1.1rem;
    font-weight: 700;
    color: var(--ewa-muted);
    transition: all 160ms ease;
}

.project-tab-link:hover,
.project-tab-link.active {
    background: rgba(255, 255, 255, 0.98);
    color: var(--ewa-primary);
    box-shadow: 0 16px 32px -24px rgba(8, 31, 35, 0.55);
}

html[data-theme="dark"] .project-tab-link:hover,
html[data-theme="dark"] .project-tab-link.active,
html[data-theme="dark"] .project-tabs a.active {
    background: rgba(238, 248, 250, 0.08);
}

.stat-card {
    display: block;
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
    border: 1px solid rgba(189, 200, 203, 0.22);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 22px 50px -26px rgba(8, 31, 35, 0.45);
}

.record-row {
    border: 1px solid transparent;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.record-row:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 98, 110, 0.12);
    box-shadow: 0 18px 30px -28px rgba(8, 31, 35, 0.45);
}

.record-anchor:target {
    outline: 3px solid rgba(0, 98, 110, 0.18);
    box-shadow: 0 0 0 6px rgba(0, 98, 110, 0.07);
}

.alert-strip {
    border-radius: 1.25rem;
    border: 1px solid transparent;
    box-shadow: 0 12px 30px -24px rgba(8, 31, 35, 0.45);
}

.alert-success {
    background: rgba(0, 98, 110, 0.08);
    border-color: rgba(0, 98, 110, 0.14);
    color: var(--ewa-primary);
}

.alert-error {
    background: rgba(186, 26, 26, 0.08);
    border-color: rgba(186, 26, 26, 0.15);
    color: #8f1212;
}

.line-clamp-2,
.line-clamp-3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    -webkit-line-clamp: 2;
}

.line-clamp-3 {
    -webkit-line-clamp: 3;
}

@media (max-width: 1023px) {
    .project-tab-shell {
        top: 5.75rem;
    }

    [data-sidebar] {
        display: block;
        max-width: 88vw;
        width: 22rem;
        border-radius: 0 1.75rem 1.75rem 0;
    }

    html[dir="rtl"] [data-sidebar] {
        border-radius: 1.75rem 0 0 1.75rem;
    }

    .table-shell table {
        min-width: 36rem;
    }

    .topbar-shell {
        border-radius: 1.35rem;
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .project-tab-link {
        padding: 0.75rem 0.95rem;
        font-size: 0.92rem;
    }

    .metric-tile .metric-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 767px) {
    body {
        background: var(--ewa-bg);
    }

    .ewa-card {
        border-radius: 1.15rem;
    }

    .app-main-shell {
        padding-left: 1rem;
        padding-right: 1rem;
        padding-top: 1rem;
    }

    .topbar-shell {
        padding: 1rem;
    }

    .topbar-shell > div {
        min-width: 0;
        width: 100%;
    }

    .topbar-shell .ewa-card,
    .topbar-shell .ewa-soft {
        border-radius: 1rem;
    }

    .metric-strip {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .table-shell table {
        min-width: 30rem;
    }

    .project-tab-shell {
        top: 5.4rem;
        margin-left: -1rem;
        margin-right: -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .chat-bubble {
        max-width: 100%;
    }

    .login-shell {
        padding: 0;
    }

    .login-card {
        border-radius: 1.35rem;
    }

    .table-shell {
        margin-left: -0.35rem;
        margin-right: -0.35rem;
        padding-left: 0.35rem;
        padding-right: 0.35rem;
    }
}

@media (min-width: 768px) {
    .page-hero {
        flex-direction: row;
        align-items: end;
        justify-content: space-between;
    }

    .filter-toolbar {
        grid-template-columns: 1.7fr repeat(4, minmax(0, 1fr));
        align-items: end;
    }

    .workspace-hero {
        grid-template-columns: minmax(0, 1.7fr) minmax(18rem, 0.95fr);
        align-items: start;
    }
}
