.routing-page {
    max-width: 1380px;
    margin: 0 auto;
    color: #203047;
    font-family: Cairo, Tajawal, Arial, sans-serif;
}
.routing-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
    padding: 28px;
    border-radius: 20px;
    color: #fff;
    background: linear-gradient(135deg, #123d5d, #008069 70%, #00a884);
    box-shadow: 0 16px 36px rgba(17, 61, 93, .18);
}
.routing-hero span { opacity: .78; }
.routing-hero h2 { margin: 5px 0 7px; font-weight: 800; }
.routing-hero p { margin: 0; }
.routing-hero-count {
    min-width: 125px;
    padding: 14px 22px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 16px;
    text-align: center;
    background: rgba(255,255,255,.12);
}
.routing-hero-count strong, .routing-hero-count small { display: block; }
.routing-hero-count strong { font-size: 30px; }
.routing-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(330px, .85fr);
    gap: 20px;
    align-items: start;
}
.routing-editor-card, .routing-rules-card, .routing-events-card {
    overflow: hidden;
    border: 1px solid #e0e8ee;
    border-radius: 17px;
    background: #fff;
    box-shadow: 0 8px 25px rgba(30, 60, 85, .06);
}
.routing-editor-card { padding: 23px; }
.routing-editor-card > header, .routing-rules-card > header, .routing-events-card > header,
.routing-condition-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}
.routing-editor-card > header { margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid #e7edf1; }
.routing-editor-card h3, .routing-rules-card h3, .routing-events-card h3 { margin: 0 0 5px; font-weight: 700; }
.routing-editor-card p, .routing-events-card p, .routing-condition-heading p { margin: 0; color: #6b7b88; font-size: 12px; }
.routing-field { margin-bottom: 17px; }
.routing-field > label { display: block; margin-bottom: 7px; color: #314659; }
.routing-groups-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.routing-source-card { margin-bottom: 17px; padding: 13px; border: 1px solid #dfe9e7; border-radius: 12px; background: #f8fbfa; }
.routing-source-title { margin-bottom: 10px; color: #314659; font-weight: 700; }
.routing-source-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.routing-source-modes label { min-width: 0; margin: 0; cursor: pointer; }
.routing-source-modes input { position: absolute; opacity: 0; }
.routing-source-modes span { display: block; padding: 8px 4px; border: 1px solid #d8e4e0; border-radius: 8px; color: #506473; background: #fff; font-size: 11px; text-align: center; }
.routing-source-modes input:checked + span { border-color: #25a987; color: #086d55; background: #e4f6f0; font-weight: 700; }
.routing-source-modes input:focus-visible + span { outline: 2px solid #008069; outline-offset: 2px; }
.routing-source-panel { margin-top: 12px; }
.routing-source-panel[hidden], .routing-source-category[hidden] { display: none !important; }
.routing-source-panel > label { display: block; margin-bottom: 7px; color: #415565; font-size: 12px; font-weight: 700; }
.routing-source-panel > small { display: block; margin-top: 7px; color: #647782; line-height: 1.6; }
.routing-category-search { margin-bottom: 8px; }
.routing-source-category-list { display: grid; gap: 5px; max-height: 200px; overflow-y: auto; padding: 5px; border: 1px solid #e1e9e6; border-radius: 9px; background: #fff; }
.routing-source-category { display: flex; align-items: center; gap: 8px; margin: 0; padding: 7px 9px; border-radius: 7px; cursor: pointer; font-size: 12px; }
.routing-source-category:hover { background: #eef8f4; }
.routing-source-category input { margin: 0; }
.routing-source-category small { margin-right: auto; color: #718591; white-space: nowrap; }
.routing-category-color { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; }
.routing-source-empty { padding: 10px; border-radius: 8px; background: #fff6e3; }
.routing-condition-heading { margin: 7px 0 12px; }
.routing-condition-heading h4 { margin: 0 0 4px; font-weight: 700; }
.routing-conditions { display: flex; flex-direction: column; gap: 9px; }
.routing-condition-row {
    display: grid;
    grid-template-columns: 105px 145px minmax(155px, .75fr) minmax(180px, 1.25fr) 40px;
    gap: 8px;
    align-items: center;
    padding: 11px;
    border: 1px solid #dfe8ed;
    border-radius: 12px;
    background: #f8fafb;
}
.routing-join { color: #008069; font-weight: 700; }
.routing-join.is-first { visibility: hidden; }
.routing-remove-condition {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 9px;
    color: #d14d4d;
    background: #fcebec;
}
.routing-remove-condition:disabled { cursor: not-allowed; color: #aab4bb; background: #edf1f3; }
.routing-enabled { margin: 18px 0; }
.routing-auto-reply { margin-top: 18px; padding: 14px 16px; border: 1px solid #cde8df; border-radius: 11px; background: #f2faf7; }
.routing-auto-reply label { display: flex; align-items: flex-start; gap: 10px; margin: 0; cursor: pointer; }
.routing-auto-reply input { flex: 0 0 auto; margin-top: 3px; accent-color: #008069; }
.routing-auto-reply strong { display: block; color: #174d40; }
.routing-auto-reply small { display: block; margin-top: 5px; color: #526e66; line-height: 1.65; }
.routing-enabled label { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.routing-enabled input { position: absolute; opacity: 0; }
.routing-enabled label > span { position: relative; width: 44px; height: 24px; border-radius: 20px; background: #b5c0c7; transition: .2s; }
.routing-enabled label > span:after { content: ""; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.routing-enabled input:checked + span { background: #00a884; }
.routing-enabled input:checked + span:after { transform: translateX(-20px); }
.routing-forward-preview { display: flex; align-items: center; gap: 13px; margin-bottom: 17px; padding: 13px; border-radius: 11px; color: #385b52; background: #eaf7f3; }
.routing-forward-preview > i { font-size: 22px; color: #00a884; }
.routing-forward-preview strong { display: block; margin-bottom: 3px; }
.routing-forward-preview p { margin: 0; font-size: 11px; }
.routing-save { min-width: 210px; }
.routing-rules-card > header { padding: 18px; border-bottom: 1px solid #e7edf1; }
.routing-rules-card > header span { min-width: 30px; padding: 4px 9px; border-radius: 15px; color: #fff; text-align: center; background: #00a884; }
.routing-rules-list { max-height: 840px; overflow-y: auto; }
.routing-rule { padding: 16px; border-bottom: 1px solid #e8edf1; }
.routing-rule:last-child { border-bottom: 0; }
.routing-rule.is-paused { opacity: .68; background: #fafbfb; }
.routing-rule-top { display: flex; justify-content: space-between; gap: 12px; }
.routing-rule-top > div { display: flex; min-width: 0; flex-direction: column; }
.routing-rule-top strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.routing-rule-top small { color: #6c7d89; }
.routing-rule-status { width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: #adb9bf; }
.routing-rule.is-active .routing-rule-status { background: #00a884; box-shadow: 0 0 0 4px rgba(0,168,132,.12); }
.routing-rule-path { display: flex; align-items: center; gap: 8px; margin: 12px 0; color: #526673; font-size: 11px; }
.routing-rule-path span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.routing-rule-path i { color: #00a884; }
.routing-reply-badge { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 10px; padding: 5px 9px; border-radius: 14px; color: #08765e; background: #e0f5ee; font-size: 11px; }
.routing-rule-conditions { display: flex; flex-direction: column; gap: 5px; padding: 10px; border-radius: 9px; background: #f4f7f8; font-size: 11px; }
.routing-rule-conditions b { color: #008069; }
.routing-rule-stats { display: flex; gap: 14px; margin: 11px 0; color: #6b7b88; font-size: 10px; }
.routing-rule-stats i.fa-check { color: #00a884; }
.routing-rule-stats i.fa-exclamation-triangle { color: #e19b2c; }
.routing-rule-actions { display: flex; align-items: center; gap: 6px; }
.routing-rule-actions form { margin: 0; }
.routing-empty { padding: 45px 20px; color: #778791; text-align: center; }
.routing-empty i { font-size: 35px; color: #b2c0c7; }
.routing-empty.compact { padding: 25px; }
.routing-events-card { margin-top: 20px; }
.routing-events-card > header { padding: 18px 20px; border-bottom: 1px solid #e7edf1; }
.routing-events-card table { margin: 0; }
.routing-events-card th { color: #5b6f7b; background: #f7f9fa; }
.routing-event-preview { max-width: 310px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.routing-event-status { display: inline-block; padding: 4px 8px; border-radius: 12px; font-size: 10px; }
.routing-event-status.is-forwarded { color: #08765e; background: #dff5ee; }
.routing-event-status.is-failed { color: #ae3434; background: #fbe4e4; }
.routing-event-status.is-processing { color: #8a671d; background: #fbf0d7; }
.routing-event-error { display: block; max-width: 220px; margin-top: 4px; color: #b64b4b; }
@media (max-width: 1100px) {
    .routing-layout { grid-template-columns: 1fr; }
    .routing-rules-list { max-height: none; }
}
@media (max-width: 760px) {
    .routing-hero, .routing-editor-card > header, .routing-events-card > header { align-items: stretch; flex-direction: column; }
    .routing-hero-count { width: 100%; }
    .routing-groups-grid { grid-template-columns: 1fr; }
    .routing-condition-row { grid-template-columns: 82px 1fr 40px; }
    .routing-condition-field, .routing-condition-operator { grid-column: auto; }
    .routing-condition-value { grid-column: 1 / 3; }
    .routing-remove-condition { grid-column: 3; grid-row: 1; }
    .routing-save { width: 100%; }
}
