:root {
  --ink: #15221d;
  --muted: #65736d;
  --line: #dce3df;
  --soft: #f4f7f5;
  --paper: #ffffff;
  --green: #0d6b4f;
  --green-dark: #084c39;
  --blue: #175d8c;
  --amber: #9a5d00;
  --red: #a13737;
  --shadow: 0 12px 30px rgba(21, 34, 29, 0.08);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; clip: rect(0,0,0,0); overflow: hidden; }
.muted { color: var(--muted); }

.access-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    linear-gradient(90deg, rgba(13,107,79,.04) 1px, transparent 1px),
    linear-gradient(rgba(13,107,79,.04) 1px, transparent 1px),
    #f7faf8;
  background-size: 32px 32px;
}
.access-panel {
  width: min(430px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 34px;
}
.brand-mark {
  width: 48px; height: 48px; display: grid; place-items: center;
  color: white; background: var(--green); font-weight: 800;
}
.brand-mark.small { width: 36px; height: 36px; font-size: 13px; }
.company { margin: 24px 0 7px; color: var(--green); font-size: 13px; font-weight: 700; }
.access-panel h1 { margin: 0; font-size: 27px; line-height: 1.25; }
.access-panel > .muted { margin: 10px 0 26px; line-height: 1.6; }
.access-form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 650; color: #34433d; }
input, select, textarea {
  width: 100%; border: 1px solid #bfcac5; background: white; color: var(--ink);
  padding: 11px 12px; border-radius: 4px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(13,107,79,.12); }
textarea { resize: vertical; }
.notice { padding: 12px 14px; border-left: 3px solid var(--blue); background: #edf5fa; color: #27485c; font-size: 13px; line-height: 1.55; }
.form-hint { margin: -6px 0 0; color: var(--muted); font-size: 12px; }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); padding: 3px; background: var(--soft); }
.segment { border: 0; background: transparent; padding: 9px; color: var(--muted); }
.segment.active { background: white; color: var(--green); box-shadow: 0 1px 4px rgba(21,34,29,.12); font-weight: 700; }

