:root {
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-soft: #F1F5F9;
  --text: #0F172A;
  --muted: #64748B;
  --border: #E2E8F0;
  --primary: #0F172A;
  --primary-soft: #1E293B;
  --accent: #F59E0B;
  --accent-strong: #F97316;
  --danger: #DC2626;
  --success: #16A34A;
  --radius: 18px;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.10);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(245, 158, 11, .16), transparent 28rem),
    linear-gradient(180deg, #eef5ff 0, var(--bg) 18rem);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.app-header, .admin-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1rem;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-soft));
  box-shadow: 0 10px 30px rgba(15, 23, 42, .18);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  flex: 0 0 auto;
  border-radius: 14px;
  color: var(--primary);
  background: linear-gradient(135deg, #FBBF24, var(--accent));
  font-weight: 900;
  box-shadow: inset 0 -2px 0 rgba(15,23,42,.18);
}
.brand strong { display: block; font-size: 1.18rem; line-height: 1; }
.brand small { display: block; margin-top: .2rem; color: #CBD5E1; font-size: .78rem; }
.user-pill {
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: .45rem .7rem;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  color: #E2E8F0;
  font-size: .85rem;
}

.app-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 1.15rem 1rem 6.4rem;
}
.page-title { margin: .25rem 0 1rem; font-size: clamp(1.7rem, 7vw, 2.6rem); line-height: 1.04; }
.lead { color: var(--muted); font-size: 1rem; line-height: 1.55; }
.muted { color: var(--muted); }
.notice {
  margin: 0 0 1rem;
  padding: .9rem 1rem;
  border: 1px solid #FDE68A;
  border-radius: 14px;
  background: #FFFBEB;
  color: #78350F;
}

.card, .auth-card, .night-card, .document-card, .upload-note {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-wrap { min-height: calc(100vh - 5rem); display: grid; align-content: center; }
.auth-card { padding: 1.25rem; }
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin: .85rem 0;
}
.stat, .badge {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: .35rem .65rem;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 700;
  font-size: .85rem;
}
.badge.pending, .badge.quick { background: #FEF3C7; color: #92400E; }
.badge.approved, .badge.report { background: #DCFCE7; color: #166534; }
.badge.rejected { background: #E5E7EB; color: #374151; }
.badge.suspended { background: #FEE2E2; color: #991B1B; }
.badge.confirmation { background: #DBEAFE; color: #1D4ED8; }

.actions { display: grid; gap: .7rem; margin-top: 1rem; }
.actions.inline { display: flex; flex-wrap: wrap; }
.btn, button, input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: .75rem 1rem;
  border: 0;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(15, 23, 42, .16);
}
.btn:hover, button:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); }
.btn-accent { background: var(--accent-strong); }
.btn-danger, .loud-button { background: linear-gradient(135deg, var(--danger), var(--accent-strong)); }
.btn-success { background: var(--success); }
.btn-soft, .btn-ghost { background: var(--surface-soft); color: var(--text); box-shadow: none; border: 1px solid var(--border); }
.loud-button { width: 100%; min-height: 64px; font-size: 1.12rem; }

form p { margin: .75rem 0; }
label { display: block; margin: 0 0 .35rem; font-weight: 800; color: var(--text); }
input, textarea, select {
  width: 100%;
  min-height: 48px;
  padding: .78rem .9rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
input[type="checkbox"] { width: 1.2rem; min-height: 1.2rem; vertical-align: middle; }
.helptext, .errorlist { color: var(--muted); font-size: .9rem; }
.errorlist { color: #B91C1C; }
.chip-grid, ul[id$="disturbance_types"] {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: .65rem;
  padding: 0;
  margin: .5rem 0 1rem;
  list-style: none;
}
.chip-grid label, ul[id$="disturbance_types"] label {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: 48px;
  padding: .65rem .75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
}
.upload-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: .7rem;
  margin: .5rem 0 1rem;
}
.upload-actions .btn {
  width: 100%;
  min-height: 54px;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.bottom-nav {
  position: fixed;
  right: .75rem;
  bottom: .75rem;
  left: .75rem;
  z-index: 30;
  display: grid;
  grid-auto-flow: column;
  gap: .35rem;
  padding: .45rem;
  border: 1px solid rgba(226,232,240,.9);
  border-radius: 24px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 16px 35px rgba(15, 23, 42, .18);
  backdrop-filter: blur(12px);
}
.bottom-nav a {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 54px;
  border-radius: 18px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  text-decoration: none;
}
.bottom-nav span { display: block; color: var(--accent-strong); font-size: 1rem; }
.bottom-nav a:hover { background: var(--surface-soft); color: var(--text); }
.nav-badge {
  position: absolute;
  top: .32rem;
  right: .55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 .35rem;
  border: 2px solid rgba(255,255,255,.94);
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 6px 14px rgba(220, 38, 38, .28);
}

.chat-list { display: grid; gap: .75rem; }
.chat-bubble {
  max-width: 86%;
  padding: .85rem 1rem;
  border-radius: 18px 18px 18px 6px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .07);
}
.chat-bubble.mine {
  margin-left: auto;
  border-radius: 18px 18px 6px 18px;
  background: #FFF7ED;
  border-color: #FED7AA;
}
.chat-name { display: block; color: var(--primary); font-weight: 900; }
.chat-meta { display: block; margin-top: .35rem; color: var(--muted); font-size: .78rem; }
.chat-compose {
  position: sticky;
  bottom: 5.8rem;
  margin-top: 1rem;
  padding: .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow);
}

.admin-body { background: var(--bg); }
.admin-shell { width: min(100%, 1280px); margin: 0 auto; padding: 1.25rem; }
.admin-nav {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding: .7rem 1rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.admin-nav a {
  flex: 0 0 auto;
  padding: .55rem .8rem;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--primary);
  font-weight: 800;
  text-decoration: none;
}
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.metric { padding: 1rem; border-radius: var(--radius); background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); }
.metric strong { display: block; font-size: 2rem; }
.admin-detail-head, .admin-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.admin-subcard {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}
.admin-subcard h3, .admin-subcard h4 { margin-bottom: .35rem; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem;
  margin: 1rem 0;
}
.detail-grid div {
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.detail-grid dt { color: var(--muted); font-size: .8rem; font-weight: 800; text-transform: uppercase; }
.detail-grid dd { margin: .25rem 0 0; }
.compact-form {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.compact-form select { min-width: 12rem; }
.admin-work-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.delete-confirm {
  max-width: 760px;
  margin: 2rem auto;
}
.delete-details {
  margin: 1rem 0;
  padding: 1rem 1rem 1rem 2rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}
.confirm-check {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin: 1rem 0;
  padding: .9rem 1rem;
  border: 1px solid #FCA5A5;
  border-radius: 14px;
  background: #FEF2F2;
}
.confirm-check input { flex: 0 0 auto; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
table { width: 100%; min-width: 720px; border-collapse: collapse; }
th, td { padding: .85rem .9rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-soft); }
tr:last-child td { border-bottom: 0; }
.image-preview {
  display: grid;
  place-items: center;
  width: 88px;
  height: 66px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  text-decoration: none;
}
.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.image-preview-placeholder {
  border-style: dashed;
}

@media (min-width: 768px) {
  .app-shell { padding-bottom: 2rem; }
  .bottom-nav { right: 50%; left: auto; bottom: 1rem; width: min(520px, calc(100vw - 2rem)); transform: translateX(50%); }
  .actions { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .auth-card { padding: 1.6rem; }
}
