/* ── TradeForge — Project Cost Tracking Panel ── */

/* ── Running Total Header ── */
.ct-total-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(140,106,62,.12) 0%, rgba(46,49,54,.6) 100%);
  border: 1px solid rgba(140,106,62,.25);
  border-radius: var(--r, 14px);
  padding: 20px 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.ct-total-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ct-total-label {
  font-size: 11px;
  font-weight: 650;
  color: var(--muted, #888);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.ct-total-val {
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}
.ct-total-count {
  font-size: 12px;
  color: var(--muted, #888);
  margin-top: 2px;
}
.ct-total-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Category KPI Cards ── */
.ct-categories {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.ct-cat-card {
  background: var(--graphite, #2E3136);
  border: 1px solid rgba(181,183,185,.08);
  border-radius: 12px;
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.ct-cat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.ct-cat-card.equipment::before { background: #f59e0b; }
.ct-cat-card.materials::before { background: #3b82f6; }
.ct-cat-card.waste::before { background: #6b7280; }
.ct-cat-card.labor::before { background: #a855f7; }
.ct-cat-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.ct-cat-icon svg {
  width: 16px;
  height: 16px;
}
.ct-cat-card.equipment .ct-cat-icon { background: rgba(245,158,11,.12); color: #f59e0b; }
.ct-cat-card.materials .ct-cat-icon { background: rgba(59,130,246,.12); color: #3b82f6; }
.ct-cat-card.waste .ct-cat-icon { background: rgba(107,114,128,.12); color: #9ca3af; }
.ct-cat-card.labor .ct-cat-icon { background: rgba(168,85,247,.12); color: #a855f7; }
.ct-cat-name {
  font-size: 11px;
  font-weight: 650;
  color: var(--muted, #888);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}
.ct-cat-amount {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
}
.ct-cat-items {
  font-size: 11px;
  color: var(--muted, #888);
  margin-top: 4px;
}

/* ── Breakdown List ── */
.ct-breakdown {
  background: var(--graphite, #2E3136);
  border-radius: var(--r, 14px);
  overflow: hidden;
  margin-bottom: 16px;
}
.ct-breakdown-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.ct-breakdown-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ct-breakdown-title svg {
  width: 18px;
  height: 18px;
  color: var(--bronze, #8C6A3E);
}
.ct-breakdown-filter {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.ct-filter-btn {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,.08);
  background: transparent;
  color: var(--muted, #888);
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.ct-filter-btn:hover { border-color: rgba(140,106,62,.4); color: #fff; }
.ct-filter-btn.active {
  background: rgba(140,106,62,.15);
  border-color: rgba(140,106,62,.4);
  color: var(--bronze, #8C6A3E);
}

/* ── Cost Entry Rows ── */
.ct-entry {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  transition: background .1s;
}
.ct-entry:last-child { border-bottom: none; }
.ct-entry:hover { background: rgba(255,255,255,.02); }
.ct-entry-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ct-entry-desc {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ct-entry-meta {
  font-size: 11px;
  color: var(--muted, #888);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.ct-entry-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.ct-entry-badge.equipment { background: rgba(245,158,11,.12); color: #f59e0b; }
.ct-entry-badge.materials { background: rgba(59,130,246,.12); color: #3b82f6; }
.ct-entry-badge.waste { background: rgba(107,114,128,.12); color: #9ca3af; }
.ct-entry-badge.labor { background: rgba(168,85,247,.12); color: #a855f7; }
.ct-entry-amount {
  font-size: 15px;
  font-weight: 700;
  color: var(--bronze, #8C6A3E);
  white-space: nowrap;
}
.ct-entry-date {
  font-size: 12px;
  color: var(--muted, #888);
  white-space: nowrap;
  min-width: 70px;
  text-align: right;
}

/* ── Add Cost Form (inline) ── */
.ct-add-form {
  background: var(--graphite, #2E3136);
  border: 1px solid rgba(140,106,62,.2);
  border-radius: var(--r, 14px);
  padding: 20px;
  margin-bottom: 16px;
  display: none;
}
.ct-add-form.open { display: block; }
.ct-add-form h4 {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ct-add-form h4 svg {
  width: 16px;
  height: 16px;
  color: var(--bronze, #8C6A3E);
}
.ct-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.ct-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ct-form-field.full { grid-column: 1 / -1; }
.ct-form-field label {
  font-size: 11px;
  font-weight: 650;
  color: var(--muted, #888);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.ct-form-field input,
.ct-form-field select,
.ct-form-field textarea {
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(255,255,255,.1);
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
  width: 100%;
}
.ct-form-field input:focus,
.ct-form-field select:focus,
.ct-form-field textarea:focus {
  outline: none;
  border-color: var(--bronze, #8C6A3E);
}
.ct-form-field textarea {
  resize: vertical;
  min-height: 60px;
}
.ct-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: flex-end;
}

/* ── Empty State ── */
.ct-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted, #888);
}
.ct-empty svg {
  width: 40px;
  height: 40px;
  margin: 0 0 10px;
  opacity: .4;
}
.ct-empty p {
  font-size: 13px;
  margin: 0 0 14px;
  line-height: 1.5;
}

/* ── Remove button ── */
.ct-remove-btn {
  background: none;
  border: none;
  color: var(--muted, #888);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color .15s, background .15s;
  font-family: inherit;
}
.ct-remove-btn:hover {
  color: #ef4444;
  background: rgba(239,68,68,.1);
}
.ct-remove-btn svg {
  width: 14px;
  height: 14px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .ct-categories { grid-template-columns: repeat(2, 1fr); }
  .ct-total-val { font-size: 26px; }
  .ct-breakdown-head { flex-direction: column; align-items: flex-start; gap: 10px; }
}
@media (max-width: 520px) {
  .ct-categories { grid-template-columns: 1fr 1fr; }
  .ct-cat-amount { font-size: 18px; }
  .ct-total-strip { padding: 16px; }
  .ct-total-val { font-size: 22px; }
  .ct-entry { grid-template-columns: 1fr auto; gap: 8px; padding: 12px 14px; }
  .ct-entry-date { display: none; }
  .ct-form-grid { grid-template-columns: 1fr; }
  .ct-total-actions { width: 100%; }
  .ct-total-actions .btn { flex: 1; text-align: center; justify-content: center; }
}

/* ── Mobile Field Optimization ── */
@media (max-width: 900px) {
  /* Touch targets — min 44px for interactive elements */
  .ct-filter-btn { min-height: 44px; padding: 10px 14px; font-size: 12px; display: inline-flex; align-items: center; }
  .ct-remove-btn { min-width: 44px; min-height: 44px; padding: 10px; }
  .ct-remove-btn svg { width: 18px; height: 18px; }
  .ct-entry { min-height: 48px; padding: 14px 20px; }
  .ct-cat-card { min-height: 48px; }

  /* Input font size — 16px prevents iOS zoom */
  .ct-form-field input,
  .ct-form-field select,
  .ct-form-field textarea { font-size: 16px; padding: 12px 14px; min-height: 48px; }

  /* Readable text for outdoor cost tracking */
  .ct-total-val { font-size: 28px; }
  .ct-total-label { font-size: 12px; }
  .ct-total-count { font-size: 13px; }
  .ct-cat-amount { font-size: 20px; }
  .ct-cat-name { font-size: 12px; }
  .ct-cat-items { font-size: 12px; }
  .ct-entry-desc { font-size: 15px; }
  .ct-entry-amount { font-size: 16px; }
  .ct-entry-meta { font-size: 12px; }
  .ct-entry-badge { font-size: 11px; }
  .ct-breakdown-title { font-size: 16px; }

  /* Card and item spacing */
  .ct-cat-card { padding: 14px; }
  .ct-breakdown-head { padding: 14px 18px; }
  .ct-add-form { padding: 18px; }

  /* Full-width buttons on small screens */
  .ct-total-actions { flex-direction: column; width: 100%; }
  .ct-total-actions .btn { width: 100%; justify-content: center; }
  .ct-form-actions { flex-direction: column; }
  .ct-form-actions .btn,
  .ct-form-actions button { width: 100%; justify-content: center; }
  .ct-form-grid { grid-template-columns: 1fr; }
}
