/* ══════════════════════════════════════════════════════════════
   K&G PORTAL - 공새로 입찰관리 ECOUNT ERP DESIGN SYSTEM
   ══════════════════════════════════════════════════════════════ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #059669;
    --success-light: #ecfdf5;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --border: #cbd5e1;
    --border-light: #e2e8f0;
    --bg-page: #f1f5f9;
    --bg-card: #ffffff;
    --bg-header: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --erp-row-height: 26px;
    --gongsaero-brand: #ff6b35;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    font-size: 12px;
    line-height: 1.4;
}

/* ── 1. Top ERP Header & Compact KPI Bar ── */
.app-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 8px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-title h1 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 6px;
}

.brand-badge {
    background: linear-gradient(135deg, #ff6b35, #ff8c42);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* Compact ERP KPI Strip */
.erp-kpi-bar {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 6px 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.kpi-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid var(--border-light);
    font-size: 11.5px;
}

.kpi-pill .kpi-label {
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-pill .kpi-val {
    font-weight: 700;
    color: #0f172a;
}

.kpi-pill.warning .kpi-val { color: #d97706; }
.kpi-pill.success .kpi-val { color: #059669; }
.kpi-pill.primary .kpi-val { color: #2563eb; }
.kpi-pill.purple .kpi-val { color: #7c3aed; }

/* ── 2. Buttons in ECOUNT ERP Style ── */
.btn-erp {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 26px;
    padding: 0 10px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: #ffffff;
    color: #1e293b;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.12s ease;
    user-select: none;
    text-decoration: none;
}

.btn-erp:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
}

.btn-erp-primary {
    background: #2563eb;
    border-color: #1d4ed8;
    color: #ffffff;
}
.btn-erp-primary:hover {
    background: #1d4ed8;
    border-color: #1e40af;
    color: #ffffff;
}

.btn-erp-success {
    background: #059669;
    border-color: #047857;
    color: #ffffff;
}
.btn-erp-success:hover {
    background: #047857;
    color: #ffffff;
}

.btn-erp-warning {
    background: #d97706;
    border-color: #b45309;
    color: #ffffff;
}
.btn-erp-warning:hover {
    background: #b45309;
    color: #ffffff;
}

.btn-erp-danger {
    background: #dc2626;
    border-color: #b91c1c;
    color: #ffffff;
}
.btn-erp-danger:hover {
    background: #b91c1c;
    color: #ffffff;
}

.btn-erp-xs {
    height: 20px;
    padding: 0 6px;
    font-size: 10.5px;
}

/* ── 3. ERP Filter Ribbon ── */
.erp-filter-ribbon {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 6px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.erp-ribbon-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.erp-ribbon-left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.erp-ribbon-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-preset-group {
    display: inline-flex;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.date-preset-btn {
    border: none;
    background: #ffffff;
    color: #334155;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    border-right: 1px solid var(--border);
    transition: all 0.1s ease;
    height: 24px;
}
.date-preset-btn:last-child {
    border-right: none;
}
.date-preset-btn:hover {
    background: #f1f5f9;
}
.date-preset-btn.active {
    background: #2563eb;
    color: #ffffff;
    font-weight: 700;
}

.erp-select-sm {
    height: 26px;
    font-size: 11.5px;
    padding: 2px 24px 2px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background-color: #ffffff;
    color: #1e293b;
    outline: none;
    cursor: pointer;
}
.erp-select-sm:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.erp-search-box {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 280px;
}
.erp-search-box i {
    position: absolute;
    left: 8px;
    color: var(--text-muted);
    font-size: 14px;
}
.erp-search-box input {
    width: 100%;
    height: 26px;
    padding: 2px 8px 2px 26px;
    font-size: 11.5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #f8fafc;
    color: #1e293b;
    outline: none;
    transition: all 0.15s ease;
}
.erp-search-box input:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* ── 4. Main View Tabs (공고별 / 품목별) ── */
.view-tabs-strip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 18px 0 18px;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border);
}

.view-tab-btn {
    border: 1px solid var(--border);
    border-bottom: none;
    background: #e2e8f0;
    color: var(--text-muted);
    padding: 5px 14px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.12s ease;
    margin-bottom: -1px;
}
.view-tab-btn:hover {
    background: #edf2f7;
    color: #0f172a;
}
.view-tab-btn.active {
    background: #ffffff;
    color: var(--primary);
    border-color: var(--border);
    border-bottom: 1px solid #ffffff;
    z-index: 2;
}

/* ── 5. ECOUNT ERP High-Density Spreadsheet Data Grid ── */
.main-content-wrap {
    padding: 10px 18px 24px 18px;
}

.erp-grid-wrapper {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 220px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.erp-sheet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.5px;
    background-color: #ffffff;
    table-layout: auto;
}

.erp-sheet-table thead th {
    background-color: var(--bg-header) !important;
    color: #334155;
    font-weight: 700;
    text-align: center;
    vertical-align: middle;
    padding: 4px 6px;
    border: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    height: 28px;
    box-sizing: border-box;
    user-select: none;
}

.erp-sheet-table tbody td {
    padding: 3px 6px;
    border: 1px solid var(--border);
    vertical-align: middle;
    height: var(--erp-row-height);
    box-sizing: border-box;
    white-space: nowrap;
    transition: background-color 0.1s ease;
}

.erp-sheet-table tbody tr:hover td {
    background-color: #f1f5f9 !important;
}

.erp-sheet-table tbody tr.row-won td {
    background-color: #f0fdf4;
}
.erp-sheet-table tbody tr.row-lost td {
    background-color: #fafaf9;
}

/* Status Badges */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 12px;
    font-size: 10.5px;
    font-weight: 700;
    white-space: nowrap;
}
.status-pill.bidding {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}
.status-pill.won {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}
.status-pill.lost {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}
.status-pill.abandoned {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* What-If Simulation Badges & Cells */
.cell-bid-compare {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
}

.winning-amount-label {
    font-weight: 700;
    color: #0f172a;
    font-size: 11.5px;
}

.badge-diff-plus {
    font-size: 9.5px;
    font-weight: 600;
    color: #b91c1c;
    background: #fee2e2;
    padding: 0 4px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
}

.badge-diff-minus {
    font-size: 9.5px;
    font-weight: 600;
    color: #15803d;
    background: #dcfce7;
    padding: 0 4px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
}

.badge-whatif-margin {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    display: inline-block;
}
.badge-whatif-margin.high {
    background: #dcfce7;
    color: #15803d;
}
.badge-whatif-margin.mid {
    background: #e0f2fe;
    color: #0369a1;
}
.badge-whatif-margin.low {
    background: #fef3c7;
    color: #b45309;
}
.badge-whatif-margin.deficit {
    background: #fee2e2;
    color: #b91c1c;
    font-weight: 800;
}

/* ── 6. ECOUNT ERP Form Table (Modal Header) ── */
.erp-form-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: #ffffff;
    border: 1px solid var(--border);
    margin-bottom: 8px;
}

.erp-form-table th {
    background-color: var(--bg-header);
    color: #334155;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border: 1px solid var(--border);
    white-space: nowrap;
    vertical-align: middle;
    text-align: center;
    height: 26px;
}

.erp-form-table td {
    padding: 0;
    border: 1px solid var(--border);
    vertical-align: middle;
    background-color: #ffffff;
    height: 26px;
}

.erp-form-table .form-control,
.erp-form-table .form-select {
    width: 100%;
    height: 26px !important;
    font-size: 11.5px !important;
    padding: 2px 6px !important;
    border-radius: 0 !important;
    border: none !important;
    outline: none !important;
    color: #1e293b;
    background: transparent !important;
    box-shadow: none !important;
}

.erp-form-table td:focus-within {
    box-shadow: inset 0 0 0 2px var(--primary) !important;
    background-color: #eff6ff !important;
    position: relative;
    z-index: 5;
}

/* ── 7. What-If Result Analysis Ribbon in Modal ── */
.erp-result-panel {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 8px;
}
.erp-result-panel.lost-mode {
    background: #fff7ed;
    border-color: #fed7aa;
}

.result-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.result-sim-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.sim-box {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    padding: 5px 8px;
    display: flex;
    flex-direction: column;
}

.sim-box .sim-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
}

.sim-box .sim-val {
    font-size: 12.5px;
    font-weight: 700;
    color: #0f172a;
}
.sim-box .sim-sub {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 1px;
}

/* ── 8. Modal Sticky Summary Bar ── */
.modal-summary-bar {
    background: #0f172a;
    color: #ffffff;
    border-radius: 4px;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.summary-metric {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.summary-metric .metric-label {
    font-size: 10px;
    color: #94a3b8;
    font-weight: 500;
}

.summary-metric .metric-val {
    font-size: 13px;
    font-weight: 700;
    color: #f8fafc;
}
.summary-metric .metric-val.profit {
    color: #4ade80;
}
.summary-metric .metric-val.fee {
    color: #f87171;
}
.summary-metric .metric-val.delivery {
    color: #60a5fa;
    font-size: 14px;
}

/* ── 9. Popover & Rule Guidance ── */
.calc-logic-info-wrapper {
    position: relative;
    display: inline-block;
}
.calc-logic-popover {
    display: none;
    position: absolute;
    top: 26px;
    left: 0;
    z-index: 1099;
    width: 440px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    padding: 10px;
    font-size: 11px;
}
.calc-logic-info-wrapper.active .calc-logic-popover {
    display: block;
}

/* ── 10. Responsive ── */
@media (max-width: 992px) {
    .result-sim-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .modal-summary-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    .summary-metric {
        flex-direction: row;
        justify-content: space-between;
    }
}
