:root {
  --tg: #2aabee;
  --tg-dark: #1688c7;
  --ink: #111827;
  --ink-soft: #344054;
  --muted: #667085;
  --line: #d9e2ec;
  --line-soft: #edf1f6;
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --amber: #f59e0b;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --violet: #7c3aed;
  --violet-soft: #ede9fe;
  --blue-soft: #e7f6ff;
  --shadow: 0 18px 55px rgba(20, 38, 64, .12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 42%, #e9eff6 100%);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

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

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.05;
}

h2 {
  margin-bottom: 7px;
  font-size: 28px;
  line-height: 1.06;
}

h3 {
  margin-bottom: 6px;
  font-size: 16px;
  line-height: 1.15;
}

p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.miniapp-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
}

.admin-shell {
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: 28px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px max(14px, env(safe-area-inset-right)) 14px max(14px, env(safe-area-inset-left));
  background: rgba(248, 251, 255, .94);
  border-bottom: 1px solid rgba(217, 226, 236, .9);
  backdrop-filter: blur(18px);
}

.brand-row,
.detail-head,
.executor-head,
.profile-head,
.task-head,
.detail-row,
.mini-executor,
.section-line,
.result-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-row,
.detail-row {
  min-width: 0;
}

.detail-row,
.section-line,
.result-row,
.task-head {
  justify-content: space-between;
}

.brandmark,
.avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: #fff;
  background: var(--tg);
  font-weight: 900;
}

.brandmark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(42, 171, 238, .28);
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}

.avatar.small {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 12px;
}

.avatar.dark,
.profile-hero.dark {
  background: var(--ink);
}

.avatar.violet,
.profile-hero.violet {
  background: var(--violet);
}

.avatar.green,
.profile-hero.green {
  background: #0f766e;
}

.eyebrow,
.screen-kicker {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.meta-pill,
.status,
.chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.meta-pill {
  color: #075985;
  background: var(--blue-soft);
  border: 1px solid #bdeaff;
}

.status {
  border: 0;
}

.status.blue {
  color: #075985;
  background: var(--blue-soft);
}

.status.green {
  color: #166534;
  background: var(--green-soft);
}

.status.amber {
  color: #92400e;
  background: var(--amber-soft);
}

.status.violet {
  color: #5b21b6;
  background: var(--violet-soft);
}

.role-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 4px;
  padding: 8px 14px;
  background: rgba(248, 251, 255, .72);
  border-bottom: 1px solid rgba(217, 226, 236, .62);
}

.admin-shell .role-tabs {
  max-width: 430px;
}

.role-tab {
  min-height: 36px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, .8);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
}

.role-tab.is-active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
  box-shadow: 0 8px 16px rgba(17, 24, 39, .12);
}

.screen,
.stack {
  display: grid;
  gap: 14px;
}

.screen {
  padding: 14px;
}

.screen-head {
  padding: 2px 2px 0;
}

.screen-head p:last-child,
.card p:last-child {
  margin-bottom: 0;
}

.role-choice {
  gap: 16px;
  padding-top: 2px;
}

.role-card-grid {
  display: grid;
  gap: 12px;
}

.role-card {
  position: relative;
  display: grid;
  gap: 18px;
  min-height: 218px;
  align-content: space-between;
  padding: 18px;
  color: inherit;
  text-align: left;
  background: linear-gradient(145deg, #fff 0%, #f3fbff 100%);
  border: 1px solid rgba(20, 38, 64, .08);
  border-radius: var(--radius);
  box-shadow: 0 16px 36px rgba(20, 38, 64, .1);
  overflow: hidden;
}

.role-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--tg);
}

