/* Kapital - Clean Finance App */
:root {
  --bg: #000000;
  --bg-card: #111111;
  --bg-input: #1a1a1a;
  --border: #222222;
  --text: #ffffff;
  --text-secondary: #888888;
  --text-muted: #555555;
  --accent: #10b981;
  --accent-dark: #059669;
  --warning: #f59e0b;
  --danger: #ef4444;
  --success: #22c55e;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 500px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 40px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo img {
  width: 32px;
  height: 32px;
}

.logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

.header-date {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Budget Card */
.budget-card {
  background: linear-gradient(135deg, #0d3320 0%, #052e16 100%);
  border: 1px solid #166534;
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 20px;
}

.budget-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}

.budget-label {
  font-size: 0.9rem;
  color: #86efac;
}

.budget-remaining {
  font-size: 2.5rem;
  font-weight: 700;
  color: #ffffff;
}

.budget-remaining.warning {
  color: var(--warning);
}

.budget-remaining.danger {
  color: var(--danger);
}

.budget-bar {
  height: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  margin-bottom: 20px;
  overflow: hidden;
}

.budget-bar-fill {
  height: 100%;
  background: #4ade80;
  border-radius: 3px;
  transition: width 0.3s, background 0.3s;
}

.budget-bar-fill.warning {
  background: var(--warning);
}

.budget-bar-fill.danger {
  background: var(--danger);
}

.budget-stats {
  display: flex;
  justify-content: space-between;
}

.budget-stat {
  text-align: center;
}

.budget-stat .stat-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffffff;
}

.budget-stat .stat-label {
  font-size: 0.75rem;
  color: #86efac;
}

/* Section Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.section-total {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}

.clear-btn, .edit-btn {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
}

.clear-btn:hover, .edit-btn:hover {
  color: var(--text);
}

/* Quick Add Section */
.quick-add-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
}

.add-item-form {
  margin-bottom: 16px;
}

.item-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 10px;
}

.item-input:focus {
  outline: none;
  border-color: var(--accent);
}

.item-input::placeholder {
  color: var(--text-muted);
}

.price-row {
  display: flex;
  gap: 10px;
}

.price-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 16px;
}

.price-input-wrap:focus-within {
  border-color: var(--accent);
}

.price-prefix {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-right: 4px;
}

.price-input {
  flex: 1;
  padding: 14px 0;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 600;
}

.price-input:focus {
  outline: none;
}

.price-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.add-btn {
  padding: 14px 24px;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  color: #000;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.add-btn:hover {
  background: var(--accent-dark);
}

/* Quick Presets */
.quick-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-btn {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* Cart Section */
.cart-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
}

