:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #d9e0e7;
  --primary: #2457a6;
  --primary-dark: #1b4381;
  --danger: #b42318;
  --success: #0f766e;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 700;
}

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

.button.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.button.small {
  min-height: 28px;
  padding: 5px 9px;
  font-size: 12px;
}

.danger,
.link-danger {
  background: var(--danger);
  color: #fff;
}

.link-danger {
  border: 0;
  padding: 0;
  min-height: 0;
  background: transparent;
  color: var(--danger);
  font-weight: 700;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  background: #18212f;
  color: #fff;
  padding: 20px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  min-width: 0;
}

.brand img {
  width: 64px;
  height: 42px;
  flex: 0 0 64px;
  object-fit: contain;
}

.brand > div {
  min-width: 0;
  line-height: 1.15;
}

.brand strong,
.brand span {
  display: block;
  overflow-wrap: anywhere;
}

.brand strong {
  font-size: 19px;
  font-weight: 800;
}

.brand span {
  font-size: 14px;
  color: #cbd5e1;
  margin-top: 3px;
}

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

.sidebar a {
  color: #cbd5e1;
  padding: 11px 12px;
  border-radius: 6px;
}

.sidebar a.active,
.sidebar a:hover {
  background: #263449;
  color: #fff;
}

.main {
  margin-left: 248px;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.topbar span {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0;
}

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

h1 {
  font-size: 26px;
}

h2 {
  font-size: 18px;
  margin-top: 22px;
}

h3 {
  font-size: 15px;
  margin-top: 16px;
}

.panel,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.flash {
  border-radius: 6px;
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.flash.success {
  border-color: #99d5cd;
  color: #075e54;
}

.flash.error {
  border-color: #f0afa8;
  color: var(--danger);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.stat {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.stat span {
  color: var(--muted);
  line-height: 1.35;
}

.stat strong {
  font-size: 30px;
  color: var(--text);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

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

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

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

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.check input {
  width: auto;
  min-height: 0;
}

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #eef2f6;
  color: #334155;
  font-size: 12px;
  text-transform: uppercase;
}

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

.actions form {
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-weight: 800;
  font-size: 12px;
}

.status-expired,
.status-30 {
  background: #fee4e2;
  color: #912018;
}

.status-60 {
  background: #fef7c3;
  color: #854a0e;
}

.status-90 {
  background: #ffead5;
  color: #9c2a10;
}

.status-normal {
  background: #dcfce7;
  color: #166534;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.detail-grid div {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.file-list,
.export-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.file-pill {
  display: inline-flex;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
}

.remark-form {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.remark {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

.remark span {
  color: var(--muted);
  margin-left: 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

.settings-grid .wide {
  grid-column: 1 / -1;
}

.inline-form,
.user-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.permission-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

pre {
  max-width: 420px;
  white-space: pre-wrap;
  margin: 0;
  font-size: 12px;
}

.approval-form {
  display: grid;
  gap: 8px;
}

.settings-stack {
  display: grid;
  gap: 16px;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.group-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: #fcfdff;
  min-width: 0;
}

.group-head,
.user-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.compact {
  border-top: 0;
  padding: 0;
}

.user-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-top: 12px;
  background: #fff;
}

.user-card-head {
  margin-bottom: 0;
  align-items: center;
}

.access-form,
.change-list {
  display: grid;
  gap: 12px;
}

.delete-user {
  display: block;
  margin: 0;
}

.change-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.change-item span {
  color: var(--muted);
  font-size: 12px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

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

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.login-brand img {
  width: 108px;
  height: 68px;
  flex: 0 0 108px;
  object-fit: contain;
}

.login-brand strong {
  min-width: 0;
  font-size: 23px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.login-card h1 {
  margin-bottom: 2px;
}

.default-login-info {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f7f9fc;
}

.default-login-info > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.default-login-info code {
  color: var(--primary);
  font-weight: 700;
}

.default-login-info small {
  color: var(--muted);
  line-height: 1.45;
}

.muted {
  color: var(--muted);
  margin: 0;
}

@media (max-width: 780px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .main {
    margin-left: 0;
    padding: 14px;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand img {
    width: 54px;
    height: 36px;
    flex-basis: 54px;
  }
}

@media (max-width: 420px) {
  .login-brand {
    gap: 10px;
  }

  .login-brand img {
    width: 84px;
    height: 54px;
    flex-basis: 84px;
  }

  .login-brand strong {
    font-size: 20px;
  }
}
