:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-strong: #eef4ff;
  --text: #111827;
  --muted: #667085;
  --line: #dbe3ef;
  --line-strong: #c9d4e5;
  --blue: #1f5eff;
  --blue-dark: #174bd0;
  --blue-soft: #e8f0ff;
  --green: #067647;
  --green-bg: #dcfae6;
  --red: #b42318;
  --red-bg: #fee4e2;
  --amber: #b54708;
  --amber-bg: #fef0c7;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.08);
  --shadow-soft: 0 8px 22px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #ffffff 0, var(--bg) 250px),
    var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  min-height: 76px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(16, 24, 40, 0.05);
  backdrop-filter: blur(10px);
}

.topbar-item {
  border-radius: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 230px;
  padding: 8px 10px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  font-size: 19px;
  font-weight: 900;
  box-shadow: var(--shadow-soft);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  color: #344054;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 800;
}

.nav-button {
  background: transparent;
  cursor: pointer;
}

.nav-link:hover {
  background: var(--surface-soft);
  border-color: var(--line);
}

.nav-link.active {
  background: #111827;
  color: #ffffff;
  box-shadow: var(--shadow-soft);
}

.main {
  width: 100%;
  min-width: 0;
  padding: 30px 28px 40px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #0b1220;
  font-size: 30px;
  line-height: 1.16;
}

h2 {
  color: #182230;
  font-size: 18px;
}

.page-header p {
  margin-top: 7px;
  color: var(--muted);
}

.header-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-stats span,
.mini-label,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: #475467;
  font-size: 13px;
  font-weight: 800;
}

.header-stats span {
  background: var(--blue-soft);
  border-color: #cddcff;
  color: #1849a9;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 190px auto;
  gap: 14px;
  align-items: end;
  width: 100%;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

label {
  display: grid;
  gap: 7px;
  color: #475467;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 240px;
  padding: 13px 14px;
  line-height: 1.55;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(31, 94, 255, 0.12);
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 10px 18px rgba(31, 94, 255, 0.18);
}

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

.button.secondary {
  background: #ffffff;
  border-color: var(--line-strong);
  color: #182230;
}

.button.secondary:hover {
  border-color: #aab8cd;
  box-shadow: var(--shadow-soft);
}

.button.danger {
  background: var(--red-bg);
  color: var(--red);
}

.button.success {
  background: var(--green-bg);
  color: var(--green);
}

.table-wrap,
.panel {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.table-wrap {
  overflow: hidden;
}

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

th,
td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f7f9fc;
  color: #475467;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: #f8fbff;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.user-cell strong {
  display: block;
  margin-bottom: 5px;
  color: #101828;
}

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

.badge.active {
  background: var(--green-bg);
  color: var(--green);
  border-color: #abefc6;
}

.badge.inactive,
.badge.expired {
  background: var(--red-bg);
  color: var(--red);
  border-color: #fecdca;
}

.badge.neutral {
  background: #f2f4f7;
  color: #475467;
}

.badge.warning {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: #fedf89;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.actions-col {
  text-align: right;
}

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

.back-link {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--blue);
  font-weight: 900;
}

.details-grid {
  display: grid;
  grid-template-columns: minmax(290px, 0.85fr) minmax(360px, 1.15fr);
  gap: 18px;
  align-items: start;
  width: 100%;
}

.panel {
  padding: 22px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.info-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.info-list div {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.info-list div:first-child {
  padding-top: 0;
}

.info-list div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.info-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.info-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.form-panel,
.message-form {
  display: grid;
  gap: 16px;
}

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

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.history-panel {
  margin-top: 18px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.check-row {
  display: inline-flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 10px 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 32px));
  padding: 13px 15px;
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

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

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(244, 247, 251, 0.95)),
    var(--bg);
}

.login-card {
  width: min(100%, 460px);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-brand {
  min-width: 0;
  padding: 0;
  margin-bottom: 26px;
}

.login-heading {
  margin-bottom: 22px;
}

.login-heading h1 {
  font-size: 30px;
}

.login-heading p {
  margin-top: 8px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 15px;
}

.login-button {
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
}

.form-message {
  padding: 11px 12px;
  background: var(--red-bg);
  border: 1px solid #fecdca;
  border-radius: 8px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .brand {
    min-width: 0;
    width: 100%;
    padding: 6px 0;
  }

  .nav {
    width: 100%;
    justify-content: stretch;
  }

  .nav-link {
    flex: 1;
    justify-content: center;
  }

  .main {
    padding: 24px 16px 34px;
  }

  .page-header,
  .details-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolbar,
  .two-col,
  .history-item,
  .info-list div {
    grid-template-columns: 1fr;
  }

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

  table {
    min-width: 860px;
  }
}
