:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #edf1f2;
  --text: #182126;
  --text-muted: #657178;
  --border: #d8dfe2;
  --border-strong: #bdc8cc;
  --accent: #087f72;
  --accent-hover: #06675e;
  --accent-soft: #def3ef;
  --warning: #a36207;
  --warning-soft: #fff1d5;
  --danger: #bb2d3b;
  --danger-soft: #fde8ea;
  --info: #3267a8;
  --shadow: 0 12px 32px rgba(24, 33, 38, 0.13);
  --radius: 6px;
  --topbar-height: 58px;
  --sidebar-width: 248px;
  color-scheme: light;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(8, 127, 114, 0.22);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 430px) minmax(0, 1fr);
  background: var(--surface);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 56px;
  border-right: 1px solid var(--border);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 44px;
  font-weight: 720;
  font-size: 20px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: white;
  background: var(--accent);
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.auth-panel h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.25;
  font-weight: 720;
}

.auth-subtitle {
  margin: 0 0 30px;
  color: var(--text-muted);
  line-height: 1.65;
}

.auth-form,
.form-stack {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label,
.field-label {
  color: #354147;
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea,
.input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
}

.field textarea {
  min-height: 86px;
  resize: vertical;
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.input:hover {
  border-color: #8f9da3;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(8, 127, 114, 0.12);
}

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

.auth-switch {
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 13px;
}

.text-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}

.auth-scene {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 64px;
  background: #e8eeee;
}

.scene-board {
  width: min(720px, 90%);
  border: 1px solid #c8d2d5;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 28px 60px rgba(50, 67, 74, 0.16);
  overflow: hidden;
}

.scene-top {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
}

.scene-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #aab5b9;
}

.scene-body {
  display: grid;
  grid-template-columns: 150px 1fr;
  min-height: 360px;
}

.scene-sidebar {
  padding: 22px 15px;
  border-right: 1px solid var(--border);
  background: #f7f9f9;
}

.scene-line {
  height: 10px;
  margin: 0 0 16px;
  border-radius: 2px;
  background: #d7dfe1;
}

.scene-line.active {
  background: #94c9c1;
}

.scene-files {
  padding: 30px;
}

.scene-file {
  display: grid;
  grid-template-columns: 26px 1fr 80px;
  align-items: center;
  gap: 14px;
  height: 56px;
  border-bottom: 1px solid #e2e7e9;
}

.scene-file-icon {
  width: 24px;
  height: 28px;
  border: 2px solid #809197;
  border-radius: 3px;
}

.scene-file-name,
.scene-file-meta {
  height: 9px;
  border-radius: 2px;
  background: #d4dcde;
}

.scene-file-name {
  width: 58%;
}

.scene-file-meta {
  width: 100%;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: var(--topbar-height) 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
}

.topbar-left,
.topbar-right,
.brand,
.user-menu-button {
  display: flex;
  align-items: center;
}

.topbar-left,
.topbar-right {
  gap: 12px;
}

.brand {
  gap: 10px;
  font-weight: 720;
  white-space: nowrap;
}

.brand .brand-mark {
  width: 31px;
  height: 31px;
}

.icon-btn.mobile-menu {
  display: none;
}

.user-menu-button {
  gap: 9px;
  min-height: 38px;
  padding: 4px 8px 4px 5px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}

.user-menu-button:hover {
  background: var(--surface-muted);
}

.avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 13px;
  font-weight: 750;
}

.layout {
  min-height: calc(100vh - var(--topbar-height));
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
  border-right: 1px solid var(--border);
  background: #f9fafa;
  overflow-y: auto;
}

.nav-label {
  margin: 18px 10px 7px;
  color: #7a858a;
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 3px;
}

