:root {
  --ink: #172026;
  --muted: #687482;
  --line: #dfe7ec;
  --soft: #f5f7f8;
  --surface: #ffffff;
  --primary: #ef4444;
  --primary-dark: #c92e2e;
  --teal: #0f9f8e;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
  background: var(--soft);
}

body.modal-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(12px, 4vw, 34px);
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand,
.topbar nav,
.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.brand strong {
  font-size: 1rem;
}

main {
  display: grid;
  gap: 16px;
  padding: 14px clamp(12px, 4vw, 34px) 34px;
}

.page {
  display: none;
  gap: 16px;
}

.page.active {
  display: grid;
}

.hero {
  display: grid;
  gap: 10px;
  padding: 20px;
  color: #ffffff;
  background: linear-gradient(135deg, rgba(23, 32, 38, 0.96), rgba(15, 159, 142, 0.86));
  border-radius: 8px;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero .eyebrow {
  color: #ffffff;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2rem, 8vw, 4rem);
  line-height: 0.98;
}

.hero p:not(.eyebrow) {
  max-width: 680px;
  margin: 0;
  color: rgba(255, 255, 255, 0.84);
  line-height: 1.65;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.stats span {
  display: grid;
  gap: 3px;
  min-height: 64px;
  align-content: center;
  padding: 10px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 850;
}

.stats strong {
  color: #ffffff;
  font-size: 1.25rem;
}

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

.step-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(23, 32, 38, 0.07);
}

.step-card span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #ffffff;
  background: var(--ink);
  border-radius: 8px;
  font-weight: 950;
}

.step-card h2,
.page-head h1 {
  margin: 0;
}

.step-card p,
.page-head p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.home-card {
  display: grid;
  gap: 9px;
  min-height: 156px;
  padding: 16px;
  text-align: left;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(23, 32, 38, 0.07);
}

.home-card strong {
  font-size: 1.18rem;
}

.home-card small {
  color: var(--muted);
  line-height: 1.55;
}

.card-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #ffffff;
  background: var(--ink);
  border-radius: 8px;
  font-size: 1.4rem;
  font-weight: 950;
}

.page-head {
  display: grid;
  gap: 8px;
  max-width: 760px;
}

.page-head h1 {
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  line-height: 1;
}

.message {
  padding: 12px;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  color: #166534;
  font-weight: 850;
}

.message.error {
  color: #9f1239;
  background: #fff1f2;
  border-color: #fecdd3;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(23, 32, 38, 0.07);
}

.form-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.narrow-form {
  width: min(760px, 100%);
}

.store-workspace {
  display: grid;
  gap: 14px;
}

.detail-card {
  display: grid;
  gap: 12px;
  width: min(760px, 100%);
  padding: 14px;
}

.detail-head {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
}

.detail-head h2 {
  margin: 0;
  font-size: 1.16rem;
}

.detail-head p {
  margin: 3px 0 0;
  color: var(--muted);
}

.detail-head img,
.detail-head .avatar {
  width: 58px;
  height: 58px;
}

.form-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-title > span {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: #ffffff;
  background: var(--ink);
  border-radius: 8px;
  font-weight: 950;
}

.form-title h2,
.section-title h2 {
  margin: 0;
}

.form-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

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

textarea {
  resize: vertical;
  padding: 11px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

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

.primary,
.secondary {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 900;
}

.primary {
  color: #ffffff;
  background: var(--primary);
  border: 1px solid var(--primary);
}

.secondary {
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.danger {
  color: #b91c1c;
  background: #fff1f2;
  border-color: #fecdd3;
}

.form-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 14px;
}

.form-modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 32, 38, 0.58);
  backdrop-filter: blur(10px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
  width: min(760px, 100%);
  max-height: min(86vh, 820px);
  overflow: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 26px 80px rgba(23, 32, 38, 0.34);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 2px 0 0;
  font-size: 1.2rem;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--ink);
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.section-title {
  margin-top: 4px;
}

.store-tabs {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  gap: 4px;
  padding: 5px;
  overflow-x: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.store-tabs button {
  min-height: 38px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

.store-tabs button.active {
  color: #ffffff;
  background: var(--ink);
}

.store-tab-panel {
  display: none;
  gap: 14px;
}

.store-tab-panel[hidden] {
  display: none;
}

.store-tab-panel.active {
  display: grid;
}

.records-tabs {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  gap: 4px;
  padding: 5px;
  overflow-x: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.records-tabs button {
  min-height: 38px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

.records-tabs button.active {
  color: #ffffff;
  background: var(--ink);
}

.record-panel {
  display: none;
  gap: 12px;
}

.record-panel.active {
  display: grid;
}

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

.record-card,
.simple-row {
  display: grid;
  gap: 12px;
  padding: 13px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.simple-row {
  gap: 0;
  cursor: pointer;
}

.clickable-card,
.simple-row {
  cursor: pointer;
}

.clickable-card:hover,
.simple-row:hover {
  border-color: #fca5a5;
  box-shadow: 0 16px 36px rgba(239, 68, 68, 0.1);
}

.record-head {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.record-head img,
.avatar {
  width: 52px;
  height: 52px;
  border-radius: 8px;
}

.record-head img {
  object-fit: cover;
  background: #eef3f5;
}

.avatar {
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--primary);
  font-weight: 950;
}

.record-card h3 {
  margin: 0;
  font-size: 1rem;
}

.simple-row h3 {
  margin: 0;
  font-size: 1rem;
}

.record-card p,
.simple-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.mini-grid span {
  display: grid;
  gap: 2px;
  padding: 9px;
  color: var(--muted);
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 850;
}

.mini-grid strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.read-only-list {
  display: grid;
  gap: 8px;
}

.read-only-row {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 11px 12px;
  text-align: left;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.read-only-row span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.read-only-row strong {
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.read-only-row:hover {
  background: #fff7f7;
  border-color: #fca5a5;
}

.empty {
  padding: 18px;
  color: var(--muted);
  background: #ffffff;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  font-weight: 850;
}

.bottom-tabs {
  position: fixed;
  right: 10px;
  bottom: 10px;
  left: 10px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 7px 7px calc(7px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 20px 54px rgba(23, 32, 38, 0.22);
  backdrop-filter: blur(18px);
}

.bottom-tabs a {
  display: grid;
  min-height: 54px;
  place-items: center;
  align-content: center;
  gap: 3px;
  color: var(--muted);
  border-radius: 12px;
  font-size: 0.73rem;
  font-weight: 950;
}

.bottom-tabs a.active {
  color: var(--primary);
  background: #fff1f2;
}

.bottom-tabs svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

@media (max-width: 820px) {
  .home-actions,
  .step-grid,
  .panel-grid,
  .record-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    justify-content: center;
  }

  main {
    padding: 12px 10px 28px;
  }

  .hero,
  .home-card,
  .step-card,
  .form-card,
  .record-card {
    padding: 12px;
  }

  .hero h1 {
    font-size: 2.1rem;
  }

  .split,
  .mini-grid {
    grid-template-columns: 1fr;
  }

  .stats {
    gap: 6px;
  }

  .store-tabs {
    width: 100%;
  }

  .store-tabs button {
    flex: 1;
  }

  .stats span {
    min-height: 58px;
    padding: 8px;
    font-size: 0.66rem;
  }

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

  .actions button,
  .actions .link-button {
    width: 100%;
  }

  .form-modal {
    align-items: end;
    padding: 8px;
  }

  .modal-panel {
    max-height: min(90vh, 760px);
    border-radius: 8px;
  }
}
