*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: #F5F6F4; color: #111827; -webkit-font-smoothing: antialiased;
  font-size: 14px; overflow: hidden;
}
#app { height: 100%; display: flex; flex-direction: column; min-height: 0; }
:root {
  --brand: #F0AF02; --brand-light: #FFD24D; --brand-dark: #C99202;
  --ink: #0b1220; --muted: #6b7280; --line: #e5e7eb; --bg: #F5F6F4;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

.appbar {
  flex-shrink: 0; display: flex; align-items: center; gap: 12px;
  padding: calc(12px + var(--safe-t)) 16px 12px; background: #fff;
  box-shadow: 0 1px 0 rgba(15,23,42,0.05); z-index: 10;
}
.appbar .brand {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color: #000; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.appbar .titles { flex: 1; min-width: 0; line-height: 1.15; }
.appbar .titles h1 { margin: 0; font-size: 17px; font-weight: 800; }
.appbar .titles .sub { font-size: 11px; color: var(--muted); font-weight: 500; }
.icon-btn {
  background: var(--bg); color: var(--muted); border: none; border-radius: 10px;
  width: 36px; height: 36px; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center;
}
.icon-btn.danger { color: #dc2626; }

.content {
  flex: 1 1 0; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); padding: 12px 12px calc(24px + var(--safe-b));
}

.card {
  background: #fff; border-radius: 16px; padding: 16px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 4px 14px rgba(15,23,42,0.04);
  margin-bottom: 12px;
}
.card h2 { margin: 0 0 12px; font-size: 14px; font-weight: 800; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px;
  background: #FFF7E0; color: var(--brand-dark);
}

.fieldgroup { margin-bottom: 12px; }
.fieldgroup label {
  display: block; font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px;
}
.field, select.field, textarea.field {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  font: inherit; background: var(--bg); color: var(--ink);
}
.field:focus, select.field:focus, textarea.field:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(240,175,2,.18); background: #fff;
}
textarea.field { min-height: 90px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 8px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip.on { background: #FFF7E0; border-color: var(--brand); color: var(--brand-dark); }

.btn-primary {
  width: 100%; border: none; border-radius: 14px; padding: 14px 18px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #0b1220; font: inherit; font-weight: 800; cursor: pointer;
}
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost {
  width: 100%; border: none; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; padding: 12px; cursor: pointer; margin-top: 8px;
}
.err { color: #b91c1c; font-size: 13px; margin-top: 10px; }
.ok { color: #059669; font-size: 13px; margin-top: 10px; }
.muted { color: var(--muted); font-size: 13px; }
.spinner {
  width: 34px; height: 34px; margin: 64px auto; display: block;
  border: 3px solid #e5e7eb; border-top-color: var(--brand); border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
}
.login-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 28px 22px;
  box-shadow: 0 8px 30px rgba(15,23,42,0.08);
}
.brand-big {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 22px;
}
.login-card h2 { text-align: center; margin: 0 0 8px; font-size: 22px; }
.login-card p { text-align: center; color: var(--muted); margin: 0 0 18px; font-size: 13px; }
.login-card label { display: block; font-size: 12px; font-weight: 700; margin: 12px 0 6px; }
