* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(160deg, #f4f8ff 0%, #ffffff 50%, #fef8f3 100%);
  color: #0f172a;
}

.topbar {
  height: 60px;
  background: #0b318f;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 28px;
  box-shadow: 0 6px 30px rgba(11, 49, 143, 0.15);
}

.brand {
  font-size: 20px;
  font-weight: 700;
}

.topbar .sub {
  color: #d9e8ff;
  margin-left: 10px;
  font-size: 13px;
}

.layout {
  display: flex;
  min-height: calc(100vh - 60px);
}

.sidebar {
  width: 240px;
  background: #fff;
  border-right: 1px solid #d8e2ee;
  padding: 18px 14px;
}

.sidebar a {
  display: block;
  color: #12315f;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 6px;
}

.sidebar a.active,
.sidebar a:hover {
  background: #ecf2ff;
  color: #0b318f;
}

.content {
  flex: 1;
  padding: 20px 24px 32px;
}

h1 {
  margin: 0 0 18px;
  font-size: 24px;
}

.card-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 16px;
}

.card {
  background: #fff;
  border: 1px solid #d8e2ee;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(11, 49, 143, 0.05);
}

.card h3 {
  margin: 0;
  color: #456;
  font-size: 13px;
}

.card .value {
  font-size: 30px;
  margin-top: 8px;
  font-weight: 700;
  color: #0b318f;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #d8e2ee;
  border-radius: 12px;
  overflow: hidden;
}

thead th {
  background: #f3f6fc;
  text-align: left;
  font-size: 13px;
  color: #263b63;
  padding: 10px;
}

td, th {
  border-top: 1px solid #edf2fa;
  padding: 10px;
  font-size: 14px;
}

button,
input[type="submit"] {
  border: 0;
  background: #176cf4;
  color: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  min-height: 40px;
}

button.ghost {
  background: #fff;
  color: #0b318f;
  border: 1px solid #bfd2f8;
}

input[type="text"],
textarea,
select {
  border: 1px solid #bfd2f8;
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
  font-size: 14px;
  font-family: inherit;
  min-height: 42px;
}

textarea {
  min-height: 120px;
}

.toolbar {
  margin-bottom: 12px;
  display: flex;
  gap: 10px;
  align-items: end;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-pending { background: #f5f7ff; color: #1c3d95; }
.status-done { background: #edf9ef; color: #116b2d; }
.status-bad { background: #fff0f0; color: #9b1b1b; }
.status-insufficient { background: #fff7eb; color: #915108; }
.status-modified { background: #edf1ff; color: #2f4eaa; }

.tag {
  display: inline-block;
  border-radius: 999px;
  border: 1px solid #c9d7f4;
  padding: 2px 8px;
  margin-right: 6px;
  margin-bottom: 6px;
  font-size: 12px;
}

.section {
  background: #fff;
  border: 1px solid #d8e2ee;
  border-radius: 12px;
  padding: 16px;
}

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

.msg {
  margin-top: 8px;
  color: #1c3d95;
  min-height: 20px;
}

.error {
  color: #9b1b1b;
}

.small {
  color: #64748b;
  font-size: 12px;
}

@media (max-width: 860px) {
  body {
    background: #f4f7fc;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: 52px;
    padding: 0 16px;
  }

  .brand {
    font-size: 18px;
  }

  .topbar .sub {
    display: none;
  }

  .layout {
    flex-direction: column;
    min-height: calc(100vh - 52px);
  }

  .sidebar {
    position: sticky;
    top: 52px;
    z-index: 20;
    width: 100%;
    display: flex;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    border-right: 0;
    border-bottom: 1px solid #d8e2ee;
    padding: 6px 8px;
    box-shadow: 0 4px 16px rgba(11, 49, 143, 0.06);
  }

  .sidebar::-webkit-scrollbar {
    display: none;
  }

  .sidebar a {
    display: flex;
    align-items: center;
    min-height: 40px;
    margin: 0 4px 0 0;
    padding: 8px 12px;
    white-space: nowrap;
  }

  .content {
    min-width: 0;
    padding: 14px 12px 28px;
  }

  h1 {
    margin-bottom: 14px;
    font-size: 22px;
    line-height: 1.35;
  }

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

  .card {
    min-width: 0;
    padding: 12px;
  }

  .card .value {
    font-size: 26px;
  }

  .card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .section {
    padding: 12px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .toolbar > * {
    width: 100% !important;
  }

  button,
  input[type="submit"] {
    min-height: 44px;
  }

  .toolbar button,
  .row > button {
    width: 100%;
  }

  textarea {
    min-height: 150px;
  }

  pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
  }

  table {
    border: 0;
    background: transparent;
    overflow: visible;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tbody tr {
    overflow: hidden;
    background: #fff;
    border: 1px solid #d8e2ee;
    border-radius: 12px;
    box-shadow: 0 5px 16px rgba(11, 49, 143, 0.05);
  }

  td {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    min-height: 42px;
    padding: 10px 12px;
    border-top: 1px solid #edf2fa;
    overflow-wrap: anywhere;
  }

  td:first-child {
    border-top: 0;
  }

  td::before {
    content: attr(data-label);
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
  }

  td.empty-state {
    display: block;
    min-height: auto;
    color: #64748b;
    text-align: center;
  }

  td.empty-state::before {
    display: none;
  }

  td a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    color: #0b56d8;
    font-weight: 600;
  }

  .tag {
    white-space: normal;
    line-height: 1.5;
  }

  .msg {
    width: 100%;
  }
}

@media (max-width: 390px) {
  .topbar {
    padding: 0 12px;
  }

  .brand {
    font-size: 17px;
  }

  .card .value {
    font-size: 24px;
  }

  td {
    grid-template-columns: 84px minmax(0, 1fr);
  }
}
