:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  background: #f4f6f8;
  color: #1d2733;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button {
  font: inherit;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #f4f6f8;
}

.login-card {
  width: min(100%, 360px);
  padding: 30px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}

.login-card h2 { margin: 4px 0 8px; }
.login-card > p:not(.login-error) { margin: 0 0 20px; color: #667484; font-size: 14px; }
.login-eyebrow { color: #2563eb !important; font-weight: 600; }
.login-card label { display: block; margin: 14px 0 6px; font-size: 14px; font-weight: 600; }
.login-card input, .login-card button { width: 100%; }
.login-card input { padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 6px; }
.login-card button { margin-top: 16px; padding: 10px 12px; border: 0; border-radius: 6px; background: #2563eb; color: white; cursor: pointer; }
.login-error { min-height: 20px; margin: 10px 0 0; color: #b91c1c; font-size: 13px; }

.topbar {
  height: 72px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border-bottom: 1px solid #dce2e8;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
}

.topbar p,
#selectedMeta {
  margin-top: 4px;
  color: #667484;
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 72px);
}

.student-list {
  background: #ffffff;
  border-right: 1px solid #dce2e8;
  padding: 16px;
}

.panel-title {
  font-weight: 600;
  margin-bottom: 12px;
}

.student-card {
  width: 100%;
  text-align: left;
  display: block;
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid #dce2e8;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

.student-card.active {
  border-color: #1f6feb;
  box-shadow: inset 3px 0 0 #1f6feb;
}

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

.student-card span {
  color: #667484;
  font-size: 12px;
  margin-top: 4px;
}

.process-panel {
  padding: 20px;
}

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

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

.process-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.tabs {
  border-bottom: 1px solid #dce2e8;
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.tab-button {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: #516171;
  flex: 0 0 auto;
  font-weight: 600;
  padding: 10px 14px;
}

.tab-button.active {
  border-bottom-color: #1f6feb;
  color: #1d2733;
}

.tab-panel[hidden] {
  display: none;
}

.browser-section {
  margin-top: 0;
}

.section-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-header h3 {
  font-size: 16px;
  margin: 0;
}

.section-header p {
  color: #667484;
  font-size: 13px;
  margin-top: 4px;
}

.status-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 5px 8px;
}

.status-pill.allowed {
  background: #e7f6ec;
  color: #137333;
}

.status-pill.blocked {
  background: #fdecec;
  color: #b4232d;
}

.status-pill.active-page {
  background: #dbeafe;
  color: #1d4ed8;
  margin-left: 6px;
  vertical-align: middle;
}

.url-cell {
  display: grid;
  gap: 3px;
  overflow-wrap: anywhere;
}

.url-cell strong {
  font-weight: 600;
}

.url-cell span {
  color: #667484;
  font-size: 12px;
}

.process-toolbar label {
  color: #516171;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.process-toolbar input {
  width: min(360px, 100%);
  border: 1px solid #bdc7d1;
  border-radius: 6px;
  color: #1d2733;
  font: inherit;
  padding: 8px 10px;
}

.process-toolbar input:focus {
  border-color: #1f6feb;
  outline: 2px solid #dbeafe;
}

.toggle-control {
  align-items: center;
  color: #516171;
  display: inline-flex;
  font-size: 14px;
  font-weight: 600;
  gap: 6px;
  white-space: nowrap;
}

.toggle-control input {
  height: 16px;
  width: 16px;
}

button {
  border: 1px solid #bdc7d1;
  background: #ffffff;
  color: #1d2733;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
}

.small-button {
  font-size: 13px;
  line-height: 1.2;
  padding: 5px 8px;
}

button:hover:not(:disabled) {
  border-color: #1f6feb;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.danger {
  border-color: #d33f49;
  color: #b4232d;
}

.dialog {
  border: 1px solid #dce2e8;
  border-radius: 8px;
  color: #1d2733;
  max-width: min(560px, calc(100vw - 32px));
  padding: 0;
  width: 560px;
}

.dialog::backdrop {
  background: rgb(29 39 51 / 42%);
}

.dialog-header {
  align-items: center;
  border-bottom: 1px solid #edf1f4;
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
}

.dialog-header h3 {
  font-size: 16px;
  margin: 0;
}

.dialog-body {
  max-height: 60vh;
  overflow: auto;
  padding: 14px;
}

.dialog-footer {
  border-top: 1px solid #edf1f4;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px 14px;
}

.dialog-toolbar {
  align-items: center;
  border-bottom: 1px solid #edf1f4;
  display: flex;
  gap: 10px;
  padding: 12px 14px;
}

.dialog-toolbar label {
  color: #516171;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.dialog-toolbar input {
  border: 1px solid #bdc7d1;
  border-radius: 6px;
  color: #1d2733;
  flex: 1;
  font: inherit;
  min-width: 0;
  padding: 8px 10px;
}

.dialog-toolbar input:focus {
  border-color: #1f6feb;
  outline: 2px solid #dbeafe;
}

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

.message-form label {
  color: #516171;
  font-size: 14px;
  font-weight: 600;
}

.message-form input,
.message-form textarea {
  border: 1px solid #bdc7d1;
  border-radius: 6px;
  color: #1d2733;
  font: inherit;
  padding: 8px 10px;
  width: 100%;
}

.message-form textarea {
  min-height: 132px;
  resize: vertical;
}

.message-form input:focus,
.message-form textarea:focus {
  border-color: #1f6feb;
  outline: 2px solid #dbeafe;
}

.update-package-dialog {
  width: 620px;
}

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

.update-package-form label {
  color: #516171;
  font-size: 14px;
  font-weight: 600;
}

.update-package-form input,
.update-package-form textarea {
  border: 1px solid #bdc7d1;
  border-radius: 6px;
  color: #1d2733;
  font: inherit;
  padding: 8px 10px;
  width: 100%;
}

.update-package-form input[type="file"] {
  background: #ffffff;
}

.update-package-form textarea {
  min-height: 96px;
  resize: vertical;
}

.update-package-form input:focus,
.update-package-form textarea:focus {
  border-color: #1f6feb;
  outline: 2px solid #dbeafe;
}

.update-current,
.form-status {
  background: #f8fafc;
  border: 1px solid #edf1f4;
  border-radius: 6px;
  color: #516171;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  padding: 10px;
}

.form-status:empty {
  display: none;
}

.whitelist-dialog-list {
  border: 1px solid #edf1f4;
  border-radius: 6px;
  overflow: hidden;
}

.whitelist-dialog-content {
  display: grid;
  gap: 16px;
}

.whitelist-section h4 {
  color: #1d2733;
  font-size: 14px;
  margin: 0 0 8px;
}

.whitelist-dialog-row {
  align-items: center;
  border-bottom: 1px solid #edf1f4;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  overflow-wrap: anywhere;
  padding: 8px 10px;
}

.whitelist-dialog-row:last-child {
  border-bottom: 0;
}

.detail-table {
  min-width: 0;
}

.detail-table th,
.detail-table td {
  font-size: 14px;
  padding: 10px 12px;
}

.detail-table th {
  width: 96px;
}

.detail-table td {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.duration-options {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.duration-options .small-button {
  min-height: 36px;
}

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

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

th,
td {
  border-bottom: 1px solid #edf1f4;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: #f8fafc;
  color: #516171;
  font-weight: 600;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.process-name-cell {
  display: grid;
  gap: 3px;
  overflow-wrap: anywhere;
}

.process-name-cell strong {
  font-weight: 600;
}

.process-name-cell span {
  color: #667484;
  font-size: 12px;
}

.icon-button {
  align-items: center;
  display: inline-flex;
  font-size: 16px;
  font-weight: 700;
  height: 28px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 28px;
}

.add-button {
  color: #1f6feb;
  flex: 0 0 auto;
}

.empty {
  color: #667484;
  text-align: center;
  padding: 40px 12px;
}

@media (max-width: 760px) {
  body {
    background: #ffffff;
  }

  .layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .student-list {
    border-right: 0;
    border-bottom: 1px solid #dce2e8;
    padding: 12px;
  }

  #students {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .topbar,
  .process-header {
    align-items: flex-start;
    flex-direction: column;
    height: auto;
    padding: 16px;
  }

  .topbar {
    gap: 12px;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .small-button {
    min-height: 32px;
  }

  .student-card {
    flex: 0 0 min(260px, 78vw);
    margin-bottom: 0;
  }

  .student-card.active {
    box-shadow: inset 0 3px 0 #1f6feb;
  }

  .process-panel {
    padding: 14px 12px 18px;
  }

  .process-header {
    gap: 10px;
    margin-bottom: 12px;
    padding: 0;
  }

  .process-header h2 {
    font-size: 20px;
  }

  #selectedMeta {
    line-height: 1.5;
  }

  .process-header-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .process-header-actions .small-button {
    flex: 1 1 calc(50% - 8px);
    min-height: 34px;
  }

  .process-header-actions .danger {
    flex-basis: 100%;
  }

  .process-toolbar {
    align-items: center;
    display: grid;
    grid-template-columns: auto 1fr auto;
    margin-bottom: 10px;
  }

  .process-toolbar input {
    width: 100%;
  }

  .toggle-control {
    grid-column: 1 / -1;
  }

  .table-wrap {
    background: transparent;
    border: 0;
    border-radius: 0;
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tr {
    background: #ffffff;
    border: 1px solid #dce2e8;
    border-radius: 6px;
    overflow: hidden;
  }

  td {
    align-items: flex-start;
    border-bottom: 1px solid #edf1f4;
    display: grid;
    gap: 8px;
    grid-template-columns: 76px minmax(0, 1fr);
    padding: 9px 10px;
  }

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

  td::before {
    color: #667484;
    content: attr(data-label);
    font-size: 12px;
    font-weight: 600;
    padding-top: 2px;
  }

  td.empty {
    display: block;
    padding: 28px 12px;
  }

  td.empty::before {
    content: none;
  }

  .row-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .row-actions .small-button {
    min-height: 32px;
    width: 100%;
  }

  .dialog {
    max-width: calc(100vw - 16px);
    width: calc(100vw - 16px);
  }

  .dialog-toolbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
  }

  .dialog-body {
    max-height: 68vh;
    padding: 10px;
  }

  .dialog-footer {
    padding: 10px;
  }

  .dialog-footer .small-button {
    min-height: 34px;
    min-width: 88px;
  }

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

  .detail-table,
  .detail-table tbody,
  .detail-table tr,
  .detail-table th,
  .detail-table td {
    display: block;
    width: 100%;
  }

  .detail-table tr {
    border: 0;
    border-bottom: 1px solid #edf1f4;
    border-radius: 0;
  }

  .detail-table th {
    border-bottom: 0;
    color: #667484;
    padding-bottom: 2px;
    width: 100%;
  }

  .detail-table td {
    border-bottom: 0;
    display: block;
    padding-top: 2px;
  }

  .detail-table td::before {
    content: none;
  }
}
