:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --border: #d9dee7;
  --primary: #1f4f82;
  --primary-dark: #15385d;
  --accent: #00b7c3;
  --danger: #b42318;
  --success: #027a48;
  --warning: #b54708;
  --shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 80px;
}

header,
.trace-header {
  background: #15385D;
  color: white;
  padding: 18px 16px;
  text-align: center;
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 12px;
}

.header-logo {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 350px;
  height: auto;
  object-fit: contain;
}

.nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin: 14px;
  background: #e7ebf1;
  border-radius: 16px;
  padding: 5px;
  gap: 5px;
}

.nav a {
  text-align: center;
  text-decoration: none;
  border-radius: 12px;
  padding: 11px 5px;
  font-weight: 700;
  color: var(--muted);
  font-size: 13px;
}

.nav a.active,
.nav a:hover {
  background: white;
  color: var(--primary);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.08);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 14px 8px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 8px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

.stat strong {
  display: block;
  font-size: 22px;
  color: var(--primary);
}

.stat span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.content {
  padding: 0 14px;
}

.card,
.entry {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.card h2,
.card h3,
.entry h3 {
  margin-top: 0;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.4;
}

.notes {
  margin: 12px 0;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.pill {
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--primary);
  font-weight: 700;
}

.pill.open {
  background: #fff7ed;
  color: var(--warning);
}

.pill.closed {
  background: #ecfdf3;
  color: var(--success);
}

.pill.critical,
.pill.commercial {
  background: #fef3f2;
  color: var(--danger);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #344054;
  margin: 12px 0 6px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px;
  font-size: 15px;
  background: white;
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 79, 130, 0.18);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn,
button {
  display: inline-block;
  border: 0;
  border-radius: 14px;
  background: var(--primary);
  color: white;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover,
button:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  background: white;
  color: var(--primary);
  border: 1px solid var(--border);
}

.btn.danger {
  background: #fff5f5;
  color: var(--danger);
  border: 1px solid #fecdca;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px 10px;
}

a {
  color: var(--primary);
}

.footer-note {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  margin: 20px;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .app {
    max-width: 100%;
  }

  .header-logo {
    max-width: 300px;
  }

  .nav {
    grid-template-columns: repeat(3, 1fr);
    margin: 12px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
    margin: 14px 12px 8px;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }

  .actions .btn,
  .actions button {
    width: 100%;
    text-align: center;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }
}
