:root {
  --black: #111111;
  --white: #ffffff;
  --red: #c8102e;
  --gray-100: #f5f5f5;
  --gray-200: #e5e5e5;
  --gray-400: #a0a0a0;
  --gray-600: #666666;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--gray-100);
  color: var(--black);
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* --- Login --- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0a0a0a 0%, #1a1a1a 60%, #2a0d12 100%);
}
.login-card {
  background: var(--white); padding: 40px 32px; border-radius: var(--radius);
  width: 100%; max-width: 380px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 22px; letter-spacing: 1px; margin: 0 0 4px; }
.login-card .brand-mark { color: var(--red); font-weight: 800; letter-spacing: 2px; }
.login-card p.sub { color: var(--gray-600); margin: 0 0 24px; font-size: 13px; }

/* --- Top bar / nav --- */
.topbar {
  background: var(--black); color: var(--white); display: flex; align-items: center;
  justify-content: space-between; padding: 12px 20px; position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 800; letter-spacing: 1px; }
.topbar .brand span { color: var(--red); }
.topbar .user-chip { font-size: 12px; color: var(--gray-400); }
.topbar button.logout {
  background: transparent; border: 1px solid var(--gray-600); color: var(--white);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px;
}

.layout { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 220px; background: #1a1a1a; color: var(--white); padding: 14px 0; flex-shrink: 0;
}
.sidebar a {
  display: block; padding: 11px 20px; color: var(--gray-400); text-decoration: none; font-size: 14px;
  border-left: 3px solid transparent; cursor: pointer;
}
.sidebar a.active, .sidebar a:hover { color: var(--white); background: #262626; border-left-color: var(--red); }

.content { flex: 1; padding: 22px; overflow-y: auto; }

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; display: flex; overflow-x: auto; padding: 6px; }
  .sidebar a { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; padding: 10px 14px; }
  .sidebar a.active { border-left-color: transparent; border-bottom-color: var(--red); }
  .content { padding: 14px; }
}

/* --- Common components --- */
h2.page-title { margin: 0 0 16px; font-size: 20px; }
.card {
  background: var(--white); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.stat-card { text-align: left; border-top: 4px solid var(--red); }
.stat-card .num { font-size: 30px; font-weight: 800; }
.stat-card .label { color: var(--gray-600); font-size: 13px; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--gray-200); text-align: left; }
th { color: var(--gray-600); font-weight: 700; font-size: 12px; text-transform: uppercase; }
tr:hover td { background: var(--gray-100); }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700;
  background: var(--gray-200); color: var(--black);
}
.badge.red { background: var(--red); color: #fff; }
.badge.black { background: var(--black); color: #fff; }
.badge.gray { background: var(--gray-200); color: var(--gray-600); }

button, .btn {
  background: var(--black); color: var(--white); border: none; padding: 10px 16px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
}
button.secondary, .btn.secondary { background: var(--gray-200); color: var(--black); }
button.red, .btn.red { background: var(--red); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.small { padding: 6px 10px; font-size: 12px; }

input, select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--gray-200); border-radius: 7px;
  font-size: 13px; margin-bottom: 12px; font-family: inherit;
}
label { font-size: 12px; color: var(--gray-600); font-weight: 700; display: block; margin-bottom: 5px; }
.field { margin-bottom: 4px; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button {
  background: var(--gray-200); color: var(--black); font-weight: 600;
}
.tabs button.active { background: var(--red); color: var(--white); }

.checklist-section { border-left: 3px solid var(--red); padding-left: 12px; margin-bottom: 18px; }
.checklist-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--gray-200); font-size: 13px; }
.checklist-row select { width: 120px; margin-bottom: 0; }

.signature-pad { border: 2px dashed var(--gray-400); border-radius: 8px; touch-action: none; background: #fff; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert.error { background: #fdeceb; color: var(--red); border: 1px solid #f3b8bd; }
.alert.success { background: #e9f8ee; color: #1a7c3c; border: 1px solid #b9ecc7; }

.timeline { border-left: 2px solid var(--gray-200); margin-left: 6px; padding-left: 16px; }
.timeline .ev { margin-bottom: 12px; font-size: 12.5px; }
.timeline .ev .t { color: var(--gray-600); font-size: 11px; }

.mobile-form-card { max-width: 480px; margin: 0 auto; }

.photo-thumb { width: 70px; height: 70px; object-fit: cover; border-radius: 6px; margin: 4px; }

footer.app-footer { text-align: center; padding: 10px; color: var(--gray-400); font-size: 11px; }
