:root {
  color-scheme: light;
  --navy: #17324d;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --ice: #eef4ff;
  --line: #dce5f1;
  --text: #172033;
  --muted: #637084;
  --danger: #b42318;
  --success: #067647;
  --radius: 14px;
  font-family: "PingFang SC", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: #f3f6fb; color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }
input, select { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: white; }
input:focus, select:focus, button:focus-visible { outline: 3px solid #93b4ff; outline-offset: 2px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg,#dbe9ff,#f4f7fb 55%,#e6f4ef); }
.login-card { width: min(420px,100%); background: white; border: 1px solid var(--line); border-radius: 22px; padding: 38px; box-shadow: 0 20px 60px #17324d1a; }
.login-card h1 { font-size: 24px; margin: 18px 0 8px; }
.login-card p { color: var(--muted); margin-top: 0; line-height: 1.6; }
.brand-mark { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 12px; background: var(--navy); color: white; font-weight: 800; }
form label { display: block; margin: 16px 0 7px; color: #404b5e; font-size: 14px; }
form input, form select { width: 100%; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border: 1px solid transparent; border-radius: 10px; padding: 0 16px; text-decoration: none; transition: transform .15s, background .15s, box-shadow .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: not-allowed; }
.primary { background: var(--blue); color: white; box-shadow: 0 7px 18px #2563eb33; }
.primary:hover:not(:disabled) { background: var(--blue-dark); }
.ghost { background: white; color: var(--navy); border-color: var(--line); }
.large { width: 100%; min-height: 48px; font-weight: 650; }

.app-header { position: sticky; top: 0; z-index: 20; background: #ffffffee; backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.header-inner { width: min(1180px,calc(100% - 32px)); margin: auto; min-height: 72px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy); text-decoration: none; }
.tab-nav { display: flex; gap: 5px; margin-left: 12px; overflow-x: auto; scrollbar-width: none; }
.tab-nav::-webkit-scrollbar { display: none; }
.tab-link { white-space: nowrap; border: 0; background: transparent; color: var(--muted); min-height: 42px; padding: 0 14px; border-radius: 9px; }
.tab-link.active { background: var(--ice); color: var(--blue-dark); font-weight: 650; }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
#currentUser { color: var(--muted); font-size: 14px; }

.page-shell { width: min(1180px,calc(100% - 32px)); margin: 28px auto 50px; }
.panel { display: none; }
.panel.active { display: block; animation: fadeIn .18s ease; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-heading h2 { margin: 0; }
.page-heading p { margin: 5px 0 0; color: var(--muted); }

.upload-card { background: white; padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); }
.drop-zone { min-height: 195px; padding: 26px; display: grid; place-content: center; text-align: center; color: var(--muted); border: 2px dashed #b8c8e0; border-radius: var(--radius); background: #fafcff; transition: border-color .2s, background .2s; cursor: pointer; }
.drop-zone.dragover { border-color: var(--blue); background: var(--ice); }
.upload-icon { font-size: 32px; color: var(--blue); margin-bottom: 10px; }
.file-preview-text { display: block; max-width: 100%; overflow-wrap: anywhere; margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--ice); color: var(--navy); }
.file-input-hidden { display: none; }
.upload-card .button { margin-top: 18px; }

.result-card { margin-top: 18px; padding: 24px; border: 1px solid #b5dfcc; border-radius: var(--radius); background: #f4fdf8; }
.result-title { display: flex; justify-content: space-between; align-items: center; gap: 15px; flex-wrap: wrap; }
.result-title h3 { color: var(--success); margin: 0; }
.metric-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin: 20px 0; }
.metric-grid div { background: white; padding: 15px; border-radius: 10px; border: 1px solid var(--line); }
.metric-grid dt { color: var(--muted); font-size: 13px; }
.metric-grid dd { margin: 5px 0 0; font-size: 22px; font-weight: 700; }
.warning-list { margin: 0; padding-left: 20px; line-height: 1.7; color: #7a3d10; }
.warning-box { margin-top: 14px; background: white; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.warning-box summary { cursor: pointer; padding: 13px 15px; color: #7a3d10; font-weight: 650; background: #fff8ed; list-style: revert; }
.warning-box[open] summary { border-bottom: 1px solid var(--line); }
.warning-box .warning-list { padding: 12px 18px 14px; max-height: 260px; overflow: auto; }
.warning-box:empty, .detail-box:empty { display: none; }
.muted { color: var(--muted); }

.table-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 13px 15px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 13px; background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdff; }
.status-completed, .badge-active { color: var(--success); background: #e8f5ef; }
.status-failed, .badge-paused { color: var(--danger); background: #feecea; }
.status-completed,.status-failed,.badge-active,.badge-paused { display: inline-block; padding: 4px 8px; border-radius: 99px; font-size: 12px; }
.row-actions { display: flex; gap: 8px; }
.row-actions .button { min-height: 34px; padding: 0 10px; font-size: 13px; }
.detail-box { margin-top: 10px; padding: 12px; background: #fff8ed; border-radius: 8px; white-space: normal; }

.inline-form { display: grid; grid-template-columns: repeat(4,1fr); gap: 15px; padding: 22px; margin-bottom: 18px; background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.inline-form .button { align-self: end; }
.settings-card { max-width: 640px; padding: 26px; background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.settings-card .button { margin-top: 22px; }
.field-help { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.toast { position: fixed; left: 50%; bottom: 25px; transform: translate(-50%,140%); width: max-content; max-width: calc(100% - 32px); padding: 13px 18px; border-radius: 10px; background: #172437; color: white; box-shadow: 0 12px 35px #17243744; transition: transform .25s; z-index: 99; }
.toast.show { transform: translate(-50%,0); }
.toast.error { background: #8c1d18; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@media (max-width: 820px) {
  .header-inner { flex-wrap: wrap; padding: 10px 0; }
  .tab-nav { order: 3; width: 100%; margin-left: 0; flex-wrap: wrap; justify-content: center; gap: 6px; overflow: visible; }
  .user-box { margin-left: auto; }
  .page-shell { width: min(100% - 22px,1180px); margin-top: 18px; }
  .page-heading { align-items: flex-start; }
  .metric-grid { grid-template-columns: repeat(2,1fr); }
  .inline-form { grid-template-columns: 1fr; }
}
@media (max-width: 460px) {
  .login-card { padding: 26px; }
  .upload-card,.result-card,.settings-card { padding: 18px; }
  .metric-grid { grid-template-columns: 1fr; }
  .result-title .button { width: 100%; }
}
