/* ============================================================
   Support & Marketing Campaigns System — main stylesheet
   Identity: corporate purple (#4A1259 / #6B1F7A) — LTR
   ============================================================ */

:root {
    --brand-900: #340C40;
    --brand-800: #4A1259;   /* العناوين الرئيسية */
    --brand-700: #6B1F7A;   /* العناوين الفرعية والأزرار */
    --brand-600: #7B2D8B;
    --brand-100: #F3E8F7;   /* صفوف الجداول الفاتحة */
    --brand-50:  #FAF5FC;
    --ink:       #2B2233;
    --muted:     #837A8C;
    --line:      #E5DCEB;
    --warn-bg:   #FFF3CD;
    --warn-text: #C0392B;
    --orange:    #E67E22;
    --blue:      #1A5276;
    --ok:        #1E7B4F;
    --bg:        #F6F3F8;
    --card:      #FFFFFF;
    --radius:    10px;
    --shadow:    0 1px 3px rgba(52, 12, 64, 0.08), 0 4px 16px rgba(52, 12, 64, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: 'IBM Plex Sans', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--ink);
    direction: ltr;
    min-height: 100vh;
    line-height: 1.65;
}

/* ------------------------------------------------------------
   صفحة تسجيل الدخول
   ------------------------------------------------------------ */
.login-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 5fr 4fr;
}

.login-side {
    background: linear-gradient(160deg, var(--brand-900) 0%, var(--brand-700) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 64px;
    position: relative;
    overflow: hidden;
}

.login-side::after {
    /* مسار دورة الحياة كعنصر بصري — خطوط المراحل */
    content: '';
    position: absolute;
    inset-inline-start: -120px;
    bottom: -120px;
    width: 420px;
    height: 420px;
    border: 2px solid rgba(255, 255, 255, 0.07);
    border-radius: 50%;
    box-shadow: 0 0 0 60px rgba(255,255,255,0.03), 0 0 0 130px rgba(255,255,255,0.02);
}

.login-side h1 {
    font-size: 1.9rem;
    font-weight: 700;
    margin-bottom: 14px;
    line-height: 1.4;
}

.login-side p {
    color: rgba(255, 255, 255, 0.75);
    max-width: 42ch;
    font-size: 0.98rem;
}

.login-side .phases {
    margin-top: 42px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.login-side .phases span {
    font-size: 0.78rem;
    padding: 5px 13px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.85);
}

.login-form-col {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: var(--card);
}

.login-card {
    width: 100%;
    max-width: 380px;
}

.login-card h2 {
    color: var(--brand-800);
    font-size: 1.35rem;
    margin-bottom: 6px;
}

.login-card .hint {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

/* ------------------------------------------------------------
   النماذج
   ------------------------------------------------------------ */
.field { margin-bottom: 18px; }

.field label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--brand-800);
    margin-bottom: 7px;
}

.field input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    background: #fff;
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
    outline: none;
    border-color: var(--brand-700);
    box-shadow: 0 0 0 3px rgba(107, 31, 122, 0.12);
}

.field input::placeholder { color: #B9B0C2; }

.btn {
    display: inline-block;
    width: 100%;
    padding: 12px 18px;
    background: var(--brand-700);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.btn:hover  { background: var(--brand-800); }
.btn:focus-visible { outline: 3px solid rgba(107, 31, 122, 0.35); outline-offset: 2px; }

.btn-ghost {
    background: transparent;
    color: var(--brand-700);
    border: 1.5px solid var(--line);
    width: auto;
}
.btn-ghost:hover { background: var(--brand-50); }

/* ------------------------------------------------------------
   التنبيهات
   ------------------------------------------------------------ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.92rem;
}

.alert-error {
    background: var(--warn-bg);
    color: var(--warn-text);
    border-inline-start: 4px solid var(--orange);
}

.alert-success {
    background: #E7F6EE;
    color: var(--ok);
    border-inline-start: 4px solid var(--ok);
}

/* ------------------------------------------------------------
   الهيكل الداخلي (بعد الدخول)
   ------------------------------------------------------------ */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 0 28px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar .brand {
    color: var(--brand-800);
    font-weight: 700;
    font-size: 1.02rem;
}

.topbar .user-area {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.88rem;
    color: var(--muted);
}

.topbar .user-area a {
    color: var(--brand-700);
    text-decoration: none;
    font-weight: 600;
}
.topbar .user-area a:hover { text-decoration: underline; }

.page {
    max-width: 1200px;
    margin: 32px auto;
    padding: 0 24px;
}

.page-title {
    color: var(--brand-800);
    font-size: 1.45rem;
    font-weight: 700;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--brand-700);
    margin-bottom: 26px;
    display: inline-block;
}

/* بطاقات الإحصاءات */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    border-top: 4px solid var(--brand-700);
}

