@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  --crosshair-size: 12px;
  --crosshair-thick: 1px;
  --border-color: #000000;
}

body {
  font-family: 'Space Mono', monospace;
  background-color: #ffffff;
  color: #000000;
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

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

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: 'Space Mono', monospace; }

/* Crosshair Border System */
.crosshair-border {
  position: relative;
  border: 1px solid #e5e5e5;
}

.corner {
  position: absolute;
  width: var(--crosshair-size);
  height: var(--crosshair-size);
  pointer-events: none;
  z-index: 10;
  transition: width 0.15s, height 0.15s, border-color 0.15s;
}

.corner-tl { top: -1px; left: -1px; border-top: var(--crosshair-thick) solid var(--border-color); border-left: var(--crosshair-thick) solid var(--border-color); }
.corner-tr { top: -1px; right: -1px; border-top: var(--crosshair-thick) solid var(--border-color); border-right: var(--crosshair-thick) solid var(--border-color); }
.corner-bl { bottom: -1px; left: -1px; border-bottom: var(--crosshair-thick) solid var(--border-color); border-left: var(--crosshair-thick) solid var(--border-color); }
.corner-br { bottom: -1px; right: -1px; border-bottom: var(--crosshair-thick) solid var(--border-color); border-right: var(--crosshair-thick) solid var(--border-color); }

