:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-alt: #ecf3fb;
  --primary: #0f4c81;
  --primary-strong: #093456;
  --accent: #2a7db7;
  --text: #10253a;
  --muted: #61758a;
  --border: #d8e2ee;
  --danger: #b63939;
  --warning: #d98518;
  --success: #217a52;
  --shadow: 0 18px 40px rgba(15, 76, 129, 0.08);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans TC", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(42, 125, 183, 0.12), transparent 30%),
    linear-gradient(180deg, #f7fbff 0%, var(--bg) 100%);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 18px 8px;
}

.topbar h1,
.auth-card h1 {
  margin: 4px 0 0;
  font-size: 1.7rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.82rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-content {
  padding: 12px 18px 24px;
}

.page-content.with-nav {
  padding-bottom: 104px;
}

.card,
.auth-card {
  background: var(--surface);
  border: 1px solid rgba(216, 226, 238, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card + .card,
.form-stack > .card,
.toolbar,
.list-grid,
.card-grid {
  margin-top: 16px;
}

.accent {
  background: linear-gradient(180deg, #f9fcff, #eef6ff);
}

.narrow-card {
  max-width: 560px;
}

.password-card {
  max-width: 760px;
}

.muted {
  color: var(--muted);
}

.danger-text {
  color: var(--danger);
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(10px);
}

.filter-grid,
.form-grid {
  display: grid;
  gap: 14px;
}

.form-stack {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.92rem;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfdff;
  padding: 12px 14px;
  color: var(--text);
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(42, 125, 183, 0.22);
  border-color: var(--accent);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.stretch-end {
  align-self: end;
}

.button,
.ghost-link,
.icon-button {
  border-radius: 14px;
  border: none;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.button:hover,
.ghost-link:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

.button.secondary {
  background: var(--surface-alt);
  color: var(--primary);
}

.button.tertiary,
.ghost-link {
  background: transparent;
  color: var(--primary-strong);
  border: 1px solid var(--border);
}

.button.danger {
  background: #fff1f1;
  color: var(--danger);
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.flash {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 0.95rem;
}

.flash-success {
  background: #ecfbf4;
  color: var(--success);
}

.flash-error {
  background: #fff2f2;
  color: var(--danger);
}

.banner.warning,
.warning-pill {
  background: #fff5e8;
  color: var(--warning);
}

.status-pill,
.delta-pill,
.muted-pill,
.success-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
}

.muted-pill {
  background: #eef2f6;
  color: var(--muted);
}

.success-pill {
  background: #eaf8f1;
  color: var(--success);
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.title-row h2,
.section-heading h2 {
  margin: 0;
  font-size: 1.15rem;
}

.meta-list {
  display: grid;
  gap: 10px;
}

.meta-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dashed rgba(216, 226, 238, 0.9);
  padding-bottom: 8px;
}

.meta-list dt {
  color: var(--muted);
}

.meta-list dd {
  margin: 0;
  text-align: right;
}

.compact {
  margin-top: 14px;
}

.list-grid,
.card-grid {
  display: grid;
  gap: 16px;
}

.material-card,
.project-card {
  display: grid;
  gap: 14px;
}

.material-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 16px;
  object-fit: cover;
  background: #dce8f4;
}

.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.disabled-card {
  opacity: 0.75;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.line-list {
  display: grid;
  gap: 12px;
}

.line-item {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: #f8fbff;
  border: 1px solid rgba(216, 226, 238, 0.75);
}

.material-line-item {
  align-items: end;
}

.line-summary {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.line-summary strong {
  line-height: 1.3;
}

.line-hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.icon-button {
  background: #eef3f8;
  color: var(--muted);
}

.summary-panel {
  display: grid;
  gap: 4px;
  align-content: center;
  min-height: 100%;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #0f4c81, #0c395f);
  color: #fff;
}

.summary-panel strong {
  font-size: 1.6rem;
}

.upload-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  border: 1px dashed rgba(42, 125, 183, 0.32);
  background: linear-gradient(180deg, #fbfdff, #f2f7fd);
}

.upload-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.upload-panel input[type="file"] {
  width: 100%;
}

.upload-summary {
  color: var(--primary-strong);
  font-weight: 600;
}

.selected-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 999px;
  background: #e7f0fa;
  color: var(--primary-strong);
  font-size: 0.85rem;
  word-break: break-all;
}

.password-panel {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.copy-password-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.copy-input {
  flex: 1 1 280px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f7fbff;
  padding: 13px 15px;
  color: var(--primary-strong);
  font-family: Consolas, "Courier New", monospace;
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.copy-input:focus {
  outline: 2px solid rgba(42, 125, 183, 0.22);
  border-color: var(--accent);
}

.helper-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.photo-card {
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(216, 226, 238, 0.82);
  background: linear-gradient(180deg, #ffffff, #f7fbff);
}

.photo-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  border-radius: 16px;
}

.photo-section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.photo-section-header h2 {
  margin: 0;
}

.photo-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
}

.photo-meta small {
  color: var(--muted);
}

.photo-delete-form {
  margin: 0;
}

.photo-archive {
  margin-top: 14px;
}

.photo-archive summary {
  cursor: pointer;
  color: var(--primary-strong);
  font-weight: 700;
}

.empty-state {
  text-align: center;
}

.project-section {
  margin-top: 16px;
}

.project-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.project-section-header h2 {
  margin: 4px 0 0;
}

.project-archive {
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(216, 226, 238, 0.8);
  box-shadow: var(--shadow);
}

.project-archive summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
}

.project-archive summary::-webkit-details-marker {
  display: none;
}

.archive-grid {
  margin-top: 16px;
}

.archive-card {
  background: linear-gradient(180deg, #ffffff, #f6fbff);
}

.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 420px);
}

.bottom-nav {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 10px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(216, 226, 238, 0.95);
  box-shadow: 0 20px 48px rgba(15, 76, 129, 0.14);
  backdrop-filter: blur(14px);
}

.bottom-nav a {
  display: grid;
  place-items: center;
  min-height: 48px;
  border-radius: 16px;
  color: var(--muted);
  font-weight: 600;
}

.bottom-nav a.active {
  background: linear-gradient(180deg, #0f4c81, #13619f);
  color: #fff;
}

.full-width {
  grid-column: 1 / -1;
}

@media (min-width: 720px) {
  .page-content {
    max-width: 1080px;
    margin: 0 auto;
  }

  .filter-grid,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .list-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .line-item {
    grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 0.8fr) minmax(0, 1fr) auto;
    align-items: end;
  }

  .material-line-item[data-line-kind="actual"] {
    grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(0, 1.15fr) auto;
  }

  .photo-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