.nav-item {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #3d494f;
  cursor: pointer;
  text-align: left;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.nav-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:hover {
  background: #eaf0f1;
}

.nav-item.active {
  background: var(--accent-soft);
  color: #075f57;
  font-weight: 680;
}

.archived-tag {
  margin-left: auto;
  color: var(--warning);
  font-size: 10px;
}

.sidebar-storage {
  margin-top: auto;
  padding: 16px 10px 8px;
  border-top: 1px solid var(--border);
}

.storage-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.progress {
  height: 6px;
  margin: 9px 0 7px;
  overflow: hidden;
  border-radius: 3px;
  background: #dce3e5;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}

.content {
  min-width: 0;
  background: var(--surface);
}

.page-header {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.page-title {
  min-width: 0;
}

.page-title h1 {
  margin: 0;
  overflow: hidden;
  font-size: 20px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-title p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.toolbar,
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn,
.icon-btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: white;
  color: #354147;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn {
  padding: 7px 12px;
  font-weight: 630;
}

.icon-btn {
  width: 36px;
  padding: 0;
}

.btn svg,
.icon-btn svg {
  width: 17px;
  height: 17px;
}

.btn:hover,
.icon-btn:hover {
  border-color: #93a0a6;
  background: #f7f9f9;
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.btn.primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.btn.danger {
  border-color: #efbdc2;
  color: var(--danger);
}

.btn.danger:hover {
  background: var(--danger-soft);
}

.btn.ghost,
.icon-btn.ghost {
  border-color: transparent;
  background: transparent;
}

.btn:disabled,
.icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.breadcrumbs-bar {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 24px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfc;
}

.breadcrumbs {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}

.breadcrumb {
  padding: 4px 5px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.breadcrumb:last-child {
  color: var(--text);
  font-weight: 650;
}

.breadcrumb-separator {
  color: #9da7ab;
}

.search {
  position: relative;
  width: min(260px, 34vw);
  margin-left: auto;
}

.search svg {
  position: absolute;
  top: 9px;
  left: 10px;
  width: 17px;
  height: 17px;
  color: var(--text-muted);
}

.search input {
  width: 100%;
  height: 36px;
  padding: 7px 10px 7px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
}

.files-wrap {
  min-height: 360px;
  overflow-x: auto;
}

.files-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.files-table th,
.files-table td {
  height: 48px;
  padding: 8px 12px;
  border-bottom: 1px solid #e6eaeb;
  text-align: left;
  vertical-align: middle;
}

.files-table th {
  height: 40px;
  background: #fbfcfc;
  color: #68747a;
  font-size: 12px;
  font-weight: 650;
}

.files-table tbody tr {
  cursor: pointer;
}

.files-table tbody tr:hover,
.files-table tbody tr.selected {
  background: #f0f7f6;
}

.name-cell {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.file-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  border-radius: 5px;
  background: #e8eeee;
  color: #536168;
}

.file-icon.folder {
  background: var(--warning-soft);
  color: var(--warning);
}

.file-icon.image {
  background: var(--accent-soft);
  color: var(--accent);
}

.file-icon.pdf {
  background: var(--danger-soft);
  color: var(--danger);
}

.file-icon svg {
  width: 18px;
  height: 18px;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 590;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  opacity: 0;
}

tr:hover .row-actions,
tr:focus-within .row-actions {
  opacity: 1;
}

.empty-state {
  min-height: 350px;
  display: grid;
  place-items: center;
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg {
  width: 42px;
  height: 42px;
  margin-bottom: 12px;
  color: #9aa7ac;
}

.empty-state h2 {
  margin: 0 0 6px;
  color: #3b474d;
  font-size: 16px;
}

.empty-state p {
  margin: 0;
  font-size: 13px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--surface-muted);
  color: #536168;
  font-size: 11px;
  font-weight: 700;
}

.status-badge.active {
  background: var(--accent-soft);
  color: #07665d;
}

.status-badge.archived,
.status-badge.pending {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-badge.disabled,
.status-badge.used {
  background: var(--danger-soft);
  color: var(--danger);
}

.upload-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 45;
  width: min(390px, calc(100vw - 40px));
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.upload-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

.upload-list {
  max-height: 260px;
  overflow-y: auto;
}

.upload-item {
  padding: 11px 13px;
  border-bottom: 1px solid #e8ebec;
}

.upload-item:last-child {
  border-bottom: 0;
}

.upload-item-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  font-size: 12px;
}

.upload-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-body {
  padding: 22px 24px 40px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--border);
  overflow: hidden;
}

.metric {
  min-height: 98px;
  padding: 18px;
  background: white;
}

.metric-label {
  color: var(--text-muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 750;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  min-height: 40px;
  padding: 8px 13px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  border-bottom-color: var(--accent);
  color: var(--text);
  font-weight: 700;
}

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

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

.data-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  min-height: 48px;
  padding: 11px 13px;
  border-bottom: 1px solid #e6eaeb;
  text-align: left;
}

.data-table th {
  background: #f8fafa;
  color: var(--text-muted);
  font-size: 12px;
}

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

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.detail-list {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 13px 16px;
  margin: 0;
}

.detail-list dt {
  color: var(--text-muted);
}

.detail-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 26, 29, 0.48);
}

.dialog {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.dialog.wide {
  width: min(720px, 100%);
}

.dialog-header,
.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
}

.dialog-header {
  border-bottom: 1px solid var(--border);
}

.dialog-header h2 {
  margin: 0;
  font-size: 17px;
}

.dialog-body {
  padding: 18px 16px;
  overflow-y: auto;
}

.dialog-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  background: #fafbfb;
}

.check-list {
  display: grid;
  gap: 7px;
  max-height: 280px;
  overflow-y: auto;
}

.check-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.check-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.toast-region {
  position: fixed;
  top: 72px;
  right: 18px;
  z-index: 100;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: white;
  box-shadow: 0 8px 22px rgba(24, 33, 38, 0.14);
  pointer-events: auto;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.context-menu {
  position: fixed;
  z-index: 60;
  min-width: 180px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  box-shadow: var(--shadow);
}

.context-menu button {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.context-menu button:hover {
  background: var(--surface-muted);
}

.context-menu button.danger {
  color: var(--danger);
}

.context-menu svg {
  width: 16px;
  height: 16px;
}

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

  .auth-scene {
    display: none;
  }

  .auth-panel {
    width: min(480px, 100%);
    margin: auto;
    border-right: 0;
  }

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

  .files-table th:nth-child(3),
  .files-table td:nth-child(3) {
    display: none;
  }
}

@media (max-width: 720px) {
  :root {
    --topbar-height: 54px;
  }

  .icon-btn.mobile-menu {
    display: inline-flex;
  }

  .topbar {
    padding: 0 10px;
  }

  .user-menu-button > span:not(.avatar) {
    display: none;
  }

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

  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(82vw, 290px);
    height: auto;
    transform: translateX(-105%);
    transition: transform 160ms ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .page-header {
    align-items: flex-start;
    padding: 14px 14px;
  }

  .page-header .toolbar .btn span {
    display: none;
  }

  .breadcrumbs-bar {
    flex-wrap: wrap;
    padding: 8px 14px;
  }

  .search {
    width: 100%;
    margin-left: 0;
  }

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

  .files-table colgroup {
    display: none;
  }

  .files-table th:last-child,
  .files-table td:last-child {
    width: 62px;
  }

  .files-table th,
  .files-table td {
    padding: 8px 10px;
  }

  .files-table th:nth-child(2),
  .files-table td:nth-child(2),
  .files-table th:nth-child(3),
  .files-table td:nth-child(3),
  .files-table th:nth-child(4),
  .files-table td:nth-child(4) {
    display: none;
  }

  .row-actions {
    opacity: 1;
  }

  .page-body {
    padding: 16px 14px 32px;
  }

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

  .metric {
    min-height: 82px;
    padding: 14px;
  }

  .metric-value {
    font-size: 19px;
  }

  .detail-list {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .detail-list dd {
    margin-bottom: 10px;
  }
}

@media (max-width: 480px) {
  .auth-panel {
    justify-content: flex-start;
    padding: 30px 22px;
  }

  .auth-brand {
    margin-bottom: 38px;
  }

  .page-title h1 {
    max-width: 44vw;
  }

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

  .dialog-backdrop {
    align-items: end;
    padding: 0;
  }

  .dialog,
  .dialog.wide {
    width: 100%;
    max-height: 90vh;
    border-radius: 8px 8px 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
