:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --primary: #1f4f7c;
  --primary-dark: #173a5a;
  --accent: #0f9c7c;
  --danger: #d94848;
  --text: #253442;
  --muted: #6b7785;
  --border: #dde3e9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 34px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.brand { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.brand small { display: block; font-size: 11px; font-weight: 400; opacity: .75; margin-top: 2px; }

.top-user { font-size: 13px; text-align: right; }
.top-user a { color: #fff; opacity: .85; margin-left: 12px; }
.top-user a:hover { opacity: 1; }

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 50px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.nav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: #45586a;
  font-size: 13px;
}
.nav a:hover { background: #eef3f7; text-decoration: none; }
.nav .active { background: var(--primary); color: #fff; }

.container { width: min(1200px, calc(100% - 36px)); margin: 18px auto 40px; }
body.upload-page .container {
  width: min(1280px, calc(100% - 36px));
  margin: 12px auto 24px;
}
body.upload-page .page-title { margin: 0 0 10px; }
body.upload-page .page-title h1 { font-size: 20px; }
body.upload-page .page-title p { font-size: 12px; margin-top: 2px; }
body.upload-page .grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}
body.upload-page .card { padding: 14px; }
body.upload-page .card h2 { font-size: 15px; margin-bottom: 10px; }
body.upload-page #project-form { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
body.upload-page #project-form .field input,
body.upload-page #project-form .field select,
body.upload-page #project-form .field textarea { padding: 7px 9px; font-size: 12px; }
body.upload-page .field textarea.project-description { min-height: 66px; line-height: 1.45; }
body.upload-page .upload-box { padding: 14px; }
body.upload-page .upload-box input[type=file] { padding: 8px; font-size: 12px; }
body.upload-page .result { margin-top: 8px; padding: 8px; font-size: 12px; }
body.upload-page #upload-result,
body.upload-page #create-result { min-height: 0; }
body.upload-page .small { font-size: 11px; line-height: 1.45; }

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 18px;
}
.page-title h1 { font-size: 22px; margin: 0; }
.page-title p { color: var(--muted); margin: 4px 0 0; font-size: 13px; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,.03);
}

.metric { text-align: left; }
.metric .label { font-size: 13px; color: var(--muted); }
.metric .value { font-size: 28px; font-weight: 700; color: var(--primary); margin-top: 4px; }
.metric .sub { font-size: 12px; color: var(--muted); margin-top: 5px; }

.global-search {
  display: flex;
  gap: 8px;
  width: min(470px, calc(100% - 72px));
  margin: 14px 22px 0 auto;
  padding: 0;
}
.global-search input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
}

