* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  color: #172033;
  background: #eef2f6;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.page-section[hidden],
.auth-required[hidden] {
  display: none !important;
}

.login-required {
  max-width: 560px;
  margin: 80px auto;
  text-align: center;
  padding: 28px;
}

.sidebar {
  background: #071b2d;
  color: #f8fbff;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 4px;
  flex: 0 0 auto;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  line-height: 1.25;
}

.login-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  display: block;
  margin: 0 auto 18px;
}

.brand small,
.sidebar-note small,
.sidebar-note span {
  color: #a7b7c7;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-list a {
  color: #d8e4ef;
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 8px;
}

.nav-list a.active,
.nav-list a:hover {
  background: #0f6f86;
  color: #fff;
}

.sidebar-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  display: grid;
  gap: 5px;
}

.main {
  padding: 28px;
  display: grid;
  gap: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #0f7188;
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}

.month-filter {
  min-width: 150px;
}

.login-box,
.user-box {
  display: flex;
  gap: 8px;
  align-items: end;
}

.login-box input {
  width: 132px;
}

.user-box span {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  color: #0e4557;
  background: #fff;
  border: 1px solid #d8e2ec;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 700;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  border: 0;
  background: #0e8f9f;
  color: #fff;
}

.ghost-button {
  color: #0e4557;
  background: #fff;
  border: 1px solid #d8e2ec;
}

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

.metric,
.panel {
  background: #fff;
  border: 1px solid #dfe7ef;
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(18, 35, 52, 0.07);
}

.metric {
  padding: 18px;
  display: grid;
  gap: 4px;
}

.metric span,
.metric small {
  color: #5a697b;
}

.metric strong {
  font-size: 34px;
  color: #0e8f9f;
}

.metric.good strong {
  color: #1f9d55;
}

.metric.warn strong {
  color: #e58416;
}

.metric.danger strong {
  color: #d63c30;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.entry-panel {
  grid-column: 1 / -1;
}

.panel {
  padding: 18px;
}

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

.status-pill {
  color: #855a12;
  background: #fff2d5;
  border: 1px solid #f5d499;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
}

.status-pill.saved {
  color: #138147;
  background: #e9f8ef;
  border-color: #b7e3c5;
}

.status-pill.error {
  color: #ba2f28;
  background: #ffe7e5;
  border-color: #f4bbb7;
}

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

.wide-field {
  grid-column: span 2;
}

label {
  display: grid;
  gap: 7px;
  color: #536273;
  font-size: 13px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #d5e0ea;
  border-radius: 8px;
  padding: 0 10px;
  color: #142134;
  background: #fff;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #e3ebf2;
  border-radius: 8px;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

.score-table th,
.score-table td {
  padding: 12px;
  border-bottom: 1px solid #e8eef5;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

.score-table th {
  background: #f7fafc;
  color: #526274;
}

.score-table tr:last-child td {
  border-bottom: 0;
}

.score-input {
  width: 76px;
}

.remark-input {
  min-width: 220px;
}

.signature-panel {
  margin-top: 16px;
  border: 1px solid #e3ebf2;
  border-radius: 8px;
  padding: 14px;
  background: #fbfdff;
}

.signature-heading {
  margin-bottom: 12px;
}

.signature-canvas {
  width: 100%;
  height: 180px;
  display: block;
  border: 1px dashed #9fb5c9;
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}

.tag {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.tag.pass,
.pass {
  color: #138147;
  background: #e9f8ef;
}

.tag.fix,
.fix {
  color: #a85d0d;
  background: #fff2dc;
}

.tag.risk,
.risk {
  color: #ba2f28;
  background: #ffe7e5;
}

.entry-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.score-box {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.score-box strong {
  font-size: 30px;
}

.score-detail {
  color: #637184;
}

.paper-preview {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: top;
  border: 1px solid #dce5ee;
  border-radius: 8px;
  background: #f8fafc;
}

.evidence-viewer {
  width: 100%;
}

.evidence-frame {
  width: 100%;
  height: 430px;
  border: 1px solid #dce5ee;
  border-radius: 8px;
  background: #f8fafc;
}

.signature-preview {
  width: 100%;
  margin-top: 10px;
  border: 1px solid #dce5ee;
  border-radius: 8px;
  background: #fff;
}

.upload-box {
  margin-top: 14px;
  border: 1px dashed #b9c9d8;
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 4px;
}

.upload-box span {
  color: #0f7188;
  font-weight: 800;
}

.upload-box small {
  color: #637184;
}

.lower-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
}

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

.bar-chart {
  min-height: 260px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  align-items: end;
  padding: 18px 6px 4px;
  background: linear-gradient(#eef4f8 1px, transparent 1px) 0 0 / 100% 52px;
}

.bar {
  height: calc(max(var(--value), 8) * 2px);
  min-height: 44px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, #18aeb7, #0b7b8b);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  font-weight: 800;
  padding: 8px 4px;
}

.warn-bar {
  background: linear-gradient(180deg, #ffb246, #e58416);
}

.danger-bar {
  background: linear-gradient(180deg, #f36b5f, #d63c30);
}

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

.template-item {
  text-align: left;
  border: 1px solid #dbe5ee;
  border-radius: 8px;
  padding: 13px;
  background: #fff;
}

.template-item strong,
.template-item span {
  display: block;
}

.template-item span {
  margin-top: 3px;
  color: #5d6b7c;
  font-size: 13px;
}

.template-controls {
  align-items: end;
}

.template-actions {
  display: flex;
  gap: 10px;
  align-items: end;
}

.row-button {
  width: 38px;
  height: 38px;
  border: 1px solid #f0b8b2;
  border-radius: 8px;
  color: #ba2f28;
  background: #fff5f4;
  cursor: pointer;
  font-weight: 900;
}

.link-button {
  margin-left: 8px;
  border: 0;
  color: #0f7188;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
  text-decoration: underline;
}

.danger-link {
  color: #ba2f28;
}

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

.history-row {
  display: grid;
  grid-template-columns: 130px 1fr 140px 1.5fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #e3ebf2;
  border-radius: 8px;
}

.history-row.clickable {
  cursor: pointer;
}

.history-row.clickable:hover {
  border-color: #0e8f9f;
  background: #f7fcfd;
}

.detail-panel {
  margin-top: 18px;
  border: 1px solid #dfe7ef;
  border-radius: 8px;
  padding: 16px;
  background: #fbfdff;
}

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

.detail-grid div {
  border: 1px solid #e3ebf2;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.detail-grid span {
  display: block;
  color: #637184;
  font-size: 12px;
}

.detail-grid strong {
  display: block;
  margin-top: 3px;
}

.signature-preview {
  max-width: 360px;
}

.history-row span,
.history-row small {
  color: #637184;
}

.history-row em {
  justify-self: start;
  border-radius: 999px;
  padding: 5px 10px;
  font-style: normal;
  font-weight: 800;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    overflow-x: auto;
  }

  .summary-grid,
  .form-grid,
  .workspace-grid,
  .lower-grid {
    grid-template-columns: 1fr 1fr;
  }

  .entry-panel,
  .wide-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .top-actions,
  .template-actions,
  .entry-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-grid,
  .form-grid,
  .workspace-grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: auto;
  }

  .history-row {
    grid-template-columns: 1fr;
  }
}
