/* =========================================
   1) RESET & BASE
========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: Segoe UI, Arial, sans-serif;
}

body {
    margin: 0;
    padding: 0;
    color: #1d2b3a;
    background: linear-gradient(135deg, #0d304f, #145487);
    overflow-x: hidden;
}

a {
    text-decoration: none;
}

button {
    font: inherit;
}

/* =========================================
   2) TOPBAR
========================================= */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #1f6fb2;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-logo {
    height: 50px;
    border-radius: 12px;
}

.top-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.top-main-title {
    font-size: 18px;
    letter-spacing: 2px;
    font-weight: 700;
}

.top-sub-title {
    font-size: 12px;
    opacity: .9;
    margin-top: 2px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* =========================================
   3) SIDEBAR
========================================= */
/* =========================================
   3) SIDEBAR
========================================= */
.sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    width: 35px;
    height: calc(100vh - 60px);
    background: linear-gradient(180deg, #145487, #0d304f);
    color: #fff;
    overflow: hidden;
    transition: width .2s ease;
    z-index: 900;
    border-top-right-radius: 14px;
    border-bottom-right-radius: 14px;
}

.sidebar:hover {
    width: 220px;
}

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-menu li {
    margin-bottom: 3px;
}

.sidebar-menu li.about-item {
    margin-top: auto;
}

/* الروابط العادية (بدون submenu) */
.sidebar-menu > li > a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    color: #e5ecf5;
    text-decoration: none;
    white-space: nowrap;
    font-size: 11px;
    border-radius: 8px;
}

.sidebar-menu > li > a:hover {
    background: rgba(0, 0, 0, .15);
}

.sidebar-menu > li > a.active {
    background: rgba(0, 0, 0, .25);
    font-weight: 600;
}

.sidebar-menu i {
    width: 22px;
    text-align: center;
    font-size: 13px;
}

/* إظهار النص فقط عند توسيع السايدبار */
.sidebar-menu > li > a span,
.sidebar-menu .menu-main-link span,
.sidebar-menu .submenu a span {
    opacity: 0;
    transition: opacity .2s ease;
}

.sidebar:hover .sidebar-menu > li > a span,
.sidebar:hover .sidebar-menu .menu-main-link span,
.sidebar:hover .sidebar-menu .submenu a span {
    opacity: 1;
}

/* عناصر فيها submenu (مثل Departments) */
.sidebar-menu li.has-submenu {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* الصف الذي يحتوي Departments + السهم */
.sidebar-menu .menu-link-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    width: 100%;
    padding: 0;
}

/* رابط Departments */
.sidebar-menu .menu-main-link {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 10px;
    color: #e5ecf5;
    text-decoration: none;
    white-space: nowrap;
    font-size: 11px;
    border-radius: 8px;
}

.sidebar-menu .menu-main-link:hover {
    background: rgba(0, 0, 0, .15);
}

.sidebar-menu .menu-main-link.active {
    background: rgba(0, 0, 0, .25);
    font-weight: 600;
}

/* زر السهم */
.sidebar-menu .submenu-arrow-btn {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #e5ecf5;
    cursor: pointer;
    border-radius: 6px;
    padding: 0;
    margin-right: 6px;
}

.sidebar-menu .submenu-arrow-btn:hover {
    background: rgba(0, 0, 0, .15);
}

.sidebar-menu .submenu-arrow-btn i {
    transition: transform .2s ease;
}

/* دوران السهم عند فتح القائمة */
.sidebar-menu li.has-submenu.open .submenu-arrow-btn i {
    transform: rotate(90deg);
}

/* Submenu */
.sidebar-menu li.has-submenu .submenu {
    list-style: none;
    margin: 4px 0 0 0;
    padding: 0 0 0 13px;
    display: none;
}

.sidebar-menu li.has-submenu.open .submenu {
    display: block;
}

.sidebar-menu li.has-submenu .submenu li {
    margin: 2px 0;
}

.sidebar-menu li.has-submenu .submenu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    font-size: 11px;
    color: #dbe7f3;
    border-radius: 8px;
    white-space: nowrap;
    transition: .2s;
}

.sidebar-menu li.has-submenu .submenu a i {
    width: 16px;
    text-align: center;
    font-size: 11px;
    color: #ffffff;
    opacity: .95;
}

.sidebar-menu li.has-submenu .submenu a.active-sub {
    background: rgba(0, 0, 0, .28);
    color: #ffffff;
    font-weight: 700;
    box-shadow: inset 3px 0 0 #ffffff;
}

/* =========================================
   4) MAIN CONTENT FRAME
========================================= */
.main-content {
    margin-top: 60px;
    margin-left: 35px;
    padding: 18px;
    min-height: calc(100vh - 60px);
    width: calc(100% - 35px);
    display: flex;
    justify-content: center;
}

/* page-shell يعمل كحاوية مركزية للمحتوى */
.page-shell {
    background: #f5f7fb;
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, .14);
    min-height: calc(100vh - 96px);
    width: 100%;
    max-width: none;
    margin: 0;
}


