:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: #17202a;
  background: #eef1f5;
}

* {
  box-sizing: border-box;
}

body {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  margin: 0;
  min-height: 100vh;
  min-width: 320px;
}

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

button,
.portal-link {
  align-items: center;
  background: #ffffff;
  border: 1px solid #cfd6df;
  border-radius: 6px;
  color: #17202a;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  min-height: 36px;
  padding: 7px 11px;
}

button:hover,
.portal-link:hover {
  background: #f5f7fa;
}

button.primary {
  background: #1264a3;
  border-color: #1264a3;
  color: #ffffff;
}

button.full,
.full {
  justify-content: center;
  width: 100%;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid #c9d2dc;
  border-radius: 6px;
  color: #17202a;
  min-height: 36px;
  padding: 7px 9px;
  width: 100%;
}

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

label {
  color: #44515f;
  display: grid;
  font-size: 13px;
  gap: 6px;
}

.hidden {
  display: none !important;
}

.sidebar {
  background: #202936;
  color: #f7f9fb;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.brand-icon {
  align-items: center;
  background: #72b7ff;
  border-radius: 8px;
  color: #102033;
  display: inline-flex;
  font-weight: 800;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.2;
  margin: 0;
}

.brand p,
.toolbar p,
.muted {
  color: #6f7d8d;
  margin: 2px 0 0;
}

.brand p {
  color: #aeb8c4;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  background: transparent;
  border-color: transparent;
  color: #d9e0e8;
  justify-content: flex-start;
}

.nav-mark {
  background: #405167;
  border-radius: 4px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  min-width: 34px;
  padding: 2px 4px;
  text-align: center;
}

.nav button.active,
.nav button:hover {
  background: #2e3a49;
  border-color: #3b4a5c;
  color: #ffffff;
}

.connection {
  display: grid;
  gap: 12px;
}

.connection h2 {
  font-size: 14px;
  margin: 0;
}

.portal-link {
  background: #17202b;
  border-color: #3b4a5c;
  color: #eaf0f6;
  justify-content: center;
  text-decoration: none;
}

.portal-link span:first-child {
  background: #72b7ff;
  border-radius: 4px;
  color: #102033;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 5px;
}

.portal-link:hover {
  background: #2e3a49;
  color: #ffffff;
}

.main {
  min-width: 0;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #d9dfe7;
  display: flex;
  justify-content: space-between;
  min-height: 58px;
  padding: 12px 20px;
}

.segmented {
  background: #eef1f5;
  border: 1px solid #d5dce5;
  border-radius: 7px;
  display: inline-flex;
  padding: 3px;
}

.segmented button {
  border: 0;
  border-radius: 5px;
  min-height: 30px;
  padding: 4px 10px;
}

.segmented button.active {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(23, 32, 42, 0.14);
}

.status-line {
  color: #6f7d8d;
  font-size: 13px;
  min-height: 20px;
}

.status-line.error {
  color: #9b1c1c;
}

.workspace {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.toolbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.toolbar h2 {
  font-size: 22px;
  margin: 0;
}

.toolbar-actions,
.icon-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.stats-grid article {
  background: #ffffff;
  border: 1px solid #d9dfe7;
  border-radius: 8px;
  padding: 14px;
}

.stats-grid span {
  color: #6f7d8d;
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.stats-grid strong {
  font-size: 24px;
}

.filters {
  align-items: end;
  background: #ffffff;
  border: 1px solid #d9dfe7;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 1fr) 170px 190px auto;
  padding: 14px;
}

.check {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  white-space: nowrap;
}

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

.table-wrap {
  background: #ffffff;
  border: 1px solid #d9dfe7;
  border-radius: 8px;
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid #e7ebf0;
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f7f9fb;
  color: #52606f;
  font-size: 12px;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  font-size: 14px;
}

td small {
  color: #738191;
  display: block;
  font-size: 12px;
  margin-top: 3px;
  max-width: 340px;
  overflow-wrap: anywhere;
}

.empty {
  color: #738191;
  padding: 32px;
  text-align: center;
}

.pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  text-transform: uppercase;
}

.pill.active {
  background: #e8f5ee;
  color: #1c6f43;
}

.pill.paused {
  background: #fff3d8;
  color: #8a5b05;
}

.pill.revoked {
  background: #fde8e8;
  color: #9b1c1c;
}

.pill.open {
  background: #e7f0f6;
  color: #1264a3;
}

.pill.reviewing {
  background: #fff3d8;
  color: #8a5b05;
}

.pill.approved,
.pill.issued {
  background: #e8f5ee;
  color: #1c6f43;
}

.pill.rejected {
  background: #fde8e8;
  color: #9b1c1c;
}

.pill.closed {
  background: #eceff3;
  color: #52606f;
}

.icon-row button {
  height: 34px;
  justify-content: center;
  padding: 0;
  width: 34px;
}

.icon-row button.danger {
  border-color: #f0b7b7;
  color: #9b1c1c;
}

.icon-row button.danger:hover {
  background: #fde8e8;
}

.overlay {
  align-items: center;
  background: rgba(16, 24, 35, 0.36);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 10;
}

.modal,
.drawer {
  background: #ffffff;
  border: 1px solid #d9dfe7;
  border-radius: 8px;
  box-shadow: 0 16px 42px rgba(16, 24, 35, 0.24);
}

.modal {
  max-height: calc(100vh - 40px);
  max-width: 760px;
  overflow: auto;
  padding: 18px;
  width: 100%;
}

.modal.narrow {
  max-width: 520px;
}

.modal-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h2 {
  font-size: 18px;
  margin: 0;
}

.modal-head button {
  font-size: 20px;
  height: 34px;
  justify-content: center;
  padding: 0;
  width: 34px;
}

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

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

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.drawer {
  bottom: 0;
  max-width: 460px;
  overflow: auto;
  padding: 18px;
  position: fixed;
  right: 0;
  top: 0;
  width: min(460px, 100vw);
  z-index: 11;
}

.application-drawer {
  max-width: 620px;
  width: min(620px, 100vw);
}

.application-detail,
.detail-stack,
.review-form,
.attachment-list {
  display: grid;
  gap: 10px;
}

.detail-stack article {
  background: #f7f9fb;
  border: 1px solid #e0e5ec;
  border-radius: 8px;
  display: grid;
  gap: 5px;
  padding: 12px;
}

.detail-stack span {
  color: #6f7d8d;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-stack p {
  margin: 0;
  white-space: pre-wrap;
}

.detail-stack a,
.attachment-link {
  color: #1264a3;
  overflow-wrap: anywhere;
}

.attachment-link {
  align-items: center;
  background: #ffffff;
  border: 1px solid #d9dfe7;
  border-radius: 7px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  text-decoration: none;
}

.attachment-link:hover {
  background: #f5f7fa;
}

.review-form {
  border-top: 1px solid #e0e5ec;
  margin-top: 16px;
  padding-top: 16px;
}

.timeline {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.timeline article {
  border: 1px solid #e0e5ec;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 20px 1fr;
  padding: 12px;
}

.timeline p {
  color: #6f7d8d;
  margin: 2px 0 8px;
}

code {
  background: #f2f5f8;
  border-radius: 5px;
  display: block;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
  padding: 8px;
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 16px;
  }

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

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

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