/* TSPS — Total Subcontracting Platform System
   Official compliance-oriented theme (light / dark) */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@500;700&family=Source+Sans+3:wght@400;500;600;700&display=swap');

:root {
  --font-display: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-body: "Source Sans 3", "PingFang SC", "Microsoft YaHei", sans-serif;

  --bg: #eef2f6;
  --bg-elev: #ffffff;
  --bg-soft: #f7f9fb;
  --ink: #0d1b2a;
  --ink-muted: #4a5b6b;
  --brand: #0a3d62;
  --brand-strong: #072c47;
  --accent: #1f6f5b;
  --line: #c5d0db;
  --line-strong: #9aabbc;
  --warn: #8a5a12;
  --danger: #8b2e2e;
  --focus: #1f6f8f;
  --shadow: 0 1px 0 rgba(13, 27, 42, 0.04);
  --hero-veil: linear-gradient(135deg, rgba(10, 61, 98, 0.92) 0%, rgba(7, 44, 71, 0.88) 48%, rgba(31, 111, 91, 0.78) 100%);
  --pattern: rgba(255, 255, 255, 0.06);
  --radius: 2px;
  --max: 1120px;
  --header-h: 64px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0b1219;
  --bg-elev: #121a24;
  --bg-soft: #16202b;
  --ink: #e7eef6;
  --ink-muted: #9aa8b7;
  --brand: #8eb9d6;
  --brand-strong: #c5dcec;
  --accent: #6fbfad;
  --line: #2a3644;
  --line-strong: #3d4d5f;
  --warn: #d4a35c;
  --danger: #d98a8a;
  --focus: #7eb6d6;
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.03);
  --hero-veil: linear-gradient(135deg, rgba(8, 18, 28, 0.94) 0%, rgba(12, 32, 48, 0.9) 50%, rgba(18, 48, 42, 0.86) 100%);
  --pattern: rgba(255, 255, 255, 0.04);
  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(10, 61, 98, 0.08), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(31, 111, 91, 0.07), transparent 55%),
    var(--bg);
  transition: background 0.25s ease, color 0.25s ease;
}

a {
  color: var(--brand);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}
a:hover { border-bottom-color: currentColor; }

img { max-width: 100%; display: block; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: 8px 12px;
  z-index: 1000;
}
.skip-link:focus { left: 8px; top: 8px; }

/* —— Header —— */
.tsps-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(10px);
}

.tsps-header__inner {
  width: min(100% - 32px, var(--max));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tsps-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--ink);
  border: 0;
}
.tsps-brand:hover { border: 0; color: var(--ink); }

.tsps-brand__mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.04em;
  color: var(--brand-strong);
  line-height: 1;
}

.tsps-brand__sub {
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tsps-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tsps-nav a {
  border: 0;
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 10px;
  position: relative;
}
.tsps-nav a:hover,
.tsps-nav a.is-active {
  color: var(--brand-strong);
}
.tsps-nav a.is-active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 4px;
  height: 2px;
  background: var(--accent);
  animation: tsps-underline 0.35s ease;
}

