:root {
  --bg: #f2efe8;
  --panel: rgba(255, 250, 244, 0.88);
  --panel-strong: #fffaf4;
  --text: #1f1a17;
  --muted: #6b625b;
  --line: rgba(79, 60, 45, 0.12);
  --primary: #c8643b;
  --primary-strong: #ab4d27;
  --accent: #1b8f75;
  --accent-soft: rgba(27, 143, 117, 0.12);
  --danger: #cf4a3c;
  --warning: #d08f22;
  --info: #3c78cf;
  --shadow: 0 18px 42px rgba(84, 57, 34, 0.14);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Plus Jakarta Sans", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(200, 100, 59, 0.16), transparent 22%),
    radial-gradient(circle at bottom right, rgba(27, 143, 117, 0.14), transparent 24%),
    linear-gradient(180deg, #fffbf6 0%, var(--bg) 100%);
}

button, input, select, textarea { font: inherit; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { font-family: "Space Grotesk", sans-serif; }

.login-screen,
.app-shell {
  min-height: 100vh;
}

.app-hidden { display: none !important; }

body.app-ready #login-screen,
#login-screen[hidden] {
  display: none !important;
}

body.app-ready #app-shell,
#app-shell:not([hidden]) {
  display: grid;
}

#app-shell[hidden] {
  display: none !important;
}

.login-screen {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card,
.sidebar-card,
.panel,
.stat-card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(760px, 100%);
  padding: 28px;
}

.login-copy {
  margin-bottom: 18px;
  color: var(--muted);
  max-width: 54ch;
}

.compact-form { gap: 14px; }

.app-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
}

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 247, 239, 0.8);
  backdrop-filter: blur(18px);
}

.brand,
.panel-header,
.topbar,
.modal-header,
.movement-line,
.timeline-item,
.report-line,
.card-header,
.assignment-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  align-items: flex-start;
  margin-bottom: 28px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #ef8b63);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-links { display: grid; gap: 10px; }

.nav-link,
.primary-button,
.ghost-button,
.text-button,
.icon-button,
.mini-button {
  border: 0;
  cursor: pointer;
  transition: 180ms ease;
}

.nav-link {
  padding: 14px 16px;
  border-radius: 16px;
  background: transparent;
  text-align: left;
  color: var(--text);
}

.nav-link:hover,
.nav-link.is-active {
  background: rgba(200, 100, 59, 0.1);
  color: var(--primary-strong);
}

.sidebar-card { margin-top: 28px; padding: 18px; }
.sidebar-note, .helper-text, .muted { color: var(--muted); font-size: 0.92rem; }
.full-width { width: 100%; }

.main-content { padding: 24px; }
.topbar { align-items: flex-start; margin-bottom: 24px; }
.topbar-actions, .pill-row, .price-grid, .card-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.primary-button,
.ghost-button,
.mini-button {
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 700;
}

.primary-button { background: var(--primary); color: white; }
.primary-button:hover { background: var(--primary-strong); }
.primary-button.accent { background: var(--accent); }
.ghost-button, .icon-button, .mini-button { background: rgba(31, 26, 23, 0.06); color: var(--text); }
.text-button { background: transparent; color: var(--primary-strong); font-weight: 700; }
.icon-button { border-radius: 12px; padding: 10px 12px; }
.mini-button { padding: 9px 12px; font-size: 0.88rem; }

.view { display: none; }
.view.is-active { display: block; }

.stats-grid,
.dashboard-grid,
.reports-grid,
.settings-grid,
.movement-layout,
.cards-grid,
.products-grid {
  display: grid;
  gap: 18px;
}

.stats-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 18px; }
.dashboard-grid,
.settings-grid { grid-template-columns: 1.15fr 0.85fr; }
.reports-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.movement-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.products-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel, .stat-card { padding: 22px; }
.stat-value { font-size: 1.85rem; font-weight: 800; }
.panel-header { margin-bottom: 18px; }
.timeline, .report-list, .tool-list { display: grid; gap: 12px; }

.timeline-item,
.report-line,
.service-card,
.client-card,
.product-card,
.tool-card {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
}

.product-card {
  overflow: hidden;
  padding: 0;
}

.product-photo {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: linear-gradient(135deg, rgba(200, 100, 59, 0.18), rgba(27, 143, 117, 0.12));
}

.product-card-body,
.client-card,
.service-card {
  display: grid;
  gap: 14px;
}

.product-card-body { padding: 18px; }

.pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.pill { background: rgba(31, 26, 23, 0.06); }
.badge { background: var(--accent-soft); color: var(--accent); }
.badge.warning { background: rgba(208, 143, 34, 0.12); color: #98640c; }
.badge.danger { background: rgba(207, 74, 60, 0.12); color: var(--danger); }
.badge.info { background: rgba(60, 120, 207, 0.12); color: var(--info); }

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

.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 8px; }
.field label { font-weight: 700; }

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
}

textarea { min-height: 110px; resize: vertical; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 0.84rem; }
.settings-copy ul { padding-left: 18px; color: var(--muted); }
.settings-copy { display: grid; gap: 14px; }

.filters { display: grid; gap: 14px; }
.three-columns { grid-template-columns: 2fr 1fr 1fr; }
.four-columns { grid-template-columns: 2fr 1fr 1fr 1fr; }
.five-columns { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.modal {
  width: min(860px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  border-radius: 26px;
  background: transparent;
}

.modal::backdrop {
  background: rgba(27, 18, 12, 0.42);
  backdrop-filter: blur(8px);
}

.modal-card {
  border-radius: 26px;
  background: var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
}

.modal-header, .modal-body { padding: 22px; }

.empty-state {
  padding: 28px;
  border-radius: 20px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.44);
  border: 1px dashed var(--line);
}

.service-meta,
.client-metrics {
  display: grid;
  gap: 8px;
}

.assignment-line {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(31, 26, 23, 0.04);
}

@media (max-width: 1180px) {
  .app-shell,
  .dashboard-grid,
  .reports-grid,
  .settings-grid,
  .movement-layout,
  .stats-grid,
  .cards-grid,
  .products-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar, .main-content, .login-screen { padding: 18px; }
  .topbar, .panel-header.stack-mobile, .filters, .form-grid {
    display: grid;
    grid-template-columns: 1fr;
  }
  .topbar-actions button, .card-actions button { flex: 1 1 100%; }
}
