:root {
  --ink: #111418;
  --ink-2: #1c2128;
  --line: #2a2f38;
  --paper: #f5f6f8;
  --card: #ffffff;
  --text: #1a1d23;
  --muted: #6b727d;
  --red: #e11d2a;
  --red-dark: #b8121f;
  --green: #1f9d55;
  --amber: #d97706;
  --radius: 14px;
  --nav-h: 62px;
  --font: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ink); color: #fff;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
}
.brand { font-weight: 800; letter-spacing: 1px; color: #fff; text-decoration: none; font-size: 20px; }
.brand span { color: var(--red); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.role-chip { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; background: var(--red); padding: 3px 8px; border-radius: 20px; font-weight: 700; }
.topbar-logout { color: #fff; text-decoration: none; font-size: 20px; opacity: .85; }

/* Content */
.content { max-width: 720px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 20px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 14px; }
.card-link { display: block; text-decoration: none; color: inherit; }
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 18px 14px; text-decoration: none; color: inherit; box-shadow: 0 1px 3px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 6px; border-left: 4px solid var(--red); }
.tile .tile-ico { font-size: 26px; }
.tile .tile-title { font-weight: 700; }
.tile .tile-sub { font-size: 12px; color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--red); color: #fff; border: none; border-radius: 12px; padding: 14px 20px; font-size: 16px; font-weight: 700; font-family: var(--font); text-decoration: none; cursor: pointer; width: 100%; }
.btn:active { background: var(--red-dark); }
.btn-lg { padding: 18px; font-size: 18px; }
.btn-dark { background: var(--ink); }
.btn-ghost { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn-green { background: var(--green); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; }

/* Forms */
.form-input, select.form-input, textarea.form-input {
  width: 100%; padding: 13px 14px; font-size: 16px; font-family: var(--font);
  border: 1.5px solid var(--line); border-radius: 11px; background: #fff; margin-bottom: 4px;
}
.form-input:focus { outline: none; border-color: var(--red); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
textarea.form-input { min-height: 90px; resize: vertical; }
.checkline { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.checkline input { width: 20px; height: 20px; }
.help { font-size: 12px; color: var(--muted); }
.errorlist { color: var(--red); font-size: 13px; list-style: none; padding: 0; margin: 4px 0; }

/* Status pills */
.pill { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 3px 9px; border-radius: 20px; }
.pill-open { background: #fee2e2; color: var(--red-dark); }
.pill-progress { background: #fef3c7; color: var(--amber); }
.pill-completed { background: #dcfce7; color: var(--green); }
.pill-submitted { background: #dbeafe; color: #1d4ed8; }
.pill-approved { background: #dcfce7; color: var(--green); }

/* Lists */
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; background: var(--card); border-radius: var(--radius); margin-bottom: 10px; text-decoration: none; color: inherit; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.list-item .li-title { font-weight: 700; }
.list-item .li-sub { font-size: 12px; color: var(--muted); }

/* Bottom nav */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; background: var(--ink); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0; color: #9aa2ad; text-decoration: none; font-size: 10.5px; position: relative; }
.bottomnav a.active { color: #fff; }
.bottomnav a.active .ico { color: var(--red); }
.bottomnav .ico { font-size: 20px; line-height: 1; }
.bottomnav .badge { position: absolute; top: 4px; right: 50%; transform: translateX(18px); background: var(--red); color: #fff; font-size: 9px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* Flash */
.flash-stack { margin-bottom: 14px; }
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error, .flash-danger { background: #fee2e2; color: var(--red-dark); }
.flash-warning { background: #fef3c7; color: #92400e; }
.flash-info { background: #dbeafe; color: #1e40af; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--ink); padding: 24px; }
.login-card { background: #fff; border-radius: 18px; padding: 28px 24px; width: 100%; max-width: 360px; }
.login-logo { text-align: center; font-weight: 800; font-size: 30px; letter-spacing: 2px; margin-bottom: 4px; }
.login-logo span { color: var(--red); }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }

/* Map */
.map { width: 100%; height: 340px; border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; z-index: 1; }
.map-lg { height: 60vh; }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.gps-warn { color: var(--amber); font-size: 12px; font-weight: 600; }

/* Chat */
.chat-scroll { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; }
.msg { max-width: 80%; padding: 9px 12px; border-radius: 14px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.msg.mine { align-self: flex-end; background: var(--red); color: #fff; }
.msg.system { align-self: center; background: transparent; box-shadow: none; color: var(--muted); font-size: 12px; font-style: italic; text-align: center; }
.msg .msg-meta { font-size: 10.5px; opacity: .7; margin-top: 3px; }
.msg img { max-width: 100%; border-radius: 10px; margin-top: 4px; }
.chat-input { position: fixed; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); padding: 8px; display: flex; gap: 8px; max-width: 720px; margin: 0 auto; }
.chat-input input[type=text] { flex: 1; }

.section-empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.timeline-item { padding: 10px 0; border-bottom: 1px solid #eef0f3; font-size: 13px; }
.timeline-item .tl-time { color: var(--muted); font-size: 11px; }
