:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --danger: #f87171;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: linear-gradient(160deg, #0b1220 0%, var(--bg) 40%, #111827 100%);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #334155;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--text);
}
.brand-logo {
  display: block;
  height: 28px;
  width: auto;
  flex-shrink: 0;
}
.brand:hover {
  text-decoration: none;
  color: var(--accent);
}
.brand:hover .brand-logo {
  filter: brightness(1.08);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.inline-form {
  display: inline;
  margin: 0;
}

.linkish {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.linkish:hover {
  text-decoration: underline;
}

/* Mobile bottom navigation (logged-in only; see layout.php) */
.nav-bottom {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  justify-content: stretch;
  align-items: stretch;
  padding: 0.3rem 0.35rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid #334155;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
}

.nav-bottom__link {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  text-align: center;
  padding: 0.35rem 0.15rem 0.45rem;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  line-height: 1.15;
  border-radius: 8px;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
}

.nav-bottom__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
}

.nav-bottom__svg {
  width: 1.4rem;
  height: 1.4rem;
  display: block;
}

.nav-bottom__logo {
  width: 1.45rem;
  height: 1.45rem;
  object-fit: contain;
  display: block;
}

.nav-bottom__link.is-active .nav-bottom__logo {
  filter: brightness(1.15);
}

.nav-bottom__link:hover {
  text-decoration: none;
  color: var(--text);
  background: rgba(56, 189, 248, 0.1);
}

.nav-bottom__link.is-active {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.14);
}

.nav-bottom__label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

@media (max-width: 767px) {
  body.logged-in {
    padding-bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
  }

  body.logged-in .nav-desktop-only {
    display: none !important;
  }

  body.logged-in .nav-bottom {
    display: flex;
  }
}

@media (min-width: 768px) {
  .nav-bottom {
    display: none !important;
  }
}

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem;
}

.foot {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  border: 1px solid #334155;
}

.card h1,
.card h2 {
  margin-top: 0;
  font-size: 1.25rem;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.err {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid var(--danger);
  color: #fecaca;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.ok {
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid #34d399;
  color: #a7f3d0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
textarea,
select {
  width: 100%;
  max-width: 420px;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  color: var(--text);
}

textarea {
  max-width: 100%;
  min-height: 80px;
}

.row {
  margin-bottom: 1rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 0;
  background: var(--accent);
  color: #0f172a;
  font-weight: 600;
  cursor: pointer;
}
.btn.secondary {
  background: #334155;
  color: var(--text);
}
.btn.danger {
  background: var(--danger);
  color: #1f2937;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data th,
table.data td {
  padding: 0.5rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid #334155;
}

table.data th {
  color: var(--muted);
  font-weight: 600;
}

.chart-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  max-height: min(380px, 50vh);
  margin-top: 0.5rem;
}

.chart-wrap canvas {
  display: block;
  max-width: 100%;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
