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

:root {
  --red: #ED2533;
  --dark: #161736;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #333;
  --muted: #888;
  --border: #e0e0e0;
  --success: #28a745;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
  font-family: 'Montserrat', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

/* Header */
.header {
  background: var(--dark);
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--red);
}

.header .subtitle {
  font-size: 11px;
  color: #aaa;
}

.header a {
  color: #ccc;
  text-decoration: none;
  font-size: 12px;
}

.header .nav-links {
  display: flex;
  gap: 12px;
}

.header .nav-links a {
  color: #ccc;
  font-size: 12px;
}

.header .nav-links a:hover,
.header .nav-links a.active {
  color: var(--red);
}

/* Container */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

.container.wide {
  max-width: 900px;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 12px;
}

.card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 8px;
}

/* Login */
.login-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 12px;
  padding: 30px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card h2 {
  font-size: 20px;
  color: var(--dark);
  margin-bottom: 20px;
}

.store-select {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.store-btn {
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.store-btn:hover,
.store-btn.selected {
  border-color: var(--red);
  color: var(--red);
}

.store-btn .addr {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  display: block;
  margin-top: 2px;
}

/* Forms */
.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 4px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border 0.2s;
}

.form-group input:focus {
  border-color: var(--red);
}

input[type="number"] {
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.pin-input {
  font-size: 28px !important;
  text-align: center;
  letter-spacing: 12px;
  font-weight: 700;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  text-align: center;
}

.btn-red {
  background: var(--red);
  color: white;
  width: 100%;
}

.btn-red:hover {
  background: #d42030;
}

.btn-dark {
  background: var(--dark);
  color: white;
}

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

.btn-outline:hover {
  border-color: var(--red);
  color: var(--red);
}

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

/* Expenses */
.expense-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  align-items: center;
}

.expense-row input:first-child {
  flex: 2;
}

.expense-row input:nth-child(2) {
  flex: 1;
}

.expense-row .remove-exp {
  background: none;
  border: none;
  color: var(--red);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
}

.add-expense {
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
  font-family: inherit;
}

/* Total row */
.total-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 2px solid var(--dark);
  margin-top: 12px;
  font-weight: 700;
  font-size: 18px;
}

.total-row .amount {
  color: var(--red);
}

/* Dashboard */
.store-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.store-card {
  flex: 1;
  min-width: 250px;
}

.store-card .store-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--red);
}

.metric {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}

.metric .label {
  color: var(--muted);
}

.metric .value {
  font-weight: 600;
}

.metric.highlight .value {
  color: var(--red);
  font-size: 16px;
  font-weight: 800;
}

.metric.subtotal {
  border-top: 1px dashed var(--border);
  margin-top: 4px;
  padding-top: 6px;
  font-weight: 700;
}

.metric .value.green { color: var(--success); }
.metric .value.red { color: var(--red); }

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--dark);
  margin-top: 10px;
  margin-bottom: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.today-mini {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 8px;
}

.today-mini .section-label {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.summary-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.summary-box {
  flex: 1;
  background: white;
  border-radius: 10px;
  padding: 14px;
  box-shadow: var(--shadow);
  text-align: center;
}

.summary-box .label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.summary-box .value {
  font-size: 20px;
  font-weight: 800;
  color: var(--dark);
}

.summary-box .value.red {
  color: var(--red);
}

/* History table */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th {
  background: var(--dark);
  color: white;
  padding: 8px 6px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}

td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tr:hover td {
  background: #f9f9f9;
}

.no-data {
  text-align: center;
  color: var(--muted);
  padding: 40px;
  font-size: 14px;
}

/* Flash */
.flash {
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 500;
}

.flash.success {
  background: #d4edda;
  color: #155724;
}

.flash.error {
  background: #f8d7da;
  color: #721c24;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.pagination a {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--dark);
  text-decoration: none;
  font-size: 13px;
}

.pagination a.active {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

/* Chart */
.chart-container {
  position: relative;
  height: 200px;
  margin-top: 12px;
}

/* Filter */
.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-row a {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: var(--dark);
  background: white;
  border: 1px solid var(--border);
}

.filter-row a.active {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

/* Date nav */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.date-nav a {
  color: var(--dark);
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
}

.date-nav .current-date {
  font-size: 15px;
  font-weight: 600;
}

/* Summary page */
.summary-date {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 16px;
}

.summary-section {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 8px;
}

.income-title { color: var(--success); }
.expense-title { color: var(--red); }

.summary-line {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 14px;
}

.summary-line .amount {
  font-weight: 600;
}

.summary-line .amount.green { color: var(--success); }
.summary-line .amount.red { color: var(--red); }

.summary-line.subtotal {
  border-top: 1px dashed var(--border);
  margin-top: 6px;
  padding-top: 8px;
  font-weight: 700;
}

.summary-line.muted span {
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
}

.total-block {
  background: var(--dark);
  color: white;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  margin: 16px 0;
}

.total-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  color: #aaa;
  margin-bottom: 4px;
}

.total-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--red);
}

.total-formula {
  font-size: 11px;
  color: #888;
  margin-top: 6px;
}

.summary-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.summary-actions .btn {
  flex: 1;
}

@media (max-width: 480px) {
  .container { padding: 10px; }
  .card { padding: 12px; }
  .store-cards { flex-direction: column; }
  .summary-row { flex-direction: column; }
}
