:root {
  --bg: #f6f1e8;
  --bg-elevated: #fffdf8;
  --card: #fffdf8;
  --label: #2b2926;
  --label-2: #4a463f;
  --secondary: #7a736a;
  --tertiary: #b3aca0;
  --separator: rgba(85, 75, 55, 0.14);
  --fill: rgba(120, 105, 80, 0.12);
  --accent: #2f4f6f;
  --accent-dim: #e9eef2;
  --green: #4a6741;
  --green-dim: #eaf0e7;
  --orange: #c1440e;
  --orange-dim: #f7e9e0;
  --red: #b23a30;
  --red-dim: #f6e4e1;
  --indigo: #2f4f6f;
  --indigo-dim: #e9eef2;
  --teal: #3f6f6a;
  --teal-dim: #e6efed;
  --purple: #6b5b7a;
  --shadow: 0 1px 3px rgba(70, 60, 40, 0.07), 0 10px 28px rgba(70, 60, 40, 0.08);
  --radius: 8px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-serif: "Hiragino Mincho ProN", "Yu Mincho", "Songti TC", serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: linear-gradient(180deg, #ffffff 0%, #fbf8f1 55%, #ffffff 100%);
  color: var(--label);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

input,
textarea,
select {
  border: 0;
  outline: none;
  background: none;
  color: var(--label);
}

input::placeholder,
textarea::placeholder {
  color: var(--tertiary);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ============ 提報端（手機） ============ */

.phone {
  position: relative;
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  background: linear-gradient(180deg, #ffffff 0%, #fbf8f1 55%, #ffffff 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
}

@media (min-width: 480px) {
  .phone {
    min-height: 100vh;
  }
}

.screen {
  display: none;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  animation: fade 0.22s ease;
}

.screen.active {
  display: block;
}

.screen.home {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  justify-content: space-between;
}

.screen.home.active {
  display: flex;
}

.screen.home .large-header {
  margin-bottom: 22px;
}

.home-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: auto;
  padding: 18px 0 6px;
  color: var(--secondary);
  font-size: 15px;
  font-weight: 600;
}

.home-qr {
  display: flex;
  justify-content: center;
  padding: 30px 0 14px;
}

.home-qr .qr-inline {
  width: 150px;
  height: 150px;
  flex-basis: 150px;
  background: #fff;
  border: 1px solid rgba(85, 75, 55, 0.1);
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(70, 60, 40, 0.08);
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.large-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 32px;
}

.large-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0;
}

.large-subtitle {
  color: var(--secondary);
  font-size: 15px;
  font-weight: 500;
  margin-top: 3px;
}

.entry-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 20px 16px;
  margin-top: 18px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid rgba(0, 122, 255, 0.12);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 122, 255, 0.08);
  text-align: left;
}

.entry-card:active {
  transform: scale(0.99);
}

.entry-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 12px;
  background: linear-gradient(140deg, #dbe9ff, #eef4ff);
  color: var(--accent);
}

.entry-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.entry-title {
  font-size: 19px;
  font-weight: 700;
}

.entry-sub {
  color: var(--secondary);
  font-size: 13px;
}

.admin-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 8px 13px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.admin-link:active {
  opacity: 0.7;
}

.header-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.qr-inline {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}

.qr-inline img,
.qr-inline canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 18px;
}

.back-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--accent);
}

.screen-title {
  font-size: 22px;
  font-weight: 700;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 26px 4px 10px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
}

.section-title .link {
  color: var(--accent);
  font-size: 13px;
  text-transform: none;
}

.category-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 26px 20px;
  margin-bottom: 18px;
  background: var(--card);
  border: 1px solid rgba(85, 75, 55, 0.08);
  border-radius: var(--radius);
  box-shadow: 0 2px 6px rgba(70, 60, 40, 0.05), 0 12px 32px rgba(70, 60, 40, 0.07);
  text-align: left;
  animation: cardIn 0.45s ease both;
}

.screen.home .category-card:nth-child(2) {
  animation-delay: 0.06s;
}

.screen.home .category-card:nth-child(3) {
  animation-delay: 0.14s;
}

.screen.home .category-card:nth-child(4) {
  animation-delay: 0.22s;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.category-card:active {
  transform: scale(0.99);
}

.cat-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 10px;
  color: var(--cat, var(--accent));
  background: linear-gradient(135deg, color-mix(in srgb, var(--cat, var(--accent)) 28%, white), color-mix(in srgb, var(--cat, var(--accent)) 7%, white));
}

.cat-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.cat-title {
  font-size: 17px;
  font-weight: 600;
}