/* =========================================
   5) PAGE HEADER & TITLE
========================================= */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.title-wrap {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.title-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #e9eef7;
    color: #5a6f87;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    margin-top: 2px;
}

.title-group h1 {
    font-size: 22px;
    font-weight: 700;
    color: #1e2d3d;
    margin-bottom: 4px;
}

.title-group .sub {
    font-size: 13px;
    color: #7b8795;
}

/* =========================================
   6) BUTTONS & TOOLBAR
========================================= */
.toolbar,
.toolbar-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.tool-btn,
.btn {
    min-width: 38px;
    height: 38px;
    padding: 0 14px;
    border: 1px solid #d8dee8;
    background: #fff;
    color: #5f6f82;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    transition: .2s;
    font-size: 13px;
    gap: 8px;
}

.tool-btn:hover,
.btn:hover {
    background: #f0f5fb;
    border-color: #bfcada;
    color: #1f6fb2;
}

.btn-primary {
    background: #1f6fb2;
    border-color: #1f6fb2;
    color: #fff;
}

.btn-primary:hover {
    background: #17598f;
    color: #fff;
    border-color: #17598f;
}

.btn-success {
    background: #0f766e;
    border-color: #0f766e;
    color: #fff;
}

.btn-success:hover {
    background: #0d645d;
    color: #fff;
    border-color: #0d645d;
}
.manpower-chip{
    background:linear-gradient(180deg,#ffffff,#fbf8ff);
    color:#6d3bd1;
    border:1px solid #ddd6fe;
}
/* =========================================
   7) CARD CONTAINERS
========================================= */
.top-filter-card,
.nav-card,
.departments-card,
.table-card,
.planning-card,
.purchase-card,
.zones-card,
.progress-card,
.modal-card {
    background: #fff;
    border: 1px solid #dbe3ee;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .04);
    margin-bottom: 16px;
}

.top-filter-card {
    background: linear-gradient(135deg, #f8fbff, #eef5fb);
    border: 1px solid #d9e6f3;
    padding: 18px;
}

/* =========================================
   8) FILTERS & PROJECT STRIP
========================================= */
.top-filter-grid {
    display: grid;
    grid-template-columns: 2fr 1.2fr; /* فقط Ship + Block */
    gap: 14px;
    align-items: end;
}


.project-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.project-info {
    background: #fff;
    border: 1px solid #dce7f2;
    border-radius: 14px;
    padding: 12px 14px;
}

.project-info .label {
    font-size: 11px;
    color: #77879a;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.project-info .value {
    font-size: 14px;
    font-weight: 700;
    color: #223244;
}

.project-info .subvalue {
    font-size: 12px;
    color: #7a8796;
    margin-top: 3px;
}

/* =========================================
   9) FORM FIELDS
========================================= */
.field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #617286;
    margin-bottom: 6px;
}

.field select,
.field input,
.field textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d1d9e6;
    border-radius: 10px;
    background: #fff;
    color: #223244;
    font-size: 13px;
    outline: none;
}

.field select:focus,
.field input:focus,
.field textarea:focus {
    border-color: #1f6fb2;
    box-shadow: 0 0 0 3px rgba(31, 111, 178, .12);
}

/* =========================================
   10) SECTION HEADERS
========================================= */
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    color: #223244;
}

.section-sub {
    font-size: 12px;
    color: #7b8795;
}

/* =========================================
   11) MAIN NAV BUTTONS
========================================= */
.main-nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 11px 18px;
    border-radius: 12px;
    border: 1px solid #d7e1ee;
    background: #f8fbff;
    color: #486176;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.nav-btn.active {
    background: #1f6fb2;
    color: #fff;
    border-color: #1f6fb2;
}

/* =========================================
   12) KPI GRID
========================================= */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.kpi-card {
    background: linear-gradient(180deg, #ffffff, #f9fbfe);
    border: 1px solid #dce4ef;
    border-radius: 16px;
    padding: 14px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .04);
}



.kpi-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.kpi-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
}

.kpi-value {
    font-size: 22px;
    font-weight: 800;
    color: #213244;
}

.kpi-label {
    font-size: 12px;
    color: #718295;
    font-weight: 700;
    margin-top: 2px;
}

.kpi-note {
    font-size: 11px;
    color: #90a0af;
    margin-top: 3px;
}

/* =========================================
   13) ACTION CHIPS (Purchases / Planning)
========================================= */
.action-chip {
    height: 40px;
    padding: 0 14px;
    border: 1px solid #d7e2ee;
    border-radius: 999px;
    background: #fff;
    color: #334155;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
    transition: .18s ease;
}

.action-chip i {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.action-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .08);
}

.purchases-chip {
    border-color: #fde7c2;
    background: #fffaf1;
    color: #9a5a00;
}

.purchases-chip i {
    background: #f59e0b;
    color: #fff;
}

.purchases-chip:hover {
    background: #fff4dd;
}