.interactive-crosshair:hover .corner {
  width: 20px;
  height: 20px;
  border-color: #333;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #000; }
::-webkit-scrollbar-thumb:hover { background: #333; }

/* App Shell */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Header */
.app-header {
  flex: none;
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  position: relative;
  z-index: 20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  width: 24px;
  height: 24px;
}

.app-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.app-version {
  font-size: 12px;
  font-weight: 400;
  color: #9ca3af;
  margin-left: 8px;
}

.btn-header {
  background: #000;
  color: #fff;
  padding: 12px 24px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: 1px solid #000;
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,0.1);
  transition: all 0.15s;
}

.btn-header:hover {
  background: #333;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,0.1);
}

.btn-header:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

/* App Body */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.app-sidebar {
  width: 100%;
  max-width: 384px;
  flex: none;
  border-right: 1px solid #e5e7eb;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-inner {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Summary Cards */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.summary-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  padding: 12px;
}

.summary-card-label {
  font-size: 9px;
  font-weight: 400;
  text-transform: uppercase;
  color: #9ca3af;
  margin-bottom: 4px;
}

.summary-card-value {
  font-size: 16px;
  font-weight: 700;
}

.summary-card-value.revenue { color: #16a34a; }
.summary-card-value.investment { color: #2563eb; }
.summary-card-value.expense { color: #000; }

.summary-card.net {
  background: #000;
  color: #fff;
  border-color: #000;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.summary-card.net .summary-card-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.6);
  margin-bottom: 0;
}

.summary-card.net .summary-card-value {
  font-size: 18px;
  color: #fff;
}

.summary-card.net .summary-card-value.negative {
  color: #f87171;
}

/* Entry Form */
.entry-form-wrapper {
  position: relative;
  background: #fff;
  padding: 4px;
}

.entry-form-inner {
  background: #fff;
  padding: 16px;
  border: 1px solid #e5e7eb;
}

.entry-form-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Type Tabs */
.type-tabs {
  display: flex;
  margin-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.type-tab {
  flex: 1;
  padding: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
  background: #fff;
  color: #999;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: all 0.15s;
}

.type-tab:hover {
  color: #666;
}

.type-tab.active {
  background: #000;
  color: #fff;
  border-color: #000;
}

.type-tab.investment-tab {
  color: #2563eb;
}

.type-tab.investment-tab.active {
  background: #000;
  color: #fff;
}

/* Form Fields */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
  color: #9ca3af;
  margin-bottom: 4px;
}

.form-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid #d1d5db;
  padding: 4px 0;
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  color: #000;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus {
  border-bottom-color: #000;
}

.form-input::placeholder {
  color: #9ca3af;
}

.form-input[type="date"] {
  color: #6b7280;
}

.form-select {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid #d1d5db;
  padding: 4px 0;
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  color: #000;
  outline: none;
  transition: border-color 0.15s;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-radius: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239ca3af'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
  padding-right: 16px;
}

.form-select:focus {
  border-bottom-color: #000;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Checkbox */
.checkbox-wrap {
  padding-top: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-box {
  width: 16px;
  height: 16px;
  border: 1px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: transparent;
  transition: all 0.15s;
  flex-shrink: 0;
}

.checkbox-label input:checked ~ .checkbox-box {
  background: #000;
  color: #fff;
}

.checkbox-text {
  font-size: 12px;
  text-transform: uppercase;
}

/* Anchor Radio Group */
.anchor-group {
  margin-bottom: 16px;
}

.anchor-radios {
  display: flex;
  gap: 16px;
  margin-top: 4px;
}

.anchor-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.anchor-radio input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border: 1px solid #000;
  border-radius: 50%;
  margin: 0;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.anchor-radio input[type="radio"]:checked {
  background: #000;
  box-shadow: inset 0 0 0 2px #fff;
}

/* Form Footer */
.form-footer {
  padding-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.attach-link {
  font-size: 10px;
  text-transform: uppercase;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  color: #000;
  cursor: pointer;
  transition: color 0.15s;
}

.attach-link:hover {
  color: #666;
}

.btn-execute {
  background: #000;
  color: #fff;
  padding: 8px 24px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: none;
}

.btn-execute:hover {
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,0.2);
}

.btn-execute:active {
  transform: translateY(1px);
  box-shadow: none;
}

.file-name-display {
  height: 16px;
  font-size: 10px;
  color: #9ca3af;
  margin-top: 4px;
}

/* Main Content / Timeline */
.app-main {
  flex: 1;
  background: #fff;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Timeline Header */
.timeline-header {
  flex: none;
  padding: 24px 32px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.timeline-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.timeline-count {
  font-size: 12px;
  color: #9ca3af;
  margin-left: 16px;
}

/* Filter Links */
.filter-links {
  display: flex;
  gap: 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-link {
  text-decoration: underline;
  text-decoration-style: solid;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: all 0.2s;
  color: #9ca3af;
}

.filter-link:hover {
  color: #6b7280;
}

.filter-link.active {
  color: #000;
  font-weight: 700;
}

/* Timeline Scroll */
.timeline-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.timeline-inner {
  max-width: 768px;
  margin: 0 auto;
  position: relative;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 0.4;
  pointer-events: none;
  padding: 80px 0;
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 14px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.empty-state-text {
  font-size: 12px;
  margin-top: 8px;
}

/* Load More */
.load-more-wrap {
  text-align: center;
  padding: 24px 0;
}

.load-more-link {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid #000;
  padding: 10px 24px;
  color: #000;
  text-decoration: none;
  transition: all 0.15s;
}

.load-more-link:hover {
  background: #000;
  color: #fff;
}

/* Timeline Container */
.timeline-container {
  position: relative;
}

/* Timeline Item */
.timeline-item {
  position: relative;
  padding-left: 32px;
  margin-bottom: 24px;
}

/* Vertical line */
.timeline-item::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 20px;
  bottom: -24px;
  width: 1px;
  background: #d4d4d4;
  z-index: 0;
}

/* Hide line on last item */
.timeline-item:last-child::before {
  display: none;
}

/* Dot */
.timeline-item::after {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid #d4d4d4;
  border-radius: 50%;
  z-index: 1;
  transition: all 0.25s ease;
}

/* Fill dot on hover */
.timeline-item:hover::after {
  background: #000;
  border-color: #000;
}

/* Timeline Card */
.timeline-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  padding: 16px;
  position: relative;
  transition: all 0.15s;
}

.timeline-card:hover {
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,0.05);
}

.timeline-card-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.timeline-card-left {
  flex: 1;
}

.timeline-card-header {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
  flex-wrap: wrap;
  gap: 4px;
}

.timeline-card-title {
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  margin-right: 8px;
}

/* Type Badge */
.type-badge {
  font-size: 10px;
  font-weight: 400;
  border: 1px solid;
  padding: 1px 4px;
  text-transform: uppercase;
  vertical-align: middle;
  display: inline-block;
  line-height: 1.4;
}

.type-badge.expense { background: #000; color: #fff; border-color: #000; }
.type-badge.expense-rec { background: #333; color: #fff; border-color: #333; }
.type-badge.revenue { background: #fff; color: #000; border-color: #000; }
.type-badge.revenue-rec { background: #f0f0f0; color: #000; border-color: #000; }
.type-badge.investment { background: #fff; color: #2563eb; border-color: #2563eb; }
.type-badge.investment-rec { background: #2563eb; color: #fff; border-color: #2563eb; }

.timeline-card-meta {
  font-size: 12px;
  color: #9ca3af;
  font-family: 'Space Mono', monospace;
  margin-top: 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.timeline-card-meta .invoice-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  border: 1px solid #d1d5db;
  padding: 1px 8px;
  color: #6b7280;
  margin-left: 8px;
}

.timeline-card-meta .attach-action {
  font-size: 10px;
  color: #9ca3af;
  text-decoration: underline;
  margin-left: 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.timeline-card:hover .attach-action {
  opacity: 1;
}

.attach-action:hover {
  color: #000;
}

/* Card Right (Amount + Delete) */
.timeline-card-right {
  text-align: right;
  margin-left: 16px;
}

.timeline-card-amount {
  font-weight: 700;
  font-size: 18px;
}

.timeline-card-amount.expense { color: #000; }
.timeline-card-amount.revenue { color: #16a34a; }
.timeline-card-amount.investment { color: #2563eb; }

.timeline-card-delete {
  font-size: 10px;
  color: #9ca3af;
  text-decoration: underline;
  margin-top: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  background: none;
  border: none;
  font-family: inherit;
}

.timeline-card:hover .timeline-card-delete {
  opacity: 1;
}

.timeline-card-delete:hover {
  color: #dc2626;
}

/* Card Actions Row */
.timeline-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* Settle Toggle */
.timeline-card-settle {
  font-size: 10px;
  font-family: inherit;
  text-transform: uppercase;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: color 0.15s;
  color: #dc2626;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.timeline-card-settle.is-settled {
  color: #16a34a;
}

.timeline-card-settle:hover {
  color: #000;
}

/* Settled Card Styling */
.timeline-card-settled {
  opacity: 0.55;
}

.timeline-card-settled:hover {
  opacity: 1;
}

.timeline-item.settled::after {
  background: #16a34a;
  border-color: #16a34a;
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-box {
  width: 100%;
  max-width: 380px;
}

.login-inner {
  padding: 32px;
  border: 1px solid #e5e7eb;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header .logo-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  display: block;
}

.login-title {
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 10px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-btn {
  width: 100%;
  margin-top: 8px;
}

.login-error {
  background: #000;
  color: #fff;
  font-size: 11px;
  text-transform: uppercase;
  padding: 8px 12px;
  margin-bottom: 16px;
  letter-spacing: 0.03em;
}

/* Header Auth */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-user {
  font-size: 11px;
  text-transform: uppercase;
  color: #6b7280;
  letter-spacing: 0.03em;
}

.header-admin-link {
  font-size: 10px;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 2px;
  color: #000;
  letter-spacing: 0.03em;
}

/* Admin Page */
.admin-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 24px;
}

.admin-section {
  margin-bottom: 40px;
}

.admin-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.admin-form .form-row {
  margin-bottom: 16px;
}

.admin-form .btn-execute {
  margin-top: 8px;
}

.admin-success {
  background: #fff;
  border: 1px solid #000;
  color: #000;
  font-size: 11px;
  text-transform: uppercase;
  padding: 8px 12px;
  margin-bottom: 16px;
  letter-spacing: 0.03em;
}

.admin-user-list {
  border: 1px solid #e5e7eb;
}

.admin-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid #f3f4f6;
}

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

.admin-user-name {
  font-weight: 700;
  flex: 1;
}

.admin-user-date {
  font-size: 11px;
  color: #9ca3af;
}

.admin-password-reveal {
  background: #000;
  color: #fff;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.admin-password-reveal .form-label {
  color: #9ca3af;
  margin-bottom: 8px;
}

.admin-password-code {
  display: block;
  font-size: 11px;
  word-break: break-all;
  line-height: 1.6;
  user-select: all;
}

/* Responsive */
@media (max-width: 768px) {
  .app-body {
    flex-direction: column;
  }
  
  .app-sidebar {
    max-width: 100%;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
  }
}