.theme-toggle {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-left: 6px;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.theme-toggle:hover { border-color: var(--brand); }
.theme-toggle:active { transform: scale(0.98); }
.theme-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* —— Hero (Portal) —— */
.tsps-hero {
  position: relative;
  min-height: calc(100vh - var(--header-h));
  display: grid;
  align-items: stretch;
  color: #f4f7fa;
  overflow: hidden;
  isolation: isolate;
}

.tsps-hero__bg {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    var(--hero-veil),
    repeating-linear-gradient(
      -18deg,
      transparent,
      transparent 18px,
      var(--pattern) 18px,
      var(--pattern) 19px
    ),
    linear-gradient(160deg, #0a3d62 0%, #0f4a58 55%, #1f6f5b 100%);
}

.tsps-hero__grid {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 70%);
  animation: tsps-grid-drift 18s linear infinite;
}

.tsps-hero__inner {
  width: min(100% - 32px, var(--max));
  margin: 0 auto;
  padding: 10vh 0 8vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 720px;
  animation: tsps-rise 0.7s ease both;
}

.tsps-hero__brand {
  font-family: var(--font-display);
  font-size: clamp(48px, 8vw, 72px);
  font-weight: 700;
  letter-spacing: 0.06em;
  margin: 0 0 18px;
  line-height: 1.05;
}

.tsps-hero__title {
  font-family: var(--font-display);
  font-size: clamp(22px, 3.2vw, 30px);
  font-weight: 500;
  margin: 0 0 14px;
  line-height: 1.35;
  max-width: 16em;
}

.tsps-hero__lead {
  margin: 0 0 28px;
  font-size: 16px;
  line-height: 1.75;
  color: rgba(244, 247, 250, 0.86);
  max-width: 36em;
}

.tsps-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.tsps-hero__meta {
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,0.18);
  font-size: 13px;
  color: rgba(244, 247, 250, 0.72);
  letter-spacing: 0.02em;
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.btn:hover { border-bottom-color: transparent; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.btn--primary {
  background: #f4f7fa;
  color: #0a3d62;
  border-color: #f4f7fa;
}
.btn--primary:hover { background: #ffffff; color: #072c47; }

.btn--ghost {
  background: transparent;
  color: #f4f7fa;
  border-color: rgba(244, 247, 250, 0.45);
}
.btn--ghost:hover { border-color: #f4f7fa; background: rgba(255,255,255,0.06); }

.btn--solid {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
html[data-theme="dark"] .btn--solid {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1219;
}
.btn--solid:hover { filter: brightness(1.05); }

.btn--line {
  background: transparent;
  color: var(--brand-strong);
  border-color: var(--line-strong);
}
.btn--line:hover { border-color: var(--brand); }

/* —— Shell / Console —— */
.tsps-shell {
  width: min(100% - 32px, var(--max));
  margin: 28px auto 56px;
  animation: tsps-rise 0.45s ease both;
}

.tsps-shell__title {
  font-family: var(--font-display);
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--brand-strong);
  letter-spacing: 0.02em;
}

.tsps-shell__desc {
  margin: 0 0 28px;
  color: var(--ink-muted);
  max-width: 46em;
}

.tsps-panel {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
}

.tsps-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}

.tsps-panel__head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--ink);
}

.tsps-panel__body { padding: 8px 0; }

.tsps-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tsps-list li {
  border-top: 1px solid var(--line);
}
.tsps-list li:first-child { border-top: 0; }

.tsps-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  color: var(--ink);
  border: 0;
  font-weight: 500;
}
.tsps-list a:hover {
  background: var(--bg-soft);
  color: var(--brand-strong);
}
.tsps-list a span {
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 400;
}

.tsps-kicker {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 10px;
}

.tsps-note {
  margin-top: 18px;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  color: var(--ink-muted);
  font-size: 14px;
}

/* —— Login —— */
.tsps-login {
  min-height: calc(100vh - var(--header-h));
  display: grid;
  place-items: center;
  padding: 32px 16px 48px;
}

.tsps-login__card {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  padding: 28px 28px 24px;
  animation: tsps-rise 0.5s ease both;
}

.tsps-login__card h1 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 6px;
  color: var(--brand-strong);
}

.tsps-login__card .lead {
  margin: 0 0 22px;
  color: var(--ink-muted);
  font-size: 14px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
}
.field input,
.field select {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--ink);
  font: inherit;
}
.field input:focus,
.field select:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}

.tsps-login__actions {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tsps-login__foot {
  margin-top: 18px;
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.6;
}

/* —— Footer —— */
.tsps-footer {
  border-top: 1px solid var(--line);
  padding: 22px 0 32px;
  color: var(--ink-muted);
  font-size: 12px;
}
.tsps-footer__inner {
  width: min(100% - 32px, var(--max));
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
}

/* —— Motion —— */
@keyframes tsps-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes tsps-underline {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@keyframes tsps-grid-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(48px, 24px, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* —— Workbench forms / tables —— */
.tsps-flash {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  background: var(--bg-soft);
  color: var(--ink);
  font-size: 14px;
}
.tsps-flash--err {
  border-color: var(--danger);
}

.tsps-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}
.tsps-form .row {
  display: grid;
  gap: 6px;
}
.tsps-form label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
}
.tsps-form input,
.tsps-form select,
.tsps-form textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--ink);
  font: inherit;
}
.tsps-form textarea { min-height: 96px; resize: vertical; }
.tsps-form .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.tsps-table-wrap { overflow-x: auto; }
.tsps-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tsps-table th,
.tsps-table td {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.tsps-table th {
  background: var(--bg-soft);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  font-weight: 700;
}
.tsps-table tr:first-child th { border-top: 0; }
.tsps-empty {
  padding: 20px 18px;
  color: var(--ink-muted);
  font-size: 14px;
}
.tsps-grid-2 {
  display: grid;
  gap: 18px;
}
@media (min-width: 900px) {
  .tsps-grid-2 { grid-template-columns: 1.1fr 0.9fr; align-items: start; }
}

@media (max-width: 720px) {
  .tsps-brand__sub { display: none; }
  .tsps-nav a { padding: 8px 6px; font-size: 13px; }
  .tsps-hero__inner { padding-top: 8vh; }
  .tsps-header__inner { width: min(100% - 20px, var(--max)); }
}
