* {
    box-sizing: border-box;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

body {
    margin: 0;
    background: #f3f5f9;
    color: #1d2433;
}

.hidden {
    display: none !important;
}

.inbound-visually-hidden-focusable {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    border: 0 !important;
    white-space: nowrap !important;
}

.inbound-aside-muted {
    display: none !important;
}

.footer-technical-hidden {
    display: none !important;
}

.inbound-field-search-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.inbound-field-search-wrap .inbound-span-2,
.inbound-field-search-wrap select {
    width: 100%;
    min-width: 0;
}

.inbound-select-filter-input {
    width: 100%;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 7px;
    border: 1px solid #b8c4d6;
    background: #fbfcfe;
}

.inbound-select-filter-input::placeholder {
    color: #6b7587;
}

select,
select option {
    background-color: #fff;
    color: #10233f;
}

select option {
    background-color: #ffffff !important;
    color: #0a1a2e !important;
}

input:not([type="button"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]),
textarea,
select {
    color: #0a1a2e !important;
    background-color: #ffffff !important;
}

select:disabled,
input:disabled,
textarea:disabled {
    background-color: #eef2f8;
    color: #6b7587;
    opacity: 1;
}

.inbound-auto-field {
    background-color: #f1f5fb !important;
    color: #667085 !important;
    border-style: dashed;
}

.inbound-route-cell-select {
    min-width: 220px;
    vertical-align: top;
}

.settings-doc-approval-list {
    width: 100%;
    max-width: 560px;
    max-height: 280px;
    overflow-y: auto;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #b8c4d6;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-doc-approval-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1.35;
}

.settings-doc-approval-item:hover {
    background: #f0f4fa;
}

.settings-doc-approval-item input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
    width: 1.05rem;
    height: 1.05rem;
    cursor: pointer;
}

.inbound-approval-hint {
    margin: 0 0 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #eef3fb;
    border: 1px solid #c5d4ec;
}

.login-root {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 16px;
    background: linear-gradient(165deg, #071c33 0%, #0b2744 38%, #124a8a 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 18px;
    padding: 28px 26px 22px;
    box-shadow: 0 24px 56px rgba(4, 18, 36, 0.28);
}

.login-title {
    margin: 0 0 6px;
    font-size: 22px;
    color: #0b2744;
}

.login-hint {
    margin: 0 0 18px;
    color: #51607a;
    font-size: 14px;
    text-align: center;
}

.login-brand-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    margin-bottom: 16px;
}

.login-logo-btn {
    padding: 8px;
    border: 0;
    background: #0b2744;
    border-radius: 16px;
    cursor: default;
    line-height: 0;
}

.login-brand-row img,
.login-logo-btn img {
    width: 72px;
    height: 72px;
    object-fit: contain;
}

.login-brand-line {
    width: 100%;
    min-width: 0;
}

.login-brand-line strong {
    display: block;
    font-size: 18px;
    color: #0b2744;
    line-height: 1.3;
}

.login-sub-org {
    display: block;
    font-size: 13px;
    color: #51607a;
    margin-top: 4px;
    line-height: 1.35;
}

.login-form {
    display: flex;
    flex-direction: column;
}

.login-form label {
    margin-top: 10px;
    margin-bottom: 4px;
    font-weight: 600;
    color: #243047;
}

.login-form input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #c9d4e5;
    border-radius: 10px;
    font-size: 15px;
    background: #f8fafc;
}

.login-form input:focus {
    outline: none;
    border-color: #1d4f8a;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(29, 79, 138, 0.15);
}

.login-submit {
    margin-top: 18px;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    border-radius: 10px;
    background: #0b2744;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.login-submit:hover {
    background: #14365a;
}

.login-error {
    min-height: 1.3em;
    margin: 12px 0 0;
    color: #b42318;
    font-size: 13px;
}

.login-foot {
    margin: 16px 0 0;
    text-align: center;
    font-size: 12px;
    color: #7a8799;
}

.login-advanced {
    margin-top: 16px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px dashed #c9d2e3;
    background: #f8fafc;
}

.login-advanced-row {
    display: flex;
    gap: 8px;
}

.login-advanced-row input {
    flex: 1;
    min-width: 0;
}

.app-root {
    min-height: 100vh;
}

.app-layout {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: 100vh;
}

.sidebar {
    width: 268px;
    flex-shrink: 0;
    background: #0b2744;
    color: #f2f6ff;
    display: flex;
    flex-direction: column;
    padding: 12px 10px;
    border-inline-end: 1px solid rgba(255, 255, 255, 0.08);
    -webkit-overflow-scrolling: touch;
}

.app-root.sidebar-collapsed .sidebar {
    width: 0;
    padding: 0;
    overflow: hidden;
    border: none;
}

.sidebar-restore {
    display: none;
    position: fixed;
    top: 12px;
    inset-inline-start: 12px;
    z-index: 1000;
    margin: 0;
    padding: 9px 12px;
    border-radius: 999px;
    border: 1px solid #b8c8dd;
    background: #0b2744;
    color: #fff;
    box-shadow: 0 6px 16px rgba(15, 35, 65, 0.22);
    cursor: pointer;
}

