:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --line: rgba(30, 41, 59, 0.12);
  --text: #0f172a;
  --muted: #475569;
  --brand: #0f172a;
  --brand-dark: #1e293b;
  --accent: #14b8a6;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app-shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 30px;
}

.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 12px;
  background: #ffffff;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

.nav {
  display: grid;
  gap: 12px;
  flex: 1 1 auto;
}

.nav-card {
  position: relative;
  display: block;
  text-decoration: none;
  color: var(--text);
  min-height: 164px;
  padding: 18px 18px;
  border-radius: 26px;
  background:
    radial-gradient(circle at 78% 24%, rgba(20, 184, 166, 0.18), transparent 32%),
    linear-gradient(160deg, #ffffff 0%, #f7fbff 100%);
  border: 1px solid rgba(20, 184, 166, 0.12);
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 12px 30px rgba(15, 23, 42, 0.06);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.nav-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.03), transparent 60%);
  pointer-events: none;
}

.nav-card:hover,
.nav-card.active {
  transform: translateY(-1px);
  border-color: rgba(20, 184, 166, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 18px 36px rgba(15, 23, 42, 0.1);
}

.nav-card.active {
  background:
    radial-gradient(circle at 78% 24%, rgba(20, 184, 166, 0.28), transparent 34%),
    linear-gradient(160deg, #effcfb 0%, #f6fffe 100%);
}

.nav-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.45)),
    rgba(20, 184, 166, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 8px 20px rgba(20, 184, 166, 0.12);
}

.nav-icon svg {
  width: 76px;
  height: 76px;
  stroke: var(--brand);
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.nav-card.active .nav-icon svg,
.nav-card:hover .nav-icon svg {
  stroke: var(--accent);
}

.nav-label {
  position: absolute;
  left: 18px;
  bottom: 18px;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  max-width: 160px;
  line-height: 1.05;
}

.content {
  padding: 28px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 28px;
  margin-bottom: 24px;
  border-radius: 26px;
  background: #fffaf6;
  box-shadow: var(--shadow);
}

.hero.slim {
  align-items: start;
}

.hero h1 {
  max-width: 900px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  font-weight: 700;
}

h1, h2 {
  margin: 0;
}

.lede {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.55;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

.button.primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #ffffff;
  border-color: transparent;
}

.logout-button {
  width: 100%;
  margin-top: 10px;
}

.metrics,
.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 20px;
}

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

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

.metric-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 20px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 10px;
}

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

.panel {
  padding: 22px;
}

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

.panel-head span {
  color: var(--muted);
  font-size: 0.9rem;
}

.chart-list {
  display: grid;
  gap: 14px;
}

.chart-row {
  display: grid;
  grid-template-columns: 210px 1fr 86px;
  gap: 12px;
  align-items: center;
}

.chart-label,
th,
td {
  font-size: 0.95rem;
}

.material-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.material-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.chart-bar {
  height: 12px;
  background: rgba(45, 36, 29, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.chart-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
}

.chart-bar.accent span {
  background: var(--accent);
}

.chart-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.chart-value.deficit {
  color: #b42318;
}

.table-wrap {
  overflow: auto;
}

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

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

.timeline {
  display: grid;
  gap: 14px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.timeline-date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.timeline-item p {
  margin: 6px 0 0;
  color: var(--muted);
}

.timeline-material {
  margin-top: 8px;
}

.timeline-qty {
  margin-left: 4px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.mini-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.department-cell {
  min-width: 220px;
}

.accordion-list {
  display: grid;
  gap: 10px;
}

.accordion-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffdfb;
  overflow: hidden;
}

.accordion-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.accordion-item summary::-webkit-details-marker {
  display: none;
}

.accordion-item summary::after {
  content: "+";
  margin-left: auto;
  color: var(--muted);
  font-size: 1.2rem;
}

.accordion-item[open] summary::after {
  content: "−";
}

.accordion-total {
  margin-left: 16px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.accordion-item .table-wrap {
  padding: 0 18px 14px;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.sidebar-user {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #ffffff;
}

.login-card {
  width: min(100%, 460px);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-card h1 {
  margin: 0 0 18px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-error {
  margin: 0;
  color: #b42318;
}

.login-button {
  width: 100%;
}

.form-panel {
  display: grid;
  gap: 20px;
}

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

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

.report-grid {
  align-items: end;
}

.report-actions {
  align-self: end;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

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

.qty-input {
  width: 100%;
  max-width: 180px;
}

.department-picker {
  position: relative;
}

.department-search {
  width: 100%;
}

.department-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

.department-dropdown[hidden] {
  display: none !important;
}

.department-option {
  width: 100%;
  display: block;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.department-option:hover,
.department-option:focus-visible {
  background: rgba(20, 184, 166, 0.08);
  outline: none;
}

.empty-table {
  color: var(--muted);
  text-align: center;
}

.material-form-list {
  display: grid;
  gap: 14px;
}

.material-form-head,
.material-form-row {
  display: grid;
  gap: 24px;
  align-items: center;
}

.material-form-head {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
  font-weight: 700;
}

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

.material-form-row {
  grid-template-columns: minmax(0, 1fr) 180px;
  padding: 14px 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
}

.material-form-name {
  min-width: 0;
}

.material-form-qty {
  display: flex;
  justify-content: flex-start;
}

@media (max-width: 1080px) {
  .app-shell,
  .metrics,
  .grid.two,
  .form-grid {
    grid-template-columns: 1fr;
  }

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

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

  .nav-card {
    min-height: 142px;
  }

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

  .nav-icon svg {
    width: 60px;
    height: 60px;
  }

  .chart-row {
    grid-template-columns: 1fr;
  }

  .material-form-head,
  .material-form-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .material-form-body {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .material-form-head {
    display: none;
  }

  .material-form-row {
    padding: 12px 0;
  }

  .hero {
    flex-direction: column;
    align-items: start;
  }
}

@media (max-width: 720px) {
  .nav {
    grid-template-columns: 1fr;
  }

  .nav-card {
    min-height: 132px;
  }

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

  .nav-icon svg {
    width: 56px;
    height: 56px;
  }
}
