:root {
  --navy: #122d50;
  --neutral: #f5f5f3;
  --white: #ffffff;
  --text: #1c2430;
  --muted: #4d5866;
  --border: #d5d8dc;
  --red-tint: #ffebee;
  --red-text: #8a1c2b;
  --yellow-tint: #fff9e6;
  --yellow-text: #6b5200;
  --green-tint: #e8f5e9;
  --green-text: #1b5e20;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--neutral);
}

a { color: var(--navy); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #2f6fbd;
  outline-offset: 2px;
}

.site-header { background: var(--navy); color: var(--white); }
.site-header .inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--white); text-decoration: none; font-weight: bold; font-size: 1.25rem; }
.brand img { height: 36px; width: auto; display: block; }
.brand-fallback { letter-spacing: 0.02em; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-left: auto; }
.nav-list { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
.nav-user { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.nav form { margin: 0; }
.nav a.nav-link, .nav button.nav-logout {
  display: inline-block;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.nav a.nav-link { color: var(--white); background: transparent; }
.nav a.nav-link:hover { background: rgba(255, 255, 255, 0.14); }
.nav a.nav-link.is-current { background: rgba(255, 255, 255, 0.2); border-color: rgba(255, 255, 255, 0.55); font-weight: bold; }
.nav a.nav-primary { background: var(--white); color: var(--navy); font-weight: bold; }
.nav a.nav-primary:hover { background: var(--neutral); }
.nav a.nav-primary.is-current { background: var(--neutral); border-color: var(--white); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5); }
.nav button.nav-logout { color: var(--white); background: transparent; border-color: rgba(255, 255, 255, 0.7); }
.nav button.nav-logout:hover { background: var(--white); color: var(--navy); }
.nav a.nav-link:focus-visible, .nav button.nav-logout:focus-visible { outline: 3px solid var(--white); outline-offset: 2px; box-shadow: 0 0 0 5px #2f6fbd; }
.nav .who { display: inline-block; padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); color: #dfe6ee; font-size: 0.85rem; max-width: 100%; overflow-wrap: anywhere; }

@media (max-width: 520px) {
  .nav { margin-left: 0; width: 100%; }
}

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { color: var(--navy); font-size: 1.6rem; margin: 0 0 16px; }
h2 { color: var(--navy); font-size: 1.2rem; margin: 24px 0 8px; }

.card { background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }

.button, button.button {
  display: inline-block;
  background: var(--navy);
  color: var(--white);
  border: 2px solid var(--navy);
  border-radius: 6px;
  padding: 8px 16px;
  font: inherit;
  font-weight: bold;
  text-decoration: none;
  cursor: pointer;
}
.button.secondary { background: var(--white); color: var(--navy); }
.button.small { padding: 4px 10px; font-size: 0.9rem; }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: bold; margin-bottom: 4px; }
.field input[type="text"], .field input[type="password"], .field input[type="datetime-local"], .field input[type="url"] {
  width: 100%;
  padding: 10px;
  font: inherit;
  border: 1px solid #6c7682;
  border-radius: 6px;
  background: var(--white);
  color: var(--text);
}
.field.checkbox label { display: inline; margin-left: 6px; }
.help { color: var(--muted); font-size: 0.9rem; margin: 4px 0 0; }
.errorlist { list-style: none; margin: 4px 0 0; padding: 8px 10px; background: var(--red-tint); color: var(--red-text); border-radius: 6px; font-weight: bold; }

.messages { list-style: none; padding: 0; margin: 0 0 20px; }
.messages li { padding: 12px 16px; border-radius: 6px; margin-bottom: 8px; border: 1px solid var(--border); word-break: break-word; }
.messages li.success { background: var(--green-tint); color: var(--green-text); border-color: #a5d6a7; }
.messages li.warning { background: var(--yellow-tint); color: var(--yellow-text); border-color: #f2d675; }
.messages li.error { background: var(--red-tint); color: var(--red-text); border-color: #ef9a9a; }

.status { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.85rem; font-weight: bold; }
.status.active { background: var(--green-tint); color: var(--green-text); }
.status.disabled { background: var(--red-tint); color: var(--red-text); }
.status.expired { background: var(--yellow-tint); color: var(--yellow-text); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--white); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--navy); color: var(--white); font-size: 0.9rem; }
td.url { word-break: break-all; max-width: 280px; }
.thumb { width: 72px; height: 72px; display: block; border: 1px solid var(--border); background: var(--white); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }

.link-cards { display: none; }

.toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.pagination { display: flex; gap: 16px; align-items: center; margin-top: 16px; }
.qr-preview { max-width: 240px; width: 100%; height: auto; border: 1px solid var(--border); background: var(--white); }
.two-col { display: grid; grid-template-columns: 1fr; gap: 20px; }
.public-wrap { max-width: 520px; margin: 64px auto; text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }

@media (min-width: 800px) {
  .two-col { grid-template-columns: 2fr 1fr; }
}

@media (max-width: 720px) {
  .table-wrap { display: none; }
  .link-cards { display: block; }
  .link-card { background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 12px; display: grid; grid-template-columns: 72px 1fr; gap: 12px; }
  .link-card dl { margin: 0; }
  .link-card dt { font-size: 0.8rem; color: var(--muted); }
  .link-card dd { margin: 0 0 6px; word-break: break-all; }
  .link-card .actions { grid-column: 1 / -1; }
}