.app-root.sidebar-collapsed .sidebar-restore {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.app-root.sidebar-collapsed .app-main {
    width: 100%;
}

.sidebar-brand {
    padding: 8px 6px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.sidebar-brand img {
    flex-shrink: 0;
    width: 52px;
    height: auto;
    max-height: 52px;
    object-fit: contain;
}

.sidebar-brand-text {
    min-width: 0;
}

.sidebar-brand strong {
    display: block;
    font-size: 15px;
    line-height: 1.25;
}

.sidebar-brand-sub {
    display: block;
    font-size: 11px;
    opacity: 0.85;
    line-height: 1.3;
    margin-top: 2px;
}

.sidebar-legal {
    margin-top: auto;
    padding: 10px 6px;
    font-size: 10px;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.72);
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.app-version-badge {
    display: block;
    margin-top: 4px;
    font-size: 9px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.4px;
}

.sidebar-toggle {
    width: 100%;
    margin-top: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 13px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.sidebar .tab-btn.side-nav-btn,
.sidebar .side-nav-btn {
    width: 100%;
    margin-top: 6px;
    text-align: right;
    background: rgba(255, 255, 255, 0.08);
    color: #f2f6ff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 14px;
}

.sidebar .tab-btn.side-nav-btn.active {
    background: #1f6fe5;
    border-color: #4d8ef0;
}

.side-nav-nested {
    font-size: 13px;
}

.side-nav-soon {
    opacity: 0.45;
    cursor: not-allowed;
}

.sidebar-group {
    margin-top: 8px;
}

.sidebar-group-toggle {
    width: 100%;
    margin-top: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: #dbe7ff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14px;
    font-weight: 600;
}

.sidebar-group-body {
    padding: 4px 0 2px 6px;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-user {
    display: block;
    font-size: 13px;
    margin-bottom: 8px;
    opacity: 0.92;
    word-break: break-word;
}

.btn-logout {
    width: 100%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

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

.content-main {
    flex: 1;
    padding: 12px;
    overflow: auto;
}

.header {
    padding: 14px 18px;
    background: #005ed7;
    color: #fff;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.header-left {
    flex: 1;
    min-width: 0;
}

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

.header-quick-search {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.header-quick-search input {
    flex: 1;
    min-width: 180px;
    max-width: 420px;
    padding: 8px 11px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.95);
    color: #152238;
}

.header-quick-btn {
    flex-shrink: 0;
}

.header-search-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.operational-text-pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    background: #f4f7fc;
    color: #243047;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #dfe5f0;
    margin: 8px 0 0;
}

.mailbox-dev-hint {
    margin: 10px 0 0;
    font-size: 13px;
}

.sub {
    margin: 6px 0 0;
    opacity: 0.9;
    font-size: 14px;
}

.status-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.header-guide-btn {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    padding: 6px 12px;
    font: inherit;
    cursor: pointer;
}

.header-guide-btn[aria-expanded="true"] {
    background: #fff;
    color: #0b2744;
}

.window-guide-panel {
    margin: 0 18px 10px;
    padding: 14px 16px 16px;
    border: 1px solid #d4dbe8;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(15, 35, 65, 0.08);
}

.window-guide-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.window-guide-head h2 {
    margin: 0 0 4px;
    font-size: 18px;
    color: #0b2744;
}

.window-guide-head-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.window-guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.window-guide-step {
    display: block;
    width: 100%;
    text-align: inherit;
    font: inherit;
    cursor: pointer;
    border: 1px solid #d4dbe8;
    border-radius: 12px;
    background: #f8fafc;
    padding: 12px;
}

.window-guide-step:hover,
.window-guide-step.is-current {
    border-color: #1d4f8a;
    background: #eef6ff;
}

.window-guide-step b {
    display: block;
    color: #0b2744;
    margin-bottom: 4px;
}

.window-guide-step p {
    margin: 0;
    color: #51607a;
    font-size: 13px;
    line-height: 1.45;
}

.window-guide-step .who {
    margin-top: 6px;
    font-size: 12px;
    color: #1d4f8a;
}

.window-guide-manual {
    margin-top: 10px;
    max-height: 62vh;
    overflow: auto;
    padding-inline-end: 6px;
}

.window-guide-manual h3 {
    margin: 16px 0 6px;
    font-size: 16px;
    color: #0b2744;
}

.window-guide-manual p,
.window-guide-manual li {
    color: #243047;
    font-size: 14px;
    line-height: 1.6;
}

.window-guide-manual ol {
    padding-inline-start: 1.3em;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
    background: #ffffff;
    border-bottom: 1px solid #dde3ef;
}

.tab-btn {
    width: auto;
    border: 1px solid #c8d1e4;
    background: #eff4ff;
    color: #17417f;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
}

.tab-btn.active {
    background: #005ed7;
    color: #fff;
    border-color: #005ed7;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.village-reports-card {
    margin-top: 12px;
}

.village-report-controls {
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

.table-wrap {
    overflow: auto;
    max-height: min(55vh, 520px);
    margin-top: 10px;
    border: 1px solid #dde3ef;
    border-radius: 8px;
    background: #fff;
}

.dev-user-detail-wrap .data-table td {
    white-space: normal;
    word-break: break-word;
    max-width: min(560px, 48vw);
}

.data-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 12px;
}

.data-table th,
.data-table td {
    border: 1px solid #e2e8f5;
    padding: 6px 8px;
    text-align: right;
    vertical-align: top;
    white-space: nowrap;
}

.data-table thead th {
    position: sticky;
    top: 0;
    background: #e8eef8;
    z-index: 1;
}

.data-table tbody tr:nth-child(even) {
    background: #fafcff;
}

.json-pre {
    max-height: min(50vh, 480px);
    overflow: auto;
    margin: 0;
    padding: 12px;
    background: #0b1020;
    color: #e8eef8;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.45;
    text-align: right;
    direction: ltr;
}

.mail-subtabs {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.mail-tab-btn {
    width: auto;
    background: #edf3ff;
    color: #17417f;
    border: 1px solid #c8d1e4;
    padding: 8px 12px;
    border-radius: 8px;
}

.mail-tab-btn.active {
    background: #0b5ed7;
    color: #fff;
    border-color: #0b5ed7;
}

.mail-panel {
    display: none;
}

.mail-panel.active {
    display: block;
}

.mail-link-tabs {
    display: flex;
    gap: 8px;
    margin: 8px 0;
}

.mail-link-tab-btn {
    width: auto;
    background: #f3f6fc;
    color: #2f466e;
    border: 1px solid #cfd9ec;
    border-radius: 8px;
    padding: 6px 10px;
}

.mail-link-tab-btn.active {
    background: #1f6fe5;
    color: #fff;
    border-color: #1f6fe5;
}

.mail-link-panel {
    display: none;
}

.mail-link-panel.active {
    display: block;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 980px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

.card {
    background: #fff;
    border: 1px solid #dde3ef;
    border-radius: 10px;
    padding: 12px;
}

h2 {
    margin: 0 0 10px;
    font-size: 20px;
}

label {
    display: block;
    margin: 8px 0 4px;
    color: #4f596d;
    font-size: 13px;
}

input,
textarea,
select,
button {
    width: 100%;
    padding: 9px;
    border-radius: 7px;
    border: 1px solid #c8d1e4;
}

textarea {
    min-height: 74px;
    resize: vertical;
}

select[multiple] {
    min-height: 120px;
    padding: 6px;
}

button {
    background: #0b5ed7;
    color: #fff;
    border: none;
    margin-top: 8px;
    cursor: pointer;
}

button:hover {
    background: #0849a7;
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    margin-bottom: 10px;
}

.list {
    border-top: 1px solid #edf1f8;
    max-height: 520px;
    overflow: auto;
}

.doc-item {
    padding: 10px;
    border-bottom: 1px solid #edf1f8;
    cursor: pointer;
}

.doc-item:hover {
    background: #f7faff;
}

.doc-item strong {
    display: block;
}

.doc-meta {
    font-size: 12px;
    color: #51607a;
}

.checklist-box {
    max-height: 180px;
    overflow: auto;
    border: 1px solid #d7e0ef;
    border-radius: 8px;
    background: #fbfdff;
    padding: 8px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    font-size: 13px;
}

.checklist-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
}

.checklist-tools button {
    width: auto;
    margin-top: 0;
    padding: 6px 10px;
    background: #5f6f8f;
}

.dropdown-check {
    margin-bottom: 8px;
}

.dropdown-check-btn {
    width: 100%;
    text-align: right;
    background: #ffffff;
    color: #1e2f4d;
    border: 1px solid #c8d1e4;
}

.dropdown-check-panel {
    display: none;
    border: 1px solid #d7e0ef;
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 8px;
    background: #fff;
}

.dropdown-check-panel.active {
    display: block;
}

pre {
    margin-top: 10px;
    background: #0f172a;
    color: #d9e4ff;
    padding: 10px;
    border-radius: 8px;
    max-height: 260px;
    overflow: auto;
}

/* ——— شاشة الوارد ——— */
.inbound-wrap {
    padding: 14px;
}

.inbound-title-row h2 {
    margin: 0 0 6px;
}

.inbound-intro {
    margin-bottom: 12px;
}

.inbound-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 8px 0 12px;
    border-bottom: 1px solid #dde3ef;
    margin-bottom: 12px;
}

.inbound-toolbar-label {
    font-size: 13px;
    color: #51607a;
    margin-inline-end: 8px;
}

.btn-tool {
    width: auto;
    margin-top: 0;
    padding: 6px 12px;
    background: #e8eef8;
    color: #1e2f4d;
    border: 1px solid #c8d1e4;
    cursor: not-allowed;
}

.btn-tool-active {
    cursor: pointer;
    background: #0b5ed7;
    color: #fff;
    border-color: #0b5ed7;
}

.btn-tool-active:hover {
    background: #0849a7;
}

.inbound-nav-search {
    min-width: 180px;
    max-width: 280px;
    margin-top: 0;
}

.inbound-nav-status {
    margin: 4px 0 10px;
}

.inbound-layout {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 12px;
    align-items: start;
}

.inbound-layout-single {
    grid-template-columns: 1fr;
}

@media (max-width: 900px) {
    .inbound-layout {
        grid-template-columns: 1fr;
    }
}

.header-org-title {
    font-size: 1.2rem;
    margin: 0 0 4px;
}

.inbound-aside {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-aside {
    width: 100%;
    margin-top: 0;
    padding: 10px;
    background: #fff8e6;
    color: #5c4a00;
    border: 1px solid #e6d49a;
    font-size: 13px;
}

.inbound-center {
    min-width: 0;
}

.inbound-grid-form {
    display: grid;
    grid-template-columns: 150px 1fr 150px 1fr 150px 1fr;
    gap: 8px 10px;
    align-items: center;
    margin-bottom: 14px;
}

.inbound-grid-form label {
    margin: 0;
    font-size: 13px;
}

.inbound-span-3 {
    grid-column: 1 / -1;
}

.inbound-span-2 {
    grid-column: span 5;
}

.inbound-chk-label {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    grid-column: 1 / span 2;
}

.inbound-chk-label input {
    width: auto;
}

.inbound-split {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    margin: 14px 0;
    border: 1px solid #dde3ef;
    border-radius: 10px;
    padding: 10px;
    background: #fafcff;
}

.inbound-vtabs {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ib-vtab {
    width: 100%;
    margin-top: 0;
    padding: 10px 8px;
    background: #fff;
    color: #1e2f4d;
    border: 1px solid #c8d1e4;
    border-radius: 8px;
    font-size: 13px;
    text-align: right;
}

.ib-vtab.active {
    background: #fff8c4;
    border-color: #e6c200;
    font-weight: 600;
}

.ib-panel {
    display: none;
}

.ib-panel.active {
    display: block;
}

.inbound-h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

.inbound-routing {
    margin-top: 14px;
}

.inbound-table-wrap {
    max-height: 220px;
}

.inbound-routing .inbound-route-table-wrap {
    max-height: min(50vh, 420px);
    overflow: auto;
}

.inbound-saved-guide {
    margin-bottom: 10px;
    font-weight: 500;
}

.inbound-route-table input,
.inbound-route-table select {
    width: 100%;
    min-width: 72px;
    font-size: 12px;
    padding: 6px;
}

.inbound-route-table {
    min-width: 980px;
}

.inbound-route-table th,
.inbound-route-table td {
    white-space: nowrap;
}

.inbound-route-table select.ib-route-dept {
    min-width: 220px;
}

.inbound-route-table select.ib-route-user {
    min-width: 240px;
}

.inbound-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 14px;
}

@media (max-width: 900px) {
    .inbound-bottom-grid {
        grid-template-columns: 1fr;
    }
}

.inbound-notes-block {
    grid-column: 1 / -1;
}

.inbound-notes-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: start;
}

.inbound-notes-row textarea {
    min-height: 100px;
}

.inbound-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    grid-column: 1 / -1;
}

.inbound-field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 180px;
}

.inbound-field-group input,
.inbound-field-group select {
    max-width: 320px;
}

.inbound-span-full {
    grid-column: 1 / -1;
}

.inbound-footer-fields {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    grid-column: 1 / -1;
}

@media (max-width: 900px) {
    .inbound-footer-fields {
        grid-template-columns: 1fr 1fr;
    }
}

.inbound-security {
    grid-column: 1 / -1;
    max-width: 220px;
}

.inbound-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #dde3ef;
}

.btn-primary {
    background: #0b5ed7;
    color: #fff;
}

.btn-secondary {
    background: #5f6f8f;
    color: #fff;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ——— ملف العميل / القطعة (تبويبان منفصلان) ——— */
.dossier-tab-lead {
    max-width: 900px;
    line-height: 1.5;
    margin-bottom: 8px;
}

.dossier-subh {
    font-size: 14px;
    color: #0b2744;
    margin: 16px 0 8px;
    border-bottom: 1px solid #dde3ef;
    padding-bottom: 4px;
}

.dossier-select,
.dossier-guid-input,
.dossier-search-input {
    width: 100%;
    max-width: 520px;
    margin-bottom: 8px;
}

.dossier-card .btn-primary {
    margin-top: 8px;
}

.dossier-related-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.dossier-print-banner {
    padding: 12px 14px;
    background: #e8f0fe;
    border: 1px solid #c5d9f5;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
}

/* ——— معاينة ملف القطعة / العميل (شاشة تشبه الورق + طباعة) ——— */
.dossier-doc-item {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px 14px;
}

.dossier-doc-actions {
    flex-shrink: 0;
}

.dossier-print-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.dossier-print-modal.hidden {
    display: none !important;
}

.dossier-print-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 30, 50, 0.5);
    cursor: pointer;
}