.planning-chip {
    border-color: #d9e7f7;
    background: #f4f9ff;
    color: #1d5d96;
}

.planning-chip i {
    background: #1f6fb2;
    color: #fff;
}

.planning-chip:hover {
    background: #eaf4ff;
}

/* =========================================
   14) DEPARTMENTS GRID & CARDS
========================================= */
.dept-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.dept-card {
    border: 1px solid #dce4ef;
    border-radius: 14px;
    padding: 14px;
    background: linear-gradient(180deg, #ffffff, #f9fbfe);
    cursor: pointer;
    transition: .2s;
    position: relative;
    color: inherit;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 180px; /* توحيد ارتفاع الكروت */
}

.dept-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--dept-color, #1f6fb2);
}

.dept-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .06);
}

.dept-card.active {
    border: 2px solid var(--dept-color, #1f6fb2);
    background: #f2f8fe;
}

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

.dept-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dept-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
}

.dept-name {
    font-size: 14px;
    font-weight: 800;
    color: #223244;
    margin-bottom: 3px;
}

.dept-code {
    font-size: 11px;
    color: #7e8c9b;
    font-weight: 700;
}

.dept-progress {
    font-size: 12px;
    font-weight: 800;
    color: #1f6fb2;
    white-space: nowrap;
    background: #eef5fb;
    border: 1px solid #d7e6f5;
    padding: 4px 8px;
    border-radius: 999px;
    line-height: 1;
}

.mini-progress {
    width: 100%;
    height: 7px;
    background: #e9eef5;
    border-radius: 999px;
    overflow: hidden;
    margin: 10px 0 12px;
    position: relative;
}

.mini-progress span {
    display: block;
    height: 100%;
    background: linear-gradient(
        90deg,
        var(--dept-color, #1f6fb2),
        #1f6fb2
    );
    border-radius: 999px;
}

.dept-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: auto; /* تثبيت الإحصاءات في أسفل الكرت */
}

.dept-stat {
    border: 1px solid #e5ebf2;
    background: #fff;
    border-radius: 12px;
    padding: 8px;
}

.dept-stat .s-label {
    font-size: 11px;
    color: #7c8b99;
    margin-bottom: 4px;
    font-weight: 700;
}

.dept-stat .s-value {
    font-size: 16px;
    color: #213244;
    font-weight: 800;
}

/* =========================================
   15) TABLES & BADGES
========================================= */
.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid #ecf0f5;
    text-align: left;
    font-size: 12px;
    vertical-align: middle;
}

th {
    background: #fafbfd;
    color: #657588;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .4px;
    position: sticky;
    top: 0;
}

tr:hover td {
    background: #fbfdff;
}

/* باقي التنسيقات للـ badges وprogress كما هي لديك */
.seq-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    border-radius: 999px;
    background: #edf2f7;
    color: #41566d;
    font-weight: 700;
    font-size: 11px;
}

.activity-name {
    font-size: 13px;
    font-weight: 700;
    color: #233446;
    margin-bottom: 3px;
}

.activity-meta {
    font-size: 11px;
    color: #8794a3;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-success {
    background: #e8f8f0;
    color: #0d8b56;
    border-color: #bfe9d1;
}

.badge-primary {
    background: #eaf3ff;
    color: #1f6fb2;
    border-color: #cfe2fb;
}

.badge-warning {
    background: #fff7e8;
    color: #b7791f;
    border-color: #f6dfb7;
}

.badge-danger {
    background: #fff0f0;
    color: #c24141;
    border-color: #f2c6c6;
}

.badge-muted {
    background: #f1f5f9;
    color: #64748b;
    border-color: #dbe2ea;
}

/* =========================================
   16) PROGRESS SMALL
========================================= */
.progress-wrap {
    min-width: 120px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e7edf5;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
}

.progress-text {
    font-size: 11px;
    color: #5f7184;
    font-weight: 700;
}

.prog-red {
    background: #dc2626;
}

.prog-yellow {
    background: #d97706;
}

.prog-green {
    background: #16a34a;
}

/* =========================================
   17) EMPTY STATES, ZONES, GANTT, MODAL
   (كما في كودك الحالي بدون تغيير كبير)
========================================= */

/* ... يمكنك الإبقاء على بقية الأقسام كما هي (block-group, zone-grid, gantt, modal, job-suggestions) ... */

/* =========================================
   18) RESPONSIVE (لابتوب وموبايل)
========================================= */
@media (max-width: 1200px) {
    .project-strip,
    .inner-summary-grid {
        grid-template-columns: repeat(2, minmax(160px, 1fr));
    }

    .page-shell {
        max-width: 1200px;
        
    }
}

@media (max-width: 900px) {
    .top-filter-grid,
    .modal-grid {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 0;
    }

    .sidebar:hover {
        width: 220px;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 12px;
    }

    .project-strip,
    .inner-summary-grid {
        grid-template-columns: 1fr;
    }

    .page-shell {
        border-radius: 0;
        box-shadow: none;
    }
}
