:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #17211e;
  --muted: #66736f;
  --line: #dce2de;
  --teal: #116a67;
  --teal-2: #e2f3ef;
  --lime: #c9dd56;
  --amber: #996515;
  --amber-bg: #fff2d2;
  --red: #b42332;
  --red-bg: #ffe3e7;
  --violet: #6655a4;
  --violet-bg: #ece8ff;
  --gray-bg: #ecefed;
  --shadow: 0 18px 45px rgba(23, 33, 30, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

[hidden] {
  display: none !important;
}

body.cost-hidden .cost-sensitive {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 44px);
  background: #101613;
  color: #f7fbf8;
  border-bottom: 5px solid var(--lime);
}

.brand-block {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 16px;
}

.brand-visual {
  width: 92px;
  height: 58px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: #c9dd56;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 3vw, 2.45rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
  line-height: 1.25;
}

.header-actions,
.view-tools,
.row-actions,
.panel-heading,
.field-row {
  display: flex;
  align-items: center;
}

.header-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-button,
.login-link,
.data-button,
.donation-button,
.logout-button,
.primary-button,
.ghost-button {
  border: 0;
  min-height: 42px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.icon-button {
  width: 42px;
  color: inherit;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.icon-button:hover,
.login-link:hover,
.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.login-link {
  background: #f7fbf8;
  color: #111814;
  padding: 0 14px;
  font-weight: 800;
  white-space: nowrap;
}

.logout-button {
  background: rgba(255, 255, 255, 0.12);
  color: #f7fbf8;
  padding: 0 12px;
  font-weight: 900;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.data-button {
  background: var(--teal-2);
  color: #0f4f4c;
  padding: 0 12px;
  font-weight: 900;
  white-space: nowrap;
  border: 1px solid rgba(226, 243, 239, 0.72);
}

.donation-button {
  background: var(--lime);
  color: #17211e;
  padding: 0 14px;
  font-weight: 900;
  white-space: nowrap;
}

.header-actions input[type="file"] {
  display: none;
}

.app-shell,
.auth-shell,
.landing-shell {
  padding: clamp(18px, 4vw, 44px);
}

.app-shell {
  flex: 1;
}

.hosting-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #bcd7d1;
  border-left: 5px solid var(--teal);
  border-radius: 8px;
  background: var(--teal-2);
  color: #24413e;
  line-height: 1.4;
}

.hosting-notice strong {
  color: var(--teal);
  white-space: nowrap;
}

.landing-shell {
  flex: 1;
  display: grid;
  align-items: center;
}

.landing-hero {
  min-height: min(680px, calc(100vh - 174px));
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  display: grid;
  align-items: end;
  background: #101613;
  border: 1px solid rgba(17, 106, 103, 0.22);
  box-shadow: var(--shadow);
}

.landing-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.62;
}

.landing-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(16, 22, 19, 0.94), rgba(16, 22, 19, 0.7) 44%, rgba(16, 22, 19, 0.18));
}

.landing-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
  padding: clamp(24px, 5vw, 58px);
  color: #f7fbf8;
}

.landing-content h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.45rem);
  line-height: 1.02;
}

.landing-content p:not(.eyebrow) {
  max-width: 620px;
  margin: 18px 0 0;
  color: rgba(247, 251, 248, 0.86);
  font-size: 1.04rem;
  line-height: 1.55;
}

.landing-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.landing-actions .primary-button,
.landing-actions .ghost-button {
  width: auto;
  min-width: 150px;
}

.auth-shell {
  flex: 1;
  min-height: calc(100vh - 112px);
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-copy {
  color: var(--muted);
  margin: 8px 0 18px;
  line-height: 1.45;
}

.auth-error {
  min-height: 20px;
  color: var(--red);
  font-weight: 800;
  margin: 0;
}

.auth-switch {
  border: 0;
  background: transparent;
  color: var(--teal);
  cursor: pointer;
  font-weight: 900;
  padding: 4px 0;
  text-align: center;
}

.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid #cfd8d4;
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.consent-check input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
  flex: 0 0 auto;
}

.consent-check a {
  color: var(--teal);
  font-weight: 900;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.editor-panel,
.list-panel,
.admin-panel,
.renewal-panel,
.chart-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 118px;
  padding: 18px;
  display: grid;
  gap: 7px;
  align-content: center;
  border-top: 5px solid var(--teal);
}