.dossier-print-modal-panel {
    position: relative;
    z-index: 1;
    max-width: 920px;
    width: 100%;
    max-height: 92vh;
    overflow: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.dossier-print-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid #dde3ef;
    background: #f0f4fb;
}

.dossier-print-toolbar-title {
    font-weight: 700;
    color: #0b2744;
}

.dossier-print-toolbar-btns {
    display: flex;
    gap: 8px;
}

.dossier-print-sheet {
    padding: 28px 32px 36px;
    direction: rtl;
    text-align: right;
    background: #fafbfd;
}

.dossier-print-sheet h1 {
    margin: 0 0 12px;
    font-size: 20px;
    color: #0b2744;
    border-bottom: 3px solid #0b5ed7;
    padding-bottom: 10px;
}

.dossier-print-grid {
    display: grid;
    grid-template-columns: minmax(120px, 160px) 1fr;
    gap: 8px 18px;
    font-size: 13px;
    margin-bottom: 18px;
}

.dossier-print-label {
    color: #51607a;
    font-weight: 600;
}

.dossier-print-notes {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 13px;
    line-height: 1.65;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #dde3ef;
    border-radius: 10px;
    max-height: 320px;
    overflow: auto;
}

.dossier-print-att-table {
    font-size: 12px;
}

.dossier-print-att-previews {
    margin-top: 12px;
}

