:root {
  --coral: #FF6F61;
  --blue: #A8D8EA;
  --yellow: #FFD166;
  --deep-coral: #E85A4F;
  --soft: #FFF7F5;
  --ink: #2E2E2E;
  --muted: #6f6664;
  --line: #f0ded9;
  --surface: #ffffff;
  --shadow: 0 18px 50px rgba(46, 46, 46, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  overflow-x: hidden;
  background: var(--soft);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea,
a.sheet-link {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 0.7rem 0.9rem;
  font: inherit;
  font-weight: 800;
}

button {
  cursor: pointer;
  color: #fff;
  background: var(--coral);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

button:hover,
a.sheet-link:hover {
  filter: brightness(0.98);
}

button.secondary,
a.sheet-link {
  color: var(--ink);
  background: var(--blue);
}

button.danger {
  color: #fff;
  background: #B42318;
}

a.sheet-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 650;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

.hidden {
  display: none;
}

.sidebar {
  min-height: 100vh;
  padding: 1.2rem;
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
}

.brand-logo {
  width: 76px;
  height: 76px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: #fff url("/brand-logo.png") center/82% no-repeat;
  box-shadow: 0 12px 34px rgba(255, 111, 97, 0.35), 0 0 0 5px rgba(255, 209, 102, 0.18);
}

.sidebar h1 {
  margin: 1rem 0 0.2rem;
}

.sidebar p {
  margin-top: 0;
  color: #f3d9d4;
}

nav {
  display: grid;
  gap: 0.45rem;
  margin-top: 1.2rem;
}

nav button {
  text-align: left;
  color: #fff;
  background: transparent;
  border: 1px solid transparent;
}

nav button.active {
  background: #3f3f3f;
  border-color: var(--coral);
}

main {
  min-width: 0;
  padding: 1.4rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.topbar h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--coral);
  font-weight: 950;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.status {
  margin-bottom: 1rem;
}

.notice {
  border: 1px solid #f2ce75;
  border-radius: 8px;
  background: #fff7df;
  color: #644b12;
  padding: 0.85rem;
}

.error {
  border-color: #ffc9c2;
  background: #fff0ee;
  color: #8f241a;
}

.grid {
  display: grid;
  gap: 1rem;
}

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

.grid.two {
  grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr);
}

.dashboard-grid,
.dashboard-wide {
  margin-top: 1rem;
}

.card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.action-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(0, 1.25fr);
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  border-color: rgba(255, 111, 97, 0.32);
  background: linear-gradient(135deg, #ffffff 0%, #fff7f5 72%, #fff2da 100%);
}

.action-panel h3 {
  margin: 0.15rem 0 0.35rem;
  font-size: 1.35rem;
}

.action-panel p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.55rem;
}

.quick-action {
  min-height: 84px;
  display: grid;
  align-content: center;
  gap: 0.22rem;
  padding: 0.7rem;
  text-align: left;
  line-height: 1.15;
}

.quick-action strong,
.quick-action small {
  display: block;
  min-width: 0;
}

.quick-action small {
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.76rem;
  font-weight: 750;
}

.quick-action.secondary small {
  color: rgba(46, 46, 46, 0.7);
}

.record-list {
  display: grid;
  gap: 0.7rem;
}

.record-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfb;
}

.record-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.75rem;
}

.record-card strong,
.record-card span,
.record-card small {
  display: block;
}

.record-card span {
  margin-top: 0.2rem;
  color: var(--muted);
}

.record-card small {
  margin-top: 0.25rem;
  color: var(--ink);
  font-weight: 800;
}

.record-card.low-stock {
  border-color: #f4bb49;
  background: #fff8e5;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.card-actions button {
  min-height: 36px;
  padding: 0.55rem 0.7rem;
  white-space: nowrap;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.product-thumb {
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff7f5;
  object-fit: cover;
}

.product-thumb.empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-align: center;
}

.photo-preview {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--muted);
  font-weight: 850;
}

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

.metric strong {
  display: block;
  margin-top: 0.25rem;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
}

.compact-list {
  display: grid;
  gap: 0.65rem;
}

.compact-row {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}

.compact-row span {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.55rem;
}

.compact-row b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-row small {
  color: var(--muted);
  font-weight: 850;
  text-align: right;
}

.alert-pill {
  margin: 0.2rem 0.2rem 0.2rem 0;
}

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

form {
  display: grid;
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-weight: 850;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: 0.85rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.stage {
  min-height: 420px;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stage header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.65rem;
  margin-bottom: 0.7rem;
}

.stage h3 {
  margin: 0;
}

.deal-card,
.lead-card {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
}

.deal-card span,
.lead-card span,
.muted {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 0.55rem;
  color: var(--ink);
  background: var(--yellow);
  font-weight: 950;
  font-size: 0.78rem;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.8rem 0.65rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

@media (max-width: 920px) {
  body {
    display: block;
  }

  .sidebar {
    min-height: auto;
    position: static;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.5rem 0.85rem;
    padding: 0.85rem;
  }

  .brand-logo {
    width: 54px;
    height: 54px;
    grid-row: span 2;
  }

  .sidebar h1 {
    margin: 0;
    font-size: 1.2rem;
  }

  .sidebar p {
    margin: 0;
    font-size: 0.88rem;
  }

  nav {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.45rem;
    overflow-x: auto;
    padding-bottom: 0.2rem;
    scrollbar-width: thin;
  }

  nav button {
    min-width: 118px;
    text-align: center;
    white-space: nowrap;
  }

  main {
    padding: 0.85rem;
  }

  .topbar {
    flex-direction: column;
    gap: 0.75rem;
  }

  .topbar h2 {
    font-size: 1.65rem;
  }

  .top-actions {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .top-actions > * {
    justify-content: center;
    text-align: center;
  }

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

  .action-panel {
    grid-template-columns: 1fr;
  }

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

  .card {
    padding: 0.85rem;
    box-shadow: 0 10px 24px rgba(46, 46, 46, 0.08);
  }

  .pipeline {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  .stage {
    min-width: 82vw;
    scroll-snap-align: start;
  }

  .record-card {
    grid-template-columns: 1fr;
  }

  .record-main,
  .compact-row,
  .compact-row span {
    align-items: flex-start;
  }

  .compact-row {
    flex-direction: column;
  }

  .compact-row small {
    text-align: left;
  }

  .card-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
  }

  .card-actions button {
    width: 100%;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }
}

@media (max-width: 520px) {
  .top-actions,
  .quick-actions,
  .card-actions,
  .form-actions {
    grid-template-columns: 1fr;
  }

  button,
  input,
  select,
  textarea,
  a.sheet-link {
    width: 100%;
  }
}