.stat-card .num {
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--blue);
    line-height: 1.2;
}

.stat-card .label {
    color: var(--muted);
    font-size: 0.88rem;
    margin-top: 4px;
}

.notice-box {
    margin-top: 28px;
    background: var(--warn-bg);
    border-inline-start: 5px solid var(--orange);
    color: #7D3C00;
    border-radius: var(--radius);
    padding: 16px 20px;
    font-size: 0.93rem;
}

/* صفحات الأخطاء */
.error-page {
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
}

.error-page .code {
    font-size: 4.5rem;
    font-weight: 700;
    color: var(--brand-700);
    line-height: 1;
}

.error-page .msg {
    color: var(--muted);
    margin: 14px 0 26px;
}

/* الجداول — تُستخدم من المرحلة ٢ فصاعداً */
table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.92rem;
}

table.data th {
    background: var(--brand-700);
    color: #fff;
    font-weight: 700;
    padding: 11px 14px;
    text-align: left;
    border: 1px solid var(--brand-600);
}

table.data td {
    padding: 9px 14px;
    border: 1px solid #E9E2EE;
}

table.data tbody tr:nth-child(even) { background: var(--brand-100); }
table.data tbody tr.dup-warning     { background: var(--warn-bg); }
table.data tbody tr.dup-warning td  { color: var(--warn-text); font-weight: 700; }