.dossier-print-att-preview-block {
    margin-bottom: 20px;
    page-break-inside: avoid;
}

.dossier-print-att-cap {
    margin-bottom: 6px;
}

.attachment-preview-wrap {
    margin-top: 8px;
    border-radius: 8px;
    overflow: hidden;
    background: #f8fafc;
    border: 1px solid #dde3ef;
}

.attachment-preview-img {
    display: block;
    max-width: 100%;
    max-height: 320px;
    width: auto;
    height: auto;
    margin: 0 auto;
}

.attachment-preview-pdf {
    width: 100%;
    min-height: 360px;
    border: none;
    display: block;
}

.attachment-open-block {
    margin-bottom: 12px;
}

/* —— لوحة تشغيل ومهام مشتقة —— */
.dash-card h2 {
    margin-top: 0;
}

.dash-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.wrap-row {
    flex-wrap: wrap;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin: 14px 0 18px;
}

.kpi-card {
    background: linear-gradient(165deg, #f8fafc 0%, #eef2fb 100%);
    border: 1px solid #d4dbe8;
    border-radius: 12px;
    padding: 14px 14px 12px;
    min-height: 92px;
}

button.kpi-btn {
    display: block;
    width: 100%;
    text-align: inherit;
    font: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

button.kpi-btn:hover {
    border-color: #7d93b8;
    box-shadow: 0 4px 14px rgba(15, 36, 70, 0.08);
}

button.kpi-btn.is-open {
    border-color: #1d4f8a;
    box-shadow: 0 0 0 2px rgba(29, 79, 138, 0.18);
    background: linear-gradient(165deg, #eef6ff 0%, #e3edfb 100%);
}

.dash-kpi-panel {
    margin: 0 0 18px;
    padding: 14px 16px 16px;
    border: 1px solid #d4dbe8;
    border-radius: 12px;
    background: #fff;
}

.dash-kpi-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.dash-kpi-panel .dash-row {
    margin-top: 2px;
}

.kpi-card.kpi-warn {
    border-color: #f5c4a8;
    background: linear-gradient(165deg, #fff8f4 0%, #fff0e6 100%);
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: #0b2744;
    line-height: 1.1;
}

.kpi-label {
    font-size: 13px;
    color: #51607a;
    margin-top: 6px;
}

.dash-two-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    margin-top: 8px;
}

.dash-h3 {
    margin: 0 0 10px;
    font-size: 15px;
    color: #243047;
}

.dashboard-mini-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dash-row {
    border: 1px solid #e4e8f1;
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
}

.dash-row-title {
    font-weight: 600;
    color: #1d2433;
}

.dash-row-meta {
    font-size: 13px;
    color: #51607a;
    margin-top: 4px;
}

.dash-hints {
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px dashed #c9d2e3;
    font-size: 13px;
    color: #46556d;
}

.tasks-scope-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tasks-scope-label .lbl {
    white-space: nowrap;
}

.task-card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.task-card {
    border: 1px solid #dfe5f0;
    border-radius: 12px;
    padding: 14px 14px 12px;
    background: #fff;
}

.task-card-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
}

.task-card-title {
    font-weight: 600;
    margin: 0;
    color: #152238;
}

.task-card-actions {
    display: flex;
    gap: 8px;
}

.task-card-meta {
    font-size: 13px;
    color: #51607a;
    margin-top: 8px;
    line-height: 1.5;
}

/* —— التداول المستندي (Document Flow) —— */
.flow-shell.flow-shell {
    margin-bottom: 24px;
}

.flow-page-head h2 {
    margin-top: 0;
}

.flow-toolbar {
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.flow-toolbar-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 220px;
}

.flow-toolbar-label input {
    width: 100%;
    max-width: 520px;
}

.flow-status-line {
    min-height: 1.25em;
}

.flow-header-banner {
    margin: 14px 0;
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid #c8d4e8;
    background: linear-gradient(120deg, #fff 0%, #f2f6ff 100%);
}

.flow-h-inner .flow-h-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.flow-h-badge {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #0b2744;
    color: #fff;
    font-weight: 600;
}

.flow-h-name {
    font-size: 18px;
}

.flow-h-meta {
    margin-top: 8px;
    font-size: 14px;
    color: #46556d;
}

.flow-code {
    font-size: 12px;
}

.flow-main-grid {
    display: grid;
    grid-template-columns: 1fr minmax(260px, 340px);
    gap: 20px;
    align-items: start;
}

@media (max-width: 960px) {
    .flow-main-grid {
        grid-template-columns: 1fr;
    }
}

.flow-section-title {
    margin: 18px 0 10px;
    font-size: 15px;
    color: #152238;
}

.flow-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.flow-dl-cell {
    padding: 10px 12px;
    border: 1px solid #e4e8f1;
    border-radius: 10px;
    background: #fff;
}

.flow-dl-k {
    display: block;
    font-size: 12px;
    color: #62708c;
}

.flow-dl-v {
    font-size: 14px;
    word-break: break-word;
}

.flow-attachments-host {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flow-att-block {
    padding: 10px;
    margin-bottom: 4px;
}

.inbound-att-block {
    padding: 10px;
    margin-bottom: 4px;
}

.inbound-attachments-preview-host {
    margin-top: 12px;
}

.flow-timeline-host {
    max-height: 560px;
    overflow: auto;
    padding-inline-start: 8px;
    border-inline-start: 2px solid #dbe3ef;
}

.flow-tl-item {
    position: relative;
    padding-inline-start: 18px;
    padding-bottom: 14px;
}

.flow-tl-dot {
    position: absolute;
    inset-inline-start: -9px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #1672ce;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #dbe3ef;
}

.flow-tl-title {
    font-weight: 600;
    font-size: 14px;
}

.flow-tl-meta {
    font-size: 12px;
    color: #62708c;
    margin-top: 4px;
}

.flow-movements-wrap {
    margin-bottom: 12px;
}

.flow-actions-inner {
    border: 1px solid #dde3ef;
    background: #fafbfd;
}

.flow-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.flow-action-h {
    margin: 0 0 10px;
    font-size: 14px;
}

.flow-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.flow-field-block textarea {
    width: 100%;
    min-height: 72px;
}

.flow-lbl {
    font-size: 12px;
    color: #51607a;
}

.flow-h-official {
    font-size: 12px;
    font-weight: 600;
    color: #0d6b4a;
}

.flow-hr {
    border: none;
    border-top: 1px solid #e2e7f0;
    margin: 14px 0;
}

.inbound-official-chk-row {
    margin: 10px 0 6px;
}

.flow-action-msg {
    margin-top: 12px;
}

.dossier-doc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.doc-item-with-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

@media print {
    body.dossier-print-open .login-root,
    body.dossier-print-open .app-root {
        display: none !important;
    }

    body.dossier-print-open #dossierPrintPreviewRoot {
        position: static !important;
        display: block !important;
        padding: 0 !important;
    }

    body.dossier-print-open #dossierPrintPreviewRoot .no-print {
        display: none !important;
    }

    body.dossier-print-open #dossierPrintPreviewRoot .dossier-print-modal-backdrop {
        display: none !important;
    }

    body.dossier-print-open #dossierPrintPreviewRoot .dossier-print-modal-panel {
        box-shadow: none !important;
        max-height: none !important;
        overflow: visible !important;
        border-radius: 0 !important;
    }

    body.dossier-print-open #dossierPrintPreviewRoot .dossier-print-sheet {
        background: #fff !important;
        padding: 12mm !important;
    }

    body.dossier-print-open #dossierPrintPreviewRoot .dossier-print-notes {
        max-height: none !important;
        overflow: visible !important;
    }
}