.cart-items {
  margin-bottom: 16px;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.cart-item:last-child {
  border-bottom: none;
}

.cart-item-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cart-item-name {
  font-size: 0.95rem;
}

.cart-item-price {
  font-size: 1rem;
  font-weight: 600;
}

.remove-item {
  width: 28px;
  height: 28px;
  background: rgba(239, 68, 68, 0.1);
  border: none;
  border-radius: 8px;
  color: var(--danger);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-item:hover {
  background: rgba(239, 68, 68, 0.2);
}

.cart-total {
  display: flex;
  justify-content: space-between;
  padding: 16px 0;
  border-top: 2px solid var(--border);
  font-size: 1.1rem;
  font-weight: 600;
}

.cart-impact {
  text-align: center;
  padding: 12px;
  background: var(--bg-input);
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.cart-impact span {
  color: var(--accent);
  font-weight: 600;
}

.cart-impact.warning span {
  color: var(--warning);
}

.cart-impact.danger span {
  color: var(--danger);
}

.confirm-btn {
  width: 100%;
  padding: 16px;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  color: #000;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.confirm-btn:hover {
  background: var(--accent-dark);
}

.confirm-btn:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
}

/* Spending List */
.spending-list {
  max-height: 300px;
  overflow-y: auto;
}

.spending-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.spending-item:last-child {
  border-bottom: none;
}

.spending-item-info {
  flex: 1;
}

.spending-item-name {
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.spending-item-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.spending-item-amount {
  font-size: 1rem;
  font-weight: 600;
  color: var(--danger);
}

.delete-spending {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 8px;
}

.delete-spending:hover {
  color: var(--danger);
}

.empty-state {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
}

/* Accounts Grid */
.accounts-card {
  padding-bottom: 16px;
}

.accounts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.account-box {
  background: var(--bg-input);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.account-box:hover {
  background: #222;
}

.account-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.account-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 600;
}

.rent-box {
  grid-column: span 2;
}

.rent-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px 0 6px;
  overflow: hidden;
}

.rent-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}

.rent-target {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.net-worth-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.net-worth-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

/* Week Bars */
.week-bars {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: 80px;
  margin-bottom: 20px;
  padding: 0 4px;
}

.week-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 36px;
}

.week-bar-track {
  width: 24px;
  height: 50px;
  background: var(--bg-input);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  margin-bottom: 8px;
}

.week-bar-fill {
  position: absolute;
  bottom: 0;
  width: 100%;
  background: var(--accent);
  border-radius: 6px;
  transition: height 0.3s;
}

.week-bar-fill.warning {
  background: var(--warning);
}

.week-bar-fill.danger {
  background: var(--danger);
}

.week-bar-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.week-bar-label.today {
  color: var(--accent);
  font-weight: 600;
}

.week-summary {
  display: flex;
  justify-content: space-around;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.week-stat {
  text-align: center;
}

.week-stat-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 600;
}

.week-stat-value.positive {
  color: var(--success);
}

.week-stat-value.negative {
  color: var(--danger);
}

.week-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Obligations List */
.obligations-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.obligation-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-input);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.obligation-item:hover {
  background: #222;
}

.obligation-check {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.obligation-item.checked .obligation-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

.obligation-info {
  flex: 1;
  min-width: 0;
}

.obligation-name {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.obligation-amount {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* History & Settings Links */
.history-link, .settings-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s;
}

.history-link:hover, .settings-link:hover {
  background: #1a1a1a;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 500px;
  background: var(--bg-card);
  border-radius: 24px 24px 0 0;
  max-height: 80vh;
  transform: translateY(100%);
  transition: transform 0.3s;
}

.modal-full {
  max-height: 90vh;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  background: var(--bg-input);
  border: none;
  border-radius: 50%;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(80vh - 70px);
}

.modal-full .modal-body {
  max-height: calc(90vh - 70px);
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 16px;
}

.input-wrap:focus-within {
  border-color: var(--accent);
}

.input-wrap span {
  color: var(--text-muted);
  margin-right: 8px;
}

.input-wrap input {
  flex: 1;
  padding: 14px 0;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.1rem;
}

.input-wrap input:focus {
  outline: none;
}

.save-btn {
  width: 100%;
  padding: 16px;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  color: #000;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
}

/* Settings */
.settings-group {
  margin-bottom: 30px;
}

.settings-group h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 16px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.toggle {
  width: 50px;
  height: 28px;
  background: var(--bg-input);
  border-radius: 14px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle.active {
  background: var(--accent);
}

.toggle::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
}

.toggle.active::after {
  transform: translateX(22px);
}

.budget-info {
  background: var(--bg-input);
  border-radius: 12px;
  padding: 16px;
}

.budget-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.budget-row:last-child {
  border-bottom: none;
}

.budget-row.highlight {
  color: var(--accent);
  font-weight: 600;
}

.action-btn {
  width: 100%;
  padding: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  margin-bottom: 10px;
  text-align: left;
}

.action-btn:hover {
  background: #222;
}

.action-btn.danger {
  color: var(--danger);
}

/* History List */
.history-list {
  padding-bottom: 20px;
}

.history-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 16px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.history-item-name {
  font-size: 0.95rem;
}

.history-item-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-item-amount {
  font-weight: 600;
}

.history-item-amount.expense {
  color: var(--danger);
}

.history-item-amount.income {
  color: var(--success);
}

/* Toast */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
}

.toast {
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  animation: slideDown 0.3s ease;
}

.toast.success {
  border-color: var(--success);
}

.toast.warning {
  border-color: var(--warning);
}

.toast.error {
  border-color: var(--danger);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Safe area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .app {
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
