:root {
  --ink: #183734;
  --muted: #73817c;
  --line: #d8c08a;
  --deep: #0f5f53;
  --deep-2: #174f49;
  --gold: #c9a44b;
  --paper: #fbf5e8;
  --panel: #fffaf0;
  --soft: #f1eadc;
  --blue: #386c7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 95, 83, 0.08), transparent 32%),
    linear-gradient(315deg, rgba(201, 164, 75, 0.14), transparent 36%),
    var(--paper);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app {
  width: min(1400px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 30px;
  border-radius: 8px;
  color: #fffaf0;
  background: var(--deep-2);
  box-shadow: 0 18px 40px rgba(24, 55, 52, 0.18);
}

.entry-nav {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.entry-nav a {
  padding: 10px 14px;
  border: 1px solid rgba(217, 189, 104, 0.72);
  border-radius: 999px;
  color: #fffaf0;
  text-decoration: none;
  font-weight: 700;
}

.home-view {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.entry-card {
  min-height: 260px;
  display: grid;
  align-content: end;
  gap: 10px;
  padding: 28px;
  border: 1px solid rgba(201, 164, 75, 0.78);
  border-radius: 8px;
  color: #fffaf0;
  text-decoration: none;
  box-shadow: 0 18px 40px rgba(24, 55, 52, 0.18);
}

.entry-card span {
  color: #d9bd68;
  font-weight: 700;
}

.entry-card strong {
  font-size: clamp(32px, 6vw, 54px);
  line-height: 1.05;
}

.entry-card small {
  color: rgba(255, 250, 240, 0.82);
  font-size: 15px;
}

.staff-card {
  background:
    linear-gradient(135deg, rgba(255, 250, 240, 0.12), transparent 45%),
    #0f5f53;
}

.boss-card {
  background:
    linear-gradient(135deg, rgba(217, 189, 104, 0.18), transparent 48%),
    #183734;
}

body.role-home .work-view,
body.role-home .metrics,
body.role-home .lower,
body.role-staff .home-view,
body.role-staff .boss-only,
body.role-boss .home-view,
body.role-boss .staff-work {
  display: none;
}

body.role-staff .layout {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.72fr);
}

.eyebrow {
  margin: 0 0 8px;
  color: #d9bd68;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 46px);
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
}

.status-pill {
  min-width: 120px;
  padding: 10px 14px;
  border: 1px solid rgba(217, 189, 104, 0.72);
  border-radius: 999px;
  text-align: center;
  color: #f4deb0;
}

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

.metrics article,
.panel {
  border: 1px solid rgba(201, 164, 75, 0.62);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.92);
  box-shadow: 0 10px 26px rgba(24, 55, 52, 0.1);
}

.metrics article {
  padding: 18px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 18px;
}

.lower {
  margin-top: 18px;
}

.boss-dashboard {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
  margin-top: 18px;
}

.hero-ledger {
  grid-row: span 2;
}

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

.overview-tile {
  min-height: 118px;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid #e5d4a9;
  background: #fffdf6;
}

.overview-tile span,
.rank-row span,
.manager-notes p,
.attendance-chip span {
  color: var(--muted);
}

.overview-tile strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.overview-tile.highlight {
  color: #fffaf0;
  border-color: var(--deep);
  background: var(--deep);
}

.overview-tile.highlight span {
  color: #f4deb0;
}

.panel {
  padding: 20px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.filter-group {
  display: flex;
  align-items: end;
  gap: 10px;
}

.filter-group label {
  color: var(--muted);
  font-size: 12px;
  gap: 4px;
}

.filter-group input {
  min-width: 150px;
  padding: 9px 10px;
}

.panel-title.small {
  margin: 22px 0 10px;
}

.panel-title span {
  color: var(--muted);
  font-size: 14px;
}

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

.amount-share-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.72fr);
  gap: 18px;
  align-items: end;
}

.share-output {
  min-height: 48px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 8px 14px;
  border: 1px solid rgba(15, 95, 83, 0.35);
  border-radius: 8px;
  background: rgba(15, 95, 83, 0.07);
}

.share-output span,
.share-output small {
  color: var(--muted);
}

.share-output span {
  font-size: 13px;
}

.share-output strong {
  color: var(--deep);
  font-size: 24px;
  line-height: 1;
}

.share-output small {
  font-size: 12px;
}

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

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d7c8a6;
  border-radius: 6px;
  background: #fffdf6;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 104px;
  padding: 12px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--deep);
  box-shadow: 0 0 0 3px rgba(15, 95, 83, 0.12);
}