/* استجابة الموبايل */
@media (max-width: 860px) {
    .login-wrap { grid-template-columns: 1fr; }
    .login-side { padding: 40px 28px; min-height: 220px; }
    .login-side .phases { display: none; }
    .topbar { padding: 0 16px; }
    .topbar .brand { font-size: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ============================================================
   Phase 2 — Branch & User management
   ============================================================ */

/* Admin navigation bar */
.admin-nav {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 0 28px;
    display: flex;
    gap: 2px;
}
.admin-nav .nav-link {
    display: inline-block;
    padding: 11px 16px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.admin-nav .nav-link:hover  { color: var(--brand-700); }
.admin-nav .nav-link.active { color: var(--brand-700); border-bottom-color: var(--brand-700); }

/* Page actions row (title + search + button) */
.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 14px;
    flex-wrap: wrap;
}
.page-actions .page-title { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }

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

/* Search input */
.search-bar {
    padding: 8px 13px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.9rem;
    width: 240px;
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.search-bar:focus {
    outline: none;
    border-color: var(--brand-700);
    box-shadow: 0 0 0 3px rgba(107,31,122,0.1);
}

/* Small buttons */
.btn-sm {
    display: inline-block;
    padding: 6px 13px;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 7px;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background 0.13s, color 0.13s;
    white-space: nowrap;
    line-height: 1.4;
}
.btn-add      { background: var(--brand-700); color: #fff; border-color: var(--brand-700); }
.btn-add:hover{ background: var(--brand-800); border-color: var(--brand-800); }

.btn-edit       { background: #EAF2FB; color: var(--blue);       border-color: #BDD3E8; }
.btn-edit:hover { background: #D3E8F7; }

.btn-deactivate       { background: #FFF3CD; color: #7D5A00; border-color: #F0D785; }
.btn-deactivate:hover { background: #FFE89A; }

.btn-activate       { background: #E7F6EE; color: var(--ok); border-color: #A7D9BC; }
.btn-activate:hover { background: #CCEFDA; }

.btn-reset        { background: #FBEAEA; color: var(--warn-text); border-color: #F0BBBB; }
.btn-reset:hover  { background: #F5D0D0; }

.btn-sm:disabled { opacity: 0.55; cursor: not-allowed; }

.tbl-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Status / role badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}
.badge-active   { background: #E7F6EE; color: var(--ok); }
.badge-inactive { background: #EFEFEF; color: #888; }
.badge-admin    { background: var(--brand-100); color: var(--brand-800); }
.badge-manager  { background: #EAF2FB; color: var(--blue); }
.badge-user     { background: #FEF5E7; color: #7D5A00; }

/* No-results table row */
.no-results td {
    text-align: center;
    color: var(--muted);
    padding: 30px !important;
    font-style: italic;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(36, 8, 46, 0.42);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay[hidden] { display: none; }

.modal-box {
    background: var(--card);
    border-radius: 14px;
    box-shadow: 0 10px 48px rgba(36,8,46,0.22);
    width: 100%;
    max-width: 460px;
    max-height: 92vh;
    overflow-y: auto;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 0;
}
.modal-head h3 { color: var(--brand-800); font-size: 1.05rem; font-weight: 700; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 20px 24px 24px; }

.modal-error {
    background: var(--warn-bg);
    color: var(--warn-text);
    border-left: 3px solid var(--orange);
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 0.88rem;
    margin-bottom: 14px;
}

/* Password reveal box */
.pass-box {
    background: var(--brand-50);
    border: 1.5px solid var(--brand-100);
    border-radius: var(--radius);
    padding: 20px 18px;
    text-align: center;
    margin-bottom: 16px;
}
.pass-box .pass-label { font-size: 0.83rem; color: var(--muted); margin-bottom: 6px; }
.pass-box .pass-val {
    font-family: 'Courier New', monospace;
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--brand-800);
    letter-spacing: 3px;
    display: block;
    margin: 4px 0 8px;
}
.pass-box .pass-note { font-size: 0.8rem; color: var(--orange); }

@media (max-width: 700px) {
    .search-bar { width: 100%; }
    .page-actions { flex-direction: column; align-items: flex-start; }
    .admin-nav { padding: 0 14px; }
    .admin-nav .nav-link { padding: 10px 11px; font-size: 0.82rem; }
}

/* ============================================================
   Phase 3 — Customer Database
   ============================================================ */

.card-panel {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 28px;
}

.section-title {
    color: var(--brand-800);
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

/* Progress bar */
.progress-wrap {
    background: var(--line);
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}
.progress-bar {
    background: linear-gradient(90deg, var(--brand-700), var(--brand-600));
    height: 100%;
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* Import results cards */
.import-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 14px;
}
.ir-card {
    border-radius: var(--radius);
    padding: 16px 14px;
    text-align: center;
    border: 1.5px solid transparent;
}
.ir-num   { font-size: 1.8rem; font-weight: 700; line-height: 1.2; }
.ir-label { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

.ir-added     { background: #E7F6EE; border-color: #A7D9BC; }
.ir-added     .ir-num { color: var(--ok); }
.ir-updated   { background: #EAF2FB; border-color: #BDD3E8; }
.ir-updated   .ir-num { color: var(--blue); }
.ir-unchanged { background: #F5F5F5; border-color: #DDD; }
.ir-unchanged .ir-num { color: var(--muted); }
.ir-skipped   { background: var(--warn-bg); border-color: #F0D785; }
.ir-skipped   .ir-num { color: var(--orange); }

/* Column checker pills */
.col-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    margin: 3px 4px;
}
.col-pill-ok      { background: #E7F6EE; color: var(--ok); }
.col-pill-missing { background: #EFEFEF; color: var(--muted); }

@media (max-width: 600px) {
    .card-panel { padding: 18px 16px; }
    .import-results { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   Phase 4 — Campaigns
   ============================================================ */

/* Phase badges */
.phase-badge {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}
.phase-draft       { background:#EFEFEF;color:#888; }
.phase-collecting  { background:#EAF2FB;color:var(--blue); }
.phase-review      { background:#FEF5E7;color:#7D5A00; }
.phase-amendment   { background:#FBEAEA;color:var(--warn-text); }
.phase-approved    { background:#E7F6EE;color:var(--ok); }
.phase-agreements  { background:#E8F8F5;color:#1E8449; }
.phase-sales_entry { background:var(--brand-100);color:var(--brand-800); }
.phase-tax_notices { background:#EAF2FB;color:var(--blue); }
.phase-completed   { background:#1E7B4F;color:#fff; }

/* Type badges */
.type-support   { background:#EAF2FB;color:var(--blue);   }
.type-marketing { background:var(--brand-100);color:var(--brand-800); }

/* Campaign list cards */
.campaigns-table-wrap { overflow-x: auto; }

/* Phase stepper */
.phase-stepper {
    display: flex;
    align-items: flex-start;
    overflow-x: auto;
    padding: 6px 0 18px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.ps-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 72px;
    position: relative;
}
.ps-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 15px;
    left: calc(50% + 16px);
    width: calc(100% - 32px);
    height: 2px;
    background: var(--line);
    z-index: 0;
}
.ps-step.ps-done::after  { background: var(--brand-700); }

.ps-dot {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 2px solid var(--line);
    background: var(--card);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.72rem; font-weight: 700; color: var(--muted);
    position: relative; z-index: 1;
    transition: all 0.2s;
}
.ps-step.ps-done .ps-dot {
    background: var(--brand-700); border-color: var(--brand-700); color: #fff;
}
.ps-step.ps-current .ps-dot {
    background: var(--brand-700); border-color: var(--brand-700); color: #fff;
    box-shadow: 0 0 0 5px rgba(107,31,122,0.14);
}
.ps-label {
    font-size: 0.67rem; color: var(--muted);
    text-align: center; margin-top: 5px;
    max-width: 70px; line-height: 1.3;
}
.ps-step.ps-done .ps-label,
.ps-step.ps-current .ps-label { color: var(--brand-700); font-weight: 700; }

/* Branch status in campaign detail */
.status-open      { background:#EAF2FB;color:var(--blue); }
.status-saved     { background:#FEF5E7;color:#7D5A00; }
.status-submitted { background:#E7F6EE;color:var(--ok); }
.status-locked    { background:#EFEFEF;color:#888; }

/* Campaign detail info card */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.info-item .info-label { font-size: 0.78rem; color: var(--muted); margin-bottom: 3px; }
.info-item .info-val   { font-size: 0.95rem; font-weight: 600; color: var(--ink); }

/* Phase action card */
.phase-action-card {
    background: var(--brand-50);
    border: 1.5px solid var(--brand-100);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 22px;
}
.phase-action-card .pac-title {
    font-size: 0.82rem; font-weight: 700;
    color: var(--muted); margin-bottom: 10px;
    text-transform: uppercase; letter-spacing: 0.04em;
}

/* Create campaign form */
.branch-assign-row {
    display: grid;
    grid-template-columns: 24px 110px 1fr 1fr;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
}
.branch-assign-row:last-child { border-bottom: none; }

/* ============================================================
   Phase 4 — Campaigns
   ============================================================ */

/* Type badges */
.badge-support   { background:#E8F4FD; color:#1A5276; }
.badge-marketing { background:#FEF5E7; color:#7D5A00; }

/* Phase stepper */
.phase-stepper {
    display: flex;
    align-items: flex-start;
    overflow-x: auto;
    padding: 8px 0 4px;
    gap: 0;
    scrollbar-width: none;
}
.phase-stepper::-webkit-scrollbar { display: none; }

.phase-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-width: 88px;
    flex: 1;
}
.phase-step::after {
    content: '';
    position: absolute;
    top: 13px;
    left: 50%;
    width: 100%;
    height: 3px;
    background: var(--line);
    z-index: 0;
}
.phase-step:last-child::after { display: none; }

.phase-dot {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--card);
    border: 2.5px solid var(--line);
    z-index: 1;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.72rem; font-weight: 700;
    color: var(--muted);
    position: relative;
}
.phase-step.done .phase-dot    { background: var(--ok); border-color: var(--ok); color: #fff; }
.phase-step.current .phase-dot { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.phase-step.done::after        { background: var(--ok); }

.phase-lbl {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 6px;
    text-align: center;
    max-width: 82px;
    line-height: 1.3;
}
.phase-step.current .phase-lbl { color: var(--brand-700); font-weight: 700; }
.phase-step.done    .phase-lbl { color: var(--ok); }

/* Edit-status badges */
.badge-open      { background: #E7F6EE; color: var(--ok); }
.badge-saved     { background: #EAF2FB; color: var(--blue); }
.badge-submitted { background: var(--brand-100); color: var(--brand-800); }
.badge-locked    { background: #EFEFEF; color: #888; }

/* Campaign phase action buttons */
.phase-btn {
    display: inline-block;
    padding: 8px 20px;
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: background 0.13s;
}
.phase-btn-primary { background: var(--brand-700); color: #fff; border-color: var(--brand-700); }
.phase-btn-primary:hover { background: var(--brand-800); }
.phase-btn-warn   { background: #FFF3CD; color: #7D5A00; border-color: #F0D785; }
.phase-btn-warn:hover { background: #FFE89A; }
.phase-btn-approve{ background: #E7F6EE; color: var(--ok); border-color: #A7D9BC; }
.phase-btn-approve:hover { background: #CCEFDA; }

/* Campaign row phase pill */
.phase-pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}
.phase-collecting  { background:#EAF2FB; color:var(--blue); }
.phase-review      { background:#FEF5E7; color:#7D5A00; }
.phase-amendment   { background:var(--warn-bg); color:var(--orange); }
.phase-approved    { background:#E7F6EE; color:var(--ok); }
.phase-agreements  { background:var(--brand-100); color:var(--brand-800); }
.phase-sales_entry { background:#F0E6FF; color:#6A1B9A; }
.phase-tax_notices { background:#FEE8D6; color:#C0392B; }
.phase-completed   { background:#E8F8F5; color:#1E8449; }
.phase-draft       { background:#F5F5F5; color:#888; }

/* ============================================================
   Phase 5 — Data Entry
   ============================================================ */

/* Entry table wrapper */
.entry-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }

.entry-tbl {
    border-collapse: collapse;
    width: 100%;
    min-width: 620px;
    background: var(--card);
    font-size: 0.875rem;
}
.entry-tbl th {
    background: var(--brand-700);
    color: #fff;
    padding: 9px 8px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid var(--brand-600);
}
.entry-tbl td {
    padding: 3px 4px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.entry-tbl tbody tr:hover { background: var(--brand-50); }
.entry-tbl tr.dup-warn    { background: var(--warn-bg) !important; }
.entry-tbl tr.dup-warn td { border-bottom-color: #F0D785; }

/* Entry cell inputs */
.ec {
    width: 100%;
    border: 1.5px solid transparent;
    border-radius: 5px;
    padding: 6px 8px;
    font: inherit;
    font-size: 0.875rem;
    background: transparent;
    color: var(--ink);
    box-sizing: border-box;
    transition: border-color 0.12s, background 0.12s;
}
.ec:focus {
    outline: none;
    border-color: var(--brand-700);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(107,31,122,0.1);
}
.ec[readonly]        { color: var(--muted); cursor: default; }
.ec[readonly]:focus  { border-color: transparent; box-shadow: none; background: transparent; }
.ec-num              { text-align: right; }
.ec-name             { font-size: 0.82rem; }

/* Autocomplete */
.ac-wrap { position: relative; }
.ac-list {
    display: none;
    position: absolute;
    top: calc(100% + 2px); left: 0;
    min-width: 340px; max-height: 230px;
    overflow-y: auto;
    background: var(--card);
    border: 1.5px solid var(--brand-700);
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(52,12,64,0.16);
    z-index: 200;
}
.ac-item {
    padding: 9px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--line);
}
.ac-item:last-child    { border-bottom: none; }
.ac-item:hover         { background: var(--brand-50); }
.ac-code { font-weight: 700; color: var(--brand-800); white-space: nowrap; font-size: 0.88rem; }
.ac-name { color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-branch { font-size: 0.75rem; color: var(--brand-600); white-space: nowrap; }

/* Entry page toolbar */
.entry-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}
.entry-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Save indicator */
.saved-badge {
    font-size: 0.82rem;
    color: var(--ok);
    font-weight: 600;
    padding: 4px 10px;
    background: #E7F6EE;
    border-radius: 999px;
}

/* Duplicate warning banner */
.dup-banner {
    background: var(--warn-bg);
    border-left: 4px solid var(--orange);
    color: #7D3C00;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.88rem;
    margin-bottom: 12px;
}

/* Locked notice */
.locked-notice {
    background: #F5F5F5;
    border-left: 4px solid var(--muted);
    color: var(--muted);
    padding: 12px 18px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 0.9rem;
}

@media (max-width: 700px) {
    .entry-toolbar { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   Phase 5 — Data Entry
   ============================================================ */

/* Entry table */
.entry-table { width:100%; border-collapse:collapse; font-size:0.83rem; }
.entry-table th {
    background:var(--brand-700); color:#fff; font-weight:700;
    padding:9px 8px; white-space:nowrap; text-align:left;
    border:1px solid var(--brand-600);
}
.entry-table td { padding:4px 5px; border:1px solid #E9E2EE; vertical-align:middle; }
.entry-table tbody tr:nth-child(even) td { background:var(--brand-100); }
.entry-table tr.dup-warning td { background:#FFF3CD !important; }
.entry-table .row-num { text-align:center; width:34px; color:var(--muted); font-size:0.78rem; }

.entry-inp {
    width:100%; padding:5px 7px;
    border:1.5px solid var(--line); border-radius:6px;
    font:inherit; font-size:0.83rem; background:#fff;
}
.entry-inp:focus { outline:none; border-color:var(--brand-700); box-shadow:0 0 0 2px rgba(107,31,122,.1); }
.entry-inp[readonly] { background:var(--bg); color:var(--muted); cursor:default; }
.entry-inp.has-error  { border-color:var(--orange); }
.dup-warning .entry-inp { border-color:var(--orange) !important; }

/* Column widths */
.td-ac    { min-width:130px; }
.td-name  { min-width:200px; }
.td-num   { min-width:100px; }
.td-del   { width:36px; text-align:center; }

.del-row-btn {
    background:none; border:none; color:#C0392B; font-size:1rem;
    cursor:pointer; padding:2px 5px; border-radius:4px;
}
.del-row-btn:hover { background:#FBEAEA; }

/* Autocomplete */
.ac-wrap { position:relative; }
.ac-dropdown {
    position:absolute; top:100%; left:0; right:0;
    background:#fff; border:1.5px solid var(--brand-700);
    border-top:none; border-radius:0 0 8px 8px;
    z-index:100; max-height:190px; overflow-y:auto;
    box-shadow:0 4px 16px rgba(52,12,64,.15);
}
.ac-dropdown[hidden] { display:none; }
.ac-item { padding:8px 12px; cursor:pointer; font-size:0.83rem; border-bottom:1px solid var(--line); }
.ac-item:hover { background:var(--brand-50); }
.ac-item:last-child { border-bottom:none; }
.ac-code { font-weight:700; color:var(--brand-800); }
.ac-branch { font-size:0.73rem; color:var(--muted); background:var(--bg);
             padding:1px 5px; border-radius:4px; margin-left:6px; }

/* Entry page action bar */
.entry-actions {
    position:sticky; bottom:0; background:#fff;
    border-top:2px solid var(--line);
    padding:12px 0; margin-top:20px;
    display:flex; gap:12px; align-items:center; flex-wrap:wrap;
    z-index:10;
}
.save-indicator {
    font-size:0.82rem; color:var(--muted);
    display:flex; align-items:center; gap:5px;
}
.save-indicator.saved  { color:var(--ok); }
.save-indicator.unsaved{ color:var(--orange); }

/* Readonly notice banner */
.readonly-banner {
    background:#FEF5E7; border:1.5px solid #F0D785;
    border-radius:var(--radius); padding:13px 18px;
    font-size:0.88rem; color:#7D5A00;
    margin-bottom:18px; display:flex; align-items:center; gap:8px;
}

/* ============================================================
   Fix: Phase Stepper — horizontal connectors (replaces old stepper)
   ============================================================ */
.phase-stepper {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start;
    overflow-x: auto;
    padding: 18px 4px 10px;
    scrollbar-width: none;
    gap: 0;
}
.phase-stepper::-webkit-scrollbar { display: none; }

.ps-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 0 auto;
    width: 76px;
}

.ps-connector {
    flex: 1 1 0;
    min-width: 6px;
    max-width: 44px;
    height: 3px;
    background: var(--line);
    margin-top: 12px;   /* (28px dot - 3px line) / 2 = 12.5 */
    border-radius: 2px;
    flex-shrink: 1;
}

.ps-dot {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--card);
    border: 2.5px solid var(--line);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.72rem; font-weight: 700;
    color: var(--muted); z-index: 1;
}
.ps-lbl {
    font-size: 0.67rem;
    color: var(--muted);
    margin-top: 6px;
    text-align: center;
    line-height: 1.3;
    max-width: 74px;
    word-break: break-word;
}

.ps-step.done    .ps-dot { background: var(--ok);        border-color: var(--ok);        color: #fff; }
.ps-step.done    .ps-lbl { color: var(--ok); }
.ps-connector.done       { background: var(--ok); }
.ps-step.current .ps-dot { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.ps-step.current .ps-lbl { color: var(--brand-700); font-weight: 700; }

/* ============================================================
   Phase 7 — Agreements
   ============================================================ */
.upload-zone {
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    padding: 14px 18px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    font-size: 0.85rem;
    color: var(--muted);
}
.upload-zone:hover { border-color: var(--brand-700); background: var(--brand-50); color: var(--brand-700); }

.file-pill {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--brand-50); border: 1.5px solid var(--brand-100);
    border-radius: 20px; padding: 4px 12px 4px 8px;
    font-size: 0.8rem; color: var(--brand-800); font-weight: 600;
    max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-pill .fp-icon { font-size: 1rem; flex-shrink: 0; }

.badge-uploaded  { background: #E7F6EE; color: var(--ok); }
.badge-pending   { background: var(--warn-bg); color: var(--orange); }
.badge-disabled  { background: #EFEFEF; color: #888; }

/* Image preview modal */
.img-preview-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.80);
    z-index: 500;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.img-preview-overlay[hidden] { display: none; }
.img-preview-overlay img {
    max-width: 100%; max-height: 90vh;
    border-radius: 8px; box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.img-preview-close {
    position: absolute; top: 16px; right: 16px;
    background: rgba(255,255,255,0.15); border: none;
    color: #fff; font-size: 2rem; cursor: pointer;
    border-radius: 50%; width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
}
.img-preview-close:hover { background: rgba(255,255,255,0.3); }

.section-sep {
    border: none; border-top: 2px solid var(--line);
    margin: 24px 0;
}

/* ============================================================
   Phase 7b — Sales Entry & Tax Notices
   ============================================================ */
.badge-achieved     { background: #E7F6EE; color: var(--ok); }
.badge-not-achieved { background: #FBEAEA; color: #C0392B; }
.badge-exception    { background: #EDE7F6; color: #6B3FA0; }
.badge-no-data      { background: #EFEFEF; color: #888; }

.sales-inp {
    width: 110px; padding: 5px 7px;
    border: 1.5px solid var(--line); border-radius: 6px;
    font: inherit; font-size: 0.83rem;
}
.sales-inp:focus { outline: none; border-color: var(--brand-700); }
.sales-inp.achieved     { border-color: var(--ok); }
.sales-inp.not-achieved { border-color: #C0392B; }

.upload-progress-wrap {
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 22px 26px; margin-bottom: 18px;
}
.progress-bar-track {
    background: var(--bg); border-radius: 20px; height: 10px; overflow: hidden;
}
.progress-bar-fill {
    background: var(--brand-700); height: 100%; border-radius: 20px;
    transition: width 0.2s;
}

/* ============================================================
   Image preview — rotate & download toolbar
   ============================================================ */
.img-preview-overlay img {
    transition: transform 0.25s ease;
    transform: rotate(0deg);
}
.img-preview-overlay img.rot-90  { transform: rotate(90deg);  max-width: 90vh; max-height: 90vw; }
.img-preview-overlay img.rot-180 { transform: rotate(180deg); }
.img-preview-overlay img.rot-270 { transform: rotate(270deg); max-width: 90vh; max-height: 90vw; }

.img-preview-toolbar {
    position: absolute; top: 16px; left: 16px;
    display: flex; gap: 10px; z-index: 1;
}
.img-preview-btn {
    background: rgba(255,255,255,0.15); border: none;
    color: #fff; font-size: 0.85rem; font-weight: 600; cursor: pointer;
    border-radius: 22px; padding: 10px 18px;
    display: flex; align-items: center; gap: 6px;
    transition: background 0.15s;
}
.img-preview-btn:hover { background: rgba(255,255,255,0.3); }

/* ============================================================
   Dashboard Reports — multi-select filters
   ============================================================ */
.ms-wrap { position: relative; display: inline-block; }
.ms-trigger {
    padding: 8px 14px; border: 1.5px solid var(--line); border-radius: var(--radius);
    background: #fff; font: inherit; font-size: 0.85rem; cursor: pointer;
    display: flex; align-items: center; gap: 6px; min-width: 150px; justify-content: space-between;
}
.ms-trigger:hover { border-color: var(--brand-700); }
.ms-panel {
    position: absolute; top: 100%; left: 0; margin-top: 4px;
    background: #fff; border: 1.5px solid var(--brand-700); border-radius: 8px;
    box-shadow: 0 6px 20px rgba(52,12,64,.15); z-index: 50;
    min-width: 240px; max-height: 280px; overflow-y: auto; padding: 8px;
}
.ms-panel[hidden] { display: none; }
.ms-panel label {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px;
    border-radius: 6px; cursor: pointer; font-size: 0.85rem; font-weight: 400;
}
.ms-panel label:hover { background: var(--brand-50); }
.ms-panel-actions { display: flex; gap: 8px; padding: 4px 8px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.ms-panel-actions button {
    font-size: 0.75rem; color: var(--brand-700); background: none; border: none; cursor: pointer; text-decoration: underline;
}

.tag-input-box {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
    border: 1.5px solid var(--line); border-radius: var(--radius);
    padding: 6px 8px; min-width: 280px; background: #fff;
}
.tag-input-box:focus-within { border-color: var(--brand-700); }
.tag-chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--brand-50); border: 1px solid var(--brand-100);
    border-radius: 14px; padding: 3px 6px 3px 10px; font-size: 0.8rem; color: var(--brand-800);
}
.tag-chip button { background: none; border: none; color: var(--brand-700); cursor: pointer; font-size: 0.9rem; padding: 0 3px; }
.tag-input-box input {
    border: none; outline: none; font: inherit; font-size: 0.85rem; flex: 1; min-width: 100px; padding: 4px;
}

.report-section { margin-top: 28px; }
.report-section h2.section-title { margin-top: 0; }

/* ============================================================
   Dashboard — Danger zone (delete campaign)
   ============================================================ */
.danger-zone {
    margin-top: 32px;
    border: 2px solid #E74C3C;
    border-radius: var(--radius);
    background: #FFF5F5;
    padding: 20px 24px;
}
.danger-zone h2 { color: #C0392B; font-size: 1rem; font-weight: 700; margin: 0 0 6px; }
.danger-zone p { color: #8B2E22; font-size: 0.85rem; margin: 0 0 16px; }
.btn-danger {
    background: #E74C3C; color: #fff; border: 1.5px solid #C0392B;
    border-radius: var(--radius); padding: 9px 22px; font: inherit; font-size: 0.85rem;
    font-weight: 600; cursor: pointer;
}
.btn-danger:hover { background: #C0392B; }
.btn-danger:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============================================================
   Phase 9 — Excel column-mapped import (independent feature)
   ============================================================ */
.import-col-select {
    width: 100%; padding: 9px 12px;
    border: 1.5px solid var(--line); border-radius: var(--radius);
    font: inherit; font-size: 0.88rem; background: #fff;
}
.import-mapping-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px; margin: 16px 0;
}
.import-stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 16px 0; }
.import-stat {
    flex: 1; min-width: 130px; text-align: center;
    padding: 14px; border-radius: var(--radius); background: var(--bg);
}
.import-stat .num { font-size: 1.5rem; font-weight: 700; }
.import-stat .lbl { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

/* ============================================================
   Print Campaign Review — pivot report (independent feature)
   ============================================================ */
.pivot-table { font-size: 0.82rem; }
.pivot-table th.grp-amount { background: #E8F0FB; color: var(--blue); }
.pivot-table th.grp-target { background: #FDF0E3; color: var(--orange); }
.pivot-table tr.totals-row td {
    background: var(--brand-100); font-weight: 700; border-top: 2px solid var(--brand-700);
}
