/* JAPTA theme: modern blue, teal, white, light grey. */
:root {
    --japta-blue: #1f5fae;
    --japta-blue-dark: #174a88;
    --japta-teal: #14a3a3;
    --japta-grey: #f3f5f8;
    --japta-border: #d9dee6;
    --bs-primary: #1f5fae;
    --bs-primary-rgb: 31, 95, 174;
    --bs-link-color: #1f5fae;
    --bs-link-color-rgb: 31, 95, 174;
}

html, body {
    font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
    background: var(--japta-grey);
    font-size: 15px;
}

.btn-primary { --bs-btn-bg: var(--japta-blue); --bs-btn-border-color: var(--japta-blue); --bs-btn-hover-bg: var(--japta-blue-dark); --bs-btn-hover-border-color: var(--japta-blue-dark); }
.btn-teal { --bs-btn-color: #fff; --bs-btn-bg: var(--japta-teal); --bs-btn-border-color: var(--japta-teal); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #0f8585; }

.app-topbar {
    position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center;
    height: 54px; padding: 0 1rem;
    background: linear-gradient(90deg, var(--japta-blue), var(--japta-teal));
    color: #fff;
}
.app-brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.app-brand span { font-weight: 400; opacity: .9; margin-inline-start: .35rem; }
@media (max-width: 575.98px) { .app-brand span { display: none; } }

.app-shell { display: flex; min-height: calc(100vh - 54px); }
.app-sidebar { width: 230px; background: #fff; border-inline-end: 1px solid var(--japta-border); padding: .75rem .5rem; }
@media (min-width: 992px) {
    .app-sidebar { position: sticky; top: 54px; height: calc(100vh - 54px); overflow-y: auto; flex-shrink: 0; }
}
.app-sidebar .nav-link { color: #2b3440; border-radius: .4rem; padding: .55rem .75rem; margin-bottom: 2px; }
.app-sidebar .nav-link:hover { background: var(--japta-grey); }
.app-sidebar .nav-link.active { background: var(--japta-blue); color: #fff; }
.app-sidebar .nav-link.disabled { color: #9aa4b1; }

.app-main { flex: 1; min-width: 0; padding: 1.25rem; }
@media (max-width: 575.98px) { .app-main { padding: .75rem; } }

.page-header { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-header h1 { font-size: 1.35rem; margin: 0; font-weight: 700; color: #1d2a3a; }

.card { border-color: var(--japta-border); }
.card-header { background: #fff; font-weight: 600; }

/* Excel-like compact tables */
.table-japta { background: #fff; margin: 0; }
.table-japta thead th { background: #e9eef6; color: #1d2a3a; font-weight: 600; white-space: nowrap; border-color: var(--japta-border); }
.table-japta td, .table-japta th { border-color: var(--japta-border); vertical-align: middle; }

.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.dl-grid dt { color: #5c6b7d; font-weight: 500; }
.dl-grid dd { margin: 0; }

.badge-status-Active { background: #d7f2ec; color: #0b7a62; }
.badge-status-Inactive, .badge-status-Terminated, .badge-status-Expired { background: #eceff3; color: #59636e; }
.badge-status-Draft { background: #fff3cd; color: #8a6100; }
.badge-status-Suspended { background: #fde2e1; color: #a12622; }

/* Touch-friendly controls on phones */
@media (max-width: 767.98px) {
    .btn, .form-control, .form-select { min-height: 44px; }
    .table-responsive-cards thead { display: none; }
    .table-responsive-cards tr { display: block; border: 1px solid var(--japta-border); border-radius: .5rem; margin-bottom: .6rem; background: #fff; }
    .table-responsive-cards td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .4rem .75rem; }
    .table-responsive-cards td::before { content: attr(data-label); color: #5c6b7d; font-weight: 500; }
}

/* ---------- Monthly planning / tracking grid (vertical, Excel-like) ---------- */
.team-tabs { overflow-x: auto; overflow-y: hidden; }
.team-tabs .nav-link { white-space: nowrap; }
.team-tabs .dot, .chip-demo { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 4px; vertical-align: middle; }
.summary-bar { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; background: #fff; border: 1px solid var(--japta-border); border-radius: .4rem; padding: .45rem .8rem; font-size: .9rem; }

.plan-wrap { overflow: auto; max-height: calc(100vh - 290px); min-height: 320px; border: 1px solid var(--japta-border); border-radius: .4rem; background: #fff; }
.plan-wrap::-webkit-scrollbar { width: 14px; height: 14px; }
.plan-wrap::-webkit-scrollbar-thumb { background: #b9c4d3; border-radius: 7px; border: 3px solid #f3f5f8; }
.plan-wrap::-webkit-scrollbar-track { background: #f3f5f8; }
.grid-tools { align-items: center; gap: .4rem; margin-bottom: .35rem; }
.plan-grid td.drop-target { background: #e6f7f7 !important; outline: 2px dashed var(--japta-teal); outline-offset: -3px; }.plan-grid { border-collapse: separate; border-spacing: 0; font-size: .85rem; min-width: 100%; }
.plan-grid th, .plan-grid td { border-bottom: 1px solid var(--japta-border); border-inline-end: 1px solid var(--japta-border); padding: 2px 4px; height: 30px; white-space: nowrap; }
.plan-grid thead th { position: sticky; top: 0; z-index: 3; background: #dfe8f5; text-align: center; font-weight: 600; }
.plan-grid thead tr.sub th { top: 30px; background: #eef3fa; font-weight: 500; font-size: .75rem; }
.plan-grid .sticky-1, .plan-grid .sticky-2 { position: sticky; z-index: 2; background: #f6f8fb; font-weight: 600; }
.plan-grid .sticky-1 { inset-inline-start: 0; min-width: 84px; }
.plan-grid .sticky-2 { inset-inline-start: 84px; min-width: 96px; }
.plan-grid thead .sticky-1, .plan-grid thead .sticky-2 { z-index: 4; }
.plan-grid td { min-width: 130px; }
.plan-grid.is-track td.t-status, .plan-grid.is-track td.t-report { min-width: 82px; font-size: .78rem; text-align: center; }
.plan-grid tr.is-off th, .plan-grid tr.is-off td { background: repeating-linear-gradient(45deg, #eceff3, #eceff3 6px, #f5f6f8 6px, #f5f6f8 12px); color: #7a8594; }
.plan-grid tr.is-today th { background: #d9ecff; }
.plan-grid tr.is-today td { box-shadow: inset 0 2px 0 var(--japta-blue), inset 0 -2px 0 var(--japta-blue); }
.plan-grid tr.drop-target td { background: #e6f7f7; }
.holiday { font-size: .7rem; color: #a15c00; font-weight: 500; }
.plan-grid tr.is-holiday .sticky-2 { background: #fff5e6; }

.add-btn { width: 100%; border: 1px dashed #b9c4d3; background: transparent; color: var(--japta-blue); border-radius: .3rem; line-height: 1.4; }
.add-btn:hover, .add-btn:focus { background: #eef4fc; }

.chip { display: flex; align-items: center; gap: 4px; width: 100%; text-align: start; border: 1px solid var(--japta-border); border-inline-start: 5px solid #9aa4b1;
        border-radius: .3rem; background: #fff; padding: 1px 6px; font-size: .82rem; line-height: 1.5; cursor: pointer; }
.chip:hover, .chip:focus { box-shadow: 0 0 0 2px rgba(31, 95, 174, .25); }
.chip-name { overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.chip.band-1, .chip-demo.band-1 { border-inline-start-color: #e74c3c; } .chip-demo.band-1 { background: #e74c3c; }
.chip.band-2, .chip-demo.band-2 { border-inline-start-color: #27ae60; } .chip-demo.band-2 { background: #27ae60; }
.chip.band-3, .chip-demo.band-3 { border-inline-start-color: #f1c40f; } .chip-demo.band-3 { background: #f1c40f; }
.chip.band-4, .chip-demo.band-4 { border-inline-start-color: #e67e22; } .chip-demo.band-4 { background: #e67e22; }
.chip.band-5, .chip-demo.band-5 { border-inline-start-color: #1f5fae; } .chip-demo.band-5 { background: #1f5fae; }
.chip.band-none, .chip-demo.band-none { border-inline-start-color: #c3cad4; } .chip-demo.band-none { background: #c3cad4; }
.chip.is-ev { border-color: #f39c12; background: #fff8ec; }
.badge-ev { background: #f39c12; color: #fff; font-size: .65rem; }
.chip.is-excess { background: #fffbe6; }
.chip.st-done { background: #e8f7ef; }
.chip.st-notdone { background: #fdecec; text-decoration: line-through; text-decoration-color: rgba(161, 38, 34, .4); }
.chip.st-upcoming { opacity: .75; }
.t-status.st-done { background: #e8f7ef; color: #0b7a62; }
.t-status.st-notdone { background: #fdecec; color: #a12622; }
.t-status.st-pending, .t-status.st-upcoming { color: #6c7684; }
.t-report.rep-ok { background: #e3f6f6; color: #0f7f7f; }
.t-report.rep-wait { background: #fff5e0; color: #8a6100; }

.picker-list { max-height: 300px; overflow-y: auto; }
.balance-panel { position: sticky; top: 64px; }
.balance-panel .table-responsive { max-height: calc(100vh - 200px); }

.day-cards .day-card { background: #fff; border: 1px solid var(--japta-border); border-radius: .5rem; padding: .5rem; margin-bottom: .5rem; }
.day-cards .day-card.is-off { background: #eceff3; color: #7a8594; font-size: .85rem; padding: .35rem .6rem; }
.day-cards .day-card.is-today { border: 2px solid var(--japta-blue); }
.day-cards .day-head { margin-bottom: .35rem; }
.day-cards .chip { min-height: 44px; margin-bottom: .3rem; font-size: .95rem; }
.day-cards .chip-name { max-width: none; }

.btn-check-group .btn.active { background: var(--japta-blue); color: #fff; }

/* ---------- Dashboard ---------- */
.kpi-block { background: #fff; border: 1px solid var(--japta-border); border-radius: .5rem; padding: .7rem .9rem; margin-bottom: .75rem; }
.kpi-block h2 { font-size: 1rem; font-weight: 700; margin-bottom: .5rem; color: #1d2a3a; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .5rem; }
.kpi { border: 1px solid var(--japta-border); border-radius: .4rem; padding: .45rem .6rem; background: #fbfcfe; }
.kpi span { display: block; font-size: .78rem; color: #5c6b7d; }
.kpi b { font-size: 1.45rem; color: #1d2a3a; }
.kpi.good { border-inline-start: 4px solid #0b7a62; }
.kpi.bad { border-inline-start: 4px solid #a12622; }
.kpi.warn { border-inline-start: 4px solid #b7791f; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 1rem; color: #3b4756; }
.chart-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 4px; vertical-align: -1px; }
.sw-req { background: #e3e8ef; outline: 1px solid #c3cad4; }
.sw-con { background: #1f5fae; }
.sw-add { background: #f39c12; }
.col-chart { display: flex; align-items: stretch; gap: 6px; height: 220px; border-bottom: 1px solid #c3cad4; padding-top: 18px; }
.col-group { flex: 1; display: flex; flex-direction: column; position: relative; min-width: 0; }
.col-group .bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.col-group .bar { width: 30%; max-width: 16px; border-radius: 4px 4px 0 0; position: relative; min-height: 0; }
.col-group .bar.req { background: #e3e8ef; }
.col-group .bar.con { background: #1f5fae; }
.col-group .bar.add { background: #f39c12; }
.col-group .bar em { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-style: normal; font-size: .65rem; color: #3b4756; }
.col-group .lbl { text-align: center; font-size: .7rem; color: #5c6b7d; margin-top: 2px; }
.col-group .tip { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #1d2a3a; color: #fff;
                  font-size: .72rem; padding: .35rem .5rem; border-radius: .3rem; white-space: nowrap; z-index: 5; }
.col-group:hover .tip, .col-group:focus .tip { display: block; }
.col-group:hover .bars, .col-group:focus .bars { background: #f3f6fa; }
.meter { display: inline-block; width: 60px; height: 6px; background: #e3e8ef; border-radius: 3px; vertical-align: middle; overflow: hidden; }
.meter i { display: block; height: 100%; background: #0b7a62; }
.prio-Emergency { background: #a12622; color: #fff; }
.prio-Urgent { background: #f39c12; color: #fff; }
.prio-Normal { background: #e3e8ef; color: #1d2a3a; }

@media print {
    .app-topbar, .app-sidebar, .no-print { display: none !important; }
    .app-main { padding: 0; }
}

.app-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem;
             background: linear-gradient(135deg, var(--japta-blue), var(--japta-teal)); }
.login-shell { width: 100%; max-width: 860px; display: grid; grid-template-columns: 1fr 1.1fr; background: #fff;
               border-radius: 1rem; overflow: hidden; box-shadow: 0 20px 50px rgba(15, 40, 80, .28); }
.login-brand { padding: 3rem 2.5rem; color: #fff; display: flex; flex-direction: column; justify-content: center;
               background: linear-gradient(160deg, var(--japta-blue-dark), var(--japta-blue) 55%, var(--japta-teal)); }
.login-logo { font-size: 2.6rem; font-weight: 800; letter-spacing: .12em; line-height: 1; margin-bottom: 1.25rem; }
.login-app { font-size: 1.35rem; font-weight: 700; margin-bottom: .5rem; }
.login-tagline { opacity: .85; margin: 0; line-height: 1.7; }
.login-form { padding: 3rem 2.5rem; }
.login-form .form-control { border-radius: .6rem; }
.login-form .btn-lg { border-radius: .6rem; font-weight: 600; }
@media (max-width: 720px) {
    .login-shell { grid-template-columns: 1fr; max-width: 420px; }
    .login-brand { padding: 1.75rem 1.5rem; text-align: center; }
    .login-logo { font-size: 2rem; margin-bottom: .6rem; }
    .login-tagline { display: none; }
    .login-form { padding: 1.75rem 1.5rem; }
}
