:root {
  color-scheme: light;
  --canvas: #f5f6f0;
  --surface: #fff;
  --ink: #172c25;
  --muted: #52665c;
  --line: #dce5dc;
  --green: #19392e;
  --accent: #cbe996;
  font-family: Inter, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.05rem); line-height: 1.1; letter-spacing: -.055em; }
h2 { font-size: 1.1rem; letter-spacing: -.025em; }
p, small { color: var(--muted); }
p { line-height: 1.55; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 3px solid #609240; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.initial, noscript { display: block; margin: 2rem; }

.brand { display: flex; align-items: center; gap: .75rem; color: #f9fff4; font-weight: 700; letter-spacing: -.025em; }
.brand-icon { display: grid; align-content: center; gap: 3px; width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: var(--accent); }
.brand-icon i { display: block; height: 2px; width: 100%; border-radius: 2px; background: var(--green); }
.brand-icon i:last-child { width: 60%; }
.gate { display: grid; grid-template-columns: minmax(280px, .9fr) 1.1fr; min-height: 100vh; }
.gate-aside { display: flex; flex-direction: column; justify-content: space-between; padding: clamp(1.75rem, 5vw, 4.75rem); background: var(--green); }
.gate-intro p { margin-top: 1.65rem; color: #f8fff4; font-size: clamp(2rem, 4.3vw, 4.25rem); line-height: 1.02; letter-spacing: -.06em; font-weight: 650; }
.gate-foot { color: #c8dacd; font-size: .85rem; }
.gate-foot span { margin: 0 .28rem; color: var(--accent); }
.gate-illustration { width: 120px; height: 76px; position: relative; }
.gate-illustration i { position: absolute; width: 62px; height: 70px; border: 1px solid #afce9a; border-radius: 13px; background: #244a3b; transform: rotate(-12deg); }
.gate-illustration i:nth-child(2) { left: 24px; transform: rotate(0); background: #3a604b; }
.gate-illustration i:nth-child(3) { left: 49px; transform: rotate(12deg); background: var(--accent); border-color: var(--accent); }
.gate-illustration i:nth-child(3)::before { content: ''; position: absolute; left: 14px; top: 17px; width: 31px; height: 4px; border-radius: 3px; background: #406344; box-shadow: 0 11px #6d8d5c, 0 22px #6d8d5c; }
.gate-main { display: grid; place-items: center; padding: 2.5rem 1.5rem; }
.gate-content { width: min(100%, 410px); }
.gate-content > p { margin: .85rem 0 1.7rem; overflow-wrap: anywhere; }
.gate-content form { display: grid; gap: .65rem; }
.gate-content form .button { width: 100%; display: flex; justify-content: space-between; margin-top: .4rem; }
.gate-content > .gate-help { font-size: .875rem; margin: .85rem 0 0; }
.gate-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .7rem; }
.code { letter-spacing: .3em; font-variant-numeric: tabular-nums; }

.layout { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { min-height: 100vh; height: fit-content; position: sticky; top: 0; display: flex; flex-direction: column; padding: 1.65rem 1.1rem; background: var(--green); color: #f5fff1; }
.sidebar .brand { margin: .2rem .4rem 2.4rem; }
.sidebar nav { display: grid; gap: .4rem; }
.sidebar a, .sign-out { display: flex; align-items: center; gap: .65rem; border-radius: 9px; padding: .7rem .8rem; color: #e8f2e8; text-decoration: none; font-size: .9rem; font-weight: 600; }
.sidebar a span { min-width: 1.1rem; text-align: center; font-size: 1rem; }
.sidebar a:hover, .sign-out:hover { background: #2d4d3f; }
.sidebar a[aria-current] { background: #375746; color: #e5fac5; }
.identity { display: grid; grid-template-columns: 33px minmax(0, 1fr); gap: .6rem; align-items: center; margin-top: auto; padding: 2.2rem .5rem .55rem; }
.identity small, .identity strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity strong { font-size: .85rem; }
.identity small { color: #c5d8c9; font-size: .75rem; margin-top: .13rem; }
.avatar { display: grid; place-items: center; width: 33px; height: 33px; border-radius: 50%; background: #cbe996; color: var(--green); font-weight: 750; }
.sign-out { border: none; background: transparent; text-align: left; }
.sign-out span { margin-left: auto; }
.workspace { width: min(100%, 1260px); margin: 0 auto; padding: clamp(1.2rem, 4.4vw, 4rem); }
.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.55rem; }
.page-header p { margin-top: .4rem; }
.period-label { min-width: 180px; }
.loading { padding: .75rem 0; }

.totals { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: .9rem; margin-bottom: 1.25rem; }
.hero { display: grid; align-content: center; gap: .45rem; min-height: 180px; padding: clamp(1.2rem, 3vw, 2rem); border-radius: 20px; background: var(--green); color: #f4fff2; position: relative; isolation: isolate; overflow: hidden; }
.hero::after { content: ''; z-index: -1; position: absolute; right: -105px; bottom: -110px; width: 250px; height: 250px; border-radius: 50%; border: 1px solid #547655; box-shadow: 0 0 0 17px #19392e, 0 0 0 18px #547655, 0 0 0 35px #19392e, 0 0 0 36px #547655; }
.hero > span, .total-tile > span { font-size: .87rem; font-weight: 650; }
.hero strong { color: var(--accent); font-size: clamp(2.05rem, 5vw, 4.2rem); letter-spacing: -.065em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero small { color: #d2e2d3; }
.totals-side { display: grid; gap: .65rem; }
.total-tile { display: grid; align-content: center; gap: .2rem; border: 1px solid var(--line); border-radius: 15px; padding: .8rem 1rem; background: var(--surface); }
.total-tile span { color: var(--muted); }
.total-tile strong { font-size: clamp(1.2rem, 3vw, 1.65rem); letter-spacing: -.035em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.panel { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.bill-panel, .charging, .empty, .form-panel, .select-panel, .member-panel { padding: clamp(1rem, 2.5vw, 1.55rem); }
.bill-panel h2 { padding-bottom: .75rem; }
.bill-row { display: grid; grid-template-columns: minmax(0, 1.3fr) repeat(2, minmax(0, 1fr)); gap: .7rem; align-items: center; min-height: 66px; border-top: 1px solid var(--line); padding: .65rem 0; }
.bill-row.show-main { grid-template-columns: minmax(0, 1.3fr) repeat(3, minmax(0, 1fr)); }
.bill-title { display: flex; align-items: center; gap: .65rem; }
.bill-icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; font-size: 1.3rem; font-weight: 750; }
.hydro { background: #e4efcb; color: #3f5a27; }
.gas { background: #faead9; color: #8b4719; }
.water { background: #deeff6; color: #23566d; }
.internet { background: #ece6f5; color: #613e83; }
.bill-title small, .bill-number small, .member-row small, .preview-grid small { display: block; margin: .18rem 0; font-size: .75rem; }
.bill-number { text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.awaiting { grid-column: 2 / -1; justify-self: end; color: var(--muted); background: var(--canvas); border-radius: 6px; padding: .32rem .55rem; font-size: .75rem; }
.charging { display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: center; margin-top: .85rem; }
.charging p, .form-panel p, .select-panel p, .member-panel p { margin-top: .32rem; font-size: .875rem; }
.charging > strong { font-size: 1.2rem; }
.empty p { margin: .4rem 0; }
.empty button { margin-top: .6rem; }

.button { border-radius: 9px; border: 1px solid transparent; padding: .68rem .95rem; min-height: 42px; font-size: .9rem; font-weight: 700; }
.primary { background: var(--green); color: #f6fff4; }
.primary:hover { background: #2a5140; }
.secondary { background: #f3f7ec; border-color: #d4e1d1; color: var(--green); }
.secondary:hover { background: #e6efda; }
.text-button { padding: .55rem .05rem; border: 0; background: transparent; color: #2d5c43; font-size: .875rem; font-weight: 650; }
.text-button:hover { text-decoration: underline; }
label { display: grid; gap: .37rem; font-size: .83rem; font-weight: 650; }
input, select { width: 100%; min-width: 0; min-height: 42px; border: 1px solid #becdc0; border-radius: 9px; padding: .58rem .72rem; color: var(--ink); background: #fbfdf9; }
input::placeholder { color: #66786b; }
.message { font-size: .875rem; color: #9a3022; overflow-wrap: anywhere; }
.message:empty { display: none; }
.workspace > .message { margin: 0 0 .8rem; }
.message.success { color: #285a37; }
.tabs { display: flex; gap: .4rem; margin-bottom: 1rem; border-bottom: 1px solid #cbd8cc; }
.tabs button { border: 0; border-bottom: 3px solid transparent; background: none; padding: .6rem .85rem; color: var(--muted); font-weight: 650; }
.tabs button[aria-pressed='true'] { color: var(--green); border-bottom-color: #487d49; }
.select-panel { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .9rem; margin-bottom: .8rem; }
.selects { display: flex; flex-wrap: wrap; gap: .6rem; }
.editor { display: grid; gap: .8rem; }
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-top: .85rem; }
.editor-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; }
.preview-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .7rem; margin-top: .7rem; }
.preview-grid strong { display: block; overflow-wrap: anywhere; }
.member-panel > p { margin-bottom: .7rem; }
.member-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(130px, 180px) auto; gap: .7rem; align-items: center; border-top: 1px solid var(--line); padding: .75rem 0; }
.member-row strong { overflow-wrap: anywhere; }
.member-empty { padding: .65rem 0; border-top: 1px solid var(--line); }

@media (max-width: 760px) {
  .gate { grid-template-columns: 1fr; min-height: 0; }
  .gate-aside { padding: 1rem 1.3rem; }
  .gate-intro, .gate-foot { display: none; }
  .gate-main { padding-top: 3.75rem; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; min-height: 0; display: grid; grid-template-columns: 1fr auto; gap: .6rem; padding: .85rem 1rem; }
  .sidebar .brand { margin: 0; }
  .sidebar nav { grid-row: 2; grid-column: 1 / -1; display: flex; flex-wrap: wrap; }
  .sidebar a { padding: .48rem .62rem; }
  .identity { display: none; }
  .sign-out { grid-column: 2; grid-row: 1; padding: .5rem; }
}

@media (max-width: 500px) {
  .totals { grid-template-columns: minmax(0, 1fr); }
  .hero { min-height: 140px; }
  .totals-side { grid-auto-flow: column; grid-auto-columns: 1fr; }
  .bill-row, .bill-row.show-main { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bill-title { grid-column: 1 / -1; }
  .bill-number { text-align: left; font-size: .875rem; }
  .awaiting { grid-column: 1 / -1; justify-self: start; }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .member-row { grid-template-columns: minmax(0, 1fr) auto; }
  .member-row > div { grid-column: 1 / -1; }
}
