:root {
  --saffron: #c45b21;
  --saffron-deep: #8d2f1f;
  --maroon: #641c24;
  --maroon-dark: #43151d;
  --turmeric: #e5a835;
  --sand: #fbf4e7;
  --paper: #fffdf8;
  --ink: #30241f;
  --muted: #76675f;
  --line: #e8d9c7;
  --green: #2f7049;
  --shadow: 0 12px 32px rgba(83, 42, 22, .08);
}

html { background: var(--sand); color: var(--ink); font-family: "Noto Sans Kannada", "Noto Sans", Inter, system-ui, sans-serif; }
body { background: radial-gradient(circle at 8% 0%, rgba(229,168,53,.14), transparent 28rem), linear-gradient(180deg, #fffaf0 0%, var(--sand) 45%, #f8ecda 100%); margin: 0; min-width: 320px; }
* { box-sizing: border-box; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
h1, h2, h3 { color: var(--maroon-dark); font-family: Georgia, "Noto Serif Kannada", serif; letter-spacing: -.015em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.45rem); line-height: 1.12; margin: 0; }
h2 { font-size: 1.15rem; }
p { line-height: 1.55; }
.loading { align-items: center; color: var(--maroon); display: grid; font-family: Georgia, serif; min-height: 100vh; place-items: center; }

main { min-height: calc(100vh - 9rem); }
.page-heading, .card, .filter-card, .chart-card, .auth-card { animation: rise-in .28s ease-out both; }
@keyframes rise-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card, .filter-card, .chart-card { background: rgba(255,253,248,.94); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); }
.card, .chart-card { margin-bottom: 1rem; padding: clamp(1rem, 2.4vw, 1.4rem); }
.sf-card.e-card { background: rgba(255,253,248,.94); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); color: var(--ink); margin-bottom: 1rem; }
.sf-card.e-card .e-card-content { padding: clamp(1rem, 2.4vw, 1.4rem); }
.sf-card.e-card h2 { color: var(--maroon-dark); font-family: Georgia, "Noto Serif Kannada", serif; margin-top: 0; }
.table-card.e-card { overflow-x: auto; }
.card h2, .chart-card h2 { margin: 0 0 .4rem; }
.section-title { align-items: center; display: flex; justify-content: space-between; margin-bottom: 1rem; }
.section-title h2 { margin-bottom: 0; }
.count-badge { background: #fff0c8; border: 1px solid #eed28f; border-radius: 999px; color: var(--maroon); font-weight: 800; padding: .35rem .7rem; }
.temple-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); }
.temple-tile { background: #fffaf1; border: 1px solid var(--line); border-radius: .8rem; color: inherit; padding: 1rem; text-align: left; width: 100%; }
.temple-tile:hover { border-color: #c89554; box-shadow: 0 5px 16px rgba(83,42,22,.09); transform: translateY(-1px); }
.temple-tile-head { align-items: flex-start; display: flex; gap: .65rem; }
.temple-swatch { border: 2px solid rgba(255,255,255,.8); border-radius: 50%; box-shadow: 0 0 0 1px var(--line); flex: 0 0 1.15rem; height: 1.15rem; margin-top: .18rem; }
.temple-tile-head strong, .temple-tile-head small { display: block; }
.temple-tile-head strong { color: var(--maroon-dark); font-family: Georgia, serif; }
.temple-tile-head small { color: var(--muted); margin-top: .18rem; }
.status-pill { border-radius: 999px; font-size: .68rem; font-weight: 800; margin-left: auto; padding: .28rem .5rem; }
.status-pill.active { background: #eaf6ed; color: #245e36; }
.status-pill.inactive { background: #fff0ef; color: #982d2b; }
.temple-meta { border-top: 1px solid var(--line); display: grid; gap: .35rem; grid-template-columns: 1fr 1fr; margin-top: .8rem; padding-top: .7rem; }
.temple-meta span { color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.temple-meta b { color: var(--maroon); display: block; font-size: .65rem; letter-spacing: .06em; text-transform: uppercase; }
.empty-state { background: #fffaf1; border: 1px dashed #d9c3a8; border-radius: .7rem; color: var(--muted); padding: 1.25rem; text-align: center; }
.edit-hint { color: var(--saffron-deep); display: block; font-size: .72rem; font-weight: 750; margin-top: .7rem; }
.checkbox-field { align-items: center; display: flex; gap: .5rem; }
.card p, .chart-card p, .page-copy { color: var(--muted); }
.page-heading { align-items: flex-start; display: flex; gap: 1rem; justify-content: space-between; margin: .2rem 0 1.25rem; }
.page-heading p { color: var(--muted); margin: .35rem 0 0; max-width: 42rem; }
.eyebrow { color: var(--saffron-deep) !important; font-size: .72rem; font-weight: 800; letter-spacing: .13em; margin: 0 0 .3rem !important; text-transform: uppercase; }
.today { background: #fff0c8; border: 1px solid #eed28f; border-radius: 999px; color: #795119; font-size: .78rem; font-weight: 700; padding: .48rem .75rem; white-space: nowrap; }

label { color: #5b4438; display: grid; font-size: .8rem; font-weight: 750; gap: .35rem; }
input, select, textarea { background: #fffefa; border: 1px solid #d7c4b0; border-radius: .55rem; color: var(--ink); min-height: 2.75rem; outline: none; padding: .62rem .7rem; transition: border-color .15s, box-shadow .15s; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--saffron); box-shadow: 0 0 0 3px rgba(196,91,33,.14); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--saffron-deep); min-height: auto; width: auto; }
input[type="color"] { min-height: 2.75rem; padding: .25rem; }
.form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }

button.primary, a.primary, button.secondary, a.secondary { align-items: center; border-radius: .55rem; border: 1px solid transparent; display: inline-flex; font-weight: 750; justify-content: center; min-height: 2.75rem; padding: .62rem 1rem; text-decoration: none; transition: transform .15s, box-shadow .15s, background .15s; }
button.primary, a.primary { background: linear-gradient(135deg, var(--saffron-deep), var(--maroon)); box-shadow: 0 5px 14px rgba(100,28,36,.18); color: #fffaf1; }
button.secondary, a.secondary { background: #fff7e8; border-color: #e6cfa6; color: var(--maroon); }
button.primary:hover, a.primary:hover, button.secondary:hover, a.secondary:hover { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .55; transform: none !important; }
.plain-button { background: transparent; border: 1px solid rgba(255,245,221,.55); border-radius: .5rem; color: #fff8e9; min-height: 2.2rem; padding: .35rem .65rem; }

.hint { border-radius: .65rem; margin: 0 0 1rem; padding: .8rem 1rem; }
.success { background: #eaf6ed; border: 1px solid #bfe1c7; color: #245e36; }
.error { background: #fff0ef; border: 1px solid #efc0bb; color: #982d2b; }
.kpis { display: grid; gap: .85rem; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 1rem 0; }
.kpis article { background: var(--paper); border: 1px solid var(--line); border-radius: .9rem; box-shadow: 0 6px 18px rgba(83,42,22,.06); padding: 1rem; }
.kpis span { color: var(--muted); display: block; font-size: .75rem; font-weight: 700; }
.kpis strong { color: var(--maroon); display: block; font-family: Georgia, serif; font-size: 1.35rem; margin-top: .3rem; }
.filter-card { align-items: end; display: grid; gap: .8rem; grid-template-columns: 1fr 1fr auto; margin-bottom: 1rem; padding: 1rem; }
.search-row { align-items: end; display: grid; gap: .75rem; grid-template-columns: 1fr auto; }
.chart-card { overflow: hidden; }
table { border-collapse: collapse; min-width: 40rem; width: 100%; }
th { background: #fff4de; color: var(--maroon); font-size: .74rem; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
th, td { border-bottom: 1px solid #efdfcd; padding: .72rem .6rem; }
td { color: #4c3d35; font-size: .88rem; }
tbody tr:hover { background: #fffaf1; }
ul { color: var(--muted); line-height: 1.8; margin-bottom: 0; padding-left: 1.2rem; }

.auth-card { background: rgba(255,253,248,.96); border: 1px solid var(--line); border-radius: 1.2rem; box-shadow: var(--shadow); margin: clamp(2rem, 8vh, 5rem) auto; max-width: 31rem; padding: clamp(1.25rem, 4vw, 2rem); position: relative; }
.auth-card::before { color: var(--turmeric); content: "ॐ"; display: block; font-family: Georgia, serif; font-size: 2.4rem; line-height: 1; margin-bottom: .55rem; }
.auth-card form { display: grid; gap: 1rem; margin-top: 1.25rem; }
.auth-card form .primary { margin-top: .25rem; width: 100%; }
.auth-card .validation-message { color: #a42b2b; font-size: .8rem; font-weight: 650; margin-top: -.7rem; }
.chart-empty { align-items: center; background: linear-gradient(145deg, #fff8e9, #fffdf8); border: 1px dashed #d8b97e; border-radius: .9rem; color: var(--muted); display: flex; flex-direction: column; gap: .35rem; justify-content: center; min-height: 16rem; padding: 2rem; text-align: center; }
.chart-empty span { color: var(--turmeric); font-family: Georgia, serif; font-size: 2.5rem; }
.chart-empty strong { color: var(--maroon); font-family: Georgia, serif; }
.chart-empty small { max-width: 24rem; }
.seva-summary { margin-top: 1rem; min-width: 0; }
.bottom-nav { align-items: stretch; backdrop-filter: blur(12px); background: rgba(255,253,248,.98); border-top: 1px solid var(--line); bottom: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); left: 0; min-height: 4.35rem; padding: .2rem .3rem env(safe-area-inset-bottom); position: fixed; right: 0; z-index: 50; }
.bottom-nav a { align-items: center; border-radius: .65rem .65rem 0 0; color: #806b5d; display: flex; flex-direction: column; font-size: .7rem; gap: .22rem; justify-content: center; min-width: 0; padding: .42rem .18rem .5rem; text-align: center; text-decoration: none; }
.bottom-nav a span { color: #bb8a2a; font-size: 1.1rem; line-height: 1; }
.bottom-nav a.active { background: #fff0c8; color: var(--maroon); font-weight: 800; }
.bottom-nav a.active span { color: var(--saffron-deep); }

@media (max-width: 760px) {
  .form-grid, .filter-card, .kpis { grid-template-columns: 1fr 1fr; }
  .filter-card .primary { grid-column: 1 / -1; }
  .kpis article { padding: .8rem; }
  .kpis strong { font-size: 1.1rem; }
}
@media (max-width: 520px) {
  .form-grid, .filter-card, .search-row, .kpis { grid-template-columns: 1fr; }
  .page-heading { display: block; }
  .today { display: inline-block; margin-top: .7rem; }
  .kpis { gap: .6rem; }
  .kpis article { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
  .kpis strong { margin-top: 0; }
  table { min-width: 35rem; }
}

#blazor-error-ui { background: #fff3cd; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem; position: fixed; right: 0; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

 .temple-page-logo { background: #fff; border: 1px solid var(--line); border-radius: .7rem; flex: 0 0 4.6rem; height: 4.6rem; padding: .35rem; width: 4.6rem; }
 .receipt-logo { display: block; height: 5rem; margin: 0 auto .8rem; max-width: 12rem; object-fit: contain; object-position: center; width: 100%; }

@media print {
  @page { margin: 10mm; }
  html, body { background: #fff !important; }
  /* Remove the rest of the screen from pagination, including modal controls. */
  body:has(.print-receipt) *:not(.print-receipt):not(.print-receipt *):not(:has(.print-receipt)) { display: none !important; }
  /* Modal and app wrappers must neither repeat on pages nor reserve screen space. */
  body:has(.print-receipt), body *:has(.print-receipt) {
    display: block !important; position: static !important; inset: auto !important;
    height: auto !important; min-height: 0 !important; max-height: none !important;
    width: auto !important; min-width: 0 !important; max-width: none !important;
    margin: 0 !important; padding: 0 !important; overflow: visible !important;
    background: #fff !important; border: 0 !important; box-shadow: none !important;
    transform: none !important; animation: none !important;
  }
  .print-receipt {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
    border: 1px solid #d5a44d !important; box-shadow: inset 0 0 0 5px #fff5df, inset 0 0 0 6px #d5a44d !important;
    margin: 0 !important; position: static !important; width: auto !important;
    overflow: visible !important; break-inside: avoid;
  }
  .print-receipt tr { break-inside: avoid; }
  .print-receipt tfoot { display: table-row-group; }
  .print-receipt svg, .print-receipt .receipt-ornament { display: none !important; }
}

/* All logos retain their proportions and align within a predictable space. */
.temple-logo { display: block; object-fit: contain; object-position: center; width: 100%; height: 100%; }
.logo-picker { display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.logo-picker input[type="file"] { max-width: 100%; }
.logo-picker input::file-selector-button { background: var(--maroon); border: 0; border-radius: .4rem; color: white; cursor: pointer; margin-right: .6rem; padding: .6rem .8rem; }
.logo-picker small { color: var(--muted); }
.logo-picker button { align-self: flex-start; }
.logo-preview { align-items: center; background: white; border: 1px solid var(--line); border-radius: .7rem; display: flex; height: 8rem; justify-content: center; padding: .7rem; width: min(100%, 14rem); }
.temple-tile-logo { background: white; border-radius: .4rem; flex: 0 0 3rem; height: 3rem; padding: .2rem; width: 3rem; }