.cat-sub {
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit-badge {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--label-2);
  font-size: 12px;
  font-weight: 600;
}

.chevron {
  flex: 0 0 auto;
  color: var(--tertiary);
}

.case-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.case-card {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
}

.case-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.case-no {
  font-size: 14px;
  font-weight: 600;
}

.case-loc {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--label-2);
  font-size: 14px;
  margin-bottom: 6px;
}

.case-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--secondary);
  font-size: 12px;
}

.case-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--tertiary);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.cable {
  color: var(--accent);
  background: var(--accent-dim);
}

.badge.safety {
  color: var(--orange);
  background: var(--orange-dim);
}

.badge.business {
  color: var(--green);
  background: var(--green-dim);
}

.badge.status-new {
  color: var(--orange);
  background: var(--orange-dim);
}

.badge.status-progress {
  color: var(--accent);
  background: var(--accent-dim);
}

.badge.status-done {
  color: var(--green);
  background: var(--green-dim);
}

.badge.status-overdue {
  color: var(--red);
  background: var(--red-dim);
}

.badge.urgency-normal {
  color: var(--secondary);
  background: var(--fill);
}

.badge.urgency-urgent {
  color: var(--orange);
  background: var(--orange-dim);
}

.badge.urgency-critical {
  color: var(--red);
  background: var(--red-dim);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.chip {
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--label);
  font-size: 15px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.chip.selected {
  background: var(--accent);
  color: #fff;
}

.chips.orange .chip.selected {
  background: var(--orange);
}

.chips.green .chip.selected {
  background: var(--green);
}

.form-group {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.form-section-title {
  padding: 14px 14px 0;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 700;
}

.form-group + .form-group {
  margin-top: 16px;
}

.form-section {
  padding: 12px 14px;
}

.form-section + .form-section {
  border-top: 1px solid var(--separator);
}

.form-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
}

.form-label .required {
  color: var(--red);
}

.form-label .hint {
  color: var(--tertiary);
  font-weight: 400;
}

.text-input {
  width: 100%;
  min-height: 40px;
  font-size: 16px;
  border-bottom: 1px solid var(--separator);
  padding: 4px 0;
}

.text-input:focus {
  border-bottom-color: var(--accent);
}

.row-input {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 48px;
}

.row-input + .row-input {
  border-top: 1px solid var(--separator);
}

.row-input .text-input {
  border-bottom: 0;
  text-align: right;
}

.row-input .text-input:focus {
  border-bottom: 0;
}

.textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  line-height: 1.5;
  padding: 4px 0;
  font-size: 16px;
}

.location-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.location-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.location-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--label-2);
  font-size: 14px;
  min-width: 0;
}

.location-value .map-link {
  color: var(--accent);
  font-weight: 500;
  flex: 0 0 auto;
}

.photo-grid {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.photo-thumb {
  position: relative;
  width: 76px;
  height: 76px;
  flex: 0 0 76px;
  border-radius: 8px;
  background: var(--fill);
  overflow: hidden;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}

.photo-add {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  flex: 0 0 76px;
  border-radius: 8px;
  border: 1.5px dashed var(--tertiary);
  color: var(--tertiary);
}

.segmented {
  display: flex;
  padding: 2px;
  border-radius: 10px;
  background: var(--fill);
}

.segmented button {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
}

.segmented button.selected {
  background: var(--card);
  color: var(--label);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.segmented button.selected.urgency-urgent {
  color: var(--orange);
}

.segmented button.selected.urgency-critical {
  color: var(--red);
}

.sticky-footer {
  position: fixed;
  right: 0;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 0;
  max-width: 430px;
  margin: 0 auto;
  padding: 10px 20px;
  background: linear-gradient(to top, rgba(245, 239, 228, 0.97) 72%, rgba(245, 239, 228, 0));
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(0, 122, 255, 0.28);
}

.btn-primary:active {
  transform: scale(0.99);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--fill);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
}

.success-wrap {
  padding-top: 72px;
  text-align: center;
}

.success-icon {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--green-dim);
  color: var(--green);
}

.success-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
}

.success-sub {
  color: var(--secondary);
  font-size: 15px;
  margin-bottom: 28px;
}

.success-card {
  padding: 18px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
}

.success-card .case-no {
  font-size: 20px;
  margin-bottom: 4px;
}

.success-card .row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  font-size: 14px;
}

.success-card .row + .row {
  border-top: 1px solid var(--separator);
}

.success-card .row .k {
  color: var(--secondary);
}