/* —— قراءة المستند من صندوق الوارد —— */
.mailbox-doc-reader-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 12px;
    overflow-y: auto;
}

.mailbox-doc-reader-modal.hidden {
    display: none !important;
}

.mailbox-doc-reader-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 0;
}

.mailbox-doc-reader-dialog {
    position: relative;
    z-index: 1;
    width: min(1180px, 100%);
    max-height: min(92vh, 900px);
    overflow: auto;
    margin: 0 auto;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
}

.mailbox-doc-reader-head {
    position: sticky;
    top: 0;
    background: inherit;
    padding-bottom: 8px;
    border-bottom: 1px solid #e4e8f1;
    z-index: 2;
}

.mailbox-doc-reader-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.mailbox-doc-reader-body {
    display: grid;
    grid-template-columns: 1fr minmax(260px, 36%);
    gap: 18px;
    margin-top: 14px;
    align-items: start;
}

@media (max-width: 900px) {
    .mailbox-doc-reader-body {
        grid-template-columns: 1fr;
    }
}

.mailbox-doc-reader-summary {
    font-size: 14px;
    line-height: 1.55;
}

.mailbox-reader-dl-row {
    display: grid;
    grid-template-columns: minmax(140px, 34%) 1fr;
    gap: 8px 12px;
    padding: 8px 0;
    border-bottom: 1px solid #eef1f7;
}

