:root {
  --green-900: #082d32;
  --green-700: #0b706c;
  --green-600: #119187;
  --green-100: #ddf6f1;
  --mint: #ecf9f6;
  --cream: #f4f7f6;
  --ink: #102d34;
  --muted: #647c82;
  --line: #e2ebea;
  --white: #fff;
  --accent: #ffb554;
  --shadow: 0 18px 48px rgba(8, 45, 50, 0.08), 0 2px 9px rgba(8, 45, 50, 0.04);
  --shadow-raised: 0 28px 60px rgba(6, 42, 48, 0.14);
  --radius: 26px;
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 28%, rgba(17, 145, 135, .07), transparent 28rem),
    linear-gradient(180deg, #f7faf9 0%, var(--cream) 44%, #f1f5f4 100%);
  color: var(--ink);
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hero {
  background:
    radial-gradient(circle at 88% -10%, rgba(91, 224, 204, .3), transparent 30rem),
    radial-gradient(circle at 54% 100%, rgba(5, 47, 52, .42), transparent 38rem),
    linear-gradient(125deg, #062f36 0%, #095e60 48%, #08786f 100%);
  border-radius: 0 0 48px 48px;
  color: var(--white);
  min-height: 392px;
  padding: 27px max(24px, calc((100vw - 1200px) / 2));
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  width: 460px;
  height: 460px;
  border: 1px solid rgba(135, 239, 221, .14);
  border-radius: 50%;
  position: absolute;
  right: -130px;
  top: -40px;
  box-shadow: inset 0 0 0 52px rgba(110, 232, 213, .035);
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 52px;
  position: relative;
  z-index: 1;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.brand-icon {
  align-items: center;
  background: linear-gradient(145deg, #e6fff8, #b3ebe0);
  border-radius: 15px;
  color: var(--green-700);
  display: flex;
  font-size: 26px;
  font-weight: bold;
  height: 48px;
  justify-content: center;
  width: 48px;
}

.brand strong {
  display: block;
  font-size: 19px;
}

.brand p {
  font-size: 12px;
  margin: 1px 0 0;
  opacity: .84;
}

.ghost-button {
  background: rgba(255, 255, 255, .1);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 14px;
  color: var(--white);
  padding: 12px 18px;
  transition: background .2s ease, transform .2s ease;
}

.ghost-button:hover {
  background: rgba(255, 255, 255, .18);
  transform: translateY(-1px);
}

.user-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.owner-badge {
  background: rgba(255, 255, 255, .09);
  border-radius: 24px;
  color: rgba(255, 255, 255, .86);
  font-size: 13px;
  margin-right: 4px;
  padding: 10px 15px;
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.eyebrow {
  color: #8fe2d6;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  margin: 0 0 10px;
}

h1 {
  font-size: clamp(34px, 4.4vw, 48px);
  letter-spacing: -.04em;
  line-height: 1.15;
  margin: 0 0 13px;
}

.subtitle {
  color: rgba(255, 255, 255, .75);
  font-size: 16px;
  line-height: 1.65;
  margin: 0;
  max-width: 455px;
}

.hero-tags {
  display: flex;
  gap: 9px;
  margin-top: 27px;
}

.hero-tags span {
  background: rgba(176, 247, 233, .1);
  border: 1px solid rgba(176, 247, 233, .2);
  border-radius: 30px;
  color: #d3f8f1;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
}

.layout {
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(360px, 1.25fr) minmax(300px, .87fr);
  margin: -54px auto 48px;
  max-width: 1200px;
  padding: 0 24px;
  position: relative;
  z-index: 2;
}

.auth-layout {
  margin: -54px auto 38px;
  max-width: 450px;
  padding: 0 22px;
  position: relative;
  z-index: 2;
}

.auth-card h2 {
  margin-bottom: 8px;
}

.setup-hero {
  min-height: 280px;
}

.setup-copy {
  margin-top: 44px;
}

.setup-layout {
  margin-top: -32px;
}

.setup-warning {
  line-height: 1.6;
  margin-bottom: 22px;
}

.auth-help,
.config-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.config-note {
  font-size: 12px;
  margin: 18px 0 0;
}

.primary-link {
  background: linear-gradient(135deg, var(--green-700), var(--green-600));
  border-radius: 15px;
  color: var(--white);
  display: block;
  font-weight: 700;
  margin-top: 22px;
  padding: 15px;
  text-align: center;
  text-decoration: none;
}

.notice {
  background: #092f36;
  border-radius: 15px;
  box-shadow: var(--shadow);
  color: var(--white);
  left: 50%;
  max-width: calc(100vw - 32px);
  padding: 13px 18px;
  position: fixed;
  top: 18px;
  transform: translateX(-50%);
  z-index: 10;
}

.notice.error {
  background: #a94434;
}

.card {
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(226, 235, 234, .8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 29px 31px;
}

.editor-card {
  grid-row: span 2;
}

.section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 22px;
}

.step {
  color: var(--green-600);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  margin: 0 0 4px;
}

h2 {
  font-size: 23px;
  margin: 0;
}

h3 {
  font-size: 17px;
  margin: 29px 0 16px;
}

.text-button {
  background: var(--mint);
  border: 1px solid #d4eee8;
  border-radius: 22px;
  color: var(--green-600);
  font-size: 14px;
  font-weight: 700;
  padding: 9px 14px;
}

.grid {
  display: grid;
  gap: 15px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  color: #324e4d;
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 15px;
}

input {
  background: #f7faf9;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  display: block;
  margin-top: 8px;
  padding: 13px 14px;
  width: 100%;
}

input:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(23, 128, 116, .12);
  outline: 0;
}

.with-unit {
  align-items: center;
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  margin-top: 8px;
  padding-right: 13px;
}

.with-unit input {
  background: transparent;
  border: 0;
  box-shadow: none;
  margin: 0;
}

.with-unit span {
  color: var(--muted);
  font-weight: 500;
}

.inline-warning {
  color: #bd4a37;
  font-size: 13px;
  margin: -5px 0 15px;
}

.upload-box {
  align-items: center;
  background: linear-gradient(135deg, #f0fcf9, #e8f6f3);
  border: 1px dashed #7dcdc0;
  border-radius: 18px;
  color: var(--green-700);
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  margin-top: 3px;
  min-height: 104px;
  overflow: hidden;
  padding: 16px;
  text-align: center;
}

.upload-box input {
  display: none;
}

.upload-title {
  font-size: 14px;
  font-weight: 700;
}

.upload-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: normal;
}

#photoPreview {
  border-radius: 10px;
  margin-top: 9px;
  max-height: 140px;
  max-width: 100%;
}

.primary-button {
  background: linear-gradient(135deg, #0a665f, #0e9587);
  border: 0;
  border-radius: 15px;
  color: var(--white);
  font-size: 16px;
  font-weight: 700;
  margin-top: 19px;
  padding: 16px;
  box-shadow: 0 10px 22px rgba(11, 112, 108, .2);
  transition: transform .2s ease, box-shadow .2s ease;
  width: 100%;
}

.primary-button:hover {
  background: linear-gradient(135deg, #075750, #0d887d);
  box-shadow: 0 13px 27px rgba(11, 112, 108, .27);
  transform: translateY(-1px);
}

.invoice-card {
  background: var(--white);
  box-shadow: var(--shadow-raised);
  padding: 27px;
}

.invoice-header {
  align-items: start;
  display: flex;
  justify-content: space-between;
  margin-bottom: 17px;
}

.pill,
.count-pill {
  background: var(--green-100);
  border: 1px solid #ceeee8;
  border-radius: 24px;
  color: var(--green-700);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
}

.total-box {
  background:
    radial-gradient(circle at 100% 0, rgba(149, 245, 224, .26), transparent 130px),
    linear-gradient(135deg, #062f36 0%, #087267 100%);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 12px;
  padding: 21px 22px;
}

.total-box span,
.total-box small {
  color: rgba(225, 255, 249, .74);
  font-size: 13px;
}

.total-box strong {
  color: var(--white);
  font-size: 36px;
  line-height: 1.25;
}

.invoice-details {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}

.line {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 17px 19px;
}

.line:first-child {
  border-top: 0;
}

.line small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 3px;
}

.meter-reading {
  background: #f3faf8;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 32px;
  padding: 10px 18px;
}

.meter-reading strong {
  color: var(--ink);
  margin-left: 7px;
}

.saved-photo {
  border-top: 1px solid var(--line);
  margin: 18px 0 0;
  padding-top: 14px;
}

.saved-photo figcaption {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.saved-photo img {
  border-radius: 16px;
  display: block;
  max-height: 190px;
  object-fit: cover;
  width: 100%;
}

.tenant-line {
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
  margin: 18px 0 0;
  padding-top: 15px;
}

.tenant-line span {
  color: var(--ink);
}

.share-panel {
  background: #f7fbfa;
  border: 1px solid var(--line);
  border-radius: 17px;
  margin-top: 16px;
  padding: 2px 16px 16px;
}

.share-panel h3 {
  margin-bottom: 6px;
}

.share-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 0 0 13px;
}

.secondary-button {
  background: var(--white);
  border: 1px solid #aed9d0;
  border-radius: 13px;
  color: var(--green-700);
  font-size: 14px;
  font-weight: 700;
  padding: 11px 14px;
  width: 100%;
}

.share-result input {
  font-size: 12px;
  margin: 12px 0 10px;
}

.share-actions {
  align-items: center;
  display: flex;
  gap: 12px;
}

.share-actions .secondary-button {
  flex: 1;
  width: auto;
}

.text-link,
.danger-link {
  background: transparent;
  border: 0;
  color: var(--green-700);
  font-size: 13px;
  font-weight: 700;
  padding: 0;
  text-decoration: none;
}

.danger-link {
  color: #ae4d3e;
}

.revoke-link {
  display: block;
  margin: 14px auto 0;
}

.history-card {
  min-height: 174px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  color: var(--muted);
  font-size: 14px;
  margin: 10px 0 0;
}

.history-item {
  align-items: stretch;
  background: #f8fbfa;
  border: 1px solid #e5efed;
  border-radius: 16px;
  display: flex;
  overflow: hidden;
}

.history-open {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--ink);
  display: grid;
  flex: 1;
  gap: 3px;
  grid-template-columns: 1fr auto;
  padding: 14px 16px;
  text-align: left;
}

.history-month {
  font-weight: 700;
}

.history-usage {
  color: var(--muted);
  grid-row: 2;
}

.history-total {
  color: var(--green-700);
  grid-row: span 2;
}

.delete-button {
  background: #fdf7f6;
  border: 0;
  border-left: 1px solid #f2dad6;
  color: #ae4d3e;
  font-size: 13px;
  padding: 0 13px;
}

.usage-card {
  grid-column: 1 / -1;
}

.usage-heading {
  margin-bottom: 16px;
}

.metric-switch {
  background: #ecf4f2;
  border-radius: 16px;
  display: flex;
  gap: 5px;
  margin-bottom: 22px;
  max-width: 390px;
  padding: 5px;
}

.metric-button {
  background: transparent;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  padding: 11px 14px;
}

.metric-button.active {
  background: var(--white);
  box-shadow: 0 5px 15px rgba(12, 58, 55, .1);
  color: var(--green-700);
}

.usage-chart {
  align-items: end;
  background:
    linear-gradient(180deg, rgba(236, 249, 246, .62), rgba(255, 255, 255, .65)),
    repeating-linear-gradient(180deg, transparent, transparent 39px, #edf4f2 40px);
  border: 1px solid var(--line);
  border-radius: 20px;
  display: flex;
  gap: clamp(8px, 2vw, 18px);
  justify-content: center;
  min-height: 242px;
  overflow-x: auto;
  padding: 18px 17px 14px;
}

.usage-chart .empty-state {
  align-self: center;
  margin: auto;
}

.chart-column {
  align-items: center;
  display: flex;
  flex: 0 0 min(72px, calc((100vw - 90px) / 6));
  flex-direction: column;
  gap: 8px;
  height: 204px;
  justify-content: end;
  min-width: 48px;
}

.chart-amount {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.chart-track {
  align-items: end;
  background: rgba(220, 243, 238, .68);
  border-radius: 11px 11px 5px 5px;
  display: flex;
  flex: 1;
  justify-content: center;
  min-height: 95px;
  overflow: hidden;
  width: 100%;
}

.chart-bar {
  background: linear-gradient(180deg, #21b4a4, #087067);
  border-radius: 11px 11px 0 0;
  transition: height .22s ease;
  width: 100%;
}

.chart-month {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.usage-table-wrap {
  border: 1px solid var(--line);
  border-radius: 18px;
  margin-top: 18px;
  overflow-x: auto;
}

.usage-table {
  border-collapse: collapse;
  font-size: 14px;
  min-width: 570px;
  width: 100%;
}

.usage-table th {
  background: #f3f8f7;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

.usage-table th,
.usage-table td {
  border-bottom: 1px solid var(--line);
  padding: 14px 17px;
}

.usage-table tbody tr:last-child td {
  border-bottom: 0;
}

.usage-table th:nth-child(n+2),
.usage-table td:nth-child(n+2) {
  text-align: right;
}

.usage-table .higher {
  color: #bd4a37;
  font-weight: 700;
}

.usage-table .lower {
  color: var(--green-600);
  font-weight: 700;
}

.empty-cell {
  color: var(--muted);
  text-align: center !important;
}

.public-page {
  min-height: 100vh;
}

.public-header {
  align-items: center;
  background:
    radial-gradient(circle at 82% 0, rgba(109, 229, 212, .2), transparent 170px),
    linear-gradient(125deg, #062f36, #08766d);
  color: var(--white);
  display: flex;
  justify-content: space-between;
  padding: 22px max(20px, calc((100vw - 540px) / 2));
}

.public-layout {
  margin: 30px auto;
  max-width: 540px;
  padding: 0 15px;
}

.public-invoice {
  padding: 27px;
}

.public-history {
  margin-top: 18px;
  padding: 24px;
}

.public-status {
  background: rgba(215, 255, 247, .13);
  border: 1px solid rgba(215, 255, 247, .18);
  border-radius: 30px;
  color: rgba(232, 255, 250, .86);
  font-size: 11px;
  font-weight: 600;
  margin: 0;
  padding: 9px 12px;
}

.chart-label {
  color: var(--green-700);
  font-size: 14px;
  font-weight: 700;
  margin: 4px 0 12px;
}

.public-chart {
  justify-content: flex-start;
  min-height: 214px;
}

.public-chart .chart-column {
  flex-basis: 55px;
  height: 178px;
}

.public-table {
  font-size: 13px;
  min-width: 435px;
}

.public-table th,
.public-table td {
  padding: 12px 10px;
}

.public-error {
  text-align: center;
}

.public-error p {
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 850px) {
  .layout {
    display: flex;
    flex-direction: column;
  }

  .invoice-card {
    order: -1;
  }

  .grid.three {
    grid-template-columns: 1fr;
  }

  .usage-card {
    order: 3;
  }
}

@media (max-width: 560px) {
  .hero {
    border-radius: 0 0 34px 34px;
    min-height: 382px;
    padding-left: 18px;
    padding-right: 18px;
  }

  .layout {
    margin-top: -43px;
    padding: 0 13px;
  }

  .card {
    border-radius: 22px;
    padding: 22px 19px;
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  .user-actions {
    align-items: flex-end;
    flex-direction: column;
  }

  .owner-badge {
    display: none;
  }

  .hero-tags {
    flex-wrap: wrap;
    margin-top: 21px;
  }

  .public-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .usage-chart {
    justify-content: flex-start;
  }

  .metric-switch {
    max-width: none;
  }
}

@media print {
  @page {
    margin: 18mm;
  }

  body {
    background: var(--white);
  }

  .hero,
  .print-hidden {
    display: none !important;
  }

  .layout {
    display: block;
    margin: 0;
    max-width: none;
    padding: 0;
  }

  .invoice-card {
    border: 0;
    box-shadow: none;
    margin: 0 auto;
    max-width: 520px;
  }
}
