:root {
  --ink: #172331;
  --muted: #6b7882;
  --canvas: #dce7eb;
  --surface: #ffffff;
  --line: #d4dee2;
  --sidebar: #172b3a;
  --sidebar-soft: #284254;
  --blue: #4478b8;
  --blue-dark: #315d92;
  --teal: #2d8c87;
  --olive: #7f8e62;
  --rust: #b96550;
  --gold: #c79d48;
  --danger: #b34f48;
  --shadow: 0 18px 55px rgba(26, 48, 63, .12);
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", serif;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); font-family: var(--sans); }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(68, 120, 184, .34); outline-offset: 2px; }
.hidden { display: none !important; }
.eyebrow { margin: 0; color: var(--blue-dark); font-size: 11px; font-weight: 800; letter-spacing: .17em; }
.eyebrow.light { color: #b9ccd4; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.04em; }
.brand-light { color: #f4f5ef; }
.brand-dark { color: var(--ink); font-size: 19px; }
.brand-mark { display: grid; place-items: center; width: 27px; height: 27px; color: #e2c47c; font-size: 24px; line-height: 1; transform: rotate(1deg); }

/* authentication */
.auth-view { display: grid; grid-template-columns: 1.18fr .82fr; min-height: 100vh; background: #f1f4f3; }
.auth-art { position: relative; overflow: hidden; display: flex; align-items: center; padding: 8vw; color: #f2f3ed; background: #1a3343 url('/hero-art.svg') center/cover no-repeat; }
.auth-art::after { position: absolute; inset: 0; content: ''; background: linear-gradient(90deg, rgba(17, 37, 50, .86), rgba(17, 37, 50, .36)); }
.auth-art-content { position: relative; z-index: 1; max-width: 560px; }
.auth-art .brand { position: absolute; top: -150px; left: 0; font-size: 20px; }
.auth-art h1 { max-width: 570px; margin: 22px 0 20px; font-family: var(--serif); font-size: clamp(42px, 5vw, 76px); font-weight: 600; letter-spacing: -.07em; line-height: 1.06; }
.auth-lede { max-width: 490px; margin: 0; color: #cfdae0; font-size: 16px; line-height: 1.9; }
.auth-points { display: grid; gap: 16px; margin-top: 48px; }
.auth-points > div { display: grid; grid-template-columns: 32px 1fr; gap: 2px 12px; }
.auth-points span { grid-row: span 2; display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #78909c; color: #d8c384; font-size: 11px; }
.auth-points strong { font-size: 14px; }
.auth-points small { color: #9eb1bb; font-size: 12px; }
.auth-panel { display: grid; place-items: center; padding: 56px 7vw; background: #f6f8f6; }
.auth-panel-inner { width: min(100%, 410px); }
.auth-heading { margin: 58px 0 26px; }
.auth-heading h2 { margin: 10px 0 8px; font-family: var(--serif); font-size: 32px; letter-spacing: -.06em; }
.auth-heading p:last-child { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.tabs { display: flex; gap: 24px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.tab { padding: 0 0 13px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-weight: 700; }
.tab.active { border-color: var(--blue); color: var(--ink); }
.form-panel { display: grid; gap: 15px; }
label { display: block; color: #44535d; font-size: 13px; font-weight: 700; }
label input { display: block; width: 100%; margin-top: 7px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--ink); }
label input::placeholder { color: #a6b0b5; }
label input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(68, 120, 184, .13); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 5px; font-weight: 800; transition: transform .18s ease, background .18s ease, border-color .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .58; transform: none; }
.button.primary { background: var(--blue); color: #fff; }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { border-color: #c8d3d8; background: #fff; color: var(--ink); }
.button.secondary:hover { border-color: var(--blue); color: var(--blue-dark); }
.button.danger { border-color: #e1b9b4; background: #fff7f5; color: var(--danger); }
.button.wide { width: 100%; margin-top: 3px; }
.light-button { background: #eff5f2; color: var(--ink); }
.light-button:hover { background: #fff; }
.text-button { padding: 8px 0; border: 0; background: transparent; color: #c3d4da; font-size: 13px; }
.form-message { min-height: 18px; margin: 0; color: var(--danger); font-size: 12px; line-height: 1.5; }
.auth-note { margin: 26px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }

/* application shell */
.app-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; background: var(--canvas); }
.sidebar { display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: 28px 18px 20px; background: var(--sidebar); color: #dce6e8; }
.sidebar-caption { margin: 8px 10px 34px; color: #839ba8; font-size: 11px; }
.side-nav { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 12px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: #b8c8cf; text-align: left; font-size: 13px; }
.nav-item:hover, .nav-item.active { border-color: #425d6e; background: var(--sidebar-soft); color: #fff; }
.nav-icon { display: grid; place-items: center; width: 21px; color: #9fb8c4; font-size: 19px; }
.nav-item.active .nav-icon { color: #c6d69a; }
.sidebar-bottom { display: grid; gap: 20px; }
.sidebar-tip { padding: 14px; border: 1px solid #314a59; background: #1d3545; }
.sidebar-tip strong { display: block; margin-top: 9px; font-size: 13px; }
.sidebar-tip p { margin: 5px 0 0; color: #9eb2bb; font-size: 11px; line-height: 1.6; }
.tip-mark { color: #c4d59b; font-size: 20px; }
.sidebar-account { padding: 12px 10px 0; border-top: 1px solid #314958; color: #dce7ea; font-size: 12px; }
.sidebar-account small { display: block; margin-top: 4px; color: #8ca1ac; }
.app-main { min-width: 0; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 84px; padding: 22px 4vw; border-bottom: 1px solid rgba(74, 105, 119, .16); background: rgba(224, 234, 237, .84); }
.header-title { margin-top: 7px; font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: -.05em; }
.account-actions { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.account-actions .button { min-height: 36px; padding: 8px 12px; font-size: 12px; }
.content { width: min(100%, 1420px); margin: 0 auto; padding: 30px 4vw 60px; }
.status-banner { min-height: 0; margin-bottom: 16px; padding: 11px 14px; border-left: 3px solid var(--teal); background: rgba(255, 255, 255, .66); color: #4c6871; font-size: 13px; }
.status-banner.pending { border-color: var(--gold); color: #765d2d; }
.status-banner.rejected, .status-banner.suspended { border-color: var(--danger); color: var(--danger); }
.dashboard-hero { position: relative; min-height: 304px; overflow: hidden; display: flex; align-items: flex-end; padding: 38px; background: #1f3443 url('/hero-art.svg') center/cover no-repeat; color: #f2f3ed; box-shadow: var(--shadow); }
.dashboard-hero::after { position: absolute; inset: 0; content: ''; background: linear-gradient(90deg, rgba(19, 43, 58, .93) 0%, rgba(19, 43, 58, .68) 52%, rgba(19, 43, 58, .18) 100%); }
.hero-copy { position: relative; z-index: 1; max-width: 600px; }
.hero-copy h1 { margin: 12px 0 12px; font-family: var(--serif); font-size: clamp(36px, 5vw, 64px); font-weight: 600; letter-spacing: -.07em; line-height: 1.08; }
.hero-copy > p:not(.eyebrow) { margin: 0; color: #c9d7dc; font-size: 15px; }
.hero-actions { display: flex; align-items: center; gap: 18px; margin-top: 26px; }
.hero-art { position: absolute; z-index: 0; inset: 0; background: url('/hero-art.svg') right center/cover no-repeat; opacity: .72; }
.quota-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
.quota-card { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 16px 18px; border: 1px solid rgba(74, 105, 119, .18); background: rgba(247, 250, 249, .82); }
.quota-card strong { display: block; font-family: var(--serif); font-size: 25px; font-weight: 600; }
.quota-card small { color: var(--muted); font-size: 11px; }
.quota-card .quota-side { align-self: center; color: var(--teal); font-size: 12px; font-weight: 800; }
.quota-bar { grid-column: 1/-1; height: 4px; overflow: hidden; background: #d7e0e0; }
.quota-bar span { display: block; height: 100%; background: var(--teal); }
.workflow-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.surface { border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.upload-panel { min-height: 190px; padding: 26px; }
.upload-panel-wide { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; align-items: end; gap: 8px 28px; }
.upload-panel-wide .surface-heading { grid-column: 1; }
.upload-panel-wide .surface-copy { grid-column: 1; margin: 8px 0 12px; }
.upload-panel-wide > .button { grid-column: 2; grid-row: 1 / span 2; align-self: center; min-width: 150px; }
.upload-panel-wide .upload-note { grid-column: 1 / -1; margin-top: 4px; }
.surface-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.surface-heading h2 { margin: 8px 0 0; font-family: var(--serif); font-size: 25px; letter-spacing: -.05em; }
.surface-number { color: #9bb0b8; font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.surface-copy { max-width: 430px; margin: 14px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.7; }
code { padding: 2px 5px; background: #edf2f1; color: var(--blue-dark); font-size: 12px; }
.upload-note { margin-top: 20px; color: var(--muted); font-size: 11px; }
.upload-note span { margin-right: 5px; color: var(--teal); font-weight: 800; }
.pipeline { display: grid; grid-template-columns: 1fr 30px 1fr 30px 1fr; align-items: center; margin-top: 34px; }
.pipeline > div { text-align: center; }
.pipeline span { display: grid; place-items: center; width: 34px; height: 34px; margin: 0 auto 10px; border: 1px solid #bbcad0; color: var(--blue-dark); font-size: 11px; }
.pipeline strong, .pipeline small { display: block; }
.pipeline strong { font-size: 13px; }
.pipeline small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.pipeline i { height: 1px; background: #cad5d8; }
.project-form-wrap { margin-top: 16px; padding: 26px; }
.icon-button { width: 31px; height: 31px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 20px; line-height: 1; }
.project-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 22px; }
.project-form .check-label { grid-column: 1/-1; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; font-weight: 700; }
.project-form .check-label input { width: 16px; height: 16px; margin: 0; accent-color: var(--blue); }
.project-form .check-label small { width: 100%; margin-left: 23px; color: var(--muted); font-weight: 400; }
label small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; font-weight: 400; }
.form-actions { display: flex; gap: 9px; align-items: center; grid-column: 1/-1; }
.account-security-panel { max-width: 760px; padding: 26px; }
.password-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 22px; }
.password-form .form-actions, .password-form .form-message { grid-column: 1/-1; }
.projects-section { margin-top: 42px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 17px; }
.section-heading h2, .section-heading h1 { margin: 7px 0 4px; font-family: var(--serif); font-size: 32px; font-weight: 600; letter-spacing: -.06em; }
.section-heading > div > p:last-child { margin: 0; color: var(--muted); font-size: 13px; }
.project-list { display: grid; gap: 12px; }
.project-card { padding: 22px; border: 1px solid var(--line); background: rgba(255,255,255,.92); box-shadow: 0 10px 28px rgba(26, 48, 63, .08); }
.project-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.project-card h3 { margin: 5px 0 5px; font-family: var(--serif); font-size: 22px; letter-spacing: -.05em; }
.project-card-kicker { margin: 0; color: var(--muted); font-size: 11px; letter-spacing: .11em; }
.project-meta { margin: 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.project-status { padding: 6px 9px; background: #e5f1e7; color: #347451; font-size: 11px; font-weight: 800; white-space: nowrap; }
.project-status.draft { background: #f6ecd5; color: #85672f; }
.project-status.deleted { background: #f8e2de; color: var(--danger); }
.project-url-row { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.project-url { min-width: 0; flex: 1; padding: 11px 12px; border-left: 3px solid var(--teal); background: #eef5f3; color: #276e6b; font-size: 13px; overflow-wrap: anywhere; text-decoration: none; }
.copy-button { padding: 9px 10px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 12px; }
.upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 16px; }
.file-picker { position: relative; display: inline-flex; align-items: center; min-height: 42px; padding: 0 12px; border: 1px dashed #aebfc6; background: #f7faf9; color: var(--blue-dark); font-size: 12px; cursor: pointer; }
.file-picker input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.file-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.project-actions .button { min-height: 35px; padding: 7px 11px; font-size: 12px; }
.versions { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }
.version-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid #edf1f1; }
.version-row:last-child { border-bottom: 0; }
.version-info strong, .version-info small { display: block; }
.version-info strong { font-size: 13px; }
.version-info small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.version-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.version-actions .button { min-height: 31px; padding: 6px 9px; font-size: 11px; }
.version-current { color: var(--teal); font-size: 11px; font-weight: 800; white-space: nowrap; }
.empty-state { padding: 42px 20px; border: 1px dashed #aebfc6; background: rgba(255,255,255,.54); color: var(--muted); text-align: center; }

/* admin */
.admin-heading { margin-bottom: 24px; }
.admin-heading h1 { font-size: 42px; }
.admin-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 16px; }
.admin-stat { padding: 16px 17px; border: 1px solid rgba(74, 105, 119, .18); background: rgba(247, 250, 249, .82); }
.admin-stat strong, .admin-stat small { display: block; }
.admin-stat strong { font-family: var(--serif); font-size: 28px; font-weight: 600; }
.admin-stat small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.admin-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; margin-bottom: 16px; }
.admin-settings, .admin-guide, .users-panel { padding: 24px; }
.settings-form { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 22px; }
.settings-form .form-actions, .settings-form .form-message { grid-column: 1/-1; }
.admin-guide { background: #213c4b; color: #f0f4ef; }
.admin-guide .eyebrow { color: #b9ccd4; }
.admin-guide h2 { margin: 10px 0 14px; font-family: var(--serif); font-size: 25px; font-weight: 600; }
.admin-guide ul { display: grid; gap: 11px; margin: 0; padding-left: 18px; color: #bbccd1; font-size: 13px; line-height: 1.6; }
.users-list { display: grid; gap: 10px; margin-top: 20px; }
.user-row { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(160px, 1.15fr) auto; gap: 15px; align-items: center; padding: 14px; border: 1px solid var(--line); background: #fbfcfc; }
.user-identity strong, .user-identity small { display: block; }
.user-identity strong { font-size: 13px; }
.user-identity small { margin-top: 4px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.user-quota { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }
.user-quota strong { color: var(--ink); font-size: 12px; }
.user-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.user-actions .button { min-height: 32px; padding: 6px 9px; font-size: 11px; }
.user-limit-form { display: flex; flex-wrap: wrap; gap: 5px; }
.user-limit-form input { width: 82px; margin: 0; padding: 7px 8px; border-radius: 4px; font-size: 11px; }
.user-status { display: inline-flex; width: fit-content; padding: 4px 7px; background: #edf1ef; color: #64726b; font-size: 10px; font-weight: 800; }
.user-status.pending { background: #f6ecd5; color: #85672f; }
.user-status.approved { background: #e5f1e7; color: #347451; }
.user-status.rejected, .user-status.suspended { background: #f8e2de; color: var(--danger); }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; max-width: min(360px, calc(100vw - 48px)); padding: 12px 15px; border-left: 3px solid var(--teal); background: #172b3a; color: #f1f5f1; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity .2s ease, transform .2s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .auth-view { grid-template-columns: 1fr; }
  .auth-art { min-height: 450px; padding: 52px 8vw; }
  .auth-art .brand { position: static; margin-bottom: 90px; }
  .auth-panel { padding: 52px 8vw; }
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .admin-stats { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { min-height: 0; padding: 16px; }
  .sidebar-top { display: flex; align-items: center; gap: 18px; }
  .sidebar-caption, .sidebar-tip, .sidebar-account { display: none; }
  .side-nav { display: flex; flex: 1; gap: 3px; overflow-x: auto; }
  .nav-item { width: auto; flex: 0 0 auto; padding: 9px 10px; white-space: nowrap; }
  .nav-icon { width: auto; }
  .app-header { min-height: 72px; padding: 17px 18px; }
  .content { padding: 18px 16px 42px; }
  .dashboard-hero { min-height: 330px; padding: 25px; }
  .hero-copy h1 { font-size: 42px; }
  .quota-strip, .workflow-grid, .admin-grid { grid-template-columns: 1fr; }
  .upload-panel-wide { display: block; }
  .upload-panel-wide > .button { margin-top: 5px; }
  .project-form, .settings-form, .password-form { grid-template-columns: 1fr; }
  .project-form .check-label, .form-actions, .settings-form .form-actions, .settings-form .form-message { grid-column: auto; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .user-row { grid-template-columns: 1fr; }
  .user-actions { justify-content: flex-start; }
}

@media (max-width: 520px) {
  .auth-art { min-height: 520px; padding: 32px 24px; }
  .auth-art h1 { font-size: 43px; }
  .auth-points { margin-top: 32px; }
  .auth-panel { padding: 38px 24px; }
  .auth-heading { margin-top: 42px; }
  .account-actions > span { display: none; }
  .hero-copy h1 { font-size: 37px; }
  .hero-actions { align-items: flex-start; flex-direction: column; gap: 8px; }
  .upload-row, .project-url-row { align-items: stretch; flex-direction: column; }
  .file-picker, .upload-row .button, .copy-button { width: 100%; }
  .project-url { width: 100%; }
  .version-row { align-items: flex-start; flex-direction: column; }
}
