/* ========== PANELS ========== */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.panel::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.06) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0.5;
}

.panel-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.panel-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  transition: all var(--transition-fast);
  cursor: pointer;
  white-space: nowrap;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover::after {
  opacity: 1;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 3px;
  box-shadow: var(--shadow-glow-soft);
}

/* Primary - Main action */
.btn-primary {
  background: #fff;
  border: none;
  color: #000;
  font-weight: 600;
}

.btn-primary:hover {
  background: #e4e4e7;
}

.btn-primary:active {
  box-shadow: 0 2px 8px rgba(0, 229, 255, 0.2);
}

/* Ghost - Secondary action */
.btn-ghost {
  border: 1px solid var(--border-default);
  background: rgba(255, 255, 255, 0.02);
}

.btn-ghost:hover {
  border-color: rgba(0, 229, 255, 0.3);
  box-shadow: var(--shadow-glow-soft);
  background: rgba(0, 229, 255, 0.04);
}

/* Danger - Destructive action */
.btn-danger {
  border: 1px solid rgba(255, 128, 147, 0.28);
  background: rgba(255, 128, 147, 0.06);
  color: #ffb0bc;
  font-weight: 600;
}

.btn-danger:hover {
  border-color: rgba(255, 128, 147, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 128, 147, 0.12), 0 0 20px rgba(255, 128, 147, 0.1);
  background: rgba(255, 128, 147, 0.12);
}

/* Mini button */
.btn-mini {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.8rem;
}

/* ========== INPUTS ========== */
.field {
  display: grid;
  gap: 10px;
}

.field label {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-left: 2px;
}

.field input,
.subtle-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  outline: none;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.field input::placeholder {
  color: var(--text-subtle);
}

.field input:focus,
.cost-field input:focus,
.cost-field select:focus {
  border-color: rgba(0, 229, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.15), var(--shadow-glow-soft);
  transform: translateY(-1px);
  background: var(--bg-surface-hover);
}

/* ========== TABLES ========== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.budget-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
}

.budget-table th,
.budget-table td {
  padding: 16px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.budget-table th {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: rgba(255, 255, 255, 0.01);
}

.budget-table tbody tr {
  transition: background var(--transition-fast);
}

.budget-table tbody tr:hover {
  background: rgba(0, 229, 255, 0.03);
}

.budget-table tbody tr:last-child td {
  border-bottom: none;
}

.budget-table td:last-child {
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.95rem;
}

.cost-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.cost-table th,
.cost-table td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.cost-table th {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.cost-table td input,
.cost-table td select {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
  border: 1px solid rgba(138, 147, 166, 0.18);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

.cost-table td output {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  font-variant-numeric: tabular-nums;
  color: var(--accent-primary);
  font-weight: 600;
}

.btn-row-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  width: 100%;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 128, 147, 0.26);
  background: rgba(255, 128, 147, 0.06);
  color: #ffb0bc;
  font-weight: 600;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.btn-row-delete:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 128, 147, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 128, 147, 0.12), 0 0 20px rgba(255, 128, 147, 0.1);
  background: rgba(255, 128, 147, 0.12);
}

.cost-table tr.is-active {
  background: rgba(0, 229, 255, 0.04);
}

.empty-row td,
.empty-row td {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 20px;
  font-style: italic;
}

/* ========== TOTAL CARDS ========== */
.total-card {
  display: grid;
  gap: 10px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(124, 92, 255, 0.12) 0%, rgba(0, 229, 255, 0.06) 100%), var(--bg-surface);
  border: 1px solid rgba(124, 92, 255, 0.2);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(124, 92, 255, 0.15);
  transition: all var(--transition-smooth);
}

.total-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(124, 92, 255, 0.2);
  border-color: rgba(124, 92, 255, 0.3);
}

.total-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.total-value {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  letter-spacing: -0.03em;
  font-weight: 800;
  color: var(--text-primary);
}

/* ========== FORM HINT ========== */
.form-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ========== HEADER ACTIONS ========== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ========== CATEGORY META ========== */
.cost-category-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cost-category-meta strong {
  font-size: 1.2rem;
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
}

/* ========== ROW ACTIONS ========== */
.cost-row-actions,
.cost-simulations-head,
.cost-toolbar,
.cost-summary-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.cost-category-head, 
.cost-simulations-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 12px;
}

/* ========== GRID HELPERS ========== */
.cost-work-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  align-items: end;
  gap: 20px;
}

.cost-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cost-grid-forms {
  align-items: start;
}

.cost-category,
.cost-simulations,
.cost-categories,
.cost-work-panel,
.cost-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 24px;
}

.cost-toolbar-copy {
  display: grid;
  gap: 6px;
}

.cost-form {
  display: grid;
  gap: 14px;
}

.cost-report {
  padding-bottom: 18px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1040px) {
  .cost-grid {
    grid-template-columns: 1fr;
  }
  
  .cost-work-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .cost-grid {
    grid-template-columns: 1fr;
  }
  
  .cost-summary-head,
  .cost-category-head {
    flex-direction: column;
    align-items: flex-start;
  }
}
