:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --line: #e4e7ec;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --text: #1c2430;
  --muted: #667085;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.app { max-width: 520px; margin: 0 auto; padding: 88px 20px 100px; }
body.is-app .app { padding-top: calc(16px + env(safe-area-inset-top)); }
body.is-web .app { padding-bottom: 32px; }

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
body.is-app .topbar { display: none; }
.brand { display: flex; align-items: center; text-decoration: none; }
.brand img { width: clamp(72px, 12vw, 120px); height: auto; }
.top-nav { display: flex; justify-content: center; gap: 2px; }
.top-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 8px;
}
.top-nav a.active { color: var(--text); background: var(--accent-soft); }
.top-nav a:hover { color: var(--text); }
.user-bar { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.icon-btn, .menu-btn {
  width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); cursor: pointer;
}
.menu-btn { display: none; font-size: 18px; }
@media (max-width: 800px) {
  .menu-btn { display: inline-flex; }
  .top-nav {
    display: none;
    position: absolute;
    top: 64px; left: 0; right: 0;
    flex-direction: column;
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 8px;
    z-index: 30;
  }
  .top-nav.open { display: flex; }
  .top-nav a { padding: 12px; }
  .user-bar span { display: none; }
  .icon-btn, .menu-btn { width: 36px; height: 36px; }
}

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: none; justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line); z-index: 20;
}
body.is-app .bottom-nav, body.is-mobile .bottom-nav { display: flex; }
.bottom-nav a { color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500; padding: 8px 12px; }
.bottom-nav a.active { color: var(--accent); }

h1 { font-size: 1.5rem; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 0.95rem; font-weight: 600; margin: 14px 0 8px; }
.role { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin: 0 0 4px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}
label { font-size: 13px; color: var(--muted); font-weight: 500; }
.field, select, input[type=number], input[type=date], input[type=text], input[type=password], input[type=email] {
  width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); padding: 10px 12px; margin: 4px 0 12px; font-size: 14px; font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 10px 14px; font-weight: 600; font-size: 14px; font-family: inherit;
  cursor: pointer; width: 100%; margin-top: 4px;
}
button:hover { background: #1d4ed8; }
button.secondary { background: #fff; border: 1px solid var(--line); color: var(--text); }
button.secondary:hover { background: var(--panel-2); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; background: var(--panel-2); color: var(--muted); }
.chip.day { background: #dbeafe; color: #1d4ed8; }
.chip.night { background: #e5e7eb; color: #374151; }
.row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.row:last-child { border-bottom: none; }
.error { color: #dc2626; font-size: 13px; margin: 8px 0; }
.notice { color: #059669; font-size: 13px; margin: 8px 0; }
.plant-card {
  display: block; width: 100%; text-align: left; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 8px 0;
  color: var(--text); font-family: inherit; cursor: pointer;
}
.plant-card:hover { border-color: var(--accent); }
.cal { display: grid; grid-template-columns: repeat(7,1fr); gap: 4px; margin: 12px 0; }
.cal-head { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; font-weight: 500; }
.cal-day {
  position: relative; aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; cursor: pointer; background: #fff;
}
.cal-day .n { font-weight: 600; font-size: 13px; }
.cal-day.D { background: #dbeafe; border-color: #93c5fd; }
.cal-day.N { background: #e5e7eb; border-color: #d1d5db; }
.cal-day.- { background: var(--panel-2); }
.cal-day.empty { background: transparent; border: none; cursor: default; }
.cal-day.selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-day .crews { position: absolute; bottom: 2px; right: 3px; font-size: 8px; font-weight: 600; }
.crew-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.crew-tabs button { width: auto; padding: 6px 12px; font-size: 13px; background: #fff; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; }
.crew-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.schedule-layout { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 720px) { .app { max-width: 880px; } .schedule-layout { grid-template-columns: 1.2fr 0.8fr; align-items: start; } }
.day-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.person-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 8px 0; }
.person-name { font-weight: 600; }
.person-meta { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.hint { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.landing { text-align: center; padding: 32px 8px 10px; }
.landing-logo { width: clamp(120px, 24vw, 200px); height: auto; }
.landing-sub { color: var(--muted); margin: 8px auto 20px; max-width: 360px; }
.btn { display: block; background: var(--accent); color: #fff; text-decoration: none; border-radius: 8px; padding: 12px; font-weight: 600; margin: 8px 0; }
.btn.secondary { background: #fff; border: 1px solid var(--line); color: var(--text); }
.back { color: var(--muted); text-decoration: none; font-size: 13px; }
.auth-links { display: flex; gap: 12px; justify-content: center; margin-top: 12px; font-size: 13px; }
.auth-links a { color: var(--accent); }
.chat-panel { max-height: 420px; overflow-y: auto; }
.msg { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.msg.mine { border-color: #bfdbfe; background: var(--accent-soft); }
.msg-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.msg-body { font-size: 14px; }

.modal-back {
  position: fixed; inset: 0; background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal {
  background: #fff; border-radius: 12px; padding: 16px; width: 100%; max-width: 420px;
  border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0,0,0,.15);
}
