:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #122033;
  --muted: #65758b;
  --line: #dce5ef;
  --frame: #e8f6f5;
  --frame-strong: #d4eeec;
  --brand: #0a7f83;
  --brand-dark: #075f62;
  --blue: #2563eb;
  --green: #15803d;
  --red: #b42318;
  --amber: #b45309;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
}
button:hover { border-color: var(--brand); }
.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.danger { background: #fff1f1; border-color: #fecaca; color: var(--red); }
.paid-lock { background: var(--red); color: #fff; border-color: var(--red); font-weight: 800; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgb(45 212 191 / .22), transparent 32%),
    linear-gradient(135deg, #f6fbfc, #eef4f8);
}
.login-card {
  width: min(460px, 100%);
  padding: 28px;
  display: grid;
  gap: 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgb(255 255 255 / .96);
  box-shadow: 0 24px 70px rgb(15 23 42 / .16);
}
.login-card img {
  width: 132px;
  height: auto;
}
.login-card p {
  margin: 8px 0 0;
  color: var(--muted);
}
.login-card h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.08;
}
.login-error {
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff7f7;
  color: #991b1b;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid #b9dfdc;
  background:
    linear-gradient(90deg, var(--frame), #f7fcfc 62%, rgb(255 255 255 / .96));
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 28px rgb(10 127 131 / .08);
}
.brand {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  color: var(--brand-dark);
}
.brand img { height: 48px; max-width: 180px; object-fit: contain; }
.build-badge {
  display: inline-flex;
  margin-left: 4px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e7f5f4;
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 800;
}
.desktop-nav { margin-left: auto; display: flex; gap: 8px; }
.nav.active { background: #e7f5f4; border-color: #9bd4d1; color: var(--brand-dark); }
.name-link {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  font-weight: 900;
  text-align: left;
}
.name-link:hover {
  text-decoration: underline;
  border-color: transparent;
}

.admin-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 0 24px 40px;
  display: grid;
  gap: 18px;
}
.auth-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 320px) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.diagnostic-panel {
  padding: 14px;
  border: 1px solid #fecaca;
  border-radius: 12px;
  background: #fff7f7;
  color: #991b1b;
  line-height: 1.45;
}
.diagnostic-panel strong {
  display: block;
  margin-bottom: 4px;
}
.diagnostic-panel code {
  color: #7f1d1d;
  overflow-wrap: anywhere;
}
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }

