:root {
  --color-primary: #DEABA5;
  --color-primary-dark: #c9958e;
  --color-primary-light: #f0cdc9;
  --color-accent: #4b2d1e;
  --color-bg: #fdf6f2;
  --color-surface: #ffffff;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-income: #059669;
  --color-expense: #dc2626;
  --color-danger: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.container { max-width: 800px; margin: 0 auto; padding: 16px; padding-bottom: 80px; }

/* Nav */
.nav {
  background: var(--color-primary);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.nav-container {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: 0 16px;
  min-height: 48px;
}
.nav-brand {
  color: white !important;
  font-weight: 700;
  font-size: 1.125rem;
  text-decoration: none !important;
}
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  margin-left: auto;
  padding: 8px;
}
.nav-menu {
  display: flex;
  gap: 4px;
  margin-left: auto;
  overflow-x: auto;
}
.nav-menu a {
  color: rgba(255,255,255,0.85);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.875rem;
  white-space: nowrap;
  text-decoration: none !important;
}
.nav-menu a:hover, .nav-menu a.active {
  background: rgba(255,255,255,0.15);
  color: white;
}
.nav-logout {
  margin-left: 8px;
  opacity: 0.7;
}

@media (max-width: 640px) {
  .nav-toggle { display: block; }
  .nav-menu {
    display: none;
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    background: var(--color-primary-dark);
    flex-direction: column;
    padding: 8px;
    box-shadow: var(--shadow);
  }
  .nav-menu.open { display: flex; }
}

/* Cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.card-stat {
  text-align: center;
  padding: 20px 16px;
}
.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
}
.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}
.card-income .stat-value { color: var(--color-income); }
.card-expense .stat-value { color: var(--color-expense); }
.card-balance .stat-value { font-size: 1.75rem; }

/* Forms */
.form-group { margin-bottom: 12px; }
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--color-text);
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="time"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--color-surface);
  color: var(--color-text);
  -webkit-appearance: none;
  appearance: none;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(222,171,165,0.25);
}
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.form-inline .form-group { flex: 1; min-width: 120px; margin-bottom: 0; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none !important;
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
}
.btn:hover { background: #f9fafb; }
.btn-primary {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-danger {
  background: var(--color-danger);
  color: white;
  border-color: var(--color-danger);
}
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 6px 10px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Table */
.table-responsive {
  overflow-x: auto;
  margin-bottom: 16px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
th {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tfoot td { border-top: 2px solid var(--color-border); font-weight: 600; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-received { background: #fef3c7; color: #92400e; }
.badge-in_progress { background: #dbeafe; color: #1e40af; }
.badge-ready { background: #d1fae5; color: #065f46; }
.badge-delivered { background: #e0e7ff; color: #3730a3; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-paid { background: #f3e8ff; color: #6b21a8; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #f3f4f6; color: #6b7280; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-lg { padding: 6px 14px; font-size: 0.875rem; }

/* List */
.list { margin-bottom: 16px; }
.list-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 8px;
  text-decoration: none !important;
  color: var(--color-text);
  transition: transform 0.1s;
}
.list-item:active { transform: scale(0.99); }
.list-item-main { flex: 1; min-width: 0; }
.list-item-main strong { display: block; }
.list-item-main .text-muted { font-size: 0.8rem; }
.list-item-arrow { font-size: 1.25rem; color: var(--color-text-muted); margin-left: 8px; }
.list-item-actions { display: flex; align-items: center; gap: 8px; }

/* Search */
.search-bar { margin-bottom: 16px; }
.search-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.search-form input[type="text"] { flex: 1; min-width: 150px; }
.checkbox-label { display: flex; align-items: center; gap: 4px; font-size: 0.875rem; cursor: pointer; }

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.page-actions { display: flex; gap: 8px; align-items: center; }
.actions-bar {
  display: flex;
  gap: 8px;
  margin-top: 24px;
  flex-wrap: wrap;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #DEABA5, #f0cdc9);
}
.login-card {
  background: white;
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 360px;
  margin: 16px;
}
.login-card h1 { text-align: center; color: var(--color-primary); margin-bottom: 4px; }
.login-subtitle { text-align: center; color: var(--color-text-muted); font-size: 0.875rem; margin-bottom: 24px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-btn {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: background 0.15s, color 0.15s;
}
.tab-btn:hover { background: var(--color-surface); color: var(--color-text); }
.tab-btn.active {
  background: var(--color-surface);
  color: var(--color-primary);
  border-bottom-color: var(--color-surface);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Utility */
.text-muted { color: var(--color-text-muted); }
.hidden { display: none; }
hr { border: none; border-top: 1px solid var(--color-border); margin: 24px 0; }

/* Typography */
h1 {
  font-size: 1.375rem;
  margin-bottom: 16px;
}
h2 {
  font-size: 1.125rem;
  margin-bottom: 12px;
  margin-top: 24px;
}
h3 {
  font-size: 1rem;
  margin-bottom: 12px;
}

/* Calendar */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.calendar-month-label {
  font-size: 1.125rem;
  font-weight: 600;
  text-transform: capitalize;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-header {
  background: var(--color-primary);
  color: #fff;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 4px;
}
.cal-day {
  background: var(--color-surface);
  min-height: 100px;
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.cal-day--empty {
  background: #f9fafb;
  min-height: 0;
}
.cal-day--today .cal-day-number {
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-day-number {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--color-text);
}
.cal-day-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.cal-item {
  font-size: 0.7rem;
  padding: 3px 5px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}
.cal-item--reminder { background: #dbeafe; color: #1e40af; }
.cal-item--deadline { background: #fef3c7; color: #92400e; }
.cal-item--appointment { background: #d1fae5; color: #065f46; }
.cal-item--other { background: #f3f4f6; color: #6b7280; }
.cal-item--order {
  background: #f3e8ff;
  color: #6b21a8;
  text-decoration: none;
  cursor: pointer;
}
.cal-item--order:hover {
  background: #e9d5ff;
}

@media (max-width: 600px) {
  .cal-day { min-height: 70px; padding: 3px; }
  .cal-day-number { font-size: 0.75rem; width: 22px; height: 22px; }
  .cal-item { font-size: 0.6rem; padding: 2px 3px; }
  .cal-header { font-size: 0.7rem; padding: 4px 2px; }
}
