:root {
  --soil:   #2C1A0E;
  --earth:  #5C3D1E;
  --clay:   #A0613A;
  --wheat:  #D4A853;
  --straw:  #F2D98B;
  --leaf:   #3D7A45;
  --mist:   #F7F3EC;
  --paper:  #FFFDF7;
  --ink:    #1A120B;
  --red:    #C0392B;
  --shadow: rgba(44,26,14,0.15);
  --green:  #3D7A45;
  --muted:  #A0613A;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--mist);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(212,168,83,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 100%, rgba(61,122,69,0.10) 0%, transparent 60%);
  pointer-events: none;
}

/* ── Login ── */
#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  position: relative; z-index: 1;
}

.login-card {
  background: var(--paper);
  border: 1.5px solid rgba(92,61,30,0.18);
  border-radius: 20px;
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px var(--shadow), 0 4px 16px rgba(0,0,0,0.06);
  animation: fadeUp 0.6s cubic-bezier(.23,1,.32,1) both;
}

.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .icon { font-size: 3rem; display: block; margin-bottom: 0.5rem; animation: sway 3s ease-in-out infinite; }
.login-logo h1 { font-family: 'Playfair Display', serif; font-size: 2.2rem; font-weight: 900; color: var(--soil); letter-spacing: -0.5px; }
.login-logo h1 span { color: var(--wheat); }
.login-logo p { font-size: 0.82rem; color: var(--clay); margin-top: 0.3rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 500; }
.login-divider { height: 1.5px; background: linear-gradient(to right, transparent, var(--straw), transparent); margin: 1.8rem 0; }

@keyframes sway { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }

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

label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--earth); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 0.45rem; }

input, select, textarea {
  width: 100%; padding: 0.75rem 1rem;
  border: 1.5px solid rgba(92,61,30,0.2);
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif; font-size: 0.95rem;
  background: var(--mist); color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--leaf); box-shadow: 0 0 0 3px rgba(61,122,69,0.12); background: white; }
textarea { resize: vertical; min-height: 80px; }

