:root {
  --ink: #18211f;
  --muted: #66736e;
  --line: #dce5df;
  --canvas: #f5f7f4;
  --surface: #ffffff;
  --green: #176b4d;
  --green-dark: #10513a;
  --amber: #e6a63b;
  --danger: #b93830;
  font-family: "DM Sans", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #e9f0eb; }
.login-panel { width: min(100%, 420px); padding: 36px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 46px rgba(20, 45, 34, .12); }
.brand { display: flex; align-items: center; gap: 10px; font-family: Manrope, sans-serif; font-weight: 800; letter-spacing: 0; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 7px; color: white; background: var(--green); }
.login-panel h1 { margin: 30px 0 8px; font: 700 25px Manrope, sans-serif; }
.login-panel p { margin: 0 0 26px; color: var(--muted); line-height: 1.5; }

.field { display: grid; gap: 7px; margin-bottom: 16px; color: #35423d; font-size: 14px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; min-height: 43px; padding: 10px 12px; color: var(--ink); background: white; border: 1px solid #bdc9c1; border-radius: 5px; outline: none; }
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 77, .12); }
.field small { font-weight: 400; color: var(--muted); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 9px 14px; color: white; font-weight: 700; border: 1px solid var(--green); border-radius: 5px; background: var(--green); }
.button:hover { background: var(--green-dark); }
.button:disabled { cursor: wait; opacity: .65; }
.button-secondary { color: var(--ink); border-color: #bdc9c1; background: white; }
.button-secondary:hover { background: #f3f6f4; }
.button-danger { color: var(--danger); border-color: #e4b5b1; background: #fff7f6; }
.button-danger:hover { background: #fff0ef; }
.button-icon { width: 38px; padding: 0; }

.admin-layout { display: grid; min-height: 100vh; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; padding: 22px 14px; color: #d6e6dd; background: #142a21; }
.sidebar .brand { padding: 0 10px; color: white; }
.sidebar .brand-mark { background: var(--amber); color: #392900; }
.nav { display: grid; gap: 3px; margin-top: 38px; }
.nav button { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 42px; padding: 0 11px; color: #bdcec4; text-align: left; background: transparent; border: 0; border-radius: 5px; }
.nav button:hover, .nav button.active { color: white; background: #244635; }
.nav .lucide { width: 18px; height: 18px; }
.sidebar-footer { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid #2c4c3b; }
.sidebar-footer strong, .sidebar-footer span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer span { margin-top: 3px; color: #9cb5a7; font-size: 12px; }
.sidebar-footer button { width: 100%; margin-top: 13px; color: #bdcec4; background: transparent; border: 0; text-align: left; padding: 0; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; min-height: 72px; padding: 0 34px; background: white; border-bottom: 1px solid var(--line); }
.menu-toggle { display: none; }
.view { max-width: 1440px; margin: 0 auto; padding: 34px; }
.view-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 5px; color: var(--green); font-size: 13px; font-weight: 700; }
h1 { margin: 0; font: 700 27px Manrope, sans-serif; letter-spacing: 0; }
.view-header > div > p:last-child { margin: 8px 0 0; color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(135px, 1fr)); gap: 14px; }
.metric { min-height: 134px; padding: 19px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.metric .metric-icon { display: grid; place-items: center; width: 32px; height: 32px; margin-bottom: 18px; border-radius: 5px; color: var(--green); background: #e6f1ea; }
.metric:nth-child(4) .metric-icon, .metric:nth-child(5) .metric-icon { color: #835b12; background: #fbefd7; }
.metric strong { display: block; font: 800 28px Manrope, sans-serif; }
.metric span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }

.panel { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-title h2 { margin: 0; font: 700 17px Manrope, sans-serif; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 800px; }
th { padding: 12px 20px; color: #69766f; font-size: 12px; font-weight: 700; letter-spacing: 0; text-align: left; text-transform: uppercase; background: #f8faf8; }
td { padding: 16px 20px; color: #36423d; font-size: 14px; border-top: 1px solid #edf1ee; vertical-align: middle; }
.tenant-name { display: grid; gap: 3px; color: var(--ink); font-weight: 700; }
.tenant-name small, td small { color: var(--muted); font-size: 12px; font-weight: 400; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; color: #276747; font-size: 12px; font-weight: 700; border-radius: 99px; background: #e6f4eb; }
.badge.inactive, .badge.suspended { color: #9a3a31; background: #fbe9e7; }
.actions { display: flex; gap: 7px; }
.actions button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; color: #3f5047; background: white; border: 1px solid #ccd7cf; border-radius: 5px; }
.actions button:hover { color: var(--green); border-color: var(--green); }
.empty { padding: 38px 20px; color: var(--muted); text-align: center; }
.analytics-selector { margin-bottom: 20px; }
.selector-content { max-width: 430px; padding: 18px 20px 2px; }
.selector-content .button { margin-bottom:18px; }
.utility-list { display: grid; gap: 12px; max-width: 760px; }
.utility-item { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 15px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.utility-icon { display: grid; place-items: center; width: 42px; height: 42px; color: #835b12; background: #fbefd7; border-radius: 5px; }
.utility-icon .lucide { width: 21px; height: 21px; }
.utility-item h2 { margin: 0; font: 700 16px Manrope, sans-serif; }
.utility-item p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.analytics-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(290px, .75fr); gap: 18px; margin-top: 20px; }
.chart-panel { min-height: 280px; }
.chart-wrap { padding: 18px 20px; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-grid { stroke: #e1e9e3; stroke-width: 1; }
.chart-line { fill: none; stroke: var(--green); stroke-linecap: round; stroke-linejoin: round; stroke-width: 4; }
.chart-labels { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; margin-top: 2px; color: var(--muted); font-size: 12px; }
.chart-labels span:last-child { text-align: right; }
.bar-list { display: grid; gap: 14px; padding: 18px 20px; }
.bar-copy { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 13px; }
.bar-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-copy span { flex: 0 0 auto; color: var(--muted); }
.bar-track { height: 8px; overflow: hidden; background: #eaf0ec; border-radius: 4px; }
.bar-fill { height: 100%; border-radius: inherit; background: var(--amber); }

.modal-backdrop { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(15, 30, 23, .52); z-index: 20; }
.modal { width: min(100%, 680px); max-height: calc(100vh - 40px); overflow: auto; padding: 25px; background: white; border-radius: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.modal h2 { margin: 0; font: 700 21px Manrope, sans-serif; }
.modal-header p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.close { display: grid; place-items: center; width: 34px; height: 34px; color: #526158; background: white; border: 1px solid var(--line); border-radius: 5px; }
.form-section { margin: 22px 0 14px; color: var(--green); font-size: 13px; font-weight: 800; text-transform: uppercase; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.notice { margin: 0 0 16px; padding: 11px 12px; color: #91423a; font-size: 14px; border-left: 3px solid #c86359; background: #fff5f3; }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: min(390px, calc(100vw - 44px)); padding: 13px 16px; color: white; border-radius: 6px; background: #1f3028; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 30; }
.toast.error { background: #8c342e; }
.access-denied { max-width: 580px; margin: 12vh auto; padding: 32px; text-align: center; background: white; border: 1px solid var(--line); border-radius: 8px; }
.access-denied .metric-icon { margin: 0 auto 16px; }

@media (max-width: 1120px) { .metrics { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) {
  .admin-layout { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; transform: translateX(-102%); transition: transform .18s ease; z-index: 10; box-shadow: 12px 0 30px rgba(0,0,0,.18); }
  .sidebar.open { transform: translateX(0); }
  .topbar { min-height: 62px; padding: 0 18px; }
  .menu-toggle { display: grid; place-items: center; width: 36px; height: 36px; margin-right: 12px; border: 0; border-radius: 5px; background: #edf4ef; }
  .view { padding: 24px 18px; }
  .view-header { align-items: stretch; flex-direction: column; }
  .view-header > .button { width: 100%; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric { min-height: 118px; }
  .metric strong { font-size: 23px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .modal { padding: 20px; }
  .analytics-grid { grid-template-columns: 1fr; }
  .utility-item { grid-template-columns: 42px minmax(0, 1fr); }
  .utility-item .button { grid-column: 1 / -1; width: 100%; }
}