.mailbox-reader-dl-k {
    color: #51607a;
    font-weight: 600;
}

.mailbox-reader-dl-v {
    color: #1d2433;
    word-break: break-word;
}

.mailbox-reader-hero {
    margin-bottom: 12px;
}

.mailbox-reader-subject {
    margin: 14px 0;
    padding: 12px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e4e8f1;
}

.mailbox-reader-dept-replies {
    margin: 16px 0;
}

.mailbox-reader-reply {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #dde8f5;
    background: #fbfdff;
}

.mailbox-reader-reply-dept {
    display: block;
    font-weight: 700;
    color: #0b2744;
    margin-bottom: 6px;
}

.mailbox-reader-routes {
    margin-top: 16px;
}

.mailbox-reader-route-table {
    font-size: 13px;
}

.mailbox-doc-reader-side-lbl {
    margin: 10px 0 6px;
    font-weight: 600;
    color: #243047;
}

.mailbox-reader-original-hint {
    margin-bottom: 10px;
    padding: 8px 10px;
    background: #f0f6ff;
    border-radius: 8px;
    border: 1px solid #cfe4ff;
}

.mailbox-doc-reader-original-host .attachment-preview-img {
    max-height: 420px;
}

.mailbox-doc-reader-original-host .attachment-preview-pdf {
    min-height: 420px;
}

.mailbox-reader-sup-item {
    margin-bottom: 14px;
}

.mailbox-reader-sup-preview .attachment-preview-img {
    max-height: 220px;
}

.mailbox-doc-reader-print-layer {
    display: none;
}

body.mailbox-printing * {
    visibility: hidden !important;
}

body.mailbox-printing #mailboxDocReaderPrintLayer,
body.mailbox-printing #mailboxDocReaderPrintLayer * {
    visibility: visible !important;
}

body.mailbox-printing #mailboxDocReaderPrintLayer {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 12mm;
    background: #fff;
}

.study-watermark-banner {
    text-align: center;
    margin-bottom: 20px;
    padding: 14px;
    border: 3px solid rgba(180, 30, 30, 0.45);
    background: rgba(255, 248, 248, 0.95);
    page-break-inside: avoid;
}

.study-watermark-title {
    font-size: 22pt;
    font-weight: 800;
    color: rgba(140, 20, 20, 0.85);
    letter-spacing: 0.02em;
}

.study-watermark-warn {
    margin-top: 8px;
    font-size: 11pt;
    color: #5c1a1a;
}

.study-watermark-meta {
    margin-top: 10px;
    font-size: 10pt;
    color: #333;
}

.print-att-fig {
    margin: 16px 0;
    page-break-inside: avoid;
}

.print-att-fig figcaption {
    font-weight: 600;
    margin-bottom: 8px;
}

.print-att-img {
    max-width: 100%;
    height: auto;
    display: block;
    border: 1px solid #ccc;
}

.print-summary .mailbox-reader-route-table {
    font-size: 11px;
}

@media print {
    body.mailbox-printing {
        background: #fff !important;
    }
}

/* ===== وارد المدير ===== */
.manager-inbox-shell {
    padding: 16px;
}
.manager-inbox-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}
.manager-inbox-head h2 {
    margin: 0;
    font-size: 18px;
    color: var(--primary);
}
.manager-inbox-two-col {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 1100px) {
    .manager-inbox-two-col {
        grid-template-columns: 1fr;
    }
}
.manager-inbox-queue-col {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    background: var(--card-bg);
    max-height: 75vh;
    overflow-y: auto;
}
.manager-inbox-detail-col {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    background: var(--card-bg);
    min-height: 60vh;
}
.manager-inbox-h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
}
.manager-inbox-queue-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.manager-inbox-queue-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    background: #fff;
    transition: box-shadow .15s ease, border-color .15s ease;
}
.manager-inbox-queue-card:hover,
.manager-inbox-queue-card.active {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(11,39,68,.08);
}
.manager-inbox-queue-card.active {
    background: #f0f6ff;
}
.manager-inbox-queue-title {
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 4px;
}
.manager-inbox-queue-meta {
    font-size: 12px;
    color: var(--muted);
}
.manager-inbox-queue-warn {
    border-color: #e07b3a;
    background: #fff7ed;
}
.manager-inbox-queue-warn.active {
    background: #ffe8d6;
}
.manager-inbox-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}
.manager-inbox-doc-card {
    margin-bottom: 12px;
}
.manager-inbox-doc-card .flow-dl-cell {
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
}
.manager-inbox-escalation {
    background: #fff7ed;
    border: 1px solid #f0c080;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #8a4b0a;
}
.manager-inbox-escalation.past {
    background: #fff0f0;
    border-color: #e08080;
    color: #8a0a0a;
}
.manager-inbox-attachment-host {
    margin-bottom: 12px;
    min-height: 100px;
}
.manager-inbox-routing {
    border-top: 2px solid var(--primary);
    padding-top: 12px;
    margin-top: 8px;
}
.manager-inbox-route-row {
    display: grid;
    grid-template-columns: 1.6fr 1.2fr 2fr auto;
    gap: 8px;
    align-items: end;
    margin-bottom: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}
