:root {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --text: #111827;
  --muted: #667085;
  --line: #d7dde6;
  --teal: #0f766e;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b42318;
  --green: #15803d;
  --violet: #7c3aed;
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.phone-app {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(88px + env(safe-area-inset-bottom));
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 12px;
}

.eyebrow,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 19px;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
  line-height: 1.35;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 22px;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat-tile {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 10px;
}

.stat-tile strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
}

.stat-tile span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}

.search-panel {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.search-box,
.filter-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.search-box input,
.filter-grid select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 10px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.status-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.status-chips button {
  flex: 0 0 auto;
  min-height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
}

.status-chips button.active {
  border-color: var(--teal);
  background: #e6f4f1;
  color: #075e56;
}

.mobile-panel {
  display: none;
  padding-top: 14px;
}

.mobile-panel.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head button {
  min-height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
}

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

.case-card,
.district-card,
.point-card,
.doc-card {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  text-align: left;
  padding: 12px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  margin-top: 7px;
  font-size: 15px;
  line-height: 1.45;
}

.badge-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  background: #f9fafb;
  color: #344054;
  padding: 3px 7px;
  font-size: 12px;
}

.badge.done {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--green);
}

.badge.approved {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--blue);
}

.badge.meeting {
  border-color: #ddd6fe;
  background: #f5f3ff;
  color: var(--violet);
}

.badge.pending {
  border-color: #fed7aa;
  background: #fff7ed;
  color: var(--amber);
}

.money {
  color: var(--teal);
  font-weight: 700;
  white-space: nowrap;
}

.subline {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 8px;
}

.district-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.district-metrics span {
  border: 1px solid var(--line);
  padding: 8px;
  background: #fafafa;
  color: var(--muted);
  font-size: 11px;
}

.district-metrics strong {
  display: block;
  color: var(--text);
  font-size: 16px;
}

.point-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.point-actions a,
.point-actions button,
.drawer-actions a,
.drawer-actions button {
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  padding: 9px 10px;
}

.point-actions a {
  color: var(--blue);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
}

.bottom-nav button {
  min-height: 44px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.bottom-nav button.active {
  border-color: var(--teal);
  background: #e6f4f1;
  color: #075e56;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
}

.drawer.open {
  display: block;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.drawer-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  padding: 10px 14px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}

.drawer-handle {
  width: 42px;
  height: 4px;
  margin: 4px auto 12px;
  background: #d0d5dd;
}

.drawer-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.talking {
  margin: 12px 0;
  padding: 12px;
  border-left: 4px solid var(--teal);
  background: #f0fdfa;
  line-height: 1.55;
  font-size: 14px;
}

.drawer-fields {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 8px 10px;
  margin: 12px 0;
  font-size: 14px;
}

.drawer-fields dt {
  color: var(--muted);
}

.drawer-fields dd {
  margin: 0;
}

.point-stack {
  display: grid;
  gap: 8px;
}

.point-mini {
  border: 1px solid var(--line);
  padding: 10px;
  font-size: 13px;
  line-height: 1.45;
}

.drawer-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.drawer-actions > * {
  flex: 1;
  text-align: center;
}

.empty-state {
  border: 1px dashed var(--line);
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 760px) {
  .phone-app {
    padding-top: 22px;
  }

  .bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    width: min(100%, 720px);
  }
}


body.locked {
  min-height: 100vh;
}

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

.lock-box {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  background: #fff;
  padding: 18px;
  box-shadow: var(--shadow);
}

.lock-copy {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 10px 0 16px;
}

#unlockButton {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--teal);
  background: #e6f4f1;
  color: #075e56;
  margin-top: 12px;
}

#unlockButton:disabled {
  opacity: 0.62;
}

.lock-error {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
}