.primary, .secondary, .text-button, .quiet {
  border-radius: 4px; padding: 9px 14px; border: 1px solid transparent; font-weight: 700;
}
.primary { background: var(--green); color: white; border-color: var(--green); }
.primary:hover { background: var(--green-dark); }
.primary:disabled { cursor: not-allowed; opacity: .5; }
.secondary { background: white; border-color: #bfcac5; color: var(--ink); }
.secondary:hover { border-color: var(--green); color: var(--green); }
.text-button, .quiet { padding: 4px 0; background: transparent; color: var(--green); }
.wide { width: 100%; padding: 12px; }

.portal { min-height: 100vh; display: grid; grid-template-columns: 226px minmax(0, 1fr); }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 226px; padding: 22px 14px;
  background: #11251e; color: white; display: flex; flex-direction: column; z-index: 10;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 23px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-size: 15px; }
.sidebar-brand span { color: #9eb4aa; font-size: 12px; margin-top: 3px; }
.main-nav { display: grid; gap: 4px; margin-top: 18px; }
.nav-item {
  border: 0; text-align: left; color: #b8c9c1; background: transparent; padding: 11px 12px;
  border-left: 3px solid transparent;
}
.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.active { color: white; background: rgba(255,255,255,.1); border-left-color: #69c29f; font-weight: 700; }
.badge { float: right; min-width: 20px; padding: 2px 5px; text-align: center; background: #c37a19; color: white; font-size: 11px; border-radius: 9px; }
.sidebar-foot { margin-top: auto; display: grid; gap: 12px; padding: 16px 9px 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-foot a, .sidebar-foot button { color: #c5d4cd; font-size: 13px; text-decoration: none; text-align: left; }
.sidebar-foot button { border: 0; }

.workspace { grid-column: 2; min-width: 0; padding: 0 34px 44px; background: #fafcfb; }
.topbar {
  min-height: 92px; display: flex; align-items: center; justify-content: space-between;
  gap: 24px; border-bottom: 1px solid var(--line); margin-bottom: 26px;
}
.eyebrow { margin: 0 0 5px; color: var(--green); font-weight: 750; font-size: 10px; }
.topbar h1 { margin: 0; font-size: 23px; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.global-search input { width: min(340px, 30vw); padding: 9px 12px; }
.user-chip { min-width: 104px; padding-left: 14px; border-left: 1px solid var(--line); }
.user-chip span, .user-chip small { display: block; }
.user-chip span { font-weight: 700; font-size: 13px; }
.user-chip small { color: var(--muted); margin-top: 3px; }
.view { display: none; }
.view.active { display: block; }

.status-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line);
  background: white; margin-bottom: 26px;
}
.status-strip > div { padding: 19px 20px; border-right: 1px solid var(--line); min-width: 0; }
.status-strip > div:last-child { border-right: 0; }
.status-strip span, .status-strip small, .status-strip strong { display: block; }
.status-strip span { color: var(--muted); font-size: 12px; }
.status-strip strong { margin: 7px 0 4px; font-size: 24px; }
.status-strip small { color: #7d8a84; font-size: 11px; }
.content-section { margin-top: 28px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 13px; }
.section-heading h2 { margin: 0; font-size: 17px; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.project-shortcuts { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); border: 1px solid var(--line); background: white; }
.project-link {
  min-height: 104px; padding: 18px; border: 0; border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line); background: white; text-align: left;
}
.project-link:nth-child(4n) { border-right: 0; }
.project-link:hover { background: #f2f8f5; }
.project-link strong, .project-link span { display: block; }
.project-link strong { font-size: 14px; line-height: 1.45; }
.project-link span { margin-top: 16px; color: var(--green); font-size: 11px; }

.frequent-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: white;
}
.frequent-file {
  min-width: 0;
  min-height: 178px;
  padding: 15px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.frequent-file:nth-child(4n) { border-right: 0; }
.frequent-file.pinned { box-shadow: inset 0 3px var(--green); }
.frequent-topline, .usage-meta { display: flex; align-items: center; gap: 8px; }
.frequent-topline { justify-content: space-between; }
.file-type, .pin-label, .score-label {
  font-size: 10px;
  line-height: 1;
  padding: 4px 6px;
  color: var(--blue);
  background: #edf5fa;
}
.pin-label { color: var(--green); background: #e9f4ef; }
.score-label { color: var(--muted); background: var(--soft); }
.frequent-file h3 {
  min-width: 0;
  margin: 13px 0 6px;
  font-size: 13px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.frequent-file > p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.usage-meta {
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 13px;
  color: #78857f;
  font-size: 10px;
}
.frequent-actions { margin-top: 9px; }
.frequent-empty {
  grid-column: 1 / -1;
  min-height: 120px;
  display: grid;
  place-content: center;
  gap: 6px;
  text-align: center;
  color: var(--muted);
}
.frequent-empty strong { color: var(--ink); font-size: 13px; }
.frequent-empty span { font-size: 11px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); background: white; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { color: #66746e; font-weight: 700; background: #f4f7f5; text-align: left; white-space: nowrap; }
th, td { padding: 11px 13px; border-bottom: 1px solid #e6ebe8; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfb; }
.file-name { font-weight: 650; max-width: 360px; word-break: break-word; }
.file-path { color: var(--muted); max-width: 420px; word-break: break-word; }
.row-actions { white-space: nowrap; display: flex; gap: 9px; }
.row-actions button, .row-actions a { border: 0; padding: 0; background: transparent; color: var(--green); font-size: 12px; text-decoration: none; }
.row-actions { flex-wrap: wrap; }
.select-column { width: 42px; text-align: center; }
.select-column input, .file-select { width: 16px; height: 16px; margin: 0; accent-color: var(--green); }
.system-note { margin-top: 28px; display: flex; gap: 14px; padding: 14px 16px; background: #eff5f2; border-left: 3px solid var(--green); font-size: 12px; }
.system-note span { color: var(--muted); }

.toolbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 14px; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 12px; }
.breadcrumbs button { border: 0; background: transparent; color: var(--green); padding: 3px; }
.breadcrumbs span { color: #97a29d; }
.toolbar-actions { display: flex; gap: 8px; }
.search-summary { padding: 10px 13px; margin-bottom: 12px; background: #edf5fa; color: #315368; font-size: 12px; }
.files-table { min-height: 470px; }
.batch-action-bar {
  margin-bottom: 12px;
  min-height: 48px;
  padding: 8px 11px 8px 14px;
  border: 1px solid #a9c8bb;
  background: #edf7f2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 12px;
}
.batch-action-bar > div { display: flex; gap: 8px; }
.folder-button { border: 0; background: transparent; padding: 0; font-weight: 700; color: var(--ink); text-align: left; }
.folder-button:hover { color: var(--green); }
.empty-state { text-align: center; color: var(--muted); padding: 60px 20px !important; }

.manifest-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  background: white;
  margin-bottom: 18px;
}
.manifest-stats > div { padding: 16px 18px; border-right: 1px solid var(--line); min-width: 0; }
.manifest-stats > div:last-child { border-right: 0; }
.manifest-stats span, .manifest-stats strong, .manifest-stats small { display: block; }
.manifest-stats span { color: var(--muted); font-size: 11px; }
.manifest-stats strong { margin: 6px 0 3px; color: var(--ink); font-size: 22px; }
.manifest-stats small { color: #7d8a84; font-size: 10px; }
.manifest-filter {
  display: grid;
  grid-template-columns: 1.2fr .8fr 1.35fr 1.15fr auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}
.manifest-filter label { gap: 5px; font-size: 11px; }
.manifest-filter input, .manifest-filter select, .manifest-filter button { min-height: 40px; }
.manifest-table { min-height: 500px; }
.manifest-table .file-path { max-width: 360px; }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding: 13px 0; font-size: 12px; color: var(--muted); }

.upload-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 28px; }
.upload-main { min-width: 0; }
.dropzone {
  min-height: 174px; border: 1px dashed #8ba99d; background: #f5faf7;
  display: grid; place-content: center; text-align: center; padding: 24px; outline: none;
}
.dropzone:hover, .dropzone.dragging, .dropzone:focus { border-color: var(--green); background: #ecf6f1; }
.dropzone strong { font-size: 16px; }
.dropzone span { color: var(--muted); margin-top: 8px; font-size: 12px; }
.file-queue { display: grid; gap: 6px; margin: 12px 0; }
.queue-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; padding: 9px 11px; background: #f4f7f5; font-size: 12px; }
.queue-item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item .done { color: var(--green); }
.queue-item .error { color: var(--red); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0; }
#uploadForm > label { margin-bottom: 16px; }
.upload-guide { border-left: 1px solid var(--line); padding-left: 25px; }
.upload-guide h3 { margin: 0 0 20px; font-size: 15px; }
.upload-guide ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; }
.upload-guide li { display: grid; grid-template-columns: 28px minmax(0,1fr); gap: 10px; }
.upload-guide li > span { width: 26px; height: 26px; border: 1px solid #aebdb6; display: grid; place-items: center; color: var(--green); font-size: 11px; }
.upload-guide strong { font-size: 13px; }
.upload-guide p { margin: 3px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.pending-list { display: grid; gap: 10px; }
.pending-row {
  display: grid; grid-template-columns: minmax(220px,1.1fr) minmax(240px,1fr) 120px 150px;
  gap: 18px; align-items: center; padding: 16px 18px; background: white; border: 1px solid var(--line);
}
.pending-row h3 { margin: 0; font-size: 13px; word-break: break-word; }
.pending-row p { margin: 5px 0 0; color: var(--muted); font-size: 11px; word-break: break-word; }
.confidence { font-weight: 800; color: var(--green); }
.confidence.low { color: var(--amber); }
.tag { display: inline-block; padding: 3px 6px; background: #edf5f1; color: var(--green); font-size: 10px; }
.tag.warn { background: #fff2dd; color: var(--amber); }
.pending-actions { display: flex; gap: 8px; justify-content: flex-end; }
.pending-actions button { padding: 7px 9px; }
.danger-text { border: 0; background: transparent; color: var(--red); padding: 7px 0; font-weight: 700; }

dialog { width: min(620px, calc(100% - 30px)); border: 0; padding: 0; box-shadow: 0 18px 60px rgba(21,34,29,.28); }
dialog::backdrop { background: rgba(12, 25, 20, .56); }
dialog form { padding: 22px; display: grid; gap: 16px; }
dialog header, dialog footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
dialog h2 { margin: 0; font-size: 18px; }
dialog footer { justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 16px; }
.dialog-close, .rename-close, .move-close, .preview-close { width: 34px; height: 34px; border: 0; background: #eff3f1; font-size: 22px; line-height: 1; }
.rename-current-path { margin: 0; padding: 9px 11px; background: #f3f6f4; color: var(--muted); font-size: 11px; line-height: 1.5; word-break: break-all; }
.move-selection-summary {
  max-height: 160px;
  overflow: auto;
  padding: 10px 12px;
  background: #f3f6f4;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}
.move-selection-summary strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 12px; }
.move-selection-summary span { display: block; word-break: break-all; }
.warning { padding: 10px 12px; border-left: 3px solid var(--amber); background: #fff6e8; color: #765020; font-size: 12px; }
.preview-dialog { width: min(1100px, calc(100% - 30px)); height: min(780px, calc(100vh - 30px)); }
.preview-dialog:fullscreen { width: 100%; height: 100%; max-width: none; max-height: none; }
.preview-dialog .preview-header {
  min-height: 60px;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--line);
}
.preview-heading { min-width: 0; }
.preview-heading strong, .preview-heading span { display: block; }
.preview-heading strong { max-width: 430px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-heading span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.preview-tools { display: flex; align-items: center; gap: 6px; }
.compact { padding: 7px 9px; font-size: 11px; }
.icon-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}
.icon-button:hover { color: var(--green); border-color: var(--green); }
.icon-button:disabled { opacity: .35; cursor: not-allowed; }
#previewBody { height: calc(100% - 60px); background: #eef2f0; }
#previewBody iframe, #previewBody img, #previewBody video, #previewBody audio { width: 100%; height: 100%; border: 0; object-fit: contain; }
.preview-message {
  width: 100%;
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 9px;
  padding: 24px;
  text-align: center;
}
.preview-message strong { font-size: 15px; }
.preview-message p { max-width: 560px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.preview-message.error .preview-spinner { display: none; }
.preview-message.error strong { color: var(--red); }
.preview-spinner {
  width: 25px;
  height: 25px;
  border: 3px solid #b9cbc3;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: preview-spin .8s linear infinite;
}
@keyframes preview-spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; right: 22px; bottom: 22px; max-width: 380px; padding: 12px 15px;
  color: white; background: #17392d; box-shadow: var(--shadow); font-size: 12px;
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #873434; }

@media (max-width: 980px) {
  .portal { grid-template-columns: 184px minmax(0,1fr); }
  .sidebar { width: 184px; }
  .workspace { padding-left: 22px; padding-right: 22px; }
  .status-strip { grid-template-columns: 1fr 1fr; }
  .status-strip > div:nth-child(2) { border-right: 0; }
  .status-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .project-shortcuts { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .project-link:nth-child(2n) { border-right: 0; }
  .frequent-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .frequent-file:nth-child(n) { border-right: 1px solid var(--line); }
  .frequent-file:nth-child(2n) { border-right: 0; }
  .upload-layout { grid-template-columns: 1fr; }
  .upload-guide { border: 0; border-top: 1px solid var(--line); padding: 22px 0 0; }
  .upload-guide ol { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .pending-row { grid-template-columns: 1fr 1fr; }
  .manifest-filter { grid-template-columns: 1fr 1fr; }
  .manifest-stats { grid-template-columns: 1fr 1fr; }
  .manifest-stats > div:nth-child(2) { border-right: 0; }
  .manifest-stats > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 720px) {
  .portal { display: block; padding-bottom: 64px; }
  .sidebar { position: fixed; inset: auto 0 0; width: 100%; height: 60px; padding: 0; }
  .sidebar-brand, .sidebar-foot { display: none; }
  .main-nav { margin: 0; display: flex; height: 60px; overflow-x: auto; overflow-y: hidden; }
  .nav-item { flex: 0 0 80px; min-width: 80px; text-align: center; padding: 9px 3px; border-left: 0; border-top: 3px solid transparent; font-size: 10px; }
  .nav-item.active { border-left: 0; border-top-color: #69c29f; }
  .badge { float: none; margin-left: 4px; }
  .workspace { padding: 0 14px 24px; }
  .topbar { min-height: 112px; display: grid; grid-template-columns: minmax(0,1fr) auto; align-content: center; gap: 12px; margin-bottom: 18px; padding: 12px 0; }
  .topbar > div:first-child { grid-column: 1; grid-row: 1; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 19px; }
  .top-actions { display: contents; }
  .global-search { position: static; display: block; grid-column: 1 / -1; grid-row: 2; }
  .global-search input { width: 100%; }
  .user-chip { grid-column: 2; grid-row: 1; min-width: auto; padding-left: 9px; }
  .user-chip small { display: none; }
  .status-strip { grid-template-columns: 1fr 1fr; }
  .status-strip > div { padding: 14px; }
  .status-strip strong { font-size: 20px; }
  .project-shortcuts { grid-template-columns: 1fr; }
  .project-link, .project-link:nth-child(n) { border-right: 0; }
  .frequent-grid { grid-template-columns: 1fr; }
  .frequent-file, .frequent-file:nth-child(n) { border-right: 0; }
  .section-heading { align-items: start; }
  .system-note { display: grid; gap: 5px; }
  .toolbar { align-items: start; }
  .toolbar-actions { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .upload-guide ol { grid-template-columns: 1fr 1fr; }
  .pending-row { grid-template-columns: 1fr; gap: 10px; }
  .pending-actions { justify-content: flex-start; }
  .manifest-filter, .manifest-stats { grid-template-columns: 1fr; }
  .manifest-stats > div, .manifest-stats > div:nth-child(n) { border-right: 0; border-bottom: 1px solid var(--line); }
  .manifest-stats > div:last-child { border-bottom: 0; }
  .batch-action-bar { align-items: flex-start; }
  th, td { padding: 10px; }
  .access-panel { padding: 26px 22px; }
  .preview-dialog .preview-header { align-items: flex-start; }
  .preview-heading strong { max-width: 190px; }
  .preview-tools { flex-wrap: wrap; justify-content: flex-end; }
  #previewFolder, #previewFullscreen { display: none; }
  #previewBody { height: calc(100% - 88px); }
  .toast { left: 14px; right: 14px; bottom: 76px; max-width: none; }
}