/* ── Buttons ── */
.btn { width: 100%; padding: 0.85rem 1.5rem; border: none; border-radius: 10px; font-family: 'DM Sans', sans-serif; font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-primary { background: linear-gradient(135deg, var(--leaf) 0%, #2d6334 100%); color: white; box-shadow: 0 4px 14px rgba(61,122,69,0.35); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(61,122,69,0.45); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--mist); color: var(--earth); border: 1.5px solid rgba(92,61,30,0.2); }
.btn-secondary:hover { background: var(--straw); }

.error-msg { background: #FEF2F2; border: 1px solid #FECACA; color: var(--red); padding: 0.7rem 1rem; border-radius: 8px; font-size: 0.88rem; margin-top: 1rem; display: none; }
.success-banner { background: #F0FDF4; border: 1.5px solid #86EFAC; color: #166534; padding: 1rem 1.2rem; border-radius: 10px; font-size: 0.9rem; font-weight: 500; margin-top: 1rem; display: none; align-items: center; gap: 0.5rem; }

/* ── Top bar ── */
#app-page { display: none; position: relative; z-index: 1; }
.top-bar { background: var(--soil); color: white; padding: 0.9rem 1.5rem; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 12px rgba(0,0,0,0.2); }
.top-bar-brand { font-family: 'Playfair Display', serif; font-size: 1.3rem; font-weight: 900; }
.top-bar-brand span { color: var(--wheat); }
.top-bar-right { display: flex; align-items: center; gap: 1rem; font-size: 0.88rem; }
.user-badge { background: rgba(212,168,83,0.2); border: 1px solid rgba(212,168,83,0.4); color: var(--straw); padding: 0.3rem 0.8rem; border-radius: 20px; font-size: 0.82rem; font-weight: 500; }
.logout-btn { background: none; border: 1px solid rgba(255,255,255,0.25); color: rgba(255,255,255,0.7); padding: 0.3rem 0.8rem; border-radius: 6px; font-family: 'DM Sans', sans-serif; font-size: 0.82rem; cursor: pointer; transition: all 0.2s; }
.logout-btn:hover { background: rgba(255,255,255,0.1); color: white; }

/* ── Tabs ── */
.tabs { display: flex; background: var(--paper); border-bottom: 1.5px solid rgba(92,61,30,0.12); padding: 0 1.5rem; }
.tab { padding: 0.9rem 1.4rem; font-size: 0.88rem; font-weight: 600; color: var(--clay); cursor: pointer; border-bottom: 2.5px solid transparent; transition: all 0.2s; margin-bottom: -1.5px; }
.tab:hover { color: var(--earth); }
.tab.active { color: var(--leaf); border-bottom-color: var(--leaf); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Form section ── */
.section { max-width: 720px; margin: 2rem auto; padding: 0 1.5rem; }
.section-title { font-family: 'Playfair Display', serif; font-size: 1.5rem; font-weight: 700; color: var(--soil); margin-bottom: 0.3rem; }
.section-sub { font-size: 0.85rem; color: var(--clay); margin-bottom: 1.8rem; }
.form-card { background: var(--paper); border: 1.5px solid rgba(92,61,30,0.12); border-radius: 16px; padding: 2rem; box-shadow: 0 4px 20px var(--shadow); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.form-group.full { grid-column: 1 / -1; }
.amount-wrap { position: relative; }
.amount-wrap::before { content: '₹'; position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%); color: var(--clay); font-weight: 600; }
.amount-wrap input { padding-left: 2rem; }
.submit-area { margin-top: 1.8rem; display: flex; gap: 1rem; align-items: center; }

/* ── Upload ── */
.upload-zone { border: 2px dashed rgba(92,61,30,0.25); border-radius: 10px; padding: 1.5rem; text-align: center; cursor: pointer; transition: all 0.2s; background: var(--mist); position: relative; }
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--leaf); background: rgba(61,122,69,0.05); }
.upload-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-icon { font-size: 1.8rem; display: block; margin-bottom: 0.4rem; }
.upload-text { font-size: 0.88rem; color: var(--clay); }
.upload-text strong { color: var(--leaf); }
.file-preview { margin-top: 0.8rem; padding: 0.6rem 1rem; background: rgba(61,122,69,0.08); border-radius: 8px; font-size: 0.85rem; color: var(--leaf); font-weight: 500; display: none; align-items: center; gap: 0.5rem; }

/* ── Records ── */
.records-section { max-width: 1100px; margin: 2rem auto; padding: 0 1.5rem; }
.records-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; flex-wrap: wrap; gap: 1rem; }
.refresh-btn { background: var(--paper); border: 1.5px solid rgba(92,61,30,0.2); color: var(--earth); padding: 0.5rem 1.2rem; border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.refresh-btn:hover { background: var(--straw); }

/* ── Filter bar ── */
.filter-bar { display: flex; gap: 10px; margin: 0 0 16px; flex-wrap: wrap; align-items: center; }
.filter-bar select { padding: 8px 14px; border: 1px solid rgba(92,61,30,0.2); border-radius: 8px; font-size: 0.9rem; background: var(--paper); cursor: pointer; color: var(--ink); }
.custom-range { display: none; gap: 8px; align-items: center; }
.custom-range.visible { display: flex; }
.custom-range input { width: auto; padding: 8px; font-size: 0.9rem; }
.filter-count { font-size: 0.85rem; color: var(--clay); }

/* ── Table ── */
.table-wrap { background: var(--paper); border: 1.5px solid rgba(92,61,30,0.12); border-radius: 14px; overflow: hidden; box-shadow: 0 4px 20px var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
thead { background: var(--soil); color: white; }
th { padding: 0.9rem 1rem; text-align: left; font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
td { padding: 0.85rem 1rem; border-bottom: 1px solid rgba(92,61,30,0.08); color: var(--ink); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(212,168,83,0.06); }
.category-badge { background: rgba(61,122,69,0.1); color: var(--leaf); padding: 0.25rem 0.7rem; border-radius: 20px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.amount-cell { font-weight: 700; color: var(--soil); font-size: 0.95rem; }
.no-data { text-align: center; padding: 3rem; color: var(--clay); }
.no-data-icon { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; }

/* ── Summary cards ── */
.summary-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.summary-card { background: var(--paper); border: 1.5px solid rgba(92,61,30,0.12); border-radius: 12px; padding: 1.2rem 1.4rem; box-shadow: 0 2px 10px var(--shadow); }
.summary-card .label { font-size: 0.75rem; color: var(--clay); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 0.4rem; }
.summary-card .value { font-family: 'Playfair Display', serif; font-size: 1.6rem; font-weight: 700; color: var(--soil); line-height: 1; }
.summary-card .value.green { color: var(--leaf); }
.summary-card .value small { font-family: 'DM Sans', sans-serif; font-size: 0.75rem; color: var(--clay); font-weight: 400; }

/* ── Animations ── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: auto; }
  .top-bar-brand { font-size: 1.1rem; }
  .records-section { padding: 0 0.8rem; }
  table { font-size: 0.78rem; }
  th, td { padding: 0.65rem 0.6rem; }
}