.section { display: none; }
.section.active { display: grid; gap: 18px; padding-top: 22px; }
#requests.section.active,
#professionals.section.active { padding-top: 0; }
.section-head, .panel-head, .actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.section-head p, .panel-head p, .modal-head p, .results-head p { margin: 0; color: var(--muted); }
.section-head h1, .panel h2, .modal-head h2, .results-head h1 { margin: 3px 0 0; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.kpi {
  min-height: 112px;
  padding: 16px;
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 22px rgb(15 23 42 / .05);
}
.kpi span { color: var(--muted); font-size: 13px; }
.kpi strong { font-size: 25px; }
.kpi em { font-style: normal; color: var(--brand-dark); font-size: 12px; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.panel {
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.list, .service-list { display: grid; gap: 10px; }
.wide-list { grid-template-columns: 1fr; }
.filtered-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  min-height: calc(100vh - 72px);
}
.filter-sidebar {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 72px);
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid #b9dfdc;
  border-left: 0;
  border-top: 0;
  border-radius: 0 0 18px 0;
  background: linear-gradient(180deg, var(--frame), #f8fdfd);
  box-shadow: 14px 18px 40px rgb(10 127 131 / .08);
}
.filtered-content {
  min-width: 0;
  max-height: calc(100vh - 72px);
  overflow: auto;
  padding: 22px 4px 0 0;
}
.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 26px rgb(4 44 66 / .06);
}
.filter-modal-trigger { display: inline-flex; }
.filter-sidebar h2 {
  margin: 0;
  font-size: 18px;
}
.filter-sidebar label {
  display: grid;
  gap: 6px;
}
.filter-sidebar input,
.filter-sidebar select {
  min-height: 42px;
}
.filter-sidebar #openProfessionalCategoriesSidebar {
  width: 100%;
  min-height: 54px;
  white-space: normal;
  font-weight: 800;
  line-height: 1.2;
}
.compact-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.sidebar-divider {
  height: 1px;
  background: #b9dfdc;
  margin: 6px 0;
}
.category-manager,
.mini-form,
.category-list {
  display: grid;
  gap: 10px;
}
.mini-form textarea {
  min-height: 70px;
}
.category-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #b9dfdc;
  border-radius: 12px;
  background: rgb(255 255 255 / .72);
}
.category-row strong,
.category-row span {
  display: block;
}
.category-row span {
  color: var(--muted);
  font-size: 12px;
}
.category-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.category-modal-card {
  width: min(980px, calc(100vw - 42px));
}
.category-modal-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.category-modal-grid .category-list {
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding-right: 4px;
}
.card, .service-row {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.list-row {
  grid-template-columns: minmax(220px, 1.15fr) minmax(260px, 1.4fr) auto;
  align-items: center;
}
.list-row-main {
  min-width: 0;
}
.list-row-facts {
  min-width: 0;
}
.list-row-actions {
  justify-content: flex-end;
  white-space: nowrap;
}
.card-head, .service-row-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.card strong, .service-row strong { color: var(--brand-dark); }
.muted, .card span, .service-row span { color: var(--muted); font-size: 13px; }
.facts { display: flex; flex-wrap: wrap; gap: 7px; }
.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
}
.pill.good { background: #ecfdf3; color: var(--green); border-color: #bbf7d0; }
.pill.warn { background: #fff7ed; color: var(--amber); border-color: #fed7aa; }
.pill.bad { background: #fff1f1; color: var(--red); border-color: #fecaca; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-modal-card {
  width: min(620px, calc(100vw - 42px));
}
.filter-modal-body {
  display: grid;
  gap: 12px;
}
.filter-modal-body .filter-sidebar {
  display: grid;
  position: static;
  max-height: none;
  overflow: visible;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  padding: 0;
}
.filter-modal-body .filter-sidebar::before { display: none; }

dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  border: 0;
  padding: 0;
  background: transparent;
}
dialog::backdrop { background: rgb(15 23 42 / .6); }
.modal-card {
  width: min(1020px, calc(100vw - 42px));
  max-height: calc(100vh - 42px);
  margin: 21px auto;
  overflow: auto;
  padding: 22px;
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 70px rgb(15 23 42 / .28);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.modal-head button {
  width: 42px;
  padding: 0;
  font-size: 24px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}
.wide { grid-column: 1 / -1; }
.professional-services-field {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfd;
}
.field-title {
  display: grid;
  gap: 3px;
}
.field-title span {
  color: var(--muted);
  font-size: 13px;
}
.professional-services-checklist {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}
.service-flag {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}
.service-flag input {
  width: auto;
  margin: 0;
}
.service-flag span {
  line-height: 1.2;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.detail-body { display: grid; gap: 12px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px;
  background: #fbfcfd;
}
.detail-grid span { display: block; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  padding: 12px 14px;
  border-radius: 10px;
  background: #102033;
  color: #fff;
  box-shadow: 0 12px 34px rgb(15 23 42 / .24);
}
.mobile-bottom-nav { display: none; }

@media (max-width: 980px) {
  .admin-header { padding: 10px 12px; }
  .brand img { height: 42px; max-width: 150px; }
  .brand span, .desktop-nav { display: none; }
  .admin-shell { padding: 14px 12px 92px; }
  .section.active,
  #requests.section.active,
  #professionals.section.active { padding-top: 0; }
  .auth-panel, .grid.two, .wide-list, .detail-grid, .form-grid, .filtered-layout { grid-template-columns: 1fr; }
  .category-modal-grid { grid-template-columns: 1fr; }
  .category-modal-grid .category-list { max-height: none; overflow: visible; padding-right: 0; }
  .list-row { grid-template-columns: 1fr; align-items: stretch; }
  .list-row-actions { justify-content: stretch; }
  .list-row-actions button { width: 100%; }
  .professional-services-checklist { grid-template-columns: 1fr; max-height: none; }
  .filter-sidebar { display: none; }
  .filtered-content { max-height: none; overflow: visible; padding: 0; }
  .results-head { align-items: stretch; flex-direction: column; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-head, .panel-head, .card-head, .service-row-head { align-items: stretch; flex-direction: column; }
  .mobile-bottom-nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgb(255 255 255 / .96);
    box-shadow: 0 14px 34px rgb(16 32 51 / .18);
    backdrop-filter: blur(12px);
  }
  .mobile-bottom-nav .nav {
    min-height: 52px;
    padding: 7px 4px;
    display: grid;
    place-items: center;
    gap: 2px;
    border: 0;
    border-radius: 14px;
    background: #f8fafc;
    font-size: 10px;
  }
  .mobile-bottom-nav .nav span {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, #2dd4bf, #0f766e);
    color: #fff;
    font-weight: 900;
  }
  .mobile-bottom-nav .nav.active {
    background: #e7f5f4;
    color: var(--brand-dark);
  }
  .modal-card {
    width: 100vw;
    max-height: 100vh;
    min-height: 100vh;
    margin: 0;
    border-radius: 0;
  }
  .filter-modal-card {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .filter-modal-body {
    overflow: auto;
    padding-bottom: 8px;
  }
  .filter-modal-card .modal-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid var(--line);
    padding-top: 12px;
  }
  .modal-actions { display: grid; }
}

@media (max-width: 540px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .card-actions, .actions { display: grid; }
}
