/* ========================================
   MODUL 2 - EVIDENȚĂ CASIERII CU BANI DE ADUS
   Unified Table Layout — Slate + Teal
   ======================================== */

.modul2-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: visible;
}

/* ── Header ───────────────────────────── */

.m2-header {
    background: #ffffff;
    padding: 0;
    border-bottom: 1px solid #e2e8f0;
}

.m2-header-top {
    background: #ffffff;
    padding: 0;
    position: relative;
    overflow: hidden;
}

.m2-header-accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #0d9488 0%, #14b8a6 40%, #99f6e4 100%);
}

.m2-header-content {
    padding: 18px 28px;
    position: relative;
}

.m2-brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.m2-brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);
    border: 1.5px solid #99f6e4;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0d9488;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.12);
}

.m2-brand-text {
    min-width: 0;
}

.m2-title {
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.m2-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
}

.m2-title-group {
    display: flex;
    align-items: baseline;
    gap: 18px;
    flex-wrap: wrap;
}

.m2-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px 3px 7px;
    border-radius: 8px;
    white-space: nowrap;
}

.m2-meta-pill--date {
    background: #f0fdfa;
    border: 1px solid #99f6e4;
    color: #0f766e;
}

.m2-meta-pill--date svg { color: #14b8a6; }

.m2-meta-pill--loc {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #64748b;
    font-weight: 500;
    font-size: 10.5px;
    white-space: normal;
}

.m2-meta-pill--loc svg { color: #94a3b8; }

.m2-meta-item svg { color: #94a3b8; flex-shrink: 0; }

/* ── Stats Row ────────────────────────── */

.m2-stats-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 28px;
    background: white;
}

.m2-stat {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    padding: 10px 14px;
    min-width: 140px;
    flex: 1 1 0;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    animation: m2FadeInUp 0.3s ease-out both;
}

.m2-stat:hover {
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
    transform: translateY(-1px);
}

.m2-stat-icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: #e2e8f0; color: #475569;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.m2-stat-data { display: flex; flex-direction: column; min-width: 0; }

.m2-stat-num {
    font-size: 20px; font-weight: 700; color: #0f172a;
    line-height: 1.2; letter-spacing: -0.01em;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.m2-stat-num small { font-size: 12px; font-weight: 600; color: #64748b; letter-spacing: 0.02em; }

.m2-stat-label {
    font-size: 10px; font-weight: 600; color: #94a3b8;
    text-transform: uppercase; letter-spacing: 0.05em; margin-top: 1px;
}

/* Stat variants */
.m2-stat--danger { background: #fef2f2; border-color: #fecaca; }
.m2-stat--danger:hover { border-color: #fca5a5; }
.m2-stat--danger .m2-stat-icon { background: #fee2e2; color: #dc2626; }
.m2-stat--danger .m2-stat-num { color: #dc2626; }

.m2-stat--info { background: #eff6ff; border-color: #bfdbfe; }
.m2-stat--info:hover { border-color: #93c5fd; }
.m2-stat--info .m2-stat-icon { background: #dbeafe; color: #2563eb; }
.m2-stat--info .m2-stat-num { color: #1e40af; }

.m2-stat--amber { background: #fffbeb; border-color: #fde68a; }
.m2-stat--amber:hover { border-color: #fcd34d; }
.m2-stat--amber .m2-stat-icon { background: #fef3c7; color: #d97706; }
.m2-stat--amber .m2-stat-num { color: #92400e; }

.m2-stat--slate { background: #f1f5f9; border-color: #cbd5e1; }
.m2-stat--slate:hover { border-color: #94a3b8; }
.m2-stat--slate .m2-stat-icon { background: #e2e8f0; color: #475569; }
.m2-stat--slate .m2-stat-num { color: #1e293b; }

.m2-stat--primary { background: linear-gradient(135deg, #0d9488, #0f766e); border-color: transparent; flex: 1.5 1 0; }
.m2-stat--primary:hover { border-color: transparent; box-shadow: 0 4px 16px rgba(13, 148, 136, 0.25); }
.m2-stat--primary .m2-stat-icon, .m2-stat--primary .m2-stat-icon--lg { background: rgba(255,255,255,0.2); color: #fff; width: 40px; height: 40px; }
.m2-stat--primary .m2-stat-num, .m2-stat--primary .m2-stat-num--lg { color: #fff; font-size: 22px; font-weight: 800; }
.m2-stat--primary .m2-stat-num small { color: rgba(255,255,255,0.7); }
.m2-stat--primary .m2-stat-label { color: rgba(255,255,255,0.8); }

/* ── Toolbar ──────────────────────────── */

.m2-toolbar {
    display: flex; gap: 8px; padding: 10px 28px;
    background: #f8fafc; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap;
}

.m2-tool-btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 16px;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px; font-weight: 600; color: #475569;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
    cursor: pointer; transition: all 0.15s ease; white-space: nowrap;
}
.m2-tool-btn:hover { background: #f1f5f9; border-color: #cbd5e1; color: #1e293b; }
.m2-tool-btn:active { transform: scale(0.97); }
.m2-tool-btn svg { flex-shrink: 0; }
.m2-tool-btn--green { color: #15803d; border-color: #bbf7d0; background: #f0fdf4; }
.m2-tool-btn--green:hover { background: #dcfce7; border-color: #86efac; }
.m2-tool-btn--indigo { color: #4338ca; border-color: #c7d2fe; background: #eef2ff; }
.m2-tool-btn--indigo:hover { background: #e0e7ff; border-color: #a5b4fc; }
.m2-tool-btn--amber { color: #b45309; border-color: #fed7aa; background: #fffbeb; }
.m2-tool-btn--amber:hover { background: #fef3c7; border-color: #fdba74; }

.m2-tool-btn--slate { color: #475569; border-color: #cbd5e1; background: #f8fafc; }
.m2-tool-btn--slate:hover { background: #f1f5f9; border-color: #94a3b8; }

.m2-tool-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; padding: 0;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #475569; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
    cursor: pointer; transition: all 0.15s ease; flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}
.m2-tool-icon:hover { background: #f1f5f9; border-color: #cbd5e1; color: #1e293b; box-shadow: 0 2px 6px rgba(0,0,0,0.08); transform: translateY(-1px); }
.m2-tool-icon:active { transform: scale(0.95); }
.m2-tool-icon--green { color: #15803d; border-color: #bbf7d0; background: #f0fdf4; }
.m2-tool-icon--green:hover { background: #dcfce7; border-color: #86efac; color: #15803d; }
.m2-tool-icon--indigo { color: #4338ca; border-color: #c7d2fe; background: #eef2ff; }
.m2-tool-icon--indigo:hover { background: #e0e7ff; border-color: #a5b4fc; color: #4338ca; }
.m2-tool-icon--amber { color: #b45309; border-color: #fed7aa; background: #fffbeb; }
.m2-tool-icon--amber:hover { background: #fef3c7; border-color: #fdba74; color: #b45309; }
.m2-tool-icon--teal { color: #0f766e; border-color: #99f6e4; background: #f0fdfa; }
.m2-tool-icon--teal:hover { background: #ccfbf1; border-color: #5eead4; color: #0f766e; }

/* ── Content Area ─────────────────────── */

.modul2-content { padding: 0; min-height: 300px; }

/* Empty State */
.empty-state { text-align: center; padding: 80px 20px; }
.empty-icon { font-size: 72px; margin-bottom: 20px; opacity: 0.3; }
.empty-state h3 { font-size: 24px; color: #1e293b; margin-bottom: 10px; }
.empty-state p { font-size: 15px; color: #64748b; margin-bottom: 8px; line-height: 1.6; }
.empty-state .hint { font-size: 13px; color: #94a3b8; font-style: italic; margin-top: 12px; }

/* ── Unified Table ────────────────────── */

@keyframes m2FadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.casierii-table--unified {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    font-size: 12px;
}

.casierii-table--unified th,
.casierii-table--unified td { word-break: normal; }

/* ── THEAD ── */

.casierii-table--unified thead th {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 8px 3px;
    text-align: center;
    font-size: 9px;
    font-weight: 700;
    color: #0f766e;
    background: #f0fdfa;
    border-bottom: none;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    box-shadow: inset 0 -2px 0 #99f6e4;
}

/* ── Sticky Columns ── */

.col-sticky {
    position: sticky;
    left: 0;
    z-index: 12;
    background: inherit;
}

.col-sticky-2 {
    position: sticky;
    left: 30px;
    z-index: 12;
    background: inherit;
}

.casierii-table--unified thead .col-sticky,
.casierii-table--unified thead .col-sticky-2 {
    z-index: 25;
    background: #f0fdfa;
}

/* Shadow hint on sticky boundary */
.casierii-table--unified .col-sticky-2::after {
    content: '';
    position: absolute;
    top: 0; right: -6px; bottom: 0;
    width: 6px;
    pointer-events: none;
    background: linear-gradient(to right, rgba(0,0,0,0.04), transparent);
}

/* ── Column Specifics ── */

.col-nr {
    width: 30px; min-width: 30px;
    text-align: center !important;
    font-weight: 600; color: #94a3b8; font-size: 10px;
}

.col-casier {
    font-weight: 600; color: #1e293b;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    min-width: 110px; max-width: 150px;
    padding-left: 6px !important; padding-right: 4px !important;
    text-align: left !important;
    font-size: 11px;
}

.col-zi {
    text-align: center !important;
    font-size: 10px;
    min-width: 0;
    width: auto;
    padding: 5px 1px;
    white-space: nowrap;
}

.col-zi.zi-azi {
    background: #eff6ff !important;
    border-left: 2px solid #3b82f6;
    border-right: 2px solid #3b82f6;
}

.col-zi.zi-cu-suma { background: #f0fdf4; }

.col-supl { background: rgba(59, 130, 246, 0.06) !important; }
.col-supl.zi-cu-suma { background: rgba(59, 130, 246, 0.1) !important; }

.col-total {
    min-width: 60px; width: 70px;
    text-align: right !important;
    padding-right: 8px !important;
    background: #fffbeb;
    font-weight: 700; color: #ea580c; font-size: 11px;
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    text-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* ── TBODY ── */

.casierii-table--unified td {
    padding: 5px 3px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 11px;
    color: #1e293b;
}

/* ── Locality Group Row ───────────────── */

.loc-group-row td {
    padding: 0 !important;
    border-bottom: none !important;
    background: #f8fafc !important;
}

.loc-group-row .loc-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f1f5f9;
    border-top: 3px solid #cbd5e1;
    border-bottom: 1px solid #e2e8f0;
    min-width: max-content;
    animation: m2FadeInUp 0.35s ease-out both;
}

.casierii-table--unified tbody .loc-group-row:first-child .loc-bar { border-top: none; }

.loc-group-row--adus .loc-bar { opacity: 0.6; }
.loc-group-row--adus .loc-bar:hover { opacity: 1; }
.loc-group-row--adus .loc-bar-total { color: #94a3b8; }

.loc-bar-left {
    display: flex; align-items: center; gap: 8px;
    min-width: 0; flex-wrap: wrap;
}

.loc-bar-name {
    font-size: 14px; font-weight: 700; color: #1e293b;
    margin: 0; letter-spacing: 0.2px;
    text-shadow: 0 1px 1px rgba(0,0,0,0.06);
    white-space: nowrap;
}

.loc-bar-actions {
    display: flex;
    gap: 4px;
    margin-top: 3px;
}

.loc-bar-stat {
    font-size: 10.5px; font-weight: 700; color: #475569;
    background: #fff; border: 1.5px solid #cbd5e1;
    padding: 3px 9px; border-radius: 20px;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    letter-spacing: 0.01em;
}

.loc-bar-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px;
    font-family: 'DM Sans', -apple-system, sans-serif;
    font-size: 11px; font-weight: 600; color: #475569;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 4px;
    cursor: pointer; transition: all 0.15s ease;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}
.loc-bar-btn:hover { background: #f1f5f9; border-color: #cbd5e1; color: #1e293b; }
.loc-bar-btn:active { transform: scale(0.97); }
.loc-bar-btn svg { flex-shrink: 0; }
.loc-bar-btn--warn { color: #b45309; border-color: #fed7aa; background: #fffbeb; }
.loc-bar-btn--warn:hover { background: #fef3c7; border-color: #fdba74; }

.loc-bar-right {
    display: flex; align-items: baseline; gap: 8px; flex-shrink: 0;
}

.loc-bar-badge-adus {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; font-weight: 600; color: #16a34a;
    background: #dcfce7; padding: 2px 8px; border-radius: 4px;
    border: 1px solid #bbf7d0;
}

.loc-bar-chelt {
    font-size: 11px; font-weight: 700; color: #dc2626;
    background: #fef2f2; padding: 2px 6px; border-radius: 4px;
    border: 1px solid #fecaca;
}

.loc-bar-total {
    font-size: 16px; font-weight: 800; color: #0f766e;
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    white-space: nowrap; text-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.loc-bar-total small { font-size: 10px; font-weight: 600; color: #94a3b8; }

/* ── Day Header ── */

.zi-header {
    display: flex; flex-direction: column; gap: 0;
    align-items: center; line-height: 1.2;
}

.zi-nume { font-weight: 700; font-size: 9px; color: #475569; }
.zi-data { font-size: 8px; color: #94a3b8; font-weight: 400; }

/* ── Day Cell Values ── */

.zi-gol { color: #e2e8f0; font-size: 10px; }

.zi-suma {
    font-weight: 700; color: #15803d;
    background: #dcfce7;
    padding: 1px 3px; border-radius: 3px;
    display: inline-block; cursor: help;
    transition: all 0.15s ease;
    font-size: 10px; white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.zi-suma:hover {
    background: #bbf7d0;
    transform: scale(1.08);
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.2);
}

.zi-suma--supl { color: #2563eb; background: #dbeafe; }
.zi-suma--supl:hover { background: #bfdbfe; box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2); }

/* Total column helpers */
.total-adus-ok { display: inline-flex; align-items: center; justify-content: center; }
.total-adus-val { color: #94a3b8; font-size: 10px; font-weight: 500; margin-top: 1px; }
.total-zero { color: #cbd5e1; }

/* ── Casier Rows ── */

.casier-row { transition: background 0.15s ease; }
.casier-row:hover { background: #fafbff; }
.casier-row:hover .col-sticky,
.casier-row:hover .col-sticky-2 { background: #fafbff; }

.casier-row td.col-sticky,
.casier-row td.col-sticky-2 { background: white; }

/* Adus rows */
.casier-row--adus { opacity: 0.45; }
.casier-row--adus:hover { opacity: 0.85; }
.casier-row--adus .col-casier { font-style: italic; }
.casier-row--adus .col-total { color: #94a3b8; font-weight: 500; }

/* Legacy adus styling (used by modals) */
.zi-adus { background: #f8fafc; }
.zi-suma-adus {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 6px; border-radius: 4px;
    background: #f1f5f9; border: 1px dashed #cbd5e1;
    cursor: pointer; transition: all 0.2s ease; font-size: 12px;
}
.zi-suma-adus:hover { background: #e2e8f0; border-color: #94a3b8; transform: scale(1.05); }
.zi-adus-val { color: #94a3b8; font-weight: 600; text-decoration: line-through; text-decoration-color: #cbd5e1; }
.zi-adus-badge {
    font-size: 10px; font-weight: 700; color: #fff; background: #22c55e;
    width: 16px; height: 16px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0; line-height: 1;
}
.total-adus { margin-top: 2px; line-height: 1.2; }

/* Keep old scoped header rules hidden */
#modul2-content .localitate-header { display: none; }

/* ── Responsive ──────────────────────── */

@media (max-width: 1400px) {
    .m2-stats-row { gap: 10px; }
    .m2-stat { padding: 12px 14px; min-width: 130px; }
    .m2-stat-num { font-size: 18px; }
    .m2-stat--primary .m2-stat-num { font-size: 22px; }
}

@media (max-width: 1200px) {
    .m2-title { font-size: 18px; }
    .m2-stats-row { flex-wrap: wrap; }
    .m2-stat { flex: 1 1 calc(50% - 6px); min-width: 0; }
    .m2-stat--primary { flex: 1 1 100%; }
    .m2-toolbar { padding: 12px 20px; gap: 6px; }
    .m2-tool-btn { flex: 1 1 auto; justify-content: center; min-width: 130px; }
}

@media (max-width: 768px) {
    .m2-stats-row { flex-direction: column; gap: 8px; }
    .m2-stat { flex: 1 1 100%; }
    .m2-meta { flex-direction: column; gap: 6px; align-items: flex-start; }
    .casierii-table--unified { font-size: 10px; }
    .casierii-table--unified th, .casierii-table--unified td { padding: 4px 2px; }
    .col-casier { min-width: 90px; font-size: 10px; }
    .col-zi { min-width: 0; font-size: 9px; }
    .loc-bar { flex-direction: column; align-items: stretch; gap: 6px; }
    .loc-bar-left { justify-content: flex-start; }
    .loc-bar-right { justify-content: flex-end; }
}

/* ── Print ────────────────────────────── */

@media print {
    .m2-toolbar { display: none !important; }
    .m2-header { break-after: avoid; page-break-after: avoid; }
    .col-sticky, .col-sticky-2 { position: static !important; }
    .col-sticky-2::after { display: none !important; }
    .loc-group-row { page-break-inside: avoid; break-inside: avoid; }
    .casier-row { page-break-inside: avoid; break-inside: avoid; }
    .col-zi.zi-azi { background: #e8e8e8 !important; border-left: 1px solid #000; border-right: 1px solid #000; }
    .col-zi.zi-cu-suma { background: #f0f0f0 !important; }
    .zi-suma { background: none !important; color: #000 !important; }
    .zi-suma-adus { border: none !important; background: none !important; }
    .zi-adus-val { color: #999 !important; }
}

/* ── Modals (unchanged) ──────────────── */

.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 10000; padding: 20px; overflow-y: auto;
}

.modal-content {
    background: white; border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%; max-height: 90vh;
    display: flex; flex-direction: column; overflow: hidden;
}

.centralizatoare-header {
    padding: 16px 24px; background: var(--white, #fff);
    color: var(--slate-800, #1e293b);
    display: flex; justify-content: space-between; align-items: center;
    border-radius: 16px 16px 0 0; flex-shrink: 0;
    border-bottom: 1px solid var(--slate-200, #e2e8f0);
}

.centralizatoare-header h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--slate-800, #1e293b); }

.close-modal {
    background: var(--slate-50, #f8fafc);
    border: 1px solid var(--slate-200, #e2e8f0);
    color: var(--slate-400, #94a3b8);
    font-size: 15px; width: 34px; height: 34px; border-radius: 6px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}

.close-modal:hover {
    background: var(--red-500, #ef4444);
    border-color: var(--red-500, #ef4444);
    color: white; transform: none;
}

.centralizatoare-content { flex: 1; overflow-y: auto; padding: 20px; min-height: 200px; }

@media (max-width: 768px) {
    .modal-overlay { padding: 10px; }
    .modal-content { max-height: 95vh; }
}