:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #dde3ea;
  --accent: #0b6b5f;
  --accent-dark: #084c44;
  --accent-soft: #e1f2ef;
  --danger: #b42318;
  --shadow: 0 12px 34px rgba(23, 32, 42, 0.08);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-width: 320px;
}

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

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px calc(116px + env(safe-area-inset-bottom));
}

.wide-shell {
  width: min(1500px, 100%);
}

.topbar,
.section-heading,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  margin-bottom: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 100;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: min(680px, calc(100% - 20px));
  margin: 0 auto;
  transform: translateX(-50%);
  padding: 8px;
  border: 1px solid rgba(221, 227, 234, 0.96);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 42px rgba(23, 32, 42, 0.18);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 58px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.nav-item.is-active {
  border-color: rgba(11, 107, 95, 0.16);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.nav-icon {
  position: relative;
  display: block;
  width: 22px;
  height: 22px;
}

.nav-icon::before,
.nav-icon::after {
  content: "";
  position: absolute;
  display: block;
}

.nav-icon-contacts::before {
  top: 2px;
  left: 7px;
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.nav-icon-contacts::after {
  left: 4px;
  bottom: 2px;
  width: 14px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 8px 8px 4px 4px;
}

.nav-icon-projects::before {
  inset: 3px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.nav-icon-projects::after {
  top: 8px;
  left: 8px;
  width: 6px;
  height: 6px;
  background: currentColor;
  box-shadow: -5px 0 0 currentColor, 5px 0 0 currentColor;
}

.nav-icon-products::before {
  left: 4px;
  top: 5px;
  width: 14px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.nav-icon-products::after {
  left: 7px;
  top: 2px;
  width: 8px;
  height: 6px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
}

.nav-icon-reports::before {
  left: 4px;
  bottom: 4px;
  width: 4px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: 7px -5px 0 currentColor, 14px -10px 0 currentColor;
}

.nav-icon-reports::after {
  left: 3px;
  right: 3px;
  bottom: 2px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.nav-icon-more::before {
  left: 2px;
  top: 9px;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 8px 0 0 currentColor, 16px 0 0 currentColor;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 9vw, 3.4rem);
}

h2 {
  font-size: 1.2rem;
}

.page-layout {
  display: grid;
  gap: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-panel,
.list-panel {
  padding: 16px;
}

.icon-button,
.primary-button,
.secondary-button,
.danger-button {
  min-height: 46px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  flex: 0 0 48px;
  background: var(--text);
  color: white;
  font-size: 1.6rem;
  line-height: 1;
}

.primary-button {
  background: var(--accent);
  color: white;
  padding: 0 20px;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: white;
  color: var(--text);
  border-color: var(--line);
  padding: 0 16px;
}

.danger-button {
  background: #fff4f2;
  border-color: #ffd2cc;
  color: var(--danger);
  padding: 0 16px;
}

.topbar-link {
  flex: 0 0 auto;
}

.score-pill,
.count-badge,
.price-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 38px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 900;
}

.price-preview {
  align-self: end;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f0f4f6;
}

.tab-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.tab-button.is-active {
  border-color: rgba(11, 107, 95, 0.16);
  background: white;
  color: var(--accent-dark);
  box-shadow: 0 5px 14px rgba(23, 32, 42, 0.06);
}

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

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

.history-note-box {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

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

label,
.search-field {
  display: grid;
  gap: 6px;
}

label span,
.search-field span,
.field-title {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  min-height: 46px;
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 107, 95, 0.14);
}

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px 12px;
}

summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  color: var(--text);
  font-weight: 900;
}

.toggle-grid {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.toggle-grid label {
  min-height: 44px;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  font-weight: 700;
}

.toggle-grid input {
  min-height: auto;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.field-title {
  margin: 14px 0 8px;
}

.single-field {
  margin-top: 2px;
}

.form-actions {
  position: sticky;
  bottom: calc(96px + env(safe-area-inset-bottom));
  padding-top: 8px;
  background: linear-gradient(rgba(255, 255, 255, 0), white 28%);
}

.search-field {
  margin: 14px 0;
}

.contacts-list,
.products-list,
.activities-list {
  display: grid;
  gap: 10px;
}

.contact-card,
.project-card,
.product-card {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 8px;
  padding: 12px;
}

.contact-card strong,
.project-card strong,
.product-card strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
}

.contact-card span,
.project-card span,
.product-card span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.filters-grid {
  display: grid;
  gap: 10px;
}

.reports-layout {
  width: 100%;
}

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

.report-metric {
  display: grid;
  gap: 5px;
  min-height: 116px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.report-metric span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.report-metric strong {
  font-size: 2.05rem;
  line-height: 1;
}

.report-metric small {
  color: var(--accent-dark);
  font-size: 0.94rem;
  font-weight: 900;
}

.reports-panel {
  overflow: hidden;
}

.report-chart {
  display: grid;
  grid-auto-columns: 124px;
  grid-auto-flow: column;
  gap: 10px;
  min-height: 330px;
  margin-top: 16px;
  overflow-x: auto;
  padding: 4px 2px 8px;
}

.report-bar-card {
  display: grid;
  grid-template-rows: minmax(180px, 1fr) auto;
  gap: 10px;
  min-width: 124px;
}

.report-bar-track {
  display: flex;
  align-items: flex-end;
  min-height: 180px;
  border-radius: 8px;
  background: #eef3f5;
  border: 1px solid var(--line);
  overflow: hidden;
}

.report-bar {
  width: 100%;
  min-height: 8px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #0b6b5f, #084c44);
}

.report-bar-info {
  display: grid;
  gap: 3px;
  min-height: 100px;
}

.report-bar-info strong {
  font-size: 1.45rem;
  line-height: 1;
}

.report-bar-info span {
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 850;
  line-height: 1.2;
}

.report-bar-info small {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
}

.product-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.product-card-main {
  min-width: 0;
}

.product-price {
  flex: 0 0 auto;
  color: var(--accent-dark);
  font-weight: 900;
}

.action-pair {
  display: flex;
  gap: 8px;
}

.activity-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

.activity-group {
  display: grid;
  gap: 8px;
}

.activity-group > summary {
  cursor: pointer;
  list-style: none;
}

.activity-group > summary::-webkit-details-marker {
  display: none;
}

.activity-group-items {
  display: grid;
  gap: 8px;
  padding-left: 16px;
  border-left: 2px solid var(--line);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  object-fit: cover;
  box-shadow: 0 0 0 2px white, 0 0 0 3px var(--line);
}

.activity-icon {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.activity-icon::before,
.activity-icon::after {
  content: "";
  position: absolute;
  display: block;
}

.activity-icon-contact::before {
  top: 7px;
  left: 12px;
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.activity-icon-contact::after {
  left: 8px;
  bottom: 7px;
  width: 16px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 8px 8px 4px 4px;
}

.activity-icon-project::before {
  inset: 8px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.activity-icon-project::after {
  top: 15px;
  left: 14px;
  width: 6px;
  height: 4px;
  background: currentColor;
  box-shadow: -6px 0 0 currentColor, 6px 0 0 currentColor;
}

.activity-icon-product::before {
  left: 8px;
  top: 11px;
  width: 18px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.activity-icon-product::after {
  left: 12px;
  top: 6px;
  width: 10px;
  height: 7px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
}

.activity-card time {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.activity-card strong {
  display: block;
  margin-bottom: 3px;
}

.activity-card span {
  display: block;
  color: var(--text);
  font-weight: 800;
}

.activity-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.compact-empty {
  padding: 12px;
  margin: 0;
}

.kanban-board {
  display: grid;
  gap: 12px;
}

.kanban-column {
  display: grid;
  gap: 10px;
  align-content: start;
  background: #eef3f5;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-height: 170px;
}

.kanban-column-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.kanban-column h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.kanban-column-head span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  border-radius: 999px;
  background: white;
  color: var(--muted);
  font-weight: 900;
}

.column-total {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.kanban-cards {
  display: grid;
  gap: 10px;
  min-height: 72px;
  border-radius: 8px;
}

.kanban-insert-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: rgba(225, 242, 239, 0.86);
  color: var(--accent-dark);
  font-size: 0.9rem;
  font-weight: 900;
}

.project-card {
  padding: 0;
  background: white;
}

.project-card.is-dragging {
  opacity: 0.72;
}

.project-card-drag-preview {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  transform: translate(-200vw, -200vh);
  box-shadow: 0 18px 36px rgba(23, 32, 42, 0.22);
  opacity: 1;
  pointer-events: none;
  will-change: transform;
}

.project-card a {
  display: block;
  padding: 12px 12px 8px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 10px;
}

.tag-row span {
  display: inline-flex;
  width: auto;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

@media (max-width: 420px) {
  .bottom-nav {
    gap: 4px;
    padding: 6px;
  }

  .nav-item {
    min-height: 54px;
    font-size: 0.68rem;
  }

  .nav-icon {
    width: 20px;
    height: 20px;
  }
}

@media (min-width: 680px) {
  .app-shell {
    padding: 24px 24px calc(126px + env(safe-area-inset-bottom));
  }

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

  .toggle-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .filters-grid {
    grid-template-columns: minmax(0, 1fr) 190px;
    align-items: end;
  }

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

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

@media (min-width: 980px) {
  .page-layout {
    width: min(760px, 100%);
    margin: 0 auto;
  }

  .reports-layout {
    width: min(980px, 100%);
  }

  .wide-shell {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: none;
    overflow: hidden;
  }

  .kanban-board {
    flex: 1;
    grid-auto-columns: 320px;
    grid-auto-flow: column;
    grid-template-columns: none;
    align-items: stretch;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 6px;
    scroll-padding-inline: 24px;
  }

  .kanban-column {
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100%;
    min-height: 0;
  }

  .kanban-cards {
    align-content: start;
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
  }
}
