/*
 * Dark Minimal theme
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #111111;
  --surface: #191919;
  --surface-hover: #222222;
  --border: #333333;
  --text: #ededed;
  --text-secondary: #a0a0a0;
  --text-muted: #777777;
  --accent: #ededed;
  --amber: #f59e0b;
  --radius: 6px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", SFMono-Regular, ui-monospace, Menlo, monospace;
}

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

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.container {
  max-width: 620px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.container-narrow {
  max-width: 400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
}

.header-inner {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 3rem;
}

.site-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.site-title a {
  color: var(--text);
  text-decoration: none;
}

/* Typography */
h1, h2, h3 {
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 1rem;
  color: var(--text);
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }

p {
  margin: 0 0 0.75rem;
  color: var(--text-secondary);
}

.text-center { text-align: center; }
.text-small { font-size: 12px; }
.text-muted { color: var(--text-muted); }

/* Links */
a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--text-secondary);
}

/* Navigation */
.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.site-nav a,
.site-nav .nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.15s;
}

.site-nav a:hover,
.site-nav .nav-link:hover {
  color: var(--text);
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-header h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 0;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease;
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--text-muted);
}

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

/* Buttons */
.btn,
input[type="submit"] {
  display: inline-block;
  padding: 6px 14px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: var(--bg);
  background: var(--text);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn:hover,
input[type="submit"]:hover {
  opacity: 0.85;
  color: var(--bg);
}

.btn-block,
input[type="submit"] {
  display: block;
  width: 100%;
  text-align: center;
}

.btn-sm {
  font-size: 12px;
  padding: 5px 12px;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  opacity: 0.85;
  color: var(--text);
}

.btn-link {
  background: none;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0;
  font-weight: 500;
  border-radius: 0;
}

.btn-link:hover {
  background: none;
  color: var(--text);
  opacity: 1;
}

/* Cards (legacy, kept for forms) */
.card {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Inline forms */
.inline {
  display: inline;
}

/* Spacing */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

/* Divider */
.divider {
  display: flex;
  align-items: center;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background-color: var(--border);
}

.divider::before { margin-right: 0.75rem; }
.divider::after { margin-left: 0.75rem; }

/* Flash messages */
.flash {
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 13px;
  border-radius: var(--radius);
}

.flash-notice {
  color: #4ade80;
  background-color: #0a1f0f;
  border: 1px solid #1a3a1a;
}

.flash-alert {
  color: #fb7185;
  background-color: #1f0a0a;
  border: 1px solid #3a1a1a;
}

/* Error list */
.errors {
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  background-color: #1f0a0a;
  border: 1px solid #3a1a1a;
  border-radius: var(--radius);
}

.errors ul {
  margin: 0;
  padding-left: 1.25rem;
}

.errors li {
  color: #fb7185;
  font-size: 13px;
}

/* Date groups */
.date-group { margin-bottom: 2rem; }

.date-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* Transaction list */
.transaction-list {
  display: flex;
  flex-direction: column;
}

.transaction-row {
  display: flex;
  align-items: center;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.15s;
}

.transaction-row:last-child { border-bottom: none; }
.transaction-row.excluded { opacity: 0.25; }

.transaction-row.uncategorized .category-line {
  background: var(--text-muted);
}

.category-line {
  width: 3px;
  height: 32px;
  border-radius: 1.5px;
  margin-right: 1rem;
  flex-shrink: 0;
}

.transaction-body {
  flex: 1;
  min-width: 0;
}

.transaction-description {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transaction-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  gap: 0.5rem;
}

.transaction-sub .sep { color: var(--border); }

.category-select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  padding: 2px 4px;
  cursor: pointer;
  outline: none;
}

.category-select:hover {
  color: var(--text-secondary);
}

.category-select option {
  background: var(--surface);
  color: var(--text);
  padding: 6px 8px;
  font-size: 13px;
}

.category-select optgroup {
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 8px;
}

.transaction-amount {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  margin-left: 1rem;
  color: var(--text);
  flex-shrink: 0;
}

.transaction-amount.amount-positive { color: #4ade80; }
.transaction-amount.amount-negative { color: var(--text); }


/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  font-size: 12px;
  color: var(--text-muted);
}

.pagination-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.pagination-link:hover {
  color: var(--text-secondary);
}

.pagination-info {
  color: var(--text-muted);
}

/* Category list */
.category-list {
  display: flex;
  flex-direction: column;
}

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

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

.category-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.category-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.category-name {
  font-size: 14px;
  font-weight: 500;
}

.category-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.category-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
  margin-left: 1rem;
}

