:root {
  --navy: #0b1e3b;
  --navy-deep: #071428;
  --navy-soft: #143056;
  --gold: #d49b35;
  --gold-bright: #ffb800;
  --gold-soft: #f0d28a;
  --bg: #eef1f5;
  --bg-elev: #ffffff;
  --bg-soft: #f7f8fa;
  --line: rgba(11, 30, 59, 0.12);
  --text: #1a1a1a;
  --muted: #5c6b7e;
  --accent: var(--gold);
  --accent-2: var(--gold-bright);
  --ok: #1f7a5c;
  --danger: #d32f2f;
  --warn: #c47a12;
  --radius: 16px;
  --shadow: 0 12px 28px rgba(11, 30, 59, 0.12);
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --display: "Trebuchet MS", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 480px at 0% -5%, rgba(212, 155, 53, 0.18), transparent 55%),
    radial-gradient(800px 420px at 100% 0%, rgba(11, 30, 59, 0.08), transparent 50%),
    linear-gradient(180deg, #e8edf4 0%, var(--bg) 40%, #e6ebf2 100%);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

a { color: var(--navy-soft); }

#app { min-height: 100dvh; }

.hidden { display: none !important; }

/* Auth screens */
.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px 40px;
  background:
    radial-gradient(circle at 50% 0%, rgba(212, 155, 53, 0.25), transparent 45%),
    linear-gradient(180deg, var(--navy-deep) 0%, var(--navy) 55%, #122846 100%);
}

.auth-card {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(212, 155, 53, 0.35);
  border-radius: 24px;
  padding: 28px 22px 24px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.brand {
  text-align: center;
  margin-bottom: 22px;
}
.brand-logo {
  width: 148px;
  height: 148px;
  margin: 0 auto 14px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 3px solid var(--gold);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28), 0 0 0 6px rgba(11, 30, 59, 0.15);
  background: var(--navy);
}
.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  color: var(--navy);
  text-transform: uppercase;
}
.brand .brand-sub {
  margin: 4px 0 0;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 0.82rem;
  text-transform: uppercase;
}
.brand p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #e8edf4;
  padding: 5px;
  border-radius: 14px;
  margin-bottom: 18px;
}
.tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}
.tabs button.active {
  background: var(--navy);
  color: #fff;
}

.form-stack { display: grid; gap: 12px; }
.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: rgba(212, 155, 53, 0.75);
  box-shadow: 0 0 0 3px rgba(212, 155, 53, 0.2);
}
.field textarea { min-height: 96px; resize: vertical; }

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-bright));
  color: var(--navy-deep);
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--navy);
}
.btn-danger {
  background: rgba(211, 47, 47, 0.1);
  color: var(--danger);
  border: 1px solid rgba(211, 47, 47, 0.3);
}
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 0.85rem; }

.auth-actions { display: grid; gap: 10px; margin-top: 8px; }

.msg {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
}
.msg.error { background: rgba(211, 47, 47, 0.1); color: #a31818; }
.msg.ok { background: rgba(31, 122, 92, 0.12); color: #145a42; }
.msg.info { background: rgba(212, 155, 53, 0.15); color: #7a560f; }

/* App chrome */
.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  border-bottom: 2px solid var(--gold);
  color: #fff;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.topbar-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
  background: #fff;
  flex-shrink: 0;
}
.topbar h2 {
  margin: 0;
  font-size: 1.02rem;
  font-family: var(--display);
  color: #fff;
}
.topbar .user-line {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.badge {
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(212, 155, 53, 0.2);
  color: var(--gold-soft);
  border: 1px solid rgba(212, 155, 53, 0.45);
}
.badge.offline {
  background: rgba(211, 47, 47, 0.2);
  color: #ffb4b4;
  border-color: rgba(211, 47, 47, 0.4);
}
.badge.online {
  background: rgba(31, 122, 92, 0.25);
  color: #b6f0d6;
  border-color: rgba(120, 220, 180, 0.35);
}

.content {
  padding: 16px 16px 110px;
  width: min(920px, 100%);
  margin: 0 auto;
}

.nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 20px));
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 8px;
  background: var(--navy);
  border: 1px solid rgba(212, 155, 53, 0.35);
  border-radius: 20px;
  box-shadow: 0 16px 36px rgba(11, 30, 59, 0.35);
  z-index: 30;
}
.nav button {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  padding: 10px 6px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 0.72rem;
  display: grid;
  gap: 4px;
  justify-items: center;
}
.nav button span.icon { font-size: 1.15rem; line-height: 1; }
.nav button.active {
  background: rgba(212, 155, 53, 0.22);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(212, 155, 53, 0.45);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
  color: var(--navy);
}
.section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.list { display: grid; gap: 12px; }
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.card h4 { margin: 0 0 6px; font-size: 1.02rem; color: var(--navy); }
.card .date {
  color: var(--gold);
  font-size: 0.8rem;
  margin-bottom: 8px;
  font-weight: 600;
}
.card p {
  margin: 0;
  color: #334155;
  line-height: 1.45;
  white-space: pre-wrap;
}
.card .actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
  border: 1px dashed rgba(11, 30, 59, 0.2);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.6);
}

/* Profile form */
.profile-panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-top: 4px solid var(--gold);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.profile-panel h3 { margin: 0 0 4px; color: var(--navy); }
.profile-panel .hint { color: var(--muted); margin: 0 0 16px; font-size: 0.9rem; }
.form-grid {
  display: grid;
  gap: 12px;
}
.form-grid .full { grid-column: 1 / -1; }
@media (min-width: 700px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
}
.locked {
  opacity: 0.7;
  pointer-events: none;
}
.photo-box {
  display: grid;
  gap: 10px;
  justify-items: start;
}
.photo-preview {
  width: 120px;
  height: 140px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
}
.photo-preview.news-preview {
  width: min(100%, 280px);
  height: auto;
  max-height: 200px;
  object-fit: contain;
  background: #f0f3f8;
}
.field-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.news-image {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 12px;
  margin: 8px 0 12px;
  border: 1px solid var(--line);
  background: #f0f3f8;
}

/* Members */
.member-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  cursor: pointer;
}
.avatar {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--bg-soft);
  border: 2px solid rgba(212, 155, 53, 0.45);
}
.member-row .name { font-weight: 600; color: var(--navy); }
.member-row .sub { color: var(--muted); font-size: 0.85rem; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 20, 40, 0.55);
  display: grid;
  place-items: end center;
  z-index: 50;
  padding: 12px;
}
.modal {
  width: min(560px, 100%);
  max-height: min(88dvh, 720px);
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-top: 4px solid var(--gold);
  border-radius: 20px 20px 16px 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.modal header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 14px;
}
.modal header h3 { margin: 0; color: var(--navy); }
.detail-grid {
  display: grid;
  gap: 10px;
}
.detail-grid .item {
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
}
.detail-grid .item label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.detail-photo {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
}

.fab-area {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.toast-wrap {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 80;
  display: grid;
  gap: 8px;
}
.toast {
  background: var(--navy);
  color: #fff;
  border: 1px solid rgba(212, 155, 53, 0.45);
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: in 0.25s ease;
}
@keyframes in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.install-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 88px;
  background: #fff;
  border: 1px solid rgba(212, 155, 53, 0.4);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 40;
  box-shadow: var(--shadow);
}
.install-banner p { margin: 0; font-size: 0.9rem; color: var(--navy); }

.search {
  width: 100%;
  margin-bottom: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.loading-brand {
  text-align: center;
  color: #fff;
}
.loading-brand img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  margin-bottom: 12px;
}
