:root {
  --bg: #f3eee8;
  --surface: rgba(255, 255, 255, 0.74);
  --surface-strong: #fffdf9;
  --line: rgba(61, 79, 69, 0.1);
  --text: #3d4f45;
  --muted: #5d7c69;
  --accent: #5d7c69;
  --accent-dark: #4a6657;
  --accent-light: #8aa896;
  --warn: #d97706;
  --danger: #c2410c;
  --shadow: 0 20px 50px rgba(93, 124, 105, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background: #f3eee8;
}

.site-header {
  background: linear-gradient(135deg, #5d7c69 0%, #4a6657 100%);
  color: white;
  padding: 16px 0;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(93,124,105,0.3);
}

.site-header .container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-header .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  text-decoration: none;
}

.site-header .logo-icon {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.site-header .logo-text h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.site-header .logo-text p {
  margin: 0;
  font-size: 12px;
  opacity: 0.8;
}

.site-header nav {
  display: flex;
  gap: 20px;
}

.site-header nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: color 0.2s;
}

.site-header nav a:hover {
  color: white;
}

.app-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 24px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(145deg, rgba(255, 253, 249, 0.92), rgba(255, 255, 255, 0.68));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.hero h1,
.section-header h2 {
  margin: 0;
  line-height: 1.05;
}

.hero h1 {
  max-width: 10ch;
  font-size: clamp(2.5rem, 4vw, 4.8rem);
}

.hero-text {
  max-width: 64ch;
  font-size: 1.02rem;
  color: var(--muted);
}

.hero-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.primary-btn,
.secondary-btn,
.nav-btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover,
.secondary-btn:hover,
.nav-btn:hover {
  transform: translateY(-1px);
}

.secondary-btn {
  background: rgba(12, 124, 89, 0.09);
  color: var(--accent-dark);
}

.hero-panel,
.dashboard-grid,
.cards-grid,
.form-grid,
.layout {
  display: grid;
}

.hero-panel {
  gap: 14px;
}

.metric-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(12, 124, 89, 0.1);
}

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

.metric-card strong {
  font-size: 2rem;
}

.layout {
  grid-template-columns: 240px 1fr;
  gap: 20px;
  margin-top: 22px;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.nav-btn {
  text-align: left;
  background: transparent;
  color: var(--text);
}

.nav-btn.active {
  background: var(--text);
  color: #fff;
}

.content {
  min-width: 0;
}

.route {
  display: none;
}

.route.active {
  display: block;
  animation: fade-in 0.35s ease;
}

.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.dashboard-grid {
  grid-template-columns: 1.25fr 0.95fr;
  gap: 18px;
}

.panel {
  padding: 22px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.wide-panel {
  grid-row: span 2;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}

.panel-head h3,
.machine-card h3,
.history-card h3,
.empty-state h3 {
  margin: 0;
}

.panel-head span,
.meta,
.empty-state p {
  color: var(--muted);
}

.stack-list,
.history-list {
  display: grid;
  gap: 12px;
}

.priority-item,
.machine-card,
.history-card,
.alert-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(31, 41, 51, 0.08);
}

.priority-item {
  display: grid;
  gap: 8px;
}

.status-row,
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.badge.ok {
  background: rgba(12, 124, 89, 0.12);
  color: var(--accent-dark);
}

.badge.watch {
  background: rgba(217, 119, 6, 0.16);
  color: #9a3412;
}

.badge.critical {
  background: rgba(194, 65, 12, 0.15);
  color: var(--danger);
}

.cards-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.machine-card {
  display: grid;
  gap: 10px;
}

.machine-card a {
  color: var(--accent-dark);
  word-break: break-all;
}

.inspection-form,
.form-card {
  margin-bottom: 18px;
}

.hidden {
  display: none;
}

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

label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

label span {
  font-size: 0.92rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(31, 41, 51, 0.15);
  border-radius: 16px;
  padding: 13px 14px;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.88);
}

textarea {
  resize: vertical;
}

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

.history-card,
.alert-card {
  display: grid;
  gap: 10px;
}

.topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.empty-state {
  padding: 28px;
  text-align: center;
  border: 1px dashed rgba(31, 41, 51, 0.18);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.5);
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .hero,
  .layout,
  .dashboard-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    flex-direction: row;
    overflow-x: auto;
  }

  .nav-btn {
    white-space: nowrap;
  }

  .wide-panel {
    grid-row: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 100%);
    margin: 10px auto 28px;
  }

  .hero,
  .panel {
    padding: 18px;
  }

  .hero h1 {
    max-width: 100%;
    font-size: 2.3rem;
  }

  .section-header,
  .topline {
    align-items: start;
    flex-direction: column;
  }
}
