:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --line: #d9e0ea;
  --sidebar: #18202b;
  --sidebar-active: #253245;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --teal: #0f766e;
  --danger: #dc2626;
  --warning: #b45309;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
}

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

button {
  cursor: pointer;
}

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

h1,
h2,
p {
  margin: 0;
}

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

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 30px;
  box-shadow: 0 24px 60px rgba(31, 41, 55, 0.12);
}

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

.login-brand {
  justify-content: center;
}

.login-brand h1 {
  font-size: 26px;
  line-height: 1.15;
}

.login-brand p,
.sidebar-brand span {
  color: var(--muted);
  font-size: 13px;
}

.brand-mark {
  display: block;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 2px solid #fff;
  object-fit: cover;
  object-position: center;
  background: #eef2f7;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.12);
}

.login-brand .brand-mark {
  width: 64px;
  height: 64px;
  border-radius: 10px;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.field {
  display: grid;
  gap: 8px;
  color: #475467;
  font-size: 13px;
}

.field.compact {
  min-width: 170px;
}

.field.grow {
  flex: 1 1 300px;
}

.field-counter {
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

textarea {
  padding: 10px 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  padding: 0;
}

.password-toggle:hover {
  background: #eef2f7;
  color: var(--primary);
}

.password-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.password-toggle__eye-off {
  display: none;
}

.password-toggle.is-visible .password-toggle__eye {
  display: none;
}

.password-toggle.is-visible .password-toggle__eye-off {
  display: block;
}

.primary-btn,
.ghost-btn,
.text-btn,
.icon-btn,
.row-btn {
  border-radius: 6px;
  border: 0;
}

.primary-btn {
  height: 40px;
  padding: 0 18px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

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

.primary-btn.is-danger {
  background: var(--danger);
}

.primary-btn.is-danger:hover {
  background: #b91c1c;
}

.compact-danger-btn {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.ghost-btn,
.row-btn {
  height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  background: #fff;
  color: #344054;
}

.ghost-btn:hover,
.row-btn:hover {
  border-color: #b9c4d4;
  background: #f8fafc;
}

.text-btn {
  background: transparent;
  color: var(--primary);
  font-weight: 700;
}

.icon-btn {
  width: 32px;
  height: 32px;
  background: #eef2f7;
  color: #475467;
  font-size: 20px;
  line-height: 1;
}

.row-btn.danger {
  border-color: #fecaca;
  background: #fff7f7;
  color: var(--danger);
}

.form-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

.admin-layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 230px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar);
  color: #fff;
  padding: 22px 16px;
}

.sidebar-brand {
  padding: 0 4px 22px;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand span {
  color: rgba(255, 255, 255, 0.62);
  margin-top: 3px;
}

.side-nav {
  display: grid;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.side-nav__item {
  height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  padding: 0 12px;
  text-align: left;
}

.side-nav__item:hover,
.side-nav__item.is-active {
  background: var(--sidebar-active);
  color: #fff;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

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

.workspace-header h1 {
  margin-top: 4px;
  font-size: 24px;
}

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

.user-badge {
  max-width: 260px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #344054;
  padding: 8px 12px;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-body {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 22px;
  padding: 18px;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 16px;
}

.profile-avatar {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 2px solid #fff;
  object-fit: cover;
  object-position: center;
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.14);
}

.profile-card strong,
.profile-card span {
  display: block;
}

.profile-card strong {
  color: #101828;
  font-size: 18px;
}

.profile-card span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.profile-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.profile-details div {
  min-height: 74px;
  border-right: 1px solid #eef2f6;
  border-bottom: 1px solid #eef2f6;
  padding: 14px 16px;
}

.profile-details div:nth-child(2n) {
  border-right: 0;
}

.profile-details dt {
  color: var(--muted);
  font-size: 13px;
}

.profile-details dd {
  margin: 8px 0 0;
  color: #101828;
  line-height: 1.5;
  word-break: break-word;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

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

.stat-block,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stat-block {
  min-height: 104px;
  padding: 18px;
}

.stat-block span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat-block strong {
  display: block;
  margin-top: 10px;
  color: #101828;
  font-size: 28px;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.panel-head--tools {
  align-items: center;
}

.panel-head--actions-only {
  justify-content: flex-end;
}

.panel-head h2 {
  font-size: 17px;
  line-height: 1.25;
}

.settings-form {
  padding: 0;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px;
}

.setting-row + .setting-row {
  border-top: 1px solid var(--line);
}

.setting-main {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  gap: 14px;
}

.setting-icon {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--primary);
}

.setting-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.setting-copy {
  min-width: 0;
}

.setting-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.setting-title-line strong {
  color: #101828;
  font-size: 15px;
  line-height: 1.4;
}

.setting-copy > span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.setting-control {
  display: flex;
  flex: 0 1 520px;
  align-items: flex-end;
  justify-content: flex-end;
  min-width: 0;
  gap: 10px;
}

.title-setting-field {
  flex: 1 1 320px;
  max-width: 400px;
}

.title-setting-control .primary-btn {
  flex: 0 0 auto;
}

.setting-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #ecfdf3;
  color: #027a48;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
}

.setting-status.is-off {
  background: #f2f4f7;
  color: #667085;
}

.switch-field {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.switch-field input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.switch-track {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.2);
  content: "";
  transition: transform 0.15s ease;
}

.switch-field input:checked + .switch-track {
  background: var(--primary);
}

.switch-field input:checked + .switch-track::after {
  transform: translateX(20px);
}

.switch-field input:focus + .switch-track {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  flex-wrap: wrap;
}

.filter-row .field {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.filter-row .field > span {
  flex: 0 0 auto;
  white-space: nowrap;
}

.filter-row .field input,
.filter-row .field select {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}

.filter-submit,
.filter-btn {
  margin-bottom: 0;
}

.material-keyword-field,
.account-keyword-field {
  flex: 1 1 380px;
  max-width: min(520px, 100%);
}

.filter-row #openAccountCreateBtn {
  margin-left: auto;
}

.filter-btn {
  height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 17px;
  font-weight: 700;
}

.filter-btn--search {
  background: var(--primary);
  color: #fff;
}

.filter-btn--search:hover {
  background: var(--primary-dark);
}

.filter-btn--clear {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.filter-btn--clear:hover {
  background: #ffedd5;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

.dashboard-grid .table-wrap {
  overflow-x: hidden;
}

.dashboard-grid table {
  min-width: 0;
  table-layout: fixed;
}

.dashboard-grid th,
.dashboard-grid td {
  padding: 10px 12px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.materials-table {
  width: 100%;
  min-width: 1570px;
  table-layout: fixed;
}

.recent-materials-table {
  min-width: 1130px;
  table-layout: fixed;
}

.accounts-table {
  table-layout: fixed;
}

.accounts-col-username {
  width: 140px;
}

.accounts-col-nickname {
  width: 140px;
}

.accounts-col-remark {
  width: auto;
}

.accounts-col-role,
.accounts-col-status {
  width: 110px;
}

.accounts-col-time {
  width: 170px;
}

.accounts-col-actions {
  width: 120px;
}

.materials-col-image {
  width: 72px;
}

.materials-col-name {
  width: 150px;
}

.materials-col-remark {
  width: 190px;
}

.materials-col-category {
  width: 110px;
}

.materials-col-owner-nickname {
  width: 240px;
}

.materials-col-owner-name {
  width: 150px;
}

.materials-col-owner-phone {
  width: 140px;
}

.materials-col-size {
  width: 90px;
}

.materials-col-time {
  width: 180px;
}

.materials-col-actions {
  width: 240px;
}

th,
td {
  border-bottom: 1px solid #eef2f6;
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  background: #f8fafc;
  color: #475467;
  font-weight: 700;
  white-space: nowrap;
}

td {
  color: #344054;
}

.materials-table th,
.materials-table td {
  padding-right: 12px;
  padding-left: 12px;
  white-space: nowrap;
}

.materials-table td:not(.action-col) {
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-text-cell {
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: break-word;
}

.materials-table td.user-text-cell {
  overflow: visible;
  text-overflow: clip;
}

.action-col {
  text-align: center;
}

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

.thumb {
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  object-fit: cover;
  background: #f1f5f9;
}

.main-cell {
  min-width: 180px;
}

.materials-table .main-cell {
  min-width: 0;
}

.main-cell strong,
.main-cell span {
  display: block;
}

.main-cell strong {
  max-width: 280px;
  overflow: hidden;
  color: #101828;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.materials-table .main-cell strong {
  max-width: 100%;
}

.main-cell span {
  max-width: 320px;
  overflow: hidden;
  margin-top: 4px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remark-cell {
  max-width: 260px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.materials-table .remark-cell {
  max-width: none;
}

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

.actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.materials-table .actions {
  flex-wrap: nowrap;
}

.materials-table .table-action {
  flex: 0 0 auto;
}

.table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 30px;
  gap: 5px;
  border-color: transparent;
  background: #f1f5f9;
  color: #2563eb;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.table-action:hover {
  border-color: transparent;
  background: #dbeafe;
  color: #1d4ed8;
}

.table-action.danger {
  border-color: transparent;
  background: #fef2f2;
  color: var(--danger);
}

.table-action.danger:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.table-action svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #eef2ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.badge.success {
  background: #ecfdf3;
  color: #027a48;
}

.badge.warning {
  background: #fffbeb;
  color: var(--warning);
}

.badge.danger {
  background: #fef2f2;
  color: var(--danger);
}

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

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 14px 18px;
  color: var(--muted);
  font-size: 13px;
}

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

.dialog {
  width: min(520px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 0;
  overflow: visible;
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(2px);
}

.dialog-box {
  display: grid;
  gap: 16px;
  border: 1px solid rgba(217, 224, 234, 0.9);
  border-radius: 8px;
  background: #fff;
  padding: 20px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head h2 {
  font-size: 18px;
}

.dialog-actions {
  justify-content: flex-end;
}

.dialog-actions .ghost-btn,
.dialog-actions .primary-btn {
  min-width: 84px;
  height: 44px;
}

.confirm-dialog {
  width: min(430px, calc(100% - 32px));
}

.confirm-box {
  gap: 22px;
  padding: 22px;
}

.confirm-content {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.confirm-icon {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: #ea580c;
}

.confirm-dialog.is-danger .confirm-icon {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.confirm-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.confirm-content h2 {
  color: #101828;
  font-size: 19px;
  line-height: 1.35;
}

.confirm-content p {
  margin-top: 8px;
  color: #475467;
  font-size: 14px;
  line-height: 1.65;
}

.confirm-note {
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid #eef2f7;
  padding: 9px 10px;
}

.confirm-note[hidden] {
  display: none;
}

.confirm-dialog .dialog-actions {
  gap: 10px;
}

.confirm-dialog .ghost-btn,
.confirm-dialog .primary-btn {
  min-width: 96px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100% - 48px));
  border-radius: 8px;
  background: #101828;
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 12px 34px rgba(16, 24, 40, 0.24);
  font-size: 13px;
  display: none;
}

.toast.is-visible {
  display: block;
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 820px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .workspace {
    padding: 18px;
  }

  .workspace-header,
  .table-footer,
  .setting-row,
  .profile-body {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-body,
  .profile-details {
    grid-template-columns: 1fr;
  }

  .profile-details div {
    border-right: 0;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .setting-control {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .login-panel {
    padding: 24px;
  }

  .workspace {
    padding: 12px;
  }

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

  .panel-head,
  .filter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .material-keyword-field,
  .account-keyword-field {
    flex-basis: auto;
    max-width: none;
  }

  .filter-row .field {
    width: 100%;
  }

  .primary-btn,
  .ghost-btn,
  .row-btn,
  .filter-btn {
    width: 100%;
  }

  .filter-row #openAccountCreateBtn {
    margin-left: 0;
  }

  .setting-row {
    gap: 18px;
    padding: 18px;
  }

  .setting-main {
    gap: 12px;
  }

  .switch-field {
    justify-content: space-between;
    width: 100%;
  }

  .setting-control {
    align-items: stretch;
    flex-direction: column;
  }

  .title-setting-field {
    max-width: none;
  }

  .pager,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    align-items: center;
    flex-direction: row;
  }
}
