:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #697386;
  --line: #dfe4ea;
  --accent: #146c5d;
  --accent-2: #235789;
  --danger: #9d2b2b;
  --warn: #8a5d05;
  --shadow: 0 10px 28px rgba(21, 32, 43, .08);
  --bottom-nav-space: calc(76px + env(safe-area-inset-bottom));
  --fab-offset-bottom: calc(var(--bottom-nav-space) + 16px);
  --fab-offset-right: calc(16px + env(safe-area-inset-right));
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
button, input, textarea, select { font: inherit; }
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 42px;
  padding: 9px 12px;
}
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.ghost { background: transparent; }
.hidden { display: none !important; }
.app { max-width: 860px; margin: 0 auto; padding: 18px 14px calc(var(--bottom-nav-space) + 92px); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.topbar h1 { margin: 0; font-size: 26px; line-height: 1.15; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 13px; }
.icon-btn { width: 42px; min-width: 42px; padding: 0; font-size: 22px; line-height: 1; }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 14px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  min-height: 42px;
}
textarea { min-height: 96px; resize: vertical; }
.grid { display: grid; gap: 10px; }
.section { margin: 18px 0 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.section h2 { margin: 0; font-size: 18px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 13px;
}
.card h3 { margin: 0 0 8px; font-size: 17px; line-height: 1.25; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.pill { display: inline-flex; align-items: center; min-height: 26px; border-radius: 999px; border: 1px solid var(--line); padding: 3px 9px; color: var(--muted); background: #f9fafb; font-size: 13px; }
.pill.p1 { color: var(--danger); border-color: #efc6c6; background: #fff5f5; }
.pill.p2 { color: var(--warn); border-color: #ead39c; background: #fff9e8; }
.text { color: var(--muted); line-height: 1.42; margin: 6px 0; white-space: pre-line; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.actions a, .actions button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--text);
  background: #fff;
  padding: 8px;
  overflow-wrap: anywhere;
}
.actions a.primary { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.bottom-nav button { border: 0; background: transparent; color: var(--muted); border-radius: 8px; padding: 8px 4px; font-size: 12px; min-height: 44px; }
.bottom-nav button.active { color: #fff; background: var(--accent); }
.fab {
  position: fixed;
  right: var(--fab-offset-right);
  bottom: var(--fab-offset-bottom);
  z-index: 20;
  width: 58px;
  height: 58px;
  min-width: 58px;
  min-height: 58px;
  padding: 0;
  border-radius: 50%;
  border-color: #0f5f51;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 30px rgba(20, 108, 93, .34);
  font-size: 32px;
  line-height: 1;
}
.fab:active { transform: translateY(1px); }
.fab-actions {
  position: fixed;
  right: var(--fab-offset-right);
  bottom: calc(var(--fab-offset-bottom) + 70px);
  z-index: 21;
  display: grid;
  gap: 8px;
  width: min(250px, calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)));
}
.fab-actions button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  border-color: rgba(20, 108, 93, .22);
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--text);
  text-align: left;
}
.fab-actions button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.closed { min-height: 100vh; display: grid; place-content: center; text-align: center; padding: 24px; }
.closed h1 { margin: 0 0 8px; font-size: 26px; }
.closed p { color: var(--muted); margin: 0; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(380px, 100%);
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}
.login-card h1 { margin: 0; font-size: 28px; line-height: 1.15; }
.login-card button { width: 100%; }
.login-error { margin: -2px 0 0; color: var(--danger); line-height: 1.35; }
dialog { width: min(720px, calc(100vw - 18px)); border: 0; border-radius: 8px; padding: 0; }
dialog::backdrop { background: rgba(15, 23, 42, .42); }
.modal-card { padding: 14px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-body { display: grid; gap: 9px; margin: 12px 0; }
.form-grid { display: grid; gap: 9px; }
.field label { display: block; color: var(--muted); font-size: 13px; margin: 0 0 4px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0; margin: 12px 0 0; }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; }
.settings-list { display: grid; gap: 10px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
@media (min-width: 720px) {
  .app { padding-top: 28px; }
  .content.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