@media (max-width: 900px) {
    .manager-inbox-route-row {
        grid-template-columns: 1fr;
    }
}
.manager-inbox-route-row label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--muted);
}
.manager-inbox-route-row input,
.manager-inbox-route-row select,
.manager-inbox-route-row textarea {
    font-size: 13px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.manager-inbox-route-row textarea {
    min-height: 60px;
}
.manager-inbox-history-host {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: #f8fafc;
}
.manager-inbox-history-item {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 13px;
    align-items: flex-start;
}
.manager-inbox-history-item:last-child {
    border-bottom: none;
}
.manager-inbox-history-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
    margin-top: 4px;
}
.manager-inbox-history-dot.approve { background: #28a745; }
.manager-inbox-history-dot.route { background: #007bff; }
.manager-inbox-history-dot.task { background: #6f42c1; }
.manager-inbox-history-dot.note { background: #fd7e14; }
.manager-inbox-history-dot.seen { background: #6c757d; }
.manager-inbox-history-body {
    flex: 1;
}
.manager-inbox-history-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.manager-inbox-history-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 2px;
}
.manager-inbox-history-note {
    color: #444;
    font-size: 12px;
    background: #fff;
    padding: 6px 8px;
    border-radius: 4px;
    border-right: 3px solid var(--primary);
    margin-top: 4px;
}
.manager-inbox-history-empty {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
    padding: 12px;
}

/* ===== العمل المطلوب في التداول ===== */
.flow-work-required {
    margin: 16px 0;
    padding: 14px;
    border: 1px solid #d0e0f0;
    border-radius: 10px;
    background: #f0f7ff;
}
.flow-work-required.hidden {
    display: none;
}
.flow-work-card {
    margin-bottom: 12px;
}
.flow-work-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px dashed #c8d8ec;
    font-size: 13px;
}
.flow-work-row:last-child {
    border-bottom: none;
}
.flow-work-k {
    color: #4a6b8a;
    font-weight: 600;
}
.flow-work-v {
    color: #1a2b3c;
}
.flow-work-v.action-required {
    background: #fff3cd;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
}

/* ===== سجل الملاحظات في التداول ===== */
.flow-notes-host {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.flow-note-item {
    border: 1px solid #e0e6f0;
    border-radius: 8px;
    padding: 10px 14px;
    background: #f8fafc;
}
.flow-note-meta {
    font-size: 12px;
    color: #6b7a90;
    margin-bottom: 4px;
    font-weight: 600;
}
.flow-note-body {
    font-size: 13px;
    color: #1a2b3c;
    line-height: 1.6;
    white-space: pre-wrap;
}
.flow-add-note-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    padding: 12px;
    border: 1px dashed #c8d1e4;
    border-radius: 8px;
    background: #fff;
}

/* ========== Step builder for sequential tasks ========== */
.flow-steps-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0;
}

.flow-step-row {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    gap: 8px;
    align-items: start;
    padding: 10px;
    border: 1px solid #e2e7f0;
    border-radius: 8px;
    background: #f8fafc;
}

.flow-step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    margin-top: 2px;
}

.flow-step-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.flow-step-body input,
.flow-step-body select,
.flow-step-body textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #c8d1e4;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    color: #0f172a;
}

.flow-step-body textarea {
    min-height: 60px;
    resize: vertical;
}

.flow-step-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.flow-step-btn {
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid #c8d1e4;
    border-radius: 6px;
    background: #fff;
    color: #51607a;
    cursor: pointer;
}

.flow-step-btn:hover {
    background: #eef2f7;
}

.flow-step-btn.remove {
    color: #b91c1c;
    border-color: #fca5a5;
}

.flow-step-btn.remove:hover {
    background: #fef2f2;
}

.flow-steps-summary {
    margin: 8px 0;
    padding: 8px 12px;
    border-radius: 6px;
    background: #ecfdf5;
    color: #065f46;
    font-size: 13px;
}

.flow-actions-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

/* —— نافذة تتبع المهمة —— */
.task-track-modal {
    position: fixed;
    inset: 0;
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.task-track-modal.hidden {
    display: none !important;
}

.task-track-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 30, 50, 0.5);
    cursor: pointer;
}

.task-track-modal-panel {
    position: relative;
    z-index: 1;
    max-width: 720px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
    direction: rtl;
}

.task-track-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
    border-radius: 12px 12px 0 0;
}

.task-track-header h3 {
    margin: 0;
    font-size: 18px;
}

.task-track-body {
    padding: 18px;
}

.task-track-doc-card {
    background: #f0f7ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.task-track-doc-title {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 6px;
}

.task-track-doc-meta {
    color: #4b5563;
    font-size: 13px;
}

.task-track-section {
    margin-bottom: 16px;
}

.task-track-section h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #1e3a5f;
    border-right: 3px solid #2563eb;
    padding-right: 8px;
}

.task-track-note-box {
    background: #fefce8;
    border: 1px solid #fde047;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    white-space: pre-wrap;
}