.wide {
  grid-column: 1 / -1;
}

.custom-service-field {
  display: none;
}

.custom-service-field.is-visible {
  display: grid;
}

.project-lines {
  display: grid;
  gap: 12px;
}

.project-line {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(150px, 1fr) minmax(150px, 1fr) 84px;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid #eadbb6;
  border-radius: 8px;
  background: #fffdf6;
}

.project-line-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  grid-column: 1 / -1;
  color: var(--deep);
}

.project-line-head strong {
  font-size: 14px;
}

.remove-project {
  width: 30px;
  height: 30px;
  color: #8f2c2c;
  background: #f7e2db;
}

.add-project {
  width: max-content;
  padding: 0 16px;
}

.check-field {
  align-content: end;
}

.check-field input {
  width: 20px;
  height: 20px;
  accent-color: var(--deep);
}

button {
  height: 42px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.primary {
  color: #fffaf0;
  background: var(--deep);
}

.secondary {
  color: #fffaf0;
  background: var(--blue);
}

.ghost {
  width: 100%;
  margin-top: 10px;
  border: 1px solid var(--deep);
  color: var(--deep);
  background: transparent;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid #eadbb6;
  text-align: left;
  white-space: nowrap;
}

th {
  color: #fffaf0;
  background: var(--deep);
  font-size: 13px;
}

td.amount {
  font-weight: 700;
}

.delete-btn {
  width: 34px;
  height: 32px;
  color: #8f2c2c;
  background: #f7e2db;
}

.settlement {
  display: grid;
  gap: 12px;
}

.settlement-card {
  padding: 16px;
  border: 1px solid #e5d4a9;
  border-radius: 8px;
  background: #fffdf6;
}

.settlement-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.settlement-card strong {
  font-size: 20px;
}

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

.settlement-grid span {
  color: var(--muted);
  font-size: 12px;
}

.settlement-grid b {
  display: block;
  margin-top: 3px;
}

.ranking {
  display: grid;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  background: #fffdf6;
  border: 1px solid #eadbb6;
}

.rank-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-row b {
  font-size: 18px;
}

.bar {
  grid-column: 1 / -1;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: #eee1c5;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--deep);
}

.attendance-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.attendance-chip {
  min-width: 112px;
  padding: 13px;
  border: 1px solid #eadbb6;
  border-radius: 8px;
  background: #fffdf6;
}

.attendance-chip b {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.manager-notes {
  display: grid;
  gap: 10px;
}

.manager-notes p {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #fffdf6;
  border: 1px solid #eadbb6;
}

.settlement-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.settlement-summary div {
  padding: 14px;
  border: 1px solid #eadbb6;
  border-radius: 8px;
  background: #fffdf6;
}

.settlement-summary span,
.settlement-history-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.settlement-summary strong {
  display: block;
  margin-top: 7px;
  color: var(--deep);
  font-size: 22px;
}

.settlement-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settlement-actions span {
  color: var(--muted);
  font-size: 13px;
}

.settlement-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.settlement-history {
  display: grid;
  gap: 10px;
}

.settlement-history-card {
  border: 1px solid #eadbb6;
  border-radius: 8px;
  background: #fffdf6;
}

.settlement-history-card summary {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1.2fr;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  list-style-position: inside;
}

.settlement-history-card summary b {
  color: var(--deep);
}

.settlement-history-detail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 0 16px 16px;
}

.settlement-history-detail > div {
  padding-top: 10px;
  border-top: 1px solid #eadbb6;
}

.settlement-history-detail span {
  color: var(--muted);
  font-size: 12px;
}

.settlement-history-detail b {
  display: block;
  margin-top: 5px;
}

.history-technicians {
  grid-column: 1 / -1;
}

.history-technicians p {
  margin: 7px 0 0;
  color: var(--ink);
}

.undo-settlement {
  grid-column: 1 / -1;
  justify-self: start;
}

.empty-state {
  padding: 16px;
  color: var(--muted);
  border: 1px dashed #d8c08a;
  border-radius: 8px;
}

@media (max-width: 900px) {
  body.role-staff .layout {
    grid-template-columns: 1fr;
  }

  .metrics,
  .layout,
  .boss-dashboard,
  .form-grid,
  .form-grid.compact,
  .home-view {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .entry-nav {
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
  }

  .filter-title {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-group {
    align-items: stretch;
  }

  .filter-group label,
  .filter-group input {
    min-width: 0;
    width: 100%;
  }

  .amount-share-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .settlement-summary,
  .settlement-history-detail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settlement-history-card summary {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 901px) {
  body.role-staff .app {
    width: min(1480px, calc(100% - 72px));
    padding-top: 24px;
  }

  body.role-staff .topbar {
    min-height: 122px;
    padding: 24px 34px;
    border-radius: 10px;
  }

  body.role-staff h1 {
    font-size: 42px;
  }

  body.role-staff .staff-work {
    grid-template-columns: minmax(0, 1fr) 350px;
    gap: 20px;
    align-items: stretch;
    margin-top: 20px;
  }

  body.role-staff .entry-panel {
    padding: 26px 28px 28px;
  }

  body.role-staff .form-grid {
    column-gap: 18px;
    row-gap: 18px;
  }

  body.role-staff .form-grid input,
  body.role-staff .form-grid select {
    height: 48px;
  }

  body.role-staff .order-preview {
    position: sticky;
    top: 24px;
    min-height: 100%;
    padding: 24px;
    color: #fffaf0;
    border-color: var(--deep);
    background: var(--deep-2);
    box-shadow: 0 16px 34px rgba(24, 55, 52, 0.18);
  }

  body.role-staff .order-preview h2 {
    color: #fffaf0;
  }

  body.role-staff .order-preview .panel-title {
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 250, 240, 0.18);
  }

  .preview-kicker {
    color: #d9bd68;
    font-size: 12px;
    font-weight: 700;
  }

  .preview-total {
    margin: 20px 0;
    padding: 18px;
    border: 1px solid rgba(217, 189, 104, 0.58);
    border-radius: 8px;
    background: #0f5f53;
  }

  .preview-total span {
    color: #f4deb0;
    font-size: 13px;
  }

  .preview-total strong {
    display: block;
    margin-top: 10px;
    color: #fffaf0;
    font-size: 40px;
  }

  .preview-list {
    display: grid;
    gap: 0;
    margin-top: 10px;
  }

  .preview-list div {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 13px 0;
    border-bottom: 1px solid rgba(255, 250, 240, 0.18);
  }

  .preview-list span {
    color: rgba(255, 250, 240, 0.68);
    font-size: 13px;
  }

  .preview-list b {
    color: #fffaf0;
    font-size: 14px;
    text-align: right;
  }

  .preview-note {
    margin: 18px 0 20px;
    color: rgba(255, 250, 240, 0.68);
    font-size: 13px;
    line-height: 1.6;
  }

  .preview-submit {
    width: 100%;
    height: 52px;
    color: var(--ink);
    background: #d9bd68;
  }

  .preview-submit:hover {
    background: #e4c979;
  }

  .preview-title span {
    padding: 5px 9px;
    border: 1px solid rgba(217, 189, 104, 0.58);
    border-radius: 999px;
    color: #f4deb0;
    font-size: 12px;
  }

  .preview-title span.is-selected,
  .preview-list b.is-bonus {
    color: #d9bd68;
  }
}