.role-card.executor-card-choice {
  background: linear-gradient(145deg, #fff 0%, #f7f8fb 100%);
}

.role-card.executor-card-choice::before {
  background: var(--ink);
}

.role-card-top {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.role-card strong {
  display: block;
  color: var(--ink);
  font-size: 27px;
  line-height: 1.02;
}

.role-card-arrow {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fff;
  background: var(--tg);
  border-radius: 8px;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(42, 171, 238, .22);
}

.role-card-arrow.dark {
  background: var(--ink);
  box-shadow: 0 10px 24px rgba(17, 24, 39, .18);
}

.role-card-subtitle {
  display: block;
  max-width: 260px;
  color: var(--ink-soft);
  font-size: 18px;
  font-weight: 850;
  line-height: 1.22;
}

.role-card-meta {
  display: inline-flex;
  justify-self: start;
  min-height: 32px;
  align-items: center;
  padding: 7px 10px;
  color: #075985;
  background: rgba(231, 246, 255, .9);
  border: 1px solid #bdeaff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.executor-card-choice .role-card-meta {
  color: var(--ink-soft);
  background: var(--surface-2);
  border-color: var(--line);
}

.request-row,
.chat-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 9px;
  background: var(--surface);
  border: 1px solid #bdeaff;
  border-radius: var(--radius);
  box-shadow: 0 8px 18px rgba(42, 171, 238, .08);
}

.input,
.textarea,
.request-input,
select {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
}

.request-input {
  min-height: 40px;
  padding: 0 10px;
  background: var(--surface-2);
  border-color: var(--line-soft);
  font-size: 13px;
}

.input,
select {
  min-height: 44px;
  padding: 0 12px;
}

.textarea {
  min-height: 152px;
  padding: 12px;
  resize: vertical;
}

.field-label {
  display: block;
  margin: 2px 0 7px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 850;
}

.section-line span,
.section-line button,
.text-button {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.text-button {
  padding: 0;
  background: none;
  border: 0;
}

.quick-strip {
  display: flex;
  gap: 8px;
  margin-right: -14px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.quick-strip::-webkit-scrollbar {
  display: none;
}

.quick-grid,
.category-grid,
.service-grid,
.form-grid,
.metric-grid,
.work-grid {
  display: grid;
  gap: 8px;
}

.quick-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.category-grid,
.service-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid,
.metric-grid,
.work-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quick-card,
.category-card,
.service-card {
  position: relative;
  display: grid;
  align-content: space-between;
  min-width: 0;
  color: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid rgba(20, 38, 64, .08);
  border-radius: var(--radius);
  box-shadow: 0 10px 22px rgba(20, 38, 64, .07);
}

.quick-card {
  flex: 0 0 138px;
  min-height: 146px;
  gap: 12px;
  padding: 11px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .96), var(--soft)),
    var(--surface);
}

.quick-card.is-selected,
.service-card.is-selected,
.category-card.is-selected {
  outline: 2px solid currentColor;
  outline-offset: 0;
}

.quick-card.is-selected {
  color: var(--accent);
  border-color: var(--accent);
}

.quick-icon,
.tile-icon,
.detail-icon {
  display: grid;
  place-items: center;
  color: var(--accent, var(--tg-dark));
  background: #fff;
  border: 1px solid rgba(20, 38, 64, .06);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 900;
}

.quick-icon {
  width: 34px;
  height: 34px;
}

.tile-icon {
  width: 30px;
  height: 30px;
  margin-bottom: 9px;
}

.quick-copy strong,
.category-card strong,
.service-card strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.12;
}

.quick-copy span,
.category-card small,
.service-card span,
.mini-executor span,
.table-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.quick-status {
  justify-self: start;
  min-height: 28px;
  padding: 6px 9px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, .78);
  border: 1px solid rgba(20, 38, 64, .08);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

.quick-card.is-selected .quick-status {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.category-card,
.service-card {
  min-height: 90px;
  padding: 10px;
}

.category-card {
  background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
}

.category-card.is-selected {
  color: #fff;
  background:
    linear-gradient(145deg, rgba(17, 24, 39, .92), rgba(42, 171, 238, .78)),
    var(--tg);
  border-color: transparent;
}

.category-card.is-selected strong,
.category-card.is-selected small,
.category-card.is-selected .tile-icon {
  color: rgba(255, 255, 255, .9);
}

.service-card {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .94), var(--soft)),
    var(--surface);
}

.service-card.is-selected {
  color: var(--accent);
  border-color: var(--accent);
}

.detail-panel,
.card,
.order-card,
.executor-card,
.task-card,
.delivery-card,
.metric-card,
.profile-hero,
.next-panel {
  border-radius: var(--radius);
}

.detail-panel,
.card,
.order-card,
.executor-card,
.task-card,
.delivery-card,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 12px 26px rgba(20, 38, 64, .07);
}