.task-track-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.task-track-table th,
.task-track-table td {
    border: 1px solid #e5e7eb;
    padding: 8px 10px;
    text-align: right;
}

.task-track-table th {
    background: #f3f4f6;
    font-weight: 600;
}

.task-track-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.task-track-badge.open {
    background: #dcfce7;
    color: #15803d;
}

.task-track-badge.seen {
    background: #dbeafe;
    color: #1d4ed8;
}

.task-track-badge.done {
    background: #e5e7eb;
    color: #374151;
}

.task-track-badge.sequential {
    background: #fef3c7;
    color: #92400e;
}

.task-track-badge.parallel {
    background: #e0e7ff;
    color: #3730a3;
}

.task-track-tl-item {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}

.task-track-tl-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2563eb;
    flex-shrink: 0;
    margin-top: 6px;
}

.task-track-tl-body {
    flex: 1;
}

.task-track-tl-title {
    font-weight: 600;
    font-size: 13px;
}

.task-track-tl-meta {
    color: #6b7280;
    font-size: 12px;
}

.task-track-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

/* مطالبة القسم الفني — كتالوج Extra فقط */
.pos-shell {
    padding: 16px 18px 18px;
    min-height: calc(100vh - 140px);
}

.pos-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.pos-head h2 {
    margin: 0 0 4px;
    color: #1d2433;
    font-size: 20px;
}

.pos-head-lead {
    margin: 0;
    color: #5a6574;
    font-size: 13px;
}

.pos-head-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pos-context {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(180px, 1.2fr) minmax(180px, 1.2fr) auto;
    gap: 10px;
    align-items: end;
    background: #f7f9fc;
    border: 1px solid #d7dee8;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
}

.pos-context label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #5c5348;
}

.pos-context input,
.pos-context select {
    width: 100%;
    border: 1px solid #b8c4d6;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
}

.pos-lookup {
    gap: 4px;
}

.pos-lookup input[type="search"] {
    margin-bottom: 4px;
}

.pos-context-line {
    margin: 0 0 12px;
    color: #4a5564;
    font-size: 13px;
}

.pos-body {
    display: grid;
    grid-template-columns: minmax(280px, 340px) 1fr;
    gap: 14px;
    min-height: 560px;
}

.pos-ticket {
    background: #1d2433;
    color: #eef2f7;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.pos-ticket-brand strong {
    display: block;
    font-size: 17px;
}

.pos-ticket-brand span {
    display: block;
    margin-top: 4px;
    color: #9aa6b8;
    font-size: 12px;
}

.pos-ticket-meta {
    margin: 12px 0;
    padding: 10px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.7;
    color: #e8dfd0;
}

.pos-ticket-lines {
    flex: 1;
    overflow: auto;
    min-height: 180px;
}

.pos-empty {
    color: #9aa6b4;
    text-align: center;
    padding: 28px 8px;
}

.pos-line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    padding: 10px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
}

.pos-line-name {
    font-weight: 600;
    font-size: 13px;
}

.pos-line-sub {
    color: #b7c0cb;
    font-size: 12px;
}

.pos-line-qty {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pos-line-qty button {
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 7px;
    background: #3b82f6;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.pos-line-price {
    width: 88px;
    border: 1px solid #3d4d62;
    border-radius: 6px;
    background: #243447 !important;
    color: #eef2f7 !important;
    padding: 4px 6px;
    font-size: 12px;
}

.pos-ticket-totals {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.pos-ticket-totals div {
    display: flex;
    justify-content: space-between;
    margin: 4px 0;
    font-size: 14px;
}

.pos-ticket-note {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 10px 0;
    font-size: 12px;
    color: #9aa6b8;
}

.pos-ticket-note textarea {
    width: 100%;
    border: 1px solid #3d4d62;
    border-radius: 8px;
    background: #243447 !important;
    color: #f6f0e6 !important;
    padding: 8px;
}

.pos-issue-btn {
    width: 100%;
    border: 0;
    border-radius: 10px;
    background: #2563eb;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    padding: 12px;
    cursor: pointer;
}

.pos-issue-btn:hover {
    background: #1d4ed8;
}

.pos-issue-msg {
    min-height: 1.3em;
    margin: 8px 0 0;
    font-size: 12px;
    color: #e8dfd0;
}

.pos-menu {
    background: #fff;
    border: 1px solid #d7dee8;
    border-radius: 12px;
    padding: 12px;
    min-height: 560px;
}

.pos-menu-bar input {
    width: 100%;
    border: 1px solid #b8c4d6;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
}

.pos-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.pos-group-btn {
    border: 1px solid #c5d0de;
    background: #f3f6fa;
    color: #1d2433;
    border-radius: 999px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
}

.pos-group-btn.active {
    background: #1c2838;
    border-color: #1c2838;
    color: #f6f0e6;
}

.pos-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.pos-tile {
    appearance: none;
    border: 1px solid #d7dee8;
    border-radius: 12px;
    background: #fbfcfe;
    min-height: 104px;
    padding: 12px;
    text-align: right;
    cursor: pointer;
}

.pos-tile:hover {
    border-color: #2563eb;
    background: #f3f7ff;
}

.pos-tile-name {
    display: block;
    font-weight: 700;
    color: #1b2a3d;
    font-size: 14px;
    line-height: 1.45;
}

.pos-tile-price {
    display: block;
    margin-top: 10px;
    color: #1d4ed8;
    font-weight: 800;
    font-size: 15px;
}

.pos-tile-unit {
    display: block;
    color: #7a7166;
    font-size: 11px;
    margin-top: 2px;
}

@media (max-width: 1100px) {
    .pos-context {
        grid-template-columns: 1fr 1fr;
    }
    .pos-body {
        grid-template-columns: 1fr;
    }
}