:root {
  --bg: #f4f7f6;
  --panel: #ffffff;
  --panel-soft: #eef7f3;
  --ink: #17322b;
  --muted: #6c7d77;
  --line: #dce8e3;
  --brand: #087f5b;
  --brand-dark: #0b5d49;
  --brand-soft: #dff5ec;
  --blue: #246bfe;
  --amber: #b7791f;
  --red: #b42318;
  --shadow: 0 18px 50px rgba(20, 58, 47, 0.12);
  --radius: 8px;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(8, 127, 91, 0.14);
}

.date-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.compact-btn {
  min-height: 40px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(8, 127, 91, 0.93), rgba(15, 63, 65, 0.92)),
    radial-gradient(circle at 25% 15%, rgba(255, 255, 255, 0.22), transparent 25%);
}

.login-panel {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 10px;
  padding: 34px;
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  font-size: 13px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-panel h1 {
  margin: 12px 0 8px;
  font-size: 30px;
}

.login-copy,
.demo-note {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 15px;
  margin-top: 22px;
}

.form-error {
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px;
  background: #0e332b;
  color: #fff;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand span,
.sidebar-footer span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 7px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  padding: 0 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-icon {
  width: 22px;
  display: inline-grid;
  place-items: center;
  font-weight: 900;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.main-panel {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar h2 {
  margin: 0;
  font-size: 28px;
}

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

.sync-status {
  align-items: center;
  align-self: center;
  background: #edf7f2;
  border: 1px solid #b8dccd;
  border-radius: 999px;
  color: var(--brand-dark);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  min-height: 32px;
  padding: 0 10px;
  white-space: nowrap;
}

.sync-status[data-state="syncing"] {
  background: #fff7dc;
  border-color: #f2d47c;
  color: #7a5700;
}

.sync-status[data-state="error"] {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.sync-status[data-state="local"] {
  background: #eef2f7;
  border-color: #cbd5e1;
  color: #475569;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn {
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 800;
}

.primary-btn {
  background: var(--brand);
  color: #fff;
}

.primary-btn:hover {
  background: var(--brand-dark);
}

.secondary-btn {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.secondary-btn:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
}

.ghost-btn {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.22);
  color: inherit;
}

.main-panel .ghost-btn,
.drawer .ghost-btn {
  border-color: var(--line);
  color: var(--ink);
}

.icon-btn {
  width: 38px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 22px;
}

.full {
  width: 100%;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 26px rgba(20, 58, 47, 0.06);
}

.metric-card {
  padding: 16px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.metric-card small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.content-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
}

.panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head.wrap {
  flex-wrap: wrap;
}

.panel-head h3 {
  margin: 0;
  font-size: 18px;
}

.panel-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.filter-panel {
  display: grid;
  grid-template-columns: 1.6fr repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.search-field input {
  min-width: 260px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
}

.chip.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

.data-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

.data-table th {
  background: #f7faf9;
  color: #49645d;
  font-size: 11px;
  text-transform: uppercase;
}

.data-table tr:hover td {
  background: #fbfdfc;
}

.client-cell {
  display: grid;
  gap: 3px;
}

.client-cell strong {
  font-size: 14px;
}

.client-cell span,
.subtle {
  color: var(--muted);
  font-size: 12px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.badge,
.status-pill,
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.electricity {
  background: #fff7d6;
  color: #8a5a00;
}

.badge.internet {
  background: #e8f1ff;
  color: #1555bf;
}

.badge.cable {
  background: #efe7ff;
  color: #5b2fb8;
}

.badge.insurance {
  background: #e4f8ec;
  color: #087443;
}

.status-pill.paid {
  background: #dcfce7;
  color: #166534;
}

.status-pill.pending {
  background: #fff7d6;
  color: #8a5a00;
}

.status-pill.review {
  background: #fee2e2;
  color: #991b1b;
}

.link-btn {
  min-height: 30px;
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  font-weight: 900;
}

.activity-list,
.summary-list,
.audit-list,
.tag-manager,
.user-manager {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.activity-item,
.summary-item,
.audit-item,
.manager-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: #fff;
}

.settings-form {
  padding: 16px;
}

.settings-form label {
  max-width: 320px;
}

.activity-item strong,
.summary-item strong,
.audit-item strong,
.manager-item strong {
  display: block;
  margin-bottom: 3px;
}

.drawer,
.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 30;
}

.drawer.open,
.modal.open {
  display: block;
}

.drawer-backdrop,
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 25, 22, 0.42);
}

.drawer-panel,
.modal-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(900px, 100%);
  height: 100%;
  overflow: auto;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 20px;
}

.small-drawer {
  width: min(620px, 100%);
}

.modal-panel {
  top: 50%;
  left: 50%;
  right: auto;
  width: min(760px, calc(100% - 32px));
  height: auto;
  max-height: calc(100vh - 48px);
  transform: translate(-50%, -50%);
  border-radius: 9px;
}

.modal-panel textarea {
  min-height: 320px;
  margin-top: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.drawer-head h3 {
  margin: 0;
  font-size: 22px;
}

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

.wide {
  grid-column: 1 / -1;
}

.form-section {
  margin: 18px 0;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.form-section h4 {
  margin: 0 0 10px;
}

.tag-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.tag-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.tag-check input,
.toggle-line input {
  width: auto;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 12px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.tab {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 0 12px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.service-panel {
  display: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fbfdfc;
}

.active-service-panel {
  display: block;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 13px;
}

.commission-preview {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 12px;
}

.commission-preview span {
  color: var(--muted);
}

.drawer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .content-grid,
  .filter-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  }

  .nav-list {
    grid-template-columns: repeat(3, 1fr);
  }

  .nav-item {
    justify-content: center;
    padding: 0 8px;
    font-size: 12px;
  }

  .nav-icon {
    display: none;
  }

  .sidebar-footer {
    display: none;
  }

  .main-panel {
    padding: 16px;
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

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