.card h2, .card h3 { margin: 0 0 10px; font-size: 16px; }
.card h2 { color: var(--primary); }
.card h3 { color: #30455a; }

.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: #f8fafb; color: #4c5b69; font-weight: 700; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 12px; background: #eef3f7; color: #4c5b69; }
.badge.good { background: #e7f8f2; color: #0b7a5f; }
.badge.warn { background: #fff4e3; color: #96610b; }
.badge.bad { background: #fdeaea; color: #a52c2c; }
.badge.info { background: #e9f0fb; color: #265080; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
#project-form { gap: 10px; }
#project-form .field input, #project-form .field select, #project-form .field textarea {
  padding: 8px 10px;
}
#project-form .form-action { display: flex; align-items: flex-end; }
#project-form .form-action .btn { width: 100%; }
.field label { display: block; font-size: 12px; color: #5d6b78; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}
.field textarea { min-height: 74px; resize: vertical; }
.field input[readonly] { background: #f5f7f9; color: #5d6b78; }
.field textarea.project-description { min-height: 78px; line-height: 1.6; }
.field textarea.summary-textarea { min-height: 72px; line-height: 1.6; }
.project-progress-card { min-width: 0; }
.project-progress-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.progress-section {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #f8fafb;
}
.progress-section h3 {
  margin: 0 0 9px;
  font-size: 13px;
  color: var(--primary);
}
.progress-section .field { margin-bottom: 9px; }
.progress-section .field:last-child { margin-bottom: 0; }
.progress-section textarea { min-height: 68px; }
.progress-actions { margin-top: 12px; display: flex; justify-content: flex-start; }
.field-hint { margin-top: 5px; font-size: 11px; color: var(--muted); line-height: 1.5; }
.quantity-field { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 8px; }
.quantity-field input, .quantity-field select { min-width: 0; }
.form-alert {
  margin-bottom: 12px;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13px;
  line-height: 1.5;
}
.form-alert.success { background: #e7f8f2; color: #0b7a5f; border: 1px solid #b9e5d9; }
.form-alert.error { background: #fdeaea; color: #a52c2c; border: 1px solid #f0bcbc; }

.inline-form { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inline-form input, .inline-form select, .inline-form textarea {
  min-width: 130px;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
}
.inline-search { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.inline-search input {
  flex: 1;
  max-width: 420px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 7px;
  padding: 9px 15px;
  font-size: 13px;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
}
.btn:hover { background: var(--primary-dark); }
.btn.green { background: var(--accent); }
.btn.green:hover { background: #0b7c62; }
.btn.yellow { background: #e5a000; }
.btn.yellow:hover { background: #c98a00; }
.btn.ghost { background: #fff; color: var(--primary); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b73434; }
.small-btn { padding: 5px 9px; font-size: 12px; border-radius: 6px; }

.btn-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-group form { display: flex; gap: 6px; align-items: center; }
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.row-actions .btn {
  flex: 0 0 auto;
  white-space: nowrap;
  min-width: 52px;
  text-align: center;
}
.row-actions .project-edit-btn { background: var(--primary); color: #fff; }
.row-actions .project-edit-btn:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }
.row-actions form { display: inline-flex; margin: 0; }
.form-action { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.historical-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.historical-actions form { display: inline-flex; margin: 0; }
.historical-actions .btn {
  min-width: 74px;
  text-align: center;
  white-space: nowrap;
}

.board {
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.board-column {
  min-width: 155px;
  background: #eef3f7;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
}
.board-column h2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.board-column h2 span {
  padding: 1px 7px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
}
.board-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-top: 9px;
}
.board-card strong { display: block; font-size: 13px; margin-bottom: 4px; }
.board-card p { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.board-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
}
.board-actions form { display: flex; gap: 5px; align-items: center; }
.board-actions select {
  max-width: 92px;
  padding: 4px 5px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #173a5a, #26678d);
  padding: 20px;
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.login-card h1 { margin: 0 0 4px; font-size: 21px; color: var(--primary); }
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.login-card .field { margin-bottom: 12px; }
.login-card .btn { width: 100%; }
.error { margin: 0 0 12px; padding: 8px 10px; background: #fdeaea; color: #a52c2c; border-radius: 7px; font-size: 12px; }

.upload-box {
  border: 2px dashed #bcc8d2;
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  background: #f9fbfc;
}
.upload-box input[type=file] { width: 100%; padding: 10px; font-size: 13px; }
.drop-zone { cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.drop-zone.drag-over { border-color: var(--accent); background: #eef8f5; }
.drop-zone strong { display: block; margin-bottom: 6px; color: var(--primary); }
#selected-file-name { margin-top: 10px; font-size: 13px; color: var(--primary); }

.result { margin-top: 12px; padding: 10px; border-radius: 7px; background: #eef8f5; color: #0b7a5f; font-size: 13px; }
.result.error { background: #fdeaea; color: #a52c2c; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0 10px 20px; border-left: 2px solid var(--border); position: relative; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline .time { display: block; color: var(--muted); font-size: 12px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 16px; }
.empty { color: var(--muted); font-size: 13px; padding: 12px; }
.list-actions { display: flex; justify-content: flex-start; margin-top: 10px; }

@media (max-width: 900px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  #project-form { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #project-form .field input, #project-form .field select, #project-form .field textarea {
    padding: 7px 8px;
    font-size: 12px;
  }
  #project-form .quantity-field { grid-template-columns: minmax(0, 1fr) 92px; gap: 6px; }
  #project-form .field.project-time { order: 1; }
  #project-form .field.project-name { order: 2; }
  #project-form .field.project-customer { order: 3; }
  #project-form .field.project-owner { order: 4; }
  #project-form .field.quantity-field-wrapper { order: 5; grid-column: 1 / -1; }
  #project-form .field.estimated-amount { order: 6; }
  #project-form .field.sample-date { order: 7; }
  #project-form .form-action { order: 8; grid-column: 1 / -1; }
  #project-form .field.project-description-field { order: 9; grid-column: 1 / -1; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 8px; }
  .top-user { text-align: left; }
  .global-search { margin-left: 0; margin-right: 0; padding: 0; }
  .board { grid-template-columns: repeat(7, 155px); }
  body.upload-page .grid-2 { grid-template-columns: 1fr; }
  body.upload-page #project-form { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .project-progress-grid { grid-template-columns: 1fr; }
  .progress-section textarea { min-height: 72px; }
}
