:root {
  --bg: #eef1ef;
  --bg-deep: #e4e9e6;
  --surface: #fbfcfb;
  --ink: #121614;
  --muted: #5f6b64;
  --line: rgba(18, 22, 20, 0.1);
  --accent: #145c45;
  --accent-2: #1f7a5c;
  --accent-soft: #d7ebe2;
  --danger: #8a3030;
  --shadow: 0 20px 48px rgba(18, 22, 20, 0.07);
  --radius: 20px;
  --font: "IBM Plex Sans", sans-serif;
  --display: "Fraunces", "IBM Plex Serif", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(20, 92, 69, 0.12), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(18, 22, 20, 0.05), transparent 50%),
    linear-gradient(180deg, #f5f7f6 0%, var(--bg) 45%, var(--bg-deep) 100%);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

#app {
  display: grid;
  grid-template-columns: 272px 1fr;
  min-height: 100vh;
  animation: fade-in 0.35s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes bar-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.sidebar {
  padding: 28px 18px;
  border-right: 1px solid var(--line);
  background: rgba(251, 252, 251, 0.78);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 10px;
}
.brand-mark {
  width: 46px;
  height: 46px;
  color: var(--accent);
}
.brand-mark svg, .auth-icon svg, .icon-btn svg, .nav-item svg, .stat-icon svg, .empty svg, .btn-ico svg {
  width: 100%;
  height: 100%;
  display: block;
}
.brand-title {
  font-family: var(--display);
  font-size: 23px;
  line-height: 1;
  letter-spacing: -0.02em;
}
.brand-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav { display: grid; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 11px 14px;
  border-radius: 14px;
  text-align: left;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.nav-item svg { width: 20px; height: 20px; flex: 0 0 auto; }
.nav-item:hover {
  background: rgba(20, 92, 69, 0.08);
  color: var(--ink);
  transform: translateX(2px);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
}
.user-chip {
  padding: 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.user-chip strong { display: block; margin-bottom: 4px; }
.user-chip span { color: var(--muted); font-size: 13px; }

.main { padding: 28px; }
.topbar {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 24px;
}
.topbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.icon-btn, .ghost-btn, .primary-btn, .soft-btn {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 14px;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover, .ghost-btn:hover, .soft-btn:hover, .primary-btn:hover {
  transform: translateY(-1px);
}
.icon-btn {
  width: 44px;
  height: 44px;
  padding: 10px;
  display: none;
}
.primary-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.soft-btn {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ghost-btn { background: transparent; }
.btn-ico { width: 16px; height: 16px; flex: 0 0 auto; }

.content { display: grid; gap: 18px; }
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(12, 1fr);
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  animation: rise 0.35s ease both;
}
.card:nth-child(2) { animation-delay: 0.04s; }
.card:nth-child(3) { animation-delay: 0.08s; }
.card:nth-child(4) { animation-delay: 0.12s; }
.card.span-3 { grid-column: span 3; }
.card.span-4 { grid-column: span 4; }
.card.span-5 { grid-column: span 5; }
.card.span-6 { grid-column: span 6; }
.card.span-7 { grid-column: span 7; }
.card.span-8 { grid-column: span 8; }
.card.span-12 { grid-column: span 12; }

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 10px;
}
.stat-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat-value {
  font-family: var(--display);
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.section-title h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title h2 .btn-ico {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: rgba(20, 92, 69, 0.45);
  box-shadow: 0 0 0 3px rgba(20, 92, 69, 0.12);
}
.field textarea { min-height: 96px; resize: vertical; }

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 500; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-deep);
  font-size: 12px;
}
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: #efe4d2; color: #6f4a16; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.empty {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 36px 16px;
  color: var(--muted);
  text-align: center;
}
.empty svg { width: 48px; height: 48px; opacity: 0.7; }

.auth-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(20, 92, 69, 0.14), transparent 42%),
    #e8eeea;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  text-align: center;
  animation: rise 0.4s ease;
}
.auth-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  color: var(--accent);
}
.auth-card h2 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: -0.03em;
}
.auth-card p { color: var(--muted); line-height: 1.5; }
.auth-card .primary-btn { width: 100%; margin-top: 8px; justify-content: center; }
.muted { color: var(--muted); font-size: 13px; }
.auth-error {
  color: var(--danger);
  font-size: 14px;
  line-height: 1.4;
  min-height: 1.2em;
  margin: 12px 0 0;
  font-weight: 500;
}
.loading-state, .error-state {
  padding: 28px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.error-state { color: var(--danger); }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; gap: 6px; }
.bar-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-deep);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit;
  animation: bar-grow 0.55s ease both;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  min-width: 220px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: #f5f7f6;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: rise 0.25s ease;
}
.toast.error { background: var(--danger); }
.toast svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }

.export-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.export-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: #fff;
  text-align: left;
  color: var(--ink);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.export-card:hover {
  border-color: rgba(20, 92, 69, 0.35);
  transform: translateY(-2px);
}
.export-card .btn-ico {
  width: 28px;
  height: 28px;
  color: var(--accent);
  margin-bottom: 12px;
}
.export-card strong { display: block; margin-bottom: 4px; }
.export-card span { color: var(--muted); font-size: 13px; }

@media (max-width: 1100px) {
  .export-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    z-index: 20;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .icon-btn { display: inline-flex; }
  .card.span-3, .card.span-4, .card.span-5, .card.span-6, .card.span-7, .card.span-8, .card.span-12 {
    grid-column: span 12;
  }
  .form-grid { grid-template-columns: 1fr; }
  .main { padding: 18px; }
  .topbar h1 { font-size: 28px; }
  .export-grid { grid-template-columns: 1fr; }
}
