:root {
  --bg: #f4f7f4;
  --surface: #ffffff;
  --text: #1f2a24;
  --muted: #6d7a72;
  --brand-900: #12351f;
  --brand-800: #17452a;
  --brand-700: #22633d;
  --brand-200: #e7f2ea;
  --accent: #b29a36;
  --danger: #9b1c1c;
  --shadow: 0 12px 30px rgba(18, 53, 31, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--brand-200), var(--bg));
  padding-bottom: 5rem;
}
body.desktop-page {
  min-width: 1100px;
  padding-bottom: 0;
  background: #eef4ef;
  font-size: 13px;
}
.app-header {
  background: var(--brand-800);
  color: white;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.desktop-page .app-header { padding: .7rem 1.5rem; }
.app-header h1 { margin: 0; font-size: 1.6rem; }
.desktop-page .app-header h1 { font-size: 1.25rem; }
.eyebrow { margin: 0 0 .35rem; text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--accent); font-weight: bold; }
.login-pill { color: white; border: 1px solid #ffffff66; border-radius: 999px; padding: .45rem .8rem; text-decoration: none; white-space: nowrap; }
.container { width: min(1000px, 100%); margin: 0 auto; padding: 1rem; }
.desktop-container { width: 100%; max-width: none; padding: 1rem 1.5rem 1.5rem; }
.card {
  background: var(--surface);
  border: 1px solid #dfe7e1;
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.2rem;
  margin: 1rem 0;
}
.desktop-page .card { border-radius: 12px; margin: .7rem 0; padding: .8rem; }
.desktop-page h2 { font-size: 1.25rem; margin: 0 0 .4rem; }
.desktop-page h3 { font-size: 1rem; margin: 0 0 .55rem; }
.desktop-page p { margin: .35rem 0; }
.desktop-workspace { width: 100%; }
.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.hero h2 { margin: 0 0 .7rem; font-size: clamp(1.8rem, 8vw, 3.1rem); line-height: 1.05; color: var(--brand-900); }
.hero p { color: var(--muted); font-size: 1.05rem; }
.grid { display: grid; gap: 1rem; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check-list { padding-left: 1.1rem; line-height: 1.9; }
.form { display: grid; gap: .9rem; }
label { display: grid; gap: .35rem; font-weight: bold; }
input {
  width: 100%;
  border: 1px solid #cdd8d1;
  border-radius: 12px;
  padding: .9rem;
  font: inherit;
}
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.button {
  border: 1px solid #cdd8d1;
  border-radius: 12px;
  padding: .85rem 1rem;
  background: white;
  color: var(--brand-800);
  text-decoration: none;
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}
.button.primary { background: var(--brand-800); color: white; border-color: var(--brand-800); }
.button.whatsapp { background: #25d366; color: #0d351c; border-color: #25d366; }
.button.danger { background: var(--danger); color: white; border-color: var(--danger); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.issued-code {
  margin: 1.2rem 0 0;
  padding: 1rem;
  border-radius: 14px;
  background: var(--brand-200);
  color: var(--brand-900);
  text-align: center;
  font-size: 2rem;
  font-weight: bold;
  letter-spacing: .08em;
}
.admin-grid, .camera-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.camera-grid { grid-template-columns: repeat(2, minmax(480px, 1fr)); }
.admin-tile {
  background: var(--brand-200);
  border-radius: 14px;
  padding: 1rem;
  text-decoration: none;
  color: var(--brand-900);
  font-weight: bold;
}
.admin-tile span { display: block; margin-top: .35rem; color: var(--muted); font-weight: normal; }
.camera-box {
  min-height: 360px;
  background: #1d2520;
  color: white;
  border-radius: 14px;
  display: grid;
  place-items: center;
}
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  background: white;
  border-top: 1px solid #dfe7e1;
  box-shadow: 0 -8px 24px rgba(0,0,0,.08);
}
.desktop-page .bottom-nav {
  position: sticky;
  top: 0;
  bottom: auto;
  grid-template-columns: repeat(9, max-content);
  justify-content: start;
  padding: 0 1.5rem;
  border-top: 0;
  border-bottom: 1px solid #dfe7e1;
  box-shadow: 0 8px 20px rgba(18, 53, 31, .08);
  overflow-x: auto;
}
.bottom-nav a {
  padding: .8rem .4rem;
  text-align: center;
  color: var(--muted);
  text-decoration: none;
  font-weight: bold;
  font-size: .9rem;
}
.desktop-page .bottom-nav a { padding: .65rem .85rem; font-size: .78rem; }
.bottom-nav a.active { color: var(--brand-800); background: var(--brand-200); }
@media (max-width: 700px) {
  .mobile-page .app-header { align-items: flex-start; }
  .mobile-page .container { width: 100%; max-width: 100%; padding: .75rem; overflow-x: hidden; }
  .mobile-page .card { width: 100%; max-width: 100%; padding: 1rem; border-radius: 14px; }
  .mobile-page .narrow { max-width: 100%; }
  .mobile-page .two, .mobile-page .admin-grid, .mobile-page .camera-grid { grid-template-columns: 1fr; }
  .mobile-page .stacked-mobile { flex-direction: column; }
  .mobile-page .button { width: 100%; }
  .mobile-page input, .mobile-page select { min-width: 0; font-size: 16px; }
}

.role-line { margin: .35rem 0 0; color: #dfeee4; font-size: .85rem; }
.flash {
  border-radius: 12px;
  padding: .75rem .9rem;
  margin: .8rem 0;
  font-weight: bold;
}
.flash.success { background: #e0f6e8; color: #17452a; border: 1px solid #9bd6ad; }
.flash.error { background: #fde7e7; color: #8b1b1b; border: 1px solid #e2a1a1; }
.error-card pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #1d2520;
  color: #e8f5e9;
  padding: 1rem;
  border-radius: 12px;
  max-height: 45vh;
  overflow: auto;
}

.success-button { background: #e0f6e8 !important; color: #17452a !important; border-color: #9bd6ad !important; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-top: 1rem; }
.stat { background: var(--brand-200); border-radius: 14px; padding: .9rem; }
.stat span { display: block; color: var(--muted); font-size: .85rem; }
.stat strong { display: block; margin-top: .25rem; font-size: 1.4rem; color: var(--brand-900); }
@media (max-width: 700px) { .mobile-page .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

select {
  width: 100%;
  border: 1px solid #cdd8d1;
  border-radius: 12px;
  padding: .8rem;
  font: inherit;
  background: white;
}
.table-wrap { overflow-x: auto; width: 100%; }
.data-table { width: 100%; border-collapse: collapse; min-width: 620px; }
.desktop-page .data-table { min-width: 980px; background: white; }
.data-table th, .data-table td { padding: .75rem; border-bottom: 1px solid #dfe7e1; text-align: left; vertical-align: middle; }
.desktop-page .data-table th, .desktop-page .data-table td { padding: .45rem .55rem; }
.data-table th { color: var(--brand-900); background: #f5faf6; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.desktop-page .data-table th { font-size: .68rem; }
.data-table tbody tr:hover { background: #fbfdfb; }
.inline-form { display: contents; }
.small-button { padding: .5rem .75rem; }
.table-link { color: var(--brand-800); font-weight: bold; text-decoration: none; }
.table-link:hover { text-decoration: underline; }

.form-table { min-width: 1120px; }
.form-table input, .form-table select {
  min-width: 150px;
  padding: .45rem .55rem;
  border-radius: 8px;
  font-size: .9em;
}
.form-table input[type="file"] { min-width: 260px; }
.form-table .button { width: auto; }
.summary-table { min-width: 720px; }
.summary-table td strong { color: var(--brand-900); font-size: 1.35rem; }
.dashboard-table { min-width: 900px; }
.member-create-table, .sub-member-create-table { min-width: 1320px; }
.access-ops-table { min-width: 1060px; }
.billing-actions-table { min-width: 1380px; }
.invoice-table { min-width: 1450px; }
.role-guide-inline { margin-bottom: 0; }

.inline-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.compact-filter { max-width: 620px; grid-template-columns: 1fr 150px auto; margin: .5rem 0 .75rem; }
@media (max-width: 700px) { .mobile-page .inline-filters { grid-template-columns: 1fr; } }

.compact-table { min-width: 520px; font-size: .92rem; }
.member-table { min-width: 1380px; }
.sub-member-table { min-width: 1500px; }
.member-table th, .member-table td,
.member-create-table th, .member-create-table td,
.sub-member-create-table th, .sub-member-create-table td { border: 1px solid #dfe7e1; }
.member-table td,
.member-create-table td,
.sub-member-create-table td,
.desktop-page .member-table td,
.desktop-page .member-create-table td,
.desktop-page .sub-member-create-table td { padding: 0; background: #fff; vertical-align: top; }
.member-table tbody tr:hover td,
.member-create-table tbody tr:hover td,
.sub-member-create-table tbody tr:hover td { background: #fbfdfb; }
.member-edit-form,
.role-form { display: contents; margin: 0; padding: 0; }
.member-table input,
.member-table select,
.member-create-table input,
.member-create-table select,
.sub-member-create-table input,
.sub-member-create-table select {
  min-width: 110px;
  width: 100%;
  height: 26px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: .18rem .45rem;
  font-size: .9em;
  line-height: 1.1;
  box-shadow: none;
}
.member-table input:focus,
.member-table select:focus,
.member-create-table input:focus,
.member-create-table select:focus,
.sub-member-create-table input:focus,
.sub-member-create-table select:focus {
  outline: 2px solid var(--brand-700);
  outline-offset: -2px;
  background: #f8fcf9;
}
.member-table input[type="email"] { min-width: 220px; }
.member-table .status-badge { margin: .1rem .45rem 0; line-height: 1; }
.action-cell { display: flex; flex-wrap: nowrap; align-items: flex-start; gap: .2rem; min-width: 460px; height: 22px; padding: 0 .35rem !important; line-height: 1; overflow: hidden; }
.action-cell .inline-action-form { display: flex; align-items: flex-start; margin: 0; padding: 0; line-height: 1; }
.action-cell .button,
.member-create-table .button,
.sub-member-create-table .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 18px;
  min-height: 0;
  margin: 0;
  border-radius: 4px;
  padding: .1rem .35rem;
  font-size: .72rem;
  line-height: 1;
  box-shadow: none;
}
.action-cell .button:not(.danger),
.member-create-table .button:not(.primary),
.sub-member-create-table .button:not(.primary) {
  border-color: transparent;
  background: transparent;
  color: var(--brand-800);
}
.action-cell .button:not(.danger):hover { background: var(--brand-200); }
.inline-action-form { display: inline; }
.status-badge { display: inline-block; padding: .25rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: bold; }
.status-badge.active { background: #e0f6e8; color: #17452a; }
.status-badge.revoked { background: #fde7e7; color: #8b1b1b; }
.revoked-row { opacity: .72; background: #fff8f8; }
.modal-dialog {
  width: min(560px, calc(100% - 2rem));
  border: 1px solid #dfe7e1;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.22);
  padding: 0;
}
.modal-dialog::backdrop { background: rgba(18, 53, 31, .38); }
.modal-form { padding: 1rem; }
.modal-title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.modal-title-row h3 { margin: 0; }
.desktop-actions .button { width: auto; }

.report-box {
  max-height: 260px;
  overflow: auto;
  margin: .5rem 0 0;
  padding: .75rem;
  border: 1px solid #e8d98a;
  border-radius: 8px;
  background: #fffdf0;
  color: #4a3c00;
  font-size: .82rem;
  white-space: pre-wrap;
}