.success-card .row .v {
  font-weight: 600;
}

.success-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.success-qr {
  display: flex;
  justify-content: center;
  padding-top: 16px;
}

.success-qr .qr-inline {
  width: 96px;
  height: 96px;
  flex-basis: 96px;
}

.success-actions .btn-primary,
.success-actions .btn-secondary {
  flex: 1;
}

.tab-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  max-width: 430px;
  margin: 0 auto;
  display: flex;
  padding: 8px 28px calc(8px + env(safe-area-inset-bottom));
  background: rgba(248, 248, 250, 0.92);
  backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--separator);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 1;
  color: var(--secondary);
  font-size: 11px;
  font-weight: 500;
}

.tab.active {
  color: var(--accent);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 0 12px;
  height: 38px;
  border-radius: 10px;
  background: var(--fill);
  color: var(--secondary);
}

.search-field input {
  flex: 1;
  font-size: 15px;
}

/* ============ 後台（桌面） ============ */

.admin-body {
  background: #f5f5f7;
  min-height: 100vh;
}

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

.login-card {
  width: min(400px, 100%);
  padding: 36px 32px;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--accent-dim);
  color: var(--accent);
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.login-card .login-sub {
  color: var(--secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

.login-field {
  text-align: left;
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  margin-bottom: 6px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
}

.login-field input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--separator);
  border-radius: 10px;
  background: #fbfbfd;
  font-size: 15px;
}

.login-field select {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--separator);
  border-radius: 10px;
  background: #fbfbfd;
  color: var(--label);
  font-size: 15px;
}

.login-field textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--separator);
  border-radius: 10px;
  background: #fbfbfd;
  font-size: 15px;
  line-height: 1.5;
}

.login-note {
  margin-top: 16px;
  color: var(--tertiary);
  font-size: 12px;
}

.text-link {
  display: inline-block;
  margin-top: 14px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.perm-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 14px;
  color: var(--label-2);
}

.perm-checks label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.perm-checks input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.data-table input[type="text"],
.data-table input[type="password"] {
  width: 110px;
  padding: 6px 8px;
  border: 1px solid var(--separator);
  border-radius: 8px;
  background: #fbfbfd;
  color: var(--label);
  font-size: 13px;
}

.admin-app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: 232px;
  flex: 0 0 232px;
  padding: 18px 12px;
  background: rgba(250, 250, 252, 0.86);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--separator);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
}

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

.brand-name small {
  display: block;
  color: var(--secondary);
  font-size: 11px;
  font-weight: 500;
  margin-top: 1px;
}

.nav-group {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--tertiary);
  padding: 10px 12px 6px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--label-2);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}

.nav-item:hover {
  background: var(--fill);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

.nav-item .count {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--fill);
  font-size: 11px;
  font-weight: 600;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 12px 10px 4px;
  border-top: 1px solid var(--separator);
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--indigo-dim);
  color: var(--indigo);
  font-size: 13px;
  font-weight: 700;
}

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-meta strong {
  font-size: 13px;
}

.user-meta span {
  color: var(--secondary);
  font-size: 11px;
}

.logout-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: auto;
  border-radius: 8px;
  color: var(--secondary);
}

.logout-btn:hover {
  background: var(--fill);
  color: var(--red);
}

.content {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 48px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fade 0.2s ease;
}

.admin-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.admin-header h1 {
  font-size: 28px;
  font-weight: 700;
}

.admin-header .sub {
  color: var(--secondary);
  font-size: 14px;
  margin-top: 4px;
}

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

.kpi-card {
  padding: 16px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi-card .kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 500;
}

.kpi-card .kpi-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--kpi-color, var(--accent));
  background: color-mix(in srgb, var(--kpi-color, var(--accent)) 13%, white);
}

.kpi-card .kpi-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

.kpi-card .kpi-delta {
  margin-top: 8px;
  color: var(--secondary);
  font-size: 12px;
}

.kpi-card .kpi-delta.up {
  color: var(--green);
}

.kpi-card .kpi-delta.down {
  color: var(--red);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.chart-card {
  grid-column: span 4;
  padding: 18px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.chart-card.wide {
  grid-column: span 8;
}

.chart-card h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}

.chart-card h3 .period {
  color: var(--secondary);
  font-size: 12px;
  font-weight: 500;
}

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 36px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-row .bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--fill);
  overflow: hidden;
}

.bar-row .bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--bar-color, var(--accent));
}

.bar-row .bar-num {
  color: var(--secondary);
  text-align: right;
  font-weight: 600;
}