.metric-card.warning {
  border-top-color: var(--amber);
}

.metric-card.danger {
  border-top-color: var(--red);
}

.metric-card.money {
  border-top-color: var(--violet);
}

.metric-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.metric-card strong {
  font-size: 2rem;
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
  line-height: 1.25;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.editor-panel,
.list-panel,
.admin-panel,
.renewal-panel,
.chart-panel {
  padding: 18px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.chart-panel canvas {
  width: 100%;
  height: 260px;
  display: block;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.legend-item {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f2f5f3;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.renewal-panel {
  margin-bottom: 18px;
}

.renewal-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.renewal-item {
  min-height: 94px;
  display: grid;
  gap: 5px;
  align-content: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.renewal-item strong,
.renewal-item span,
.renewal-item small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.renewal-item span,
.renewal-item small,
.renewal-empty {
  color: var(--muted);
}

.renewal-empty {
  font-weight: 800;
}

.admin-panel {
  margin-bottom: 18px;
}

.admin-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-toggle-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 900;
  cursor: pointer;
}

.admin-toggle-button .chevron-icon {
  transition: transform 160ms ease;
}

.admin-toggle-button[aria-expanded="true"] .chevron-icon {
  transform: rotate(180deg);
}

.admin-content {
  padding-top: 16px;
}

.admin-setting {
  display: flex;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--muted);
  line-height: 1.35;
}

.owner-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 340px);
  gap: 14px;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #cfc5ef;
  border-radius: 8px;
  background: var(--violet-bg);
  color: var(--muted);
}

.owner-panel strong {
  display: block;
  color: var(--violet);
  margin-bottom: 4px;
}

.owner-panel span {
  line-height: 1.35;
}

.admin-setting input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.admin-setting strong {
  display: block;
  color: var(--ink);
  margin-bottom: 3px;
}

.panel-copy {
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.35;
}

.role-pill,
.role-badge,
.product-badge,
.urgency-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--violet-bg);
  color: var(--violet);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.role-badge.user {
  background: var(--teal-2);
  color: var(--teal);
}

.role-badge.owner {
  background: var(--violet-bg);
  color: var(--violet);
}

.product-badge {
  background: #edf1f8;
  color: #31506f;
}

.urgency-badge {
  background: #edf1f8;
  color: #31506f;
}

.urgency-overdue {
  background: var(--red-bg);
  color: var(--red);
}

.urgency-soon {
  background: var(--amber-bg);
  color: var(--amber);
}

.urgency-future {
  background: #dff4e8;
  color: #0f5c35;
}

