/* Global responsive styles and utilities */
:root {
  --bg: #0f172a; --panel: #111827; --text: #e5e7eb; --muted: #94a3b8;
  --primary: #006effff; --primary-hover: #2563eb; --danger: #ef4444; --success: #22c55e;
  --border: #ffffff08; --table-border: #1f2937;
  --wrap: 1100px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial; background: radial-gradient(800px 300px at 0% 0%, #0b1220 30%, var(--bg)), radial-gradient(800px 300px at 100% 0%, #0b1220 30%, var(--bg)); color: var(--text); }

/* Layout */
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 24px; }
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 10px; }
.title { font-weight: 700; font-size: 22px; }
.nav { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border: 1px solid var(--border); border-radius: 12px; background: #0b1220; }
.link { color: var(--primary); text-decoration: none; padding: 8px 10px; border-radius: 8px; }
.link:hover { background: rgba(0,110,255,.12); }
.link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sep { width: 1px; height: 18px; background: var(--table-border); opacity: .7; }
.divider { height: 1px; background: var(--table-border); margin: 12px 0 16px; border: none; }

.panel { background: linear-gradient(180deg, #0b1220 0%, var(--panel) 100%); border: 1px solid var(--border); border-radius: 16px; padding: 20px; box-shadow: 0 10px 30px rgba(0,0,0,.4); margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid { display:grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.metrics { display:grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.metric { background:#0b1220; border:1px solid var(--border); border-radius:12px; padding:12px; }
.metric { display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:80px; }
.metric .label { color: var(--muted); font-size:12px; margin-bottom:4px; }
.metric .value { font-size:22px; font-weight:800; }

/* Role pill */
.pill { display:inline-block; padding:4px 8px; border-radius:999px; font-size:12px; background:#0b1220; border:1px solid var(--border); color: var(--text); margin-left:6px; }

.badge { display:inline-block; padding:4px 8px; border-radius:999px; font-size:12px; }
.badge.ok { background:#14532d; color:#bbf7d0; }
.badge.wait { background:#7f1d1d; color:#fecaca; }

.table { width: 100%; border-collapse: collapse; overflow: hidden; border-radius: 12px; }
.table th, .table td { border-bottom: 1px solid var(--table-border); padding: 10px 12px; text-align: left; }
.table th { color: var(--muted); font-weight: 600; font-size: 13px; }

select, input[type="text"], input[type="number"], input[type="password"], input[type="email"] { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: #0b1220; color: var(--text); }
button, .btn { appearance: none; border: none; border-radius: 12px; padding: 8px 12px; background: var(--primary); color: white; font-weight: 600; cursor: pointer; }
button:hover, .btn:hover { background: var(--primary-hover); }
.btn.secondary { background:#374151; }
.btn.outline { background: transparent; color: var(--text); border:1px solid var(--table-border); }
.btn.danger { background: var(--danger); }

.msg { margin: 12px 0 16px; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.msg.success { background: rgba(34, 197, 94, .15); border: 1px solid #14532d; color: #bbf7d0; }
.msg.error { background: rgba(239, 68, 68, .15); border: 1px solid #7f1d1d; color: #fecaca; }

/* Utilities */
.hidden-sm { display: none; }
.actions { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }

/* Responsiveness */
@media (max-width: 1024px) {
  .grid, .metrics { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .wrap { padding: 16px; }
  .header { flex-direction: column; align-items: stretch; }
  .nav { width: 100%; justify-content: center; }
  .title { font-size: 20px; }
  .panel { padding: 16px; }
  .grid, .metrics { grid-template-columns: repeat(2, 1fr); }
  .table th, .table td { padding: 8px; }
  /* Enable horizontal scroll for wide tables, allow wrapping in cells */
  .table { display: block; overflow-x: auto; }
  .table th, .table td { white-space: normal; }
}
@media (max-width: 480px) {
  .title { font-size: 18px; }
  .grid, .metrics { grid-template-columns: 1fr; }
  .row { gap: 8px; }
  .btn, button { width: 100%; }
  .nav { flex-wrap: wrap; gap: 6px; }
  /* Stack action buttons vertically in tight cells */
  .actions { flex-direction: column; align-items: stretch; }
  .actions .btn, .actions button { width: 100%; }
}

/* Ultra-small devices tweaks */
@media (max-width: 360px) {
  .wrap { padding: 12px; }
  .panel { padding: 12px; }
  .metrics { grid-template-columns: 1fr; gap: 8px; }
  .metric { min-height: 64px; padding: 10px; min-width: 0; }
  .metric .label { font-size: 11px; }
  .metric .value { font-size: 18px; }
  .pill { font-size: 11px; padding: 3px 6px; }
}

/* Tables on mobile: stacked card layout */
@media (max-width: 600px) {
  .table.responsive { border-collapse: separate; border-spacing: 0; }
  .table.responsive thead { display: none; }
  .table.responsive tbody { display: grid; gap: 12px; }
  .table.responsive tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: #0b1220; }
  .table.responsive td { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; padding: 8px; border-bottom: none; background: #0b1523; border: 1px solid var(--border); border-radius: 10px; }
  .table.responsive td::before { content: attr(data-label); color: var(--muted); font-weight: 700; font-size: 12px; }
  .table.responsive td.actions-cell { grid-column: 1 / -1; padding-top: 8px; }
  .table.responsive td.actions-cell { background: transparent; border: none; }
  .table.responsive td.section { display: block; grid-column: 1 / -1; font-weight: 700; color: var(--muted); padding: 4px 8px; margin-top: 4px; background: rgba(255,255,255,0.02); border: 1px dashed var(--border); border-radius: 8px; }
}

/* Hide section markers on desktop */
.table.responsive td.section { display: none; }

/* Report form: input card grid */
.report-grid { display:grid; grid-template-columns: repeat(5, minmax(90px, 1fr)); gap: 12px; }
.input-card { background:#0b1220; border:none; border-radius:12px; padding:8px 10px; min-width:0; }
.input-card .label { display:block; font-size:12px; color:var(--muted); margin-bottom:6px; }
.input-card input[type="number"] { width:100%; text-align:center; font-weight:800; font-size:18px; padding:10px 12px; border-radius:10px; border:1px solid var(--border); background:#0b1523; }

/* Remove native number spinners for cleaner look */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }

/* Responsive columns for report grid */
@media (max-width: 1024px) { .report-grid { grid-template-columns: repeat(3, minmax(90px, 1fr)); } }
@media (max-width: 768px) { .report-grid { grid-template-columns: repeat(2, minmax(90px, 1fr)); } }
@media (max-width: 480px) { .report-grid { grid-template-columns: repeat(2, minmax(90px, 1fr)); } }

/* Mobile override: keep submit button compact */
@media (max-width: 480px) { .submit-report { width:auto; } }

/* Wizard */
.wizard-steps { display:flex; gap:8px; flex-wrap:wrap; margin:8px 0 12px; }
.wizard-steps .step { background:#0b1220; border:1px solid var(--border); border-radius:999px; padding:6px 10px; font-size:12px; color: var(--muted); }
.wizard-steps .step.active { color: var(--text); border-color: var(--primary); background: rgba(0,110,255,.12); }
.step-panel { display:none; }
.step-panel.active { display:block; }