.category-actions a,
.category-actions button {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font);
}

.category-actions a:hover,
.category-actions button:hover {
  color: var(--text);
}

/* Connection list */
.connection-list {
  display: flex;
  flex-direction: column;
}

.connection-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
}

.connection-card:last-child { border-bottom: none; }

.connection-name {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 0.125rem;
  color: var(--text);
}

.connection-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.meta-sep {
  margin: 0 0.125rem;
}

.account-list {
  list-style: none;
  padding: 0;
  margin: 0.625rem 0 0;
}

.account-list li {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 0.3125rem 0;
  border-top: 1px solid var(--border);
}

.account-list li:first-child {
  border-top: none;
  padding-top: 0;
}

.connection-actions {
  flex-shrink: 0;
  margin-left: 1rem;
}

.btn-danger-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}

.btn-danger-link:hover {
  color: #fb7185;
}

/* Account list (show page) */
.account-list-detail {
  display: flex;
  flex-direction: column;
}

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

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

.account-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.account-name {
  font-size: 14px;
  font-weight: 500;
}

.account-nickname-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
  margin-left: 1rem;
}

.account-actions a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}

.account-actions a:hover {
  color: var(--text);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
}

.empty-state-heading {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 0.375rem;
}

.empty-state-body {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 1.25rem;
}

/* Group sections */
.group-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.group-section:last-child { border-bottom: none; }

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.group-name {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.group-categories {
  margin-bottom: 0.75rem;
}

/* Inline forms */
.inline-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.inline-form input[type="text"] {
  width: auto;
  flex: 1;
  padding: 5px 10px;
  font-size: 13px;
}

.inline-form input[type="submit"] {
  display: inline-block;
  width: auto;
}

.inline-form a {
  font-size: 12px;
  color: var(--text-muted);
}

/* Drag-and-drop */
.sortable-ghost {
  opacity: 0.4;
  background: var(--surface-hover);
}

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}


/* Transaction row as link */
a.transaction-row {
  display: flex;
  cursor: pointer;
}

a.transaction-row:hover {
  background: var(--surface-hover);
}

/* Transaction detail (edit page) */
.transaction-detail {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.detail-label {
  font-size: 12px;
  color: var(--text-muted);
}

.detail-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* Edit transaction form */
.edit-transaction-form .form-group {
  margin-bottom: 1.25rem;
}

.form-select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: var(--text-muted);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.form-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--text);
  cursor: pointer;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.form-actions .btn {
  width: auto;
}

/* Stats page */
.stats-month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stats-nav-arrow {
  font-size: 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1;
  padding: 0.25rem 0.5rem;
}

.stats-nav-arrow:hover {
  color: var(--text);
}

.stats-month-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  min-width: 10rem;
  text-align: center;
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.stat-income { color: #4ade80; }
.stat-spent { color: var(--text); }
.stat-positive { color: #4ade80; }
.stat-negative { color: #fb7185; }

.stats-breakdown {
  margin-top: 0.5rem;
}

.stats-breakdown-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.stats-category-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stats-category-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stats-category-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stats-category-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.stats-category-amount {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-secondary);
}

.stats-bar-track {
  height: 4px;
  background: var(--surface);
  border-radius: 2px;
  margin-top: 0.25rem;
}

.stats-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

a.stats-group-link {
  text-decoration: none;
  display: block;
  padding: 0.25rem 0;
  border-radius: var(--radius);
}

a.stats-group-link:hover {
  background: var(--surface-hover);
}

/* Section border */
.section-border-top {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* Hamburger button (hidden on desktop) */
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 0;
}

.hamburger:hover {
  color: var(--text);
}

/* Mobile navigation */
@media (max-width: 640px) {
  .hamburger {
    display: block;
  }

  .site-header {
    position: relative;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0;
    z-index: 100;
  }

  .site-nav.open {
    display: flex;
  }

  .site-nav a,
  .site-nav .nav-link {
    padding: 0.75rem 1.5rem;
    font-size: 14px;
  }

  .site-nav a:hover,
  .site-nav .nav-link:hover {
    background: var(--surface-hover);
  }

  .stats-cards {
    gap: 0.375rem;
  }

  .stat-card {
    padding: 0.625rem;
    gap: 0.125rem;
  }

  .stat-label {
    font-size: 9px;
    letter-spacing: 0.04em;
  }

  .stat-value {
    font-size: 0.8125rem;
  }
}