.trend-chart {
  width: 100%;
  height: 150px;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
}

.donut {
  position: relative;
  width: 110px;
  height: 110px;
  flex: 0 0 110px;
  border-radius: 50%;
  background: conic-gradient(var(--orange) 0 18%, var(--accent) 18% 50%, var(--green) 50% 100%);
}

.donut::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: #fff;
}

.donut-center {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--label-2);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend-row .num {
  margin-left: auto;
  color: var(--secondary);
  font-weight: 600;
}

.panel {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--separator);
}

.panel-head h3 {
  font-size: 15px;
  font-weight: 600;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  padding: 10px 14px;
  color: var(--secondary);
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  background: #fbfbfd;
  border-bottom: 1px solid var(--separator);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--separator);
  vertical-align: middle;
}

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: #fafafa;
}

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

.table-primary {
  font-weight: 600;
  color: var(--accent);
}

.table-sub {
  display: block;
  color: var(--secondary);
  font-size: 12px;
  margin-top: 2px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.filter-bar .search-field {
  width: 280px;
  margin-bottom: 0;
  background: #fff;
  box-shadow: var(--shadow);
}

.select {
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--label-2);
  font-size: 13px;
  font-weight: 500;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  padding: 7px 13px;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--secondary);
  font-size: 13px;
  font-weight: 500;
}

.filter-chip.selected {
  background: var(--accent);
  color: #fff;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.detail-head .case-no {
  font-size: 22px;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  align-items: start;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  padding: 6px 18px;
}

.info-cell {
  padding: 12px 0;
  border-bottom: 1px solid var(--separator);
}

.info-cell:nth-child(odd) {
  border-right: 1px solid var(--separator);
  padding-right: 16px;
}

.info-cell:nth-child(even) {
  padding-left: 16px;
}

.info-cell .k {
  display: block;
  color: var(--secondary);
  font-size: 12px;
  margin-bottom: 4px;
}

.info-cell .v {
  font-size: 14px;
  font-weight: 500;
  word-break: break-word;
}

.status-steps {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 18px;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  color: var(--tertiary);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
}

.step .step-dot {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--fill);
}

.step.done {
  color: var(--green);
}

.step.done .step-dot {
  background: var(--green-dim);
}

.step.active .step-dot {
  background: var(--accent);
  color: #fff;
}

.step-line {
  height: 2px;
  flex: 1;
  margin-bottom: 20px;
  background: var(--separator);
}

.step-line.done {
  background: var(--green);
}

.detail-photos {
  display: flex;
  gap: 8px;
  padding: 0 18px 18px;
  overflow-x: auto;
}

.detail-photos .photo-thumb {
  width: 120px;
  height: 90px;
  flex-basis: 120px;
}

.timeline {
  padding: 4px 18px 18px;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  padding-bottom: 16px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 18px;
  bottom: -2px;
  width: 2px;
  background: var(--separator);
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--fill);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--separator);
}

.timeline-item.done .timeline-dot {
  background: var(--green);
}

.timeline-item.active .timeline-dot {
  background: var(--accent);
}

.timeline-item .t-text {
  font-size: 13px;
  font-weight: 500;
}

.timeline-item .t-time {
  color: var(--secondary);
  font-size: 12px;
  margin-top: 2px;
}

.note-box {
  padding: 16px 18px;
}

.note-box textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f5f5f7;
  font-size: 14px;
  line-height: 1.5;
}

.note-box .row-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.btn-small {
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.btn-ghost {
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--fill);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--secondary);
}

.empty-state .empty-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--tertiary);
}

@media (max-width: 960px) {
  .sidebar {
    width: 72px;
    flex-basis: 72px;
    padding: 16px 8px;
  }

  .brand {
    padding: 4px 6px 14px;
    justify-content: center;
  }

  .brand-name,
  .nav-group,
  .nav-item span,
  .nav-item .count,
  .user-meta {
    display: none;
  }

  .nav-item {
    justify-content: center;
  }

  .sidebar-user {
    justify-content: center;
    padding: 12px 0 4px;
  }

  .content {
    padding: 22px 18px 36px;
  }

  .chart-card {
    grid-column: span 12;
  }

  .chart-card.wide {
    grid-column: span 12;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .filter-bar .search-field {
    width: 100%;
  }

  .data-table {
    min-width: 760px;
  }

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

  .info-grid {
    grid-template-columns: 1fr;
  }

  .info-cell:nth-child(odd) {
    border-right: 0;
    padding-right: 0;
  }

  .info-cell:nth-child(even) {
    padding-left: 0;
  }
}
