:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-alt: #1f2937;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --danger: #f87171;
  --border: rgba(148, 163, 184, 0.18);
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #1e293b 0%, #0f172a 38%, #020617 100%);
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-panel {
  width: min(480px, 100%);
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
}

.login-panel h2 {
  margin: 0 0 12px;
  font-size: 1.8rem;
}

.login-panel p {
  margin: 0 0 24px;
  color: var(--muted);
}


.login-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

.login-panel button[type="submit"] {
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
  border-radius: 14px;
  color: white;
  padding: 12px 18px;
}

.hidden {
  display: none !important;
}

header {
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

.logo img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
}

.brand h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 3vw, 2.6rem);
}

.brand p {
  margin: 0;
  color: var(--muted);
}

.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.form-header h2 {
  margin: 0;
}

.form-status-buttons {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.call-card {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 16px;
  padding: 16px;
}

.call-card.selected {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
}

.call-card:hover {
  border-color: #38bdf8;
}

#callTable tr {
  cursor: pointer;
}

#callTable tr.selected {
  background: rgba(56, 189, 248, 0.08);
}

#callTable tr:hover {
  background: rgba(56, 189, 248, 0.06);
}

.app-shell {
  max-width: 1300px;
  margin: 0 auto;
  padding: 24px;
}

header {
  text-align: center;
  margin-bottom: 20px;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 3vw, 3rem);
}

p {
  margin: 0;
}

main {
  display: grid;
  gap: 20px;
}

.panel {
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.35);
}

label {
  display: block;
  margin-bottom: 16px;
  font-size: 0.95rem;
  color: var(--muted);
}

.autocomplete-field {
  position: relative;
}

.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}

.suggestions.hidden {
  display: none;
}

.suggestion-item {
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: rgba(56, 189, 248, 0.12);
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea,
input[type="file"] {
  width: 100%;
  margin-top: 8px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.96);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.grid-2 {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
}

#cancelEdit {
  background: #fff;
  color: #0f172a;
}

#deleteCall {
  background: #dc2626;
  color: #fff;
}

button {
  border: none;
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  padding: 12px 18px;
}

button[type="submit"] {
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
}

button#clearStorage {
  background: #334155;
}

button:hover {
  opacity: 0.95;
}

#map {
  min-height: 420px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.18);
}

#currentMapWrap { margin-top: 12px; }
#currentMap { min-height: 300px; border-radius:12px; border:1px solid rgba(148,163,184,0.12); }

.service-controls {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 16px;
}

.service-button {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
}

#serviceIn {
  background: #10b981;
}

#serviceOut {
  background: #ef4444;
}

.service-button.service-clear {
  background: #f97316;
}

.service-button.service-logout {
  background: #334155;
}

#serviceIn.active,
#serviceOut.active {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.14);
}

.current-call-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.current-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 110px;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.current-status.hidden {
  display: none;
}

.current-status.status-enroute {
  background: #0ea5e9;
}

.current-status.status-onscene {
  background: #f59e0b;
}

.current-status.status-cleared {
  background: #10b981;
}

.current-call-actions { display:flex; align-items:center; gap:12px; margin:8px 0 14px; }
.current-call-actions .status-button { padding:10px 14px; border-radius:999px; }

.status-button.status-enroute { background: #0ea5e9; }
.status-button.status-onscene { background: #f59e0b; }
.status-button.status-clear { background: #475569; }

.status-button.status-clear:hover { background: #334155; }


#callList {
  display: grid;
  gap: 14px;
}

.call-card {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 16px;
  padding: 16px;
}

.call-card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  color: #e2e8f0;
}

.call-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
}

.call-meta span {
  background: rgba(148, 163, 184, 0.1);
  padding: 6px 10px;
  border-radius: 999px;
}

.call-details {
  margin-bottom: 10px;
  white-space: pre-wrap;
  color: #cbd5e1;
}

.attachment-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.attachment-item {
  width: 96px;
  height: 96px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.15);
  background: #020617;
}

.attachment-item img,
.attachment-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.print-section {
  margin-top: 24px;
}

.print-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.print-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
}

#printTable {
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
  border: none;
  border-radius: 12px;
  color: #fff;
  padding: 10px 16px;
  cursor: pointer;
}

.table-wrap {
  overflow-x: auto;
}

#callTable {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

#callTable th,
#callTable td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  text-align: left;
  vertical-align: top;
}

#callTable th {
  color: var(--muted);
  font-weight: 600;
}

.status-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.status-button {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  background: rgba(56, 189, 248, 0.12);
  color: var(--text);
  font-weight: 600;
}

.status-button:hover {
  background: rgba(56, 189, 248, 0.24);
}

.note-list {
  margin-top: 14px;
  padding: 0;
}

.note-item {
  background: rgba(148, 163, 184, 0.08);
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 0.92rem;
}

@media print {
  body {
    background: #fff;
    color: #000;
  }
  .form-panel,
  .map-panel,
  .print-header,
  .status-buttons,
  button,
  input,
  textarea,
  select,
  #callList,
  .note-list,
  .call-card,
  .attachment-list,
  .status-button {
    display: none !important;
  }
  .app-shell {
    background: #fff !important;
    box-shadow: none !important;
  }
  .log-panel {
    border: none;
    box-shadow: none;
    background: transparent;
  }
  .table-wrap {
    overflow: visible !important;
  }
  #callTable {
    display: table !important;
    width: 100% !important;
    border-collapse: collapse !important;
    color: #000 !important;
  }
  #callTable thead {
    display: table-header-group !important;
  }
  #callTable tbody {
    display: table-row-group !important;
  }
  #callTable tr {
    display: table-row !important;
  }
  #callTable th,
  #callTable td {
    display: table-cell !important;
    visibility: visible !important;
    border: 1px solid #000 !important;
    padding: 8px !important;
    color: #000 !important;
    background: transparent !important;
  }
}

.hint {
  color: var(--muted);
  margin-top: 0;
}

@media (min-width: 980px) {
  main {
    grid-template-columns: 1.1fr 1.4fr;
    grid-template-areas:
      "form map"
      "log map";
  }

  .form-panel { grid-area: form; }
  .map-panel { grid-area: map; }
  .log-panel { grid-area: log; }

  /* Hide card-style call list (use table) */
  #callList { display: none; }

  @media (min-width: 980px) {
    .log-panel { grid-column: 1 / -1; }
  }
}

@media (max-width: 640px) {
  .panel { padding: 16px; }
}