.billing-cycle {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.user-admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.user-form {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.user-list {
  overflow-x: auto;
}

.panel-heading {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.ghost-button {
  color: var(--teal);
  background: var(--teal-2);
  padding: 0 12px;
  font-weight: 800;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cad3cf;
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 84px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(17, 106, 103, 0.14);
}

.field-row {
  gap: 12px;
}

.field-row > label {
  flex: 1 1 0;
  min-width: 0;
}

.primary-button {
  width: 100%;
  background: var(--teal);
  color: #fff;
  padding: 0 16px;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(17, 106, 103, 0.18);
}

.list-heading {
  align-items: flex-start;
}

.view-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(360px, 100%);
  min-width: 240px;
  min-height: 42px;
  border: 1px solid #cad3cf;
  border-radius: 8px;
  background: #fbfcfb;
  padding: 0 10px;
  color: var(--muted);
}

.search-field input {
  min-height: 38px;
  border: 0;
  padding: 0;
  box-shadow: none;
}

.search-field input:focus {
  box-shadow: none;
}

.view-tools select {
  width: auto;
  min-width: 150px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1040px;
}

th,
td {
  text-align: left;
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0;
  white-space: nowrap;
}

td {
  color: #24302d;
  font-size: 0.94rem;
}

.account-cell {
  display: grid;
  gap: 4px;
  max-width: 310px;
}

.address,
.notes {
  color: var(--muted);
  line-height: 1.35;
}

.notes:empty {
  display: none;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-active {
  color: #0f5c35;
  background: #dff4e8;
}

.status-past_due {
  color: var(--red);
  background: var(--red-bg);
}

.status-paused {
  color: var(--amber);
  background: var(--amber-bg);
}

.status-pending {
  color: var(--violet);
  background: var(--violet-bg);
}

.status-cancelled {
  color: #505b57;
  background: var(--gray-bg);
}

tbody .icon-button {
  color: var(--ink);
  background: #f2f5f3;
  border-color: #dbe2de;
}

.empty-state {
  border: 1px dashed #b9c5c0;
  border-radius: 8px;
  min-height: 180px;
  display: grid;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 18px clamp(18px, 4vw, 44px);
  border-top: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.footer-brand,
.footer-contact {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.footer-brand span:first-child {
  color: var(--ink);
}

.footer-contact {
  font-style: normal;
  justify-content: flex-end;
}

.footer-contact a {
  color: var(--teal);
  text-decoration: none;
}

.footer-contact a:hover {
  text-decoration: underline;
}

.cookie-banner {
  position: fixed;
  left: clamp(14px, 3vw, 28px);
  right: clamp(14px, 3vw, 28px);
  bottom: clamp(14px, 3vw, 28px);
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 18px;
  border: 1px solid #bcd7d1;
  border-left: 6px solid var(--teal);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(23, 33, 30, 0.18);
}

.cookie-banner strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

.cookie-banner p {
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.cookie-banner a {
  color: var(--teal);
  font-weight: 900;
}

.cookie-actions,
.cookie-preferences {
  display: grid;
  gap: 10px;
}

.cookie-actions .primary-button,
.cookie-actions .ghost-button,
.cookie-preferences .primary-button {
  width: 100%;
  white-space: nowrap;
}

.cookie-preferences {
  grid-column: 1 / -1;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.cookie-preferences label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  line-height: 1.4;
}

.cookie-preferences input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
  flex: 0 0 auto;
}

.policy-shell {
  flex: 1;
  width: min(980px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 44px);
}

.policy-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 38px);
}

.policy-card h2 {
  margin-top: 24px;
  margin-bottom: 8px;
}

.policy-card h2:first-of-type {
  margin-top: 0;
}

.policy-card p,
.policy-card li {
  color: var(--muted);
  line-height: 1.62;
}

.policy-card a {
  color: var(--teal);
  font-weight: 900;
}

.policy-updated {
  font-weight: 900;
  color: var(--teal) !important;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 14px;
  color: var(--muted);
  font-weight: 800;
}

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

.pagination-actions .ghost-button {
  min-width: 92px;
}

.pagination-actions .ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.page-pill {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 999px;
  background: #f2f5f3;
  color: var(--ink);
  white-space: nowrap;
}

@media (max-width: 1120px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

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

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

  .renewal-list {
    grid-template-columns: 1fr;
  }

  .user-admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

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

  .hosting-notice {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-visual {
    width: 76px;
    height: 52px;
  }

  .list-heading,
  .view-tools,
  .field-row {
    align-items: stretch;
    flex-direction: column;
  }

  .view-tools,
  .search-field,
  .view-tools select {
    width: 100%;
    min-width: 0;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 12px;
  }

  td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
    border-bottom: 0;
    padding: 9px 4px;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 900;
    font-size: 0.78rem;
    text-transform: uppercase;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .pagination-bar,
  .pagination-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-actions .ghost-button,
  .page-pill {
    width: 100%;
  }

  .admin-toggle-row {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-toggle-button,
  .role-pill {
    width: 100%;
  }

  .owner-panel {
    grid-template-columns: 1fr;
  }

  .cookie-banner {
    grid-template-columns: 1fr;
  }

  .landing-hero {
    min-height: calc(100vh - 160px);
    align-items: end;
  }

  .landing-hero::after {
    background: linear-gradient(180deg, rgba(16, 22, 19, 0.32), rgba(16, 22, 19, 0.96));
  }

  .landing-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .landing-actions .primary-button,
  .landing-actions .ghost-button {
    width: 100%;
  }
}

@media (max-width: 500px) {
  .app-shell,
  .auth-shell,
  .landing-shell {
    padding: 14px;
  }

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

  .brand-block {
    align-items: flex-start;
  }

  .editor-panel,
  .list-panel,
  .admin-panel,
  .renewal-panel,
  .chart-panel,
  .metric-card {
    padding: 14px;
  }
}
