:root {
  --ink: #17212b;
  --muted: #657282;
  --line: #d9e2e8;
  --soft: #f4f8f9;
  --teal: #0f766e;
  --teal-soft: #d9f2ee;
  --danger: #b42318;
  --shadow: 0 14px 32px rgba(23, 33, 43, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background: #edf4f5;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(rgba(237,244,245,.92), rgba(237,244,245,.92)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='520'%3E%3Crect width='900' height='520' fill='%23dfeaed'/%3E%3Cpath d='M0 370c135-58 209 22 331-36 118-56 163-163 320-143 98 13 170 73 249 35v294H0z' fill='%23bfd8d6'/%3E%3Crect x='260' y='96' width='360' height='250' rx='12' fill='%23ffffff'/%3E%3Crect x='320' y='54' width='240' height='56' rx='8' fill='%230f766e'/%3E%3Crect x='405' y='145' width='70' height='150' fill='%23d96b4e'/%3E%3Crect x='365' y='185' width='150' height='70' fill='%230f766e'/%3E%3C/svg%3E");
  background-size: cover;
}

.login-card, .card, .panel, .metrics article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card {
  width: min(440px, 100%);
  padding: 22px;
  display: grid;
  gap: 14px;
}

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.brand.compact {
  margin-bottom: 12px;
}

.brand span, .muted, .title p, .panel-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), #2b8a5e 60%, #d96b4e);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

input, select, textarea {
  min-height: 38px;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

textarea { min-height: 86px; resize: vertical; }

.btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 13px;
}

.btn.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
  font-weight: 700;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

aside {
  position: sticky;
  top: 0;
  height: 100vh;
  background: white;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

nav {
  display: grid;
  gap: 6px;
}

nav button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: #2f3d47;
  text-align: left;
}

nav button.active {
  background: var(--teal-soft);
  color: #075f58;
  font-weight: 700;
}

main {
  min-width: 0;
  padding: 20px 24px 32px;
}

header {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  margin-bottom: 18px;
}

.page { display: none; }
.page.active { display: block; }

.title {
  margin-bottom: 16px;
}

h1 { margin: 0; font-size: 28px; line-height: 1.2; }
h2 { margin: 0; font-size: 16px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metrics article {
  padding: 14px;
  min-height: 104px;
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
}

.split {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.card {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.card form {
  display: grid;
  gap: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.wide { grid-column: 1 / -1; }
.space-top { margin-top: 14px; }
.narrow { max-width: 440px; }

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 16px;
  border-bottom: 1px solid #edf2f5;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  background: #fbfcfd;
  font-size: 12px;
  text-transform: uppercase;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: #075f58;
  font-size: 12px;
  font-weight: 700;
}

.tag.urgent, .tag.emergency {
  background: #ffe4df;
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #17212b;
  color: white;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: .2s ease;
  font-size: 13px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app { grid-template-columns: 86px minmax(0, 1fr); }
  .brand.compact div:last-child, nav button { font-size: 0; }
  nav button::first-letter { font-size: 14px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .app { display: block; }
  aside { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  nav { display: flex; overflow-x: auto; }
  nav button { font-size: 14px; min-width: 104px; text-align: center; }
  main { padding: 16px 14px 28px; }
  header, .metrics, .grid { grid-template-columns: 1fr; }
  th:nth-child(4), td:nth-child(4) { display: none; }
}
