:root {
  --bg: #f3f0e8;
  --bg2: #fffdf8;
  --ink: #1c2420;
  --muted: #5c6a63;
  --line: #d5d0c4;
  --brand: #1f6b4f;
  --brand-dark: #155239;
  --accent: #c45c26;
  --card: #ffffff;
  --ok: #1f6b4f;
  --warn: #a15c12;
  --danger: #9b2c2c;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(28, 36, 32, 0.08);
  --font: "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background:
    radial-gradient(circle at top left, #e7efe9 0%, transparent 40%),
    linear-gradient(180deg, #f7f4ec 0%, var(--bg) 100%);
  color: var(--ink);
  min-height: 100%;
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { max-width: 920px; margin: 0 auto; padding: 14px 14px 72px; }

.home-hero {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.home-hero img {
  width: 96px;
  height: auto;
  max-width: 32vw;
  max-height: 52px;
  flex: 0 0 auto;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
}
.home-hero > div { min-width: 0; flex: 1 1 auto; }
.home-hero h1 { margin: 0; font-size: clamp(1.05rem, 4.5vw, 1.35rem); line-height: 1.25; }
.home-hero .muted { margin: 4px 0 0; font-size: 0.85rem; }

.app-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255,253,248,0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.app-bar-brand {
  font-weight: 800; color: var(--brand-dark); font-size: 0.9rem; letter-spacing: 0.02em;
}
.app-bar-btn {
  border: 0; background: #e8efe9; color: var(--brand-dark);
  border-radius: 999px; padding: 10px 14px;
  font: inherit; font-weight: 700; cursor: pointer;
}
.app-bar-menu { background: var(--brand); color: #fff; }

.menu-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(28, 36, 32, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.menu-overlay[hidden] { display: none !important; }
.menu-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #fffdf8;
  border-radius: 18px 18px 0 0;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.menu-sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: #fffdf8; z-index: 1;
}
.menu-sheet-head strong { font-size: 1.05rem; }
.menu-sheet-body {
  padding: 8px 12px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0;
}
.menu-sheet-body a {
  display: block;
  width: 100%;
  padding: 14px 12px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}
.menu-sheet-body a:active,
.menu-sheet-body a:hover { background: #e8efe9; text-decoration: none; }
.menu-section {
  margin: 14px 12px 4px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.menu-logout { color: var(--danger) !important; }
body.menu-open { overflow: hidden; }

.btn.danger, button.danger {
  background: #fde8e8; color: var(--danger);
}


h1 { font-size: 1.45rem; margin: 0 0 8px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 0.92rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (min-width: 720px) {
  .grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card.stat {
  padding: 6px 8px;
  border-radius: 10px;
  box-shadow: none;
}
.stat .value { font-size: 1.5rem; font-weight: 800; color: var(--brand-dark); }
.stat .label { color: var(--muted); font-size: 0.82rem; }
.card.stat .value { font-size: 0.95rem; font-weight: 800; line-height: 1.2; }
.card.stat .label { font-size: 0.68rem; margin-top: 1px; }
.home-stats { margin: 10px 0 12px; gap: 6px; }

.nav-tiles a {
  display: block;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
}
.nav-tiles a:hover { text-decoration: none; background: #eef5f0; }
.nav-tiles a span {
  display: block;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 4px;
  line-height: 1.3;
}

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.list-item strong { display: block; }
.list-item .meta { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
}
textarea { min-height: 96px; resize: vertical; }

.btn, button {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--brand);
  color: white;
}
.btn.secondary, button.secondary {
  background: #e8efe9;
  color: var(--brand-dark);
}
.btn.full, button.full { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.error {
  background: #fde8e8;
  color: var(--danger);
  border: 1px solid #f2c2c2;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}
.ok {
  background: #e7f5ee;
  color: var(--ok);
  border: 1px solid #bfe0cd;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card { width: min(420px, 100%); }

.table-lite { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table-lite th, .table-lite td {
  text-align: left;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8efe9;
  color: var(--brand-dark);
  font-size: 0.75rem;
  font-weight: 700;
}
.badge.warn { background: #fff1d6; color: var(--warn); }

.section-card { margin: 12px 0; }
.section-card h2 { margin-bottom: 4px; }
.section-card > .muted { margin: 0 0 8px; }

.assistant-card { margin: 14px 0; }
.assistant-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.assistant-head h2 { margin: 0; }
.assistant-log {
  max-height: 320px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0 12px;
  padding: 4px 2px;
}
.assistant-msg { max-width: 95%; }
.assistant-msg.user { align-self: flex-end; }
.assistant-msg.assistant { align-self: flex-start; }
.assistant-role {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.assistant-bubble {
  background: #eef5f0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  white-space: pre-wrap;
  line-height: 1.4;
  font-size: 0.95rem;
}
.assistant-msg.user .assistant-bubble {
  background: #fff7ef;
  border-color: #e8d5c4;
}
.assistant-form textarea { min-height: 64px; }