.detail-panel,
.card,
.order-card,
.task-card,
.delivery-card,
.metric-card {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.card.flat {
  box-shadow: none;
}

.detail-icon {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  color: #fff;
  background: var(--accent, var(--tg));
}

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

.chip {
  color: var(--ink-soft);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.result-row,
.next-panel {
  padding: 11px;
  background: var(--soft, var(--blue-soft));
  border: 1px solid rgba(20, 38, 64, .08);
  border-radius: var(--radius);
}

.result-row span,
.next-panel span,
.estimate-box span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.next-panel {
  display: grid;
  gap: 5px;
  color: #064e74;
  background: var(--blue-soft);
  border-color: #bdeaff;
}

.btn,
.icon-btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 900;
  text-decoration: none;
}

.btn.primary {
  color: #fff;
  background: var(--tg);
  border-color: var(--tg);
  box-shadow: 0 10px 24px rgba(42, 171, 238, .26);
}

.btn.secondary {
  background: var(--surface-2);
}

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

.btn.wide {
  width: 100%;
}

.icon-btn {
  width: 44px;
  padding: 0;
  color: #fff;
  background: var(--ink);
}

.view-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.view-switch button {
  min-height: 36px;
  color: var(--ink-soft);
  background: #fff;
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

.view-switch .is-active {
  color: #fff;
  background: var(--ink);
}

.executor-list {
  display: grid;
  gap: 10px;
}

.executor-card {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.executor-hit {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: none;
  border: 0;
}

.executor-card .button-row,
.executor-card .chip-row,
.executor-card .work-grid,
.executor-card .executor-head {
  position: relative;
  z-index: 2;
}

.work-grid.mini {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.work-preview {
  min-height: 102px;
  padding: 9px;
  overflow: hidden;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(17, 24, 39, .92), rgba(42, 171, 238, .72)),
    var(--tg);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
}

.work-preview.green {
  background:
    linear-gradient(145deg, rgba(17, 24, 39, .9), rgba(22, 163, 74, .72)),
    var(--green);
}

.work-preview.violet {
  background:
    linear-gradient(145deg, rgba(17, 24, 39, .92), rgba(124, 58, 237, .7)),
    var(--violet);
}

.mini-topbar {
  display: flex;
  gap: 3px;
  margin-bottom: 10px;
}

.mini-topbar i {
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, .72);
  border-radius: 50%;
}

.work-preview strong {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
}

.mini-lines {
  display: grid;
  gap: 4px;
}

.mini-lines i {
  display: block;
  height: 5px;
  background: rgba(255, 255, 255, .62);
  border-radius: 999px;
}

.mini-lines i:nth-child(2) {
  width: 72%;
}

.mini-lines i:nth-child(3) {
  width: 48%;
}

.profile-hero {
  display: grid;
  gap: 14px;
  padding: 14px;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(17, 24, 39, .92), rgba(42, 171, 238, .78)),
    var(--tg);
}

.profile-hero p,
.profile-hero .screen-kicker {
  color: rgba(255, 255, 255, .78);
}

.metric-row,
.estimate-box {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-row span,
.estimate-box div {
  display: grid;
  gap: 2px;
  padding: 9px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: var(--radius);
  font-size: 12px;
}

.estimate-box div {
  background: var(--surface-2);
  border-color: var(--line-soft);
}

.estimate-box.vertical {
  grid-template-columns: 1fr;
}

.timeline {
  display: grid;
}

.timeline.compact {
  margin-top: -4px;
}

.timeline-row {
  position: relative;
  padding: 9px 0 9px 22px;
  color: var(--ink-soft);
  font-size: 13px;
}

.timeline-row::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 5px;
  width: 8px;
  height: 8px;
  background: var(--tg);
  border-radius: 50%;
}

.timeline-row::after {
  content: "";
  position: absolute;
  top: 26px;
  bottom: -5px;
  left: 8px;
  width: 2px;
  background: var(--line);
}

.timeline-row:last-child::after {
  display: none;
}

.timeline-row.is-done::before {
  background: var(--green);
}

.chat {
  display: grid;
  gap: 9px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.bubble {
  max-width: 82%;
  padding: 10px 11px;
  color: var(--ink-soft);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.bubble.me {
  justify-self: end;
  color: #fff;
  background: var(--tg);
  border-color: var(--tg);
}

.file-list,
.table-list {
  display: grid;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.file-list div,
.table-row {
  display: grid;
  gap: 8px;
  align-items: center;
  padding: 11px;
  border-bottom: 1px solid var(--line-soft);
}

.file-list div {
  grid-template-columns: 1fr auto;
}

.table-row {
  grid-template-columns: 1fr auto auto auto auto;
  min-height: 60px;
}

.table-row.compact {
  grid-template-columns: 1fr auto auto;
}

.file-list div:last-child,
.table-row:last-child {
  border-bottom: 0;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 430px);
  margin: 0 auto;
  padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  display: grid;
  gap: 3px;
  min-height: 48px;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 850;
}

.bottom-nav span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: inherit;
  background: var(--surface-2);
  border-radius: 7px;
  font-size: 12px;
}

.bottom-nav button.is-active {
  color: var(--tg-dark);
  background: var(--blue-soft);
}

.admin-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 14px;
}

.side-nav,
.admin-main,
.order-detail-main,
.order-detail-side {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 26px rgba(20, 38, 64, .06);
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 10px;
}

.side-nav button {
  min-height: 38px;
  padding: 0 10px;
  color: var(--ink-soft);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-weight: 850;
}

.side-nav button.is-active {
  color: #fff;
  background: var(--ink);
}

.admin-main {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.admin-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.search {
  min-height: 42px;
  padding: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}

.admin-grid,
.order-detail-layout {
  display: grid;
  gap: 14px;
}

.admin-grid {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.metric-card strong {
  font-size: 26px;
}

.order-detail-layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.order-detail-main,
.order-detail-side {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 14px;
}

.clean-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.4;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 14px;
  z-index: 40;
  max-width: 402px;
  margin: 0 auto;
  padding: 12px 14px;
  color: #fff;
  background: var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(100% + 28px));
  transition: transform .22s ease;
  visibility: hidden;
}

.toast.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}

@media (max-width: 860px) {
  .admin-shell {
    width: min(100%, 430px);
  }

  .admin-layout,
  .admin-grid,
  .order-detail-layout {
    grid-template-columns: 1fr;
  }

  .side-nav {
    grid-auto-flow: column;
    overflow-x: auto;
  }

  .side-nav button {
    white-space: nowrap;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-row {
    grid-template-columns: 1fr auto;
  }
}

@media (max-width: 360px) {
  .quick-grid,
  .category-grid,
  .service-grid,
  .form-grid,
  .metric-row,
  .estimate-box {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 22px;
  }
}
