:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #111;
  --panel-2: #181818;
  --text: #fff;
  --muted: #c9c9c9;
  --line: #3a3a3a;
  --accent: #78d6ff;
  --danger: #ff4d4d;
  --ok: #7dffb2;
  --purple: #c084fc;
  --deep-yellow: #b8860b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(14px, 3vw, 32px);
  background: #000;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

nav a,
.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b0b0b;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

nav a:hover,
.btn:hover,
button:hover {
  border-color: #fff;
  transform: translateY(-1px);
}

button.primary {
  background: #fff;
  color: #000;
  border-color: #fff;
  font-weight: 800;
}

.wrap {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 32px) 48px;
}

.panel {
  animation: rise-in 220ms ease both;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(16px, 2vw, 24px);
  margin-bottom: 18px;
}

.narrow {
  max-width: 520px;
  margin: 40px auto;
}

.grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 18px;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

.section-title span,
label {
  color: var(--muted);
}

.form {
  display: grid;
  gap: 14px;
}

.record-form {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  align-items: end;
}

.record-form label:has(textarea) {
  grid-column: span 2;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #000;
  color: #fff;
  font: inherit;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(120, 214, 255, 0.22);
  outline: none;
}

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

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(220px, 280px) 88px 88px;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.filters .btn,
.filters button {
  width: 100%;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  transition: background-color 180ms ease;
}

th {
  color: #fff;
  background: var(--panel-2);
}

tr.normal-row td,
tr.normal-row td * {
  color: #fff !important;
}

tr.due-soon td,
tr.due-soon td * {
  color: var(--purple) !important;
}

tr.expired-one td,
tr.expired-one td * {
  color: var(--danger) !important;
}

tr.expired-warning td,
tr.expired-warning td * {
  color: var(--deep-yellow) !important;
}

tbody tr:hover td {
  background: #1d1d1d;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.actions form {
  margin: 0;
}

.alert {
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid;
}

.alert.ok {
  color: var(--ok);
  border-color: #245d38;
  background: #061c0e;
}

.alert.err {
  color: #fff;
  border-color: #7b2525;
  background: #2a0606;
}

.hint {
  margin: 0;
  color: var(--muted);
  word-break: break-all;
}

code {
  color: #fff;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 5px;
}

.footer-version {
  padding: 0 clamp(12px, 3vw, 32px) 20px;
  color: #8f8f8f;
  font-size: 13px;
  text-align: center;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    justify-content: stretch;
  }

  nav a {
    min-height: 38px;
    padding: 8px 6px;
    text-align: center;
  }

  .grid,
  .record-form {
    grid-template-columns: 1fr;
  }

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

  .filters .filter-search {
    grid-column: 1 / -1;
  }

  .record-form label:has(textarea) {
    grid-column: auto;
  }

  .section-title {
    display: block;
  }

  table {
    min-width: 740px;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 15px;
  }

  .wrap {
    padding-inline: 10px;
  }

  .panel {
    padding: 14px;
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
