*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif; font-size: 13px; background: #f5f5f3; color: #1a1a1a; }

/* ── TABS ── */
.tab-bar { display: flex; gap: 0; border-bottom: 1px solid #e0e0e0; background: #fff; padding: 0 20px; position: sticky; top: 0; z-index: 50; }
.tab-btn { padding: 12px 20px; font-size: 13px; font-weight: 500; color: #888; background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; transition: color 0.15s, border-color 0.15s; margin-bottom: -1px; }
.tab-btn:hover { color: #1a1a1a; }
.tab-btn.active { color: #185FA5; border-bottom-color: #185FA5; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── PAGE ── */
.page { max-width: 1400px; margin: 0 auto; padding: 20px; }

/* ── TOOLBAR ── */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar-title { font-size: 15px; font-weight: 500; flex: 1; }
.badge { font-size: 11px; padding: 3px 10px; border-radius: 6px; background: #fff; color: #666; border: 1px solid #e0e0e0; }
.badge.draft { background: #FFF8E7; color: #854F0B; border-color: #FAC775; }
.btn { font-size: 12px; padding: 6px 14px; border-radius: 7px; border: 1px solid #d0d0d0; background: #fff; color: #1a1a1a; cursor: pointer; transition: background 0.15s; white-space: nowrap; }
.btn:hover { background: #f0f0f0; }
.btn-primary { background: #185FA5; color: #fff; border-color: #185FA5; }
.btn-primary:hover { background: #0C447C; }

/* ── TABLE WRAP ── */
.table-wrap { background: #fff; border: 1px solid #e0e0e0; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.06); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th { background: #f8f8f6; padding: 8px 7px; text-align: left; font-weight: 500; font-size: 11px; color: #888; border-bottom: 1px solid #e8e8e8; white-space: nowrap; user-select: none; }
th.r, td.r { text-align: right; }
th.c, td.c { text-align: center; }
tbody tr.item-row { border-bottom: 1px solid #f0f0f0; transition: background 0.1s; }
tbody tr.item-row:hover { background: #fafaf8; }
tbody td { padding: 5px 7px; vertical-align: middle; white-space: nowrap; overflow: visible; }

/* ── GROUP ROWS ── */
tr.group-row { background: #f8f8f6; cursor: pointer; }
tr.group-row:hover { background: #f2f2ef; }
tr.group-row td { padding: 5px 7px; font-size: 11px; font-weight: 500; color: #555; border-bottom: 1px solid #e8e8e8; }
.group-inner { display: flex; align-items: center; gap: 6px; }
.group-arrow { font-size: 10px; color: #aaa; transition: transform 0.15s; display: inline-block; width: 14px; text-align: center; }
.group-arrow.collapsed { transform: rotate(-90deg); }
.group-count { font-size: 10px; color: #aaa; font-weight: 400; }
.group-sum { margin-left: auto; font-size: 11px; color: #888; font-weight: 400; padding-right: 8px; }

/* ── DRAG ── */
.drag-handle { cursor: grab; color: #ccc; font-size: 13px; padding: 0 3px; user-select: none; }
.drag-handle:active { cursor: grabbing; }
.drag-handle:hover { color: #999; }
tr.dragging { opacity: 0.4; }
tr.drag-over { box-shadow: inset 0 2px 0 #185FA5; }
.pos { color: #bbb; font-size: 11px; }

/* ── EDITABLE ── */
td.editable { cursor: text; }
td.editable:focus { outline: 2px solid #185FA5; outline-offset: -2px; border-radius: 3px; background: #EEF4FB; }

/* ── DROPDOWNS ── */
.dd-wrap { position: relative; }
.dd-btn { cursor: pointer; padding: 2px 5px; border-radius: 4px; border: 1px solid transparent; font-size: 12px; color: #1a1a1a; transition: border-color 0.15s; white-space: nowrap; display: inline-flex; align-items: center; gap: 3px; background: none; }
.dd-btn:hover { border-color: #d0d0d0; background: #f8f8f8; }
.dd-btn .arr { font-size: 9px; color: #bbb; }
.dd-menu { position: fixed; background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.13); z-index: 200; padding: 4px 0; min-width: 80px; }
.dd-menu.hidden { display: none; }
.dd-item { padding: 7px 14px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.dd-item:hover { background: #f5f5f3; }
.dd-item.selected { font-weight: 500; color: #185FA5; }
.dd-sep { border-top: 1px solid #f0f0f0; margin: 3px 0; }

/* ── VENDOR BADGE ── */
.vnd-badge { display: inline-block; font-size: 10px; padding: 1px 7px; border-radius: 4px; font-weight: 500; white-space: nowrap; }
.vnd-tc  { background: #E1F5EE; color: #0F6E56; }
.vnd-dan { background: #E6F1FB; color: #185FA5; }
.vnd-reb { background: #FAEEDA; color: #854F0B; }
.vnd-loc { background: #F1EFE8; color: #5F5E5A; }
.vnd-new { background: #EEEDFE; color: #534AB7; }

/* ── ADD NEW VENDOR ── */
.vnd-new-input { display: none; padding: 6px 10px; }
.vnd-new-input input { width: 150px; border: 1px solid #d0d0d0; border-radius: 5px; padding: 4px 8px; font-size: 12px; outline: none; }
.vnd-new-input input:focus { border-color: #185FA5; }
.vnd-new-actions { display: flex; gap: 5px; margin-top: 4px; }
.vnd-new-actions button { flex: 1; padding: 3px; font-size: 11px; border-radius: 4px; border: 1px solid #d0d0d0; cursor: pointer; background: #fff; }
.vnd-new-actions button.ok { background: #185FA5; color: #fff; border-color: #185FA5; }

/* ── EMPTY HIGHLIGHT ── */
.empty { outline: 1.5px solid #F5A623 !important; outline-offset: -1px; border-radius: 3px; }
.dd-btn.empty { outline: 1.5px solid #F5A623; border-radius: 4px; }
.miss { color: #ccc; }

/* ── DAYS INPUT ── */
.days-input { width: 100%; border: none; background: transparent; font-size: 12px; color: #1a1a1a; text-align: right; outline: none; padding: 2px 4px; border-radius: 4px; -moz-appearance: textfield; appearance: textfield; }
.days-input::-webkit-inner-spin-button, .days-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.days-input:focus { background: #EEF4FB; outline: 1.5px solid #185FA5; }

/* ── DELETE BTN ── */
.delete-btn { opacity: 0; background: none; border: none; cursor: pointer; color: #ccc; font-size: 14px; padding: 2px 5px; border-radius: 4px; transition: opacity 0.15s, color 0.15s, background 0.15s; line-height: 1; }
.delete-btn:hover { color: #E24B4A; background: #FCEBEB; }
tr.item-row:hover .delete-btn { opacity: 1; }
@media (hover: none) { .delete-btn { opacity: 1; } }

/* ── TOTALS ── */
.totals-row { display: flex; justify-content: flex-end; gap: 28px; padding: 11px 14px; border-top: 1px solid #e8e8e8; background: #fafaf8; flex-wrap: wrap; }
.total-item { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.total-label { font-size: 10px; color: #999; }
.total-value { font-size: 13px; font-weight: 500; }
.total-main { color: #185FA5; font-size: 14px; }

/* ── SUPPLIERS TAB ── */
.sup-group { background: #fff; border: 1px solid #e0e0e0; border-radius: 10px; margin-bottom: 16px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.sup-header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #f8f8f6; border-bottom: 1px solid #e8e8e8; flex-wrap: wrap; }
.sup-title { font-size: 14px; font-weight: 500; flex: 1; }
.sup-defaults { display: flex; gap: 16px; font-size: 12px; color: #666; align-items: center; flex-wrap: wrap; }
.sup-defaults label { display: flex; align-items: center; gap: 6px; }
.sup-defaults .dd-btn { font-size: 12px; }
.sup-items table { font-size: 12px; }
.sup-items thead th { font-size: 11px; }
.overhead-section { border-top: 1px solid #e8e8e8; padding: 12px 16px; }
.overhead-title { font-size: 12px; font-weight: 500; color: #555; margin-bottom: 8px; }
.overhead-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.overhead-item { display: flex; align-items: center; gap: 8px; }
.overhead-item label { font-size: 11px; color: #888; flex: 1; }
.overhead-item input { width: 90px; border: 1px solid #e0e0e0; border-radius: 5px; padding: 4px 8px; font-size: 12px; text-align: right; outline: none; }
.overhead-item input:focus { border-color: #185FA5; background: #EEF4FB; }
.overhead-total { margin-top: 10px; display: flex; justify-content: flex-end; gap: 20px; font-size: 12px; padding-top: 8px; border-top: 1px solid #f0f0f0; }
.overhead-total span { font-weight: 500; color: #185FA5; }

/* ── CURRENCY TAB ── */
.currency-page { max-width: 900px; }
.currency-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.currency-title { font-size: 15px; font-weight: 500; flex: 1; }
.currency-updated { font-size: 11px; color: #999; }
.currency-loading { font-size: 12px; color: #888; padding: 8px 0; }
.currency-error { font-size: 12px; color: #E24B4A; padding: 8px 0; }
.currency-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-bottom: 24px; }
.currency-card { background: #fff; border: 1px solid #e0e0e0; border-radius: 10px; padding: 16px; }
.currency-card.main-source { border-color: #185FA5; }
.currency-source-label { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; color: #888; margin-bottom: 10px; }
.currency-card.main-source .currency-source-label { color: #185FA5; }
.currency-rates { display: flex; flex-direction: column; gap: 8px; }
.currency-rate-row { display: flex; align-items: center; gap: 10px; }
.currency-flag { font-size: 18px; width: 28px; text-align: center; }
.currency-info { flex: 1; }
.currency-code { font-size: 12px; font-weight: 500; }
.currency-name { font-size: 10px; color: #999; }
.currency-value { font-size: 16px; font-weight: 500; text-align: right; }
.currency-value.main { color: #185FA5; }
.currency-change { font-size: 10px; text-align: right; }
.currency-change.up { color: #E24B4A; }
.currency-change.down { color: #1D9E75; }
.currency-note { font-size: 11px; color: #999; margin-top: 6px; }
.currency-section-title { font-size: 13px; font-weight: 500; margin-bottom: 10px; color: #333; }

tr.hidden { display: none; }
.no-spin::-webkit-inner-spin-button, .no-spin::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.sup-group input[type=number]::-webkit-inner-spin-button,
.sup-group input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.sup-group input[type=number] { -moz-appearance: textfield; appearance: textfield; }