@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --bg: #f5f7f2;
  --card: #ffffff;
  --accent: #16a34a;
  --accent-d: #166534;
  --accent-l: #bbf7d0;
  --amber: #fef3c7;
  --amber-d: #d97706;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-g: #86efac;
  --danger: #dc2626;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}

.app-wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px;
}

.page-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.page-title {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: clamp(1.9rem, 3.2vw, 2.85rem);
  line-height: 1.05;
}

.page-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.nav-tab {
  display: inline-block;
  text-decoration: none;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
  transition: border-color .15s, color .15s, background .15s;
}

.nav-tab:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.nav-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.04);
}

.card + .card {
  margin-top: 14px;
}

.section-title {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.alert {
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 0.88rem;
}

.alert-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.field {
  margin-bottom: 10px;
}

.label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #dcfce7;
  border-color: var(--line-g);
}

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

.row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.row-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  transition: transform .05s ease, background .15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

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

.btn-primary:hover {
  background: var(--accent-d);
}

.btn-soft {
  background: var(--accent-l);
  color: var(--accent-d);
}

.btn-soft:hover {
  background: #a7f3c0;
}

.btn-danger {
  background: #fee2e2;
  color: #991b1b;
}

.btn-ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
}

.btn-small {
  padding: 6px 10px;
  font-size: 0.82rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}

.stat b {
  font-family: 'Fraunces', serif;
  font-size: 1.35rem;
  line-height: 1;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 4px;
}

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

th,
td {
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.86rem;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.link:hover {
  text-decoration: underline;
}

.text-muted {
  color: var(--muted);
}

.text-danger {
  color: var(--danger);
}

.text-right {
  text-align: right;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: 700;
}

.badge-ok {
  background: var(--accent-l);
  color: var(--accent-d);
}

.badge-warn {
  background: var(--amber);
  color: var(--amber-d);
}

.badge-miss {
  background: #fee2e2;
  color: #991b1b;
}

.badge-soft {
  background: #f1f5f9;
  color: #334155;
}

.table-wrap {
  overflow-x: auto;
}

.grid-main {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 14px;
}

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

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 700px) {
  .app-wrap {
    padding: 14px;
  }

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

  .stats-grid,
  .row-4,
  .row-3,
  .row-2 {
    grid-template-columns: 1fr;
  }
}

/* ── APP NAV (dark sticky shell, shared across all authenticated pages) ── */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(13,17,23,0.94);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
}

.app-nav-logo {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  color: #e6edf3;
  text-decoration: none;
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
}

.app-nav-logo em {
  color: #52b788;
  font-style: normal;
}

.app-nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.app-nav-links::-webkit-scrollbar { display: none; }

.app-nav-link {
  color: #7d8590;
  text-decoration: none;
  font-size: 0.84rem;
  padding: 5px 11px;
  border-radius: 7px;
  transition: color .15s, background .15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.app-nav-link:hover {
  color: #e6edf3;
  background: rgba(255,255,255,0.07);
}

.app-nav-link.active {
  color: #e6edf3;
  background: rgba(255,255,255,0.1);
  font-weight: 600;
}

.app-nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.app-nav-logout {
  background: rgba(220,38,38,0.1);
  color: #f87171;
  text-decoration: none;
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid rgba(220,38,38,0.2);
  transition: background .15s;
  white-space: nowrap;
}

.app-nav-logout:hover {
  background: rgba(220,38,38,0.22);
}

@media (max-width: 700px) {
  .app-nav { padding: 0 12px; gap: 8px; }
  .app-nav-link { padding: 5px 8px; font-size: 0.8rem; }
}
