:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #62716d;
  --line: #d8e1dd;
  --surface: #ffffff;
  --surface-soft: #eef5f2;
  --accent: #155e63;
  --accent-strong: #0f4549;
  --warn: #ad5c00;
  --done: #207047;
  --pause: #7c4d95;
  font-family: "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f6f8f7;
  color: var(--ink);
}

.is-hidden {
  display: none !important;
}

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

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0 18px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(rgba(21, 94, 99, 0.08), rgba(246, 248, 247, 0.95)),
    #f6f8f7;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 5vw, 2.4rem);
}

.icon-button,
.ghost-button,
.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 44px;
  cursor: pointer;
  text-decoration: none;
}

.icon-button {
  width: 46px;
  background: var(--surface);
  border-color: var(--line);
  color: var(--accent);
  font-size: 1.3rem;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.ghost-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
  padding: 0 14px;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.danger-button {
  background: #fff;
  border-color: #f1b4b4;
  color: #b42318;
  padding: 0 14px;
  font-weight: 700;
}

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

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 86px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.55rem;
}

.toolbar,
.project-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

.crm-layout {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.pipeline {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 12px;
}

.case-sidebar,
.detail-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.stage-heading,
.detail-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.stage-heading h2,
.detail-title h2,
.detail-title h3,
.area-heading h4 {
  margin: 0;
}

.stage-heading span {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

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

.case-card {
  width: 100%;
  display: grid;
  gap: 5px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
}

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

.stage-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent-strong) !important;
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 800;
}

.case-card.active {
  outline: 2px solid rgba(21, 94, 99, 0.22);
  background: var(--surface-soft);
}

.case-card span,
.case-card small,
.case-card em {
  color: var(--muted);
  font-style: normal;
}

.detail-panel {
  display: grid;
  gap: 12px;
}

.stage-history {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.stage-history summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 800;
}

.stage-history summary::marker {
  color: var(--accent);
}

.stage-history summary strong {
  font-size: 0.85rem;
  color: var(--muted);
}

.stage-history .detail-section {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

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

.info-grid div,
.planning-grid div,
.construction-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfc;
}

.info-grid span,
.planning-grid span,
.construction-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 5px;
}

.map-link {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}

.map-link strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.map-link-action {
  flex: 0 0 auto;
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.map-link:hover strong,
.map-link:focus-visible strong {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.note-block {
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
}

.timeline {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.timeline article {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 10px;
}

.timeline p {
  margin-bottom: 0;
  color: var(--muted);
}

.planning-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.planning-list h4 {
  margin: 0;
}

.planning-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.planning-item.completed {
  border-left-color: var(--done);
  background: #fbfcfc;
}

.planning-item p {
  margin: 4px 0 0;
}

.planning-item small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.planning-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.planning-list.archive {
  margin-top: 18px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.project-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(110px, 1fr));
  gap: 12px;
  align-items: center;
}

.project-title h2 {
  margin-bottom: 6px;
  font-size: 1.25rem;
}

.project-title p,
.task-meta,
.muted {
  color: var(--muted);
}

.schedule-meta {
  margin-top: 5px;
  color: var(--accent-strong);
  font-weight: 700;
}

.area-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 22px 0 10px;
}

.area-heading h3 {
  margin: 0;
  font-size: 1.1rem;
}

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

.task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  padding: 14px;
}

.task-card.done {
  border-left-color: var(--done);
}

.task-card.paused {
  border-left-color: var(--pause);
}

.task-card.waiting {
  border-left-color: var(--warn);
}

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

.task-title h4 {
  margin: 0;
  font-size: 1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  padding: 0 9px;
  font-size: 0.78rem;
  font-weight: 700;
}

.task-note {
  margin: 9px 0 0;
  color: var(--ink);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.photo-item {
  display: grid;
  gap: 6px;
  align-content: start;
}

.photo-thumb {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: left;
  text-decoration: none;
  font-size: 0.78rem;
}

.photo-thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.photo-thumb span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.photo-thumb small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.photo-delete-button {
  width: 100%;
  border: 1px solid rgba(185, 28, 45, 0.22);
  border-radius: 8px;
  padding: 5px 8px;
  background: rgba(185, 28, 45, 0.06);
  color: #b91c2d;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
}

.photo-delete-button:hover {
  background: rgba(185, 28, 45, 0.12);
}

.photo-lightbox {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  height: 100%;
  padding: 16px;
}

.photo-lightbox header,
.photo-lightbox footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.photo-lightbox h2,
.photo-lightbox p {
  margin: 0;
}

.photo-lightbox p,
.photo-lightbox footer {
  color: var(--muted);
  font-size: 0.9rem;
}

.photo-lightbox-body {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 12px;
  min-height: 0;
}

.photo-lightbox-body img {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 220px);
  object-fit: contain;
  border-radius: 8px;
  background: #111;
}

.photo-nav-button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.8rem;
  font-weight: 800;
}

.photo-nav-button:disabled {
  cursor: default;
  opacity: 0.35;
}

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

.photo-source-card {
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 14px;
  border: 1px solid rgba(179, 25, 42, 0.16);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.photo-source-card strong {
  font-size: 0.96rem;
}

.photo-source-card small,
.field .upload-selection {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.45;
}

.photo-source-card input {
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  font-size: 0.82rem;
}

.photo-upload-summary {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  max-height: 210px;
  margin-top: 10px;
  overflow: auto;
}

.photo-upload-preview {
  position: relative;
  aspect-ratio: 1;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f3f5f4;
}

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

.photo-upload-preview figcaption {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: rgba(22, 30, 33, 0.72);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

.photo-upload-progress {
  display: grid;
  gap: 7px;
}

.photo-upload-progress > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.photo-upload-progress > span {
  display: block;
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e7e9e7;
}

.photo-upload-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

@media (max-width: 600px) {
  .photo-preview-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-height: 190px;
  }
}

.progress-stack {
  display: grid;
  align-content: center;
  gap: 8px;
}

.progress-number {
  text-align: right;
  font-size: 1.3rem;
  font-weight: 800;
}

.progress-bar {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #e3ebe8;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

dialog {
  width: min(560px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

dialog:has(.schedule-panel) {
  width: calc(100vw - 24px);
  max-width: none;
  height: calc(100vh - 24px);
  max-height: none;
}

dialog:has(.admin-panel) {
  width: min(1180px, calc(100vw - 32px));
  max-width: none;
  height: min(820px, calc(100vh - 32px));
  max-height: none;
}

dialog:has(.leave-panel) {
  width: min(1180px, calc(100vw - 32px));
  max-width: none;
  height: min(760px, calc(100vh - 32px));
  max-height: none;
}

dialog:has(.photo-lightbox) {
  width: min(1120px, calc(100vw - 24px));
  max-width: none;
  height: min(820px, calc(100vh - 24px));
  max-height: none;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialog-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-form header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.dialog-form h2 {
  margin: 0;
  font-size: 1.2rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.admin-panel {
  width: 100%;
  height: 100%;
  max-height: none;
  overflow: auto;
  align-content: start;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.admin-panel > header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 12px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.admin-panel section {
  min-width: 0;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.admin-tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 9px 14px;
  font-weight: 800;
  cursor: pointer;
}

.admin-tab.active {
  border-color: rgba(179, 25, 42, 0.28);
  background: #fff0f2;
  color: var(--accent-strong);
}

.admin-section {
  display: none;
}

.admin-section.active {
  display: grid;
  gap: 14px;
}

.schedule-panel {
  width: 100%;
  height: 100%;
  max-height: none;
  overflow: auto;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.leave-panel {
  width: 100%;
  height: 100%;
  overflow: auto;
  align-content: start;
}

.leave-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.7fr) minmax(420px, 1.3fr);
  gap: 18px;
  min-height: 0;
}

.leave-form,
.leave-list-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.leave-panel-head,
.leave-month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.leave-view-tabs {
  display: flex;
  gap: 8px;
}

.leave-list {
  overflow: auto;
}

.leave-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.leave-table th,
.leave-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.danger-link {
  border: 0;
  background: transparent;
  color: #dc2626;
  font-weight: 800;
  cursor: pointer;
}

.leave-calendar-wrap {
  display: grid;
  gap: 12px;
}

.leave-date {
  background: #eaf5ff;
}

.leave-chip {
  display: grid;
  gap: 3px;
  margin-bottom: 6px;
  padding: 7px 8px;
  border-radius: 6px;
  background: #4f91e8;
  color: #fff;
  font-size: 0.82rem;
}

.leave-chip small {
  color: rgba(255, 255, 255, 0.86);
}

.schedule-calendar {
  min-height: 0;
  overflow: auto;
}

.schedule-toolbar {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
}

.conflict-box {
  border: 1px solid #f0c36a;
  border-radius: 8px;
  background: #fff7e6;
  padding: 12px;
}

.conflict-box.ok {
  border-color: var(--line);
  background: var(--surface-soft);
}

.conflict-box p {
  margin: 6px 0 0;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
  text-align: center;
}

.calendar-weekdays span {
  padding: 6px 0;
}

.calendar-grid {
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.calendar-cell {
  min-height: 168px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 8px;
}

.calendar-cell.blank {
  background: #f4f7f6;
}

.calendar-date {
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.schedule-chip {
  display: grid;
  gap: 5px;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 9px;
  margin-bottom: 8px;
  font-size: 0.95rem;
  line-height: 1.35;
}

.schedule-chip strong {
  font-size: 1rem;
}

.schedule-chip span,
.schedule-chip small {
  font-size: 0.92rem;
}

.schedule-chip.conflict {
  border-left-color: var(--warn);
  background: #fff3df;
}

.schedule-chip.status-temporary {
  border-left-color: #d97706;
  background: #fff3df;
}

.schedule-chip.status-vendor {
  border-left-color: #2563eb;
  background: #eaf2ff;
}

.schedule-chip.status-done {
  border-left-color: #16935f;
  background: #edf9f1;
}

.schedule-chip span,
.schedule-chip small {
  color: var(--muted);
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.admin-panel .announcement-form {
  grid-template-columns: 160px minmax(240px, 360px) auto;
}

.admin-panel .announcement-content-field {
  grid-column: 1 / -1;
}

.admin-panel .announcement-form textarea {
  min-height: 220px;
  padding: 16px;
  font-size: 1.05rem;
  line-height: 1.75;
  resize: vertical;
}

.user-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding-right: 4px;
}

.activity-log-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.activity-log-row {
  display: grid;
  grid-template-columns: 120px 120px 150px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.activity-log-row time,
.activity-log-row small {
  color: var(--muted);
}

.activity-log-row small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.user-row p {
  margin-bottom: 0;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(90px);
  transition: transform 0.2s ease;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  max-width: min(360px, calc(100vw - 36px));
}

.toast.show {
  transform: translateY(0);
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

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

  .crm-layout,
  .schedule-toolbar,
  .toolbar,
  .task-card,
  .planning-item,
  .admin-form {
    grid-template-columns: 1fr;
  }

  dialog:has(.admin-panel) {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
  }

  dialog:has(.leave-panel) {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
  }

  dialog:has(.photo-lightbox) {
    width: calc(100vw - 12px);
    height: calc(100vh - 12px);
  }

  .photo-lightbox-body {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    gap: 8px;
  }

  .photo-nav-button {
    width: 40px;
    height: 60px;
  }

  .admin-panel .announcement-form {
    grid-template-columns: 1fr;
  }

  .leave-layout {
    grid-template-columns: 1fr;
  }

  .leave-panel-head,
  .leave-month-nav {
    align-items: stretch;
    flex-direction: column;
  }

  .leave-view-tabs {
    width: 100%;
  }

  .leave-view-tabs .admin-tab {
    flex: 1;
  }

  .admin-tabs {
    flex-direction: column;
  }

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

  .detail-panel {
    position: static;
  }

  .pipeline {
    position: static;
  }

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

  .top-actions {
    width: 100%;
  }

  .top-actions .secondary-button {
    flex: 1;
  }

  .user-row {
    align-items: stretch;
    flex-direction: column;
  }

  .user-actions {
    justify-content: stretch;
  }

  .user-actions .secondary-button {
    flex: 1;
  }

  .progress-number {
    text-align: left;
  }

  .schedule-panel {
    width: 100%;
    height: 100%;
    max-height: none;
  }

  .calendar-weekdays {
    display: none;
  }

  .calendar-grid {
    display: grid;
    grid-template-columns: 1fr;
    border: 0;
    gap: 8px;
  }

  .calendar-cell {
    min-height: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .calendar-date {
    font-size: 1.12rem;
  }

  .schedule-chip {
    font-size: 1rem;
  }

  .calendar-cell.blank {
    display: none;
  }
}

@media (max-width: 520px) {
  .summary-band,
  .project-grid,
  .info-grid,
  .planning-grid,
  .construction-summary,
  .two-col {
    grid-template-columns: 1fr;
  }

  .area-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .area-heading .secondary-button {
    width: 100%;
  }
}

/* Premium C theme: dark design-studio command center. */
:root {
  color-scheme: dark;
  --ink: #f3eee5;
  --muted: #a79f91;
  --line: rgba(217, 196, 151, 0.18);
  --surface: #211f1b;
  --surface-soft: #2a2721;
  --accent: #c6a15b;
  --accent-strong: #e1c27d;
  --warn: #d59a43;
  --done: #68b689;
  --pause: #b889c8;
  --danger: #e06c6c;
  --shadow-soft: 0 24px 80px rgba(0, 0, 0, 0.34);
  --shadow-panel: 0 14px 44px rgba(0, 0, 0, 0.24);
  --panel-glow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

body {
  background:
    radial-gradient(circle at 78% 0%, rgba(198, 161, 91, 0.12), transparent 32rem),
    linear-gradient(135deg, #13120f 0%, #191714 42%, #242019 100%);
  color: var(--ink);
}

.app-shell {
  max-width: 1440px;
  padding: 24px;
}

.topbar {
  min-height: 88px;
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(28, 26, 22, 0.72);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(18px);
}

.topbar h1 {
  color: #fff7e7;
  font-size: clamp(1.5rem, 2.3vw, 2.25rem);
  font-weight: 650;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 800;
}

.top-actions {
  gap: 10px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.danger-button {
  border-radius: 8px;
  min-height: 42px;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.primary-button {
  background: linear-gradient(135deg, #c6a15b, #8b6b35);
  border-color: rgba(255, 230, 170, 0.2);
  color: #171512;
  box-shadow: 0 10px 26px rgba(198, 161, 91, 0.22);
}

.primary-button:hover {
  background: linear-gradient(135deg, #e1c27d, #a67d3f);
}

.secondary-button,
.ghost-button,
.icon-button {
  background: rgba(255, 255, 255, 0.045);
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(225, 194, 125, 0.42);
  background: rgba(225, 194, 125, 0.1);
}

.danger-button {
  background: rgba(224, 108, 108, 0.1);
  border-color: rgba(224, 108, 108, 0.34);
  color: #ff9a9a;
}

.login-view {
  background:
    radial-gradient(circle at 50% 0%, rgba(198, 161, 91, 0.18), transparent 30rem),
    linear-gradient(135deg, #12110f, #242019);
}

.login-panel {
  background: rgba(33, 31, 27, 0.88);
  border-color: var(--line);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px);
}

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

.metric,
.toolbar,
.case-sidebar,
.detail-section,
.stage-history,
.project-panel,
.user-row,
dialog {
  background: rgba(33, 31, 27, 0.82);
  border-color: var(--line);
  box-shadow: var(--shadow-panel), var(--panel-glow);
  backdrop-filter: blur(18px);
}

.metric {
  min-height: 98px;
  padding: 16px;
}

.metric span,
.field span,
.case-card span,
.case-card small,
.case-card em,
.project-title p,
.task-meta,
.muted,
.schedule-chip span,
.schedule-chip small,
.calendar-date,
.calendar-weekdays,
.timeline p,
.planning-item small {
  color: var(--muted);
}

.metric strong {
  color: #fff7e7;
  font-size: 1.8rem;
  font-weight: 720;
}

.toolbar {
  margin-bottom: 16px;
  padding: 16px;
}

.crm-layout {
  grid-template-columns: minmax(340px, 410px) minmax(0, 1fr);
  gap: 16px;
}

.pipeline {
  top: 16px;
}

.case-sidebar,
.detail-section {
  padding: 16px;
}

.stage-heading,
.detail-title {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.stage-heading h2,
.detail-title h2,
.detail-title h3,
.area-heading h3,
.area-heading h4 {
  color: #fff7e7;
  font-weight: 680;
}

.stage-heading span,
.stage-pill,
.badge {
  background: rgba(198, 161, 91, 0.13);
  border: 1px solid rgba(198, 161, 91, 0.22);
  color: var(--accent-strong) !important;
}

.case-list {
  gap: 10px;
}

.case-card {
  position: relative;
  gap: 7px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(217, 196, 151, 0.14);
  border-left: 0;
  color: var(--ink);
  padding: 14px;
}

.case-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent-strong), rgba(198, 161, 91, 0.18));
}

.case-card:hover,
.case-card.active {
  background: rgba(198, 161, 91, 0.105);
  border-color: rgba(225, 194, 125, 0.36);
  outline: none;
}

.case-card strong,
.task-title h4,
.planning-item strong {
  color: #fff7e7;
}

.info-grid div,
.planning-grid div,
.construction-summary div,
.planning-item,
.task-card,
.calendar-cell,
.photo-thumb img {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(217, 196, 151, 0.14);
}

.info-grid div,
.planning-grid div,
.construction-summary div {
  padding: 12px;
}

.note-block,
.planning-item.completed,
.conflict-box.ok {
  background: rgba(104, 182, 137, 0.08);
}

.timeline article,
.planning-item,
.task-card,
.schedule-chip {
  border-left-color: var(--accent);
}

.planning-item {
  border-left-width: 3px;
}

.planning-item.completed,
.task-card.done {
  border-left-color: var(--done);
}

.task-card.paused {
  border-left-color: var(--pause);
}

.task-card.waiting,
.schedule-chip.conflict {
  border-left-color: var(--warn);
}

.task-card.vendor {
  border-left-color: #2563eb;
}

.task-card {
  border-left-width: 3px;
  box-shadow: none;
}

.task-note {
  color: #e7dcc8;
}

.progress-bar {
  background: rgba(255, 255, 255, 0.08);
}

.progress-bar span {
  background: linear-gradient(90deg, var(--accent), var(--done));
}

input,
select,
textarea {
  background: rgba(18, 17, 15, 0.68);
  border-color: rgba(217, 196, 151, 0.2);
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(198, 161, 91, 0.28);
  border-color: rgba(225, 194, 125, 0.46);
}

input::placeholder,
textarea::placeholder {
  color: rgba(167, 159, 145, 0.78);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
}

.schedule-panel,
.admin-panel,
.dialog-form {
  background: transparent;
}

.conflict-box {
  background: rgba(213, 154, 67, 0.1);
  border-color: rgba(213, 154, 67, 0.32);
}

.calendar-grid {
  border-color: var(--line);
}

.calendar-cell.blank {
  background: rgba(255, 255, 255, 0.018);
}

.schedule-chip {
  background: rgba(198, 161, 91, 0.1);
}

.schedule-chip.conflict {
  background: rgba(213, 154, 67, 0.14);
}

.toast {
  background: #fff7e7;
  color: #171512;
  box-shadow: var(--shadow-panel);
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .toolbar,
  .case-sidebar,
  .detail-section {
    padding: 14px;
  }

  .crm-layout {
    grid-template-columns: 1fr;
  }
}

/* White ARDesign theme: bright studio UI with logo-red accents. */
:root {
  color-scheme: light;
  --ink: #201c1d;
  --muted: #746d6f;
  --line: #e8e2df;
  --surface: #ffffff;
  --surface-soft: #f8f6f4;
  --accent: #b3192a;
  --accent-strong: #8f1020;
  --warn: #bd6a12;
  --done: #1f8055;
  --pause: #7c4d95;
  --danger: #b3192a;
  --shadow-soft: 0 22px 70px rgba(56, 42, 42, 0.08);
  --shadow-panel: 0 12px 34px rgba(56, 42, 42, 0.07);
  --panel-glow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

body {
  background:
    linear-gradient(135deg, rgba(179, 25, 42, 0.045), transparent 28rem),
    linear-gradient(180deg, #ffffff 0%, #f7f4f2 100%);
  color: var(--ink);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: clamp(150px, 17vw, 240px);
  height: 44px;
  object-fit: contain;
  object-position: left center;
  mix-blend-mode: multiply;
}

.login-logo {
  width: min(260px, 78vw);
  height: 64px;
  margin-bottom: 6px;
}

.app-shell {
  max-width: 1440px;
  padding: 24px;
}

.topbar {
  min-height: 92px;
  margin-bottom: 14px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(18px);
}

.topbar h1 {
  color: var(--ink);
  font-size: clamp(1.25rem, 2vw, 1.95rem);
  font-weight: 680;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
}

.primary-button {
  background: linear-gradient(135deg, #bd1e31, #8f1020);
  border-color: #a91526;
  color: #fff;
  box-shadow: 0 12px 26px rgba(179, 25, 42, 0.18);
}

.primary-button:hover {
  background: linear-gradient(135deg, #cf263b, #9d1425);
}

.secondary-button,
.ghost-button,
.icon-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(179, 25, 42, 0.34);
  background: #fff5f6;
  color: var(--accent-strong);
}

.danger-button {
  background: #fff;
  border-color: rgba(179, 25, 42, 0.26);
  color: var(--accent);
}

.login-view {
  background:
    linear-gradient(135deg, rgba(179, 25, 42, 0.07), transparent 30rem),
    linear-gradient(180deg, #ffffff, #f7f4f2);
}

.login-panel {
  background: rgba(255, 255, 255, 0.92);
  border-color: var(--line);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.announcement-form {
  display: grid;
  gap: 12px;
}

.announcement-panel {
  width: min(560px, calc(100vw - 28px));
}

.announcement-content {
  margin: 0;
  color: var(--ink);
  line-height: 1.75;
  white-space: pre-wrap;
}

.login-reminder-section {
  display: grid;
  gap: 8px;
}

.login-reminder-section + .login-reminder-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.login-reminder-section h3 {
  margin: 0;
  color: var(--accent-strong);
}

.login-reminder-section p {
  margin: 0;
}

.login-reminder-section ul {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.login-reminder-section li {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.login-reminder-section li span {
  color: var(--muted);
}

.metric,
.toolbar,
.case-sidebar,
.detail-section,
.stage-history,
.project-panel,
.user-row,
dialog {
  background: rgba(255, 255, 255, 0.92);
  border-color: var(--line);
  box-shadow: var(--shadow-panel), var(--panel-glow);
  backdrop-filter: blur(16px);
}

.metric strong,
.stage-heading h2,
.detail-title h2,
.detail-title h3,
.area-heading h3,
.area-heading h4,
.case-card strong,
.task-title h4,
.planning-item strong {
  color: var(--ink);
}

.metric span,
.field span,
.case-card span,
.case-card small,
.case-card em,
.project-title p,
.task-meta,
.muted,
.schedule-chip span,
.schedule-chip small,
.calendar-date,
.calendar-weekdays,
.timeline p,
.planning-item small {
  color: var(--muted);
}

.stage-heading,
.detail-title {
  border-bottom-color: var(--line);
}

.stage-heading span,
.stage-pill,
.badge {
  background: #fff0f2;
  border: 1px solid rgba(179, 25, 42, 0.16);
  color: var(--accent-strong) !important;
}

.case-card,
.info-grid div,
.planning-grid div,
.construction-summary div,
.planning-item,
.task-card,
.calendar-cell,
.photo-thumb img {
  background: #fff;
  border-color: var(--line);
}

.case-card {
  border-left: 0;
  box-shadow: 0 8px 22px rgba(56, 42, 42, 0.045);
}

.case-card::before {
  background: linear-gradient(180deg, var(--accent), rgba(179, 25, 42, 0.16));
}

.case-card-design::before {
  background: linear-gradient(180deg, #d69b54, rgba(214, 155, 84, 0.28));
}

.case-card-construction::before {
  background: linear-gradient(180deg, #4f8fc9, rgba(79, 143, 201, 0.26));
}

.case-card-closed::before {
  background: linear-gradient(180deg, #58a66c, rgba(88, 166, 108, 0.26));
}

.case-card:hover,
.case-card.active {
  background: #fff7f8;
  border-color: rgba(179, 25, 42, 0.28);
  outline: none;
}

.note-block {
  background: #f8f6f4;
  color: var(--ink);
}

.planning-item.completed,
.conflict-box.ok {
  background: #f3faf6;
}

.timeline article,
.planning-item,
.task-card,
.schedule-chip {
  border-left-color: var(--accent);
}

.task-note {
  color: var(--ink);
}

.progress-bar {
  background: #eee8e5;
}

.progress-bar span {
  background: linear-gradient(90deg, var(--accent), #d34a59);
}

input,
select,
textarea {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(179, 25, 42, 0.16);
  border-color: rgba(179, 25, 42, 0.38);
}

input::placeholder,
textarea::placeholder {
  color: #aaa0a1;
}

dialog::backdrop {
  background: rgba(32, 28, 29, 0.26);
  backdrop-filter: blur(8px);
}

.conflict-box {
  background: #fff8ee;
  border-color: rgba(189, 106, 18, 0.28);
}

.calendar-grid {
  border-color: var(--line);
}

.calendar-cell.blank {
  background: #faf8f7;
}

.schedule-chip {
  background: #fff5f6;
}

.schedule-chip.conflict {
  background: #fff2df;
}

.schedule-chip.status-temporary {
  border-left-color: #d97706;
  background: #fff3df;
}

.schedule-chip.status-vendor {
  border-left-color: #2563eb;
  background: #eaf2ff;
}

.schedule-chip.status-done {
  border-left-color: #16935f;
  background: #edf9f1;
}

.toast {
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-panel);
}

@media (max-width: 760px) {
  .brand-block {
    width: 100%;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .brand-logo {
    width: min(210px, 70vw);
  }
}

/* Case filtering and fixed-detail browsing layout. */
.toolbar {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.stage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.stage-tabs,
.person-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.stage-tab,
.person-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
  font-weight: 700;
}

.stage-tab {
  border-bottom: 3px solid transparent;
}

.stage-tab strong,
.person-tab strong {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.78rem;
}

.stage-tab:hover,
.stage-tab.active,
.person-tab:hover,
.person-tab.active {
  border-color: rgba(179, 25, 42, 0.34);
  background: #fff5f6;
  color: var(--accent-strong);
}

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

.stage-tab.active strong,
.person-tab.active strong {
  background: var(--accent);
  color: #fff;
}

.pipeline {
  align-self: start;
}

.case-sidebar {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 210px);
  max-height: 720px;
  min-height: 520px;
}

.case-sidebar .stage-heading {
  flex: 0 0 auto;
}

.case-list {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-gutter: stable;
}

.case-group {
  display: grid;
  gap: 10px;
  border-radius: 8px;
  padding: 10px;
  border: 1px solid var(--line);
}

.case-group-design {
  background: #fff8f0;
}

.case-group-construction {
  background: #f2f8ff;
}

.case-group-closed {
  background: #f4faf5;
}

.case-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 6px;
}

.case-group-heading strong {
  color: var(--ink);
  font-size: 0.92rem;
}

.case-group-heading span {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.case-card {
  flex: 0 0 auto;
  min-height: 108px;
  padding: 14px 16px;
}

.case-card-top {
  align-items: flex-start;
}

.case-card strong {
  line-height: 1.35;
}

.mobile-back-button {
  display: none;
  margin-bottom: 12px;
}

.mobile-inline-detail {
  display: none;
}

@media (max-width: 980px) {
  .toolbar {
    grid-template-columns: 1fr;
  }

  .stage-row {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  .crm-layout {
    gap: 12px;
  }

  .pipeline,
  .detail-panel {
    width: 100%;
  }

  .detail-panel {
    display: none;
  }

  .case-sidebar {
    height: auto;
    max-height: none;
    min-height: 0;
  }

  .case-list {
    overflow: visible;
    padding-right: 0;
  }

  .mobile-back-button {
    display: none;
    width: 100%;
    justify-content: center;
  }

  .mobile-inline-detail {
    display: grid;
    gap: 12px;
    margin: -2px 0 14px;
    padding: 14px;
    border: 1px solid rgba(179, 25, 42, 0.14);
    border-radius: 8px;
    background: linear-gradient(180deg, #fff7f8 0%, #fbf7f5 100%);
  }

  .mobile-inline-detail .detail-section,
  .mobile-inline-detail .stage-history {
    background: #fff;
    box-shadow: none;
  }

  .photo-source-grid {
    grid-template-columns: 1fr;
  }

  .photo-source-card {
    min-height: 92px;
  }
}

.quantum-bg,
.quantum-fg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.quantum-bg {
  z-index: 0;
  background:
    linear-gradient(135deg, rgba(179, 25, 42, 0.045), transparent 34rem),
    linear-gradient(180deg, #ffffff 0%, #f8f5f3 100%);
}

.quantum-fg {
  z-index: 3;
}

body {
  background: #ffffff;
}

.login-view,
.app-shell {
  position: relative;
  z-index: 1;
}

.login-view {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.56), rgba(248, 245, 243, 0.76)),
    transparent;
}

.app-shell {
  background: transparent;
}

.topbar,
.toolbar,
.case-sidebar,
.detail-section,
.stage-history,
.project-panel,
.metric,
.user-row,
dialog {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
}

@media (max-width: 760px) {
  .quantum-bg,
  .quantum-fg {
    opacity: 0.72;
  }
}

.calendar-cell.past-date {
  background: #ececec;
  color: #7a7a7a;
}

.calendar-cell.past-date .calendar-date {
  color: #8a8a8a;
}

.calendar-cell.leave-date {
  background: #eaf5ff;
}

.calendar-cell.leave-date .calendar-date {
  color: #1d4f91;
}

dialog:has(.announcement-panel) {
  width: min(1120px, calc(100vw - 32px));
  max-width: none;
}

.announcement-panel {
  width: 100%;
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
}

.announcement-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  white-space: normal;
}

.login-reminder-section {
  align-content: start;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.login-reminder-section + .login-reminder-section {
  margin-top: 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.login-reminder-section p {
  white-space: pre-wrap;
}

.login-reminder-section ul {
  max-height: 460px;
}

@media (max-width: 760px) {
  dialog:has(.announcement-panel) {
    width: calc(100vw - 16px);
  }

  .announcement-content {
    grid-template-columns: 1fr;
  }
}

/* Compact mobile field view: keep the case list and inline dashboard easy to scan. */
@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    gap: 10px;
    padding: 12px;
  }

  .brand-block {
    gap: 8px;
  }

  .brand-logo {
    width: min(168px, 54vw);
  }

  .brand-block .eyebrow {
    margin-bottom: 2px;
    font-size: 0.68rem;
  }

  .brand-block h1 {
    font-size: 1.05rem;
  }

  .top-actions {
    display: flex;
    width: 100%;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .top-actions::-webkit-scrollbar {
    display: none;
  }

  .top-actions .secondary-button,
  .top-actions .icon-button {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 10px;
    font-size: 0.78rem;
  }

  .top-actions .icon-button {
    width: 38px;
    padding: 0;
    font-size: 1.1rem;
  }

  .summary-band {
    gap: 8px;
    padding: 10px;
  }

  .metric {
    min-height: 68px;
    padding: 10px;
  }

  .metric strong {
    font-size: 1.25rem;
  }

  .toolbar {
    gap: 8px;
    padding: 10px;
  }

  .person-tabs,
  .stage-tabs {
    flex-wrap: nowrap;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .person-tabs::-webkit-scrollbar,
  .stage-tabs::-webkit-scrollbar {
    display: none;
  }

  .stage-row {
    gap: 8px;
  }

  .stage-tab,
  .person-tab {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 9px;
    gap: 6px;
    font-size: 0.78rem;
  }

  .stage-tab strong,
  .person-tab strong {
    min-width: 20px;
    height: 20px;
    font-size: 0.68rem;
  }

  #newCaseBtn {
    min-height: 40px;
    font-size: 0.84rem;
  }

  .case-sidebar {
    padding: 10px;
  }

  .case-sidebar .stage-heading {
    margin-bottom: 8px;
  }

  .stage-heading h2 {
    font-size: 1rem;
  }

  .stage-heading span {
    min-width: 26px;
    height: 26px;
    font-size: 0.72rem;
  }

  .case-list {
    gap: 9px;
  }

  .case-group {
    gap: 7px;
    padding: 8px;
  }

  .case-group-heading {
    padding: 0 1px 3px;
  }

  .case-group-heading strong {
    font-size: 0.82rem;
  }

  .case-group-heading span {
    min-width: 22px;
    height: 22px;
    font-size: 0.7rem;
  }

  .case-card {
    min-height: 0;
    gap: 3px;
    padding: 10px 12px;
  }

  .case-card strong {
    font-size: 0.91rem;
    line-height: 1.25;
  }

  .case-card small,
  .case-card span {
    font-size: 0.74rem;
    line-height: 1.3;
  }

  .case-card em {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 0.74rem;
    line-height: 1.32;
  }

  .mobile-inline-detail {
    gap: 8px;
    margin: 0 0 10px;
    padding: 10px;
  }

  .mobile-inline-detail .detail-section,
  .mobile-inline-detail .stage-history {
    padding: 10px;
  }

  .mobile-inline-detail .stage-history .detail-section {
    padding: 10px;
  }

  .mobile-inline-detail .detail-title,
  .mobile-inline-detail .stage-heading,
  .mobile-inline-detail .area-heading {
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 8px;
  }

  .mobile-inline-detail .detail-title h2 {
    font-size: 1rem;
    line-height: 1.25;
  }

  .mobile-inline-detail .detail-title h3,
  .mobile-inline-detail .area-heading h3,
  .mobile-inline-detail .area-heading h4 {
    font-size: 0.9rem;
  }

  .mobile-inline-detail .detail-section > p,
  .mobile-inline-detail .task-meta,
  .mobile-inline-detail .task-note,
  .mobile-inline-detail .planning-item p {
    font-size: 0.78rem;
    line-height: 1.45;
  }

  .mobile-inline-detail .info-grid,
  .mobile-inline-detail .planning-grid,
  .mobile-inline-detail .construction-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .mobile-inline-detail .info-grid div,
  .mobile-inline-detail .planning-grid div,
  .mobile-inline-detail .construction-summary div {
    padding: 8px;
  }

  .mobile-inline-detail .info-grid span,
  .mobile-inline-detail .planning-grid span,
  .mobile-inline-detail .construction-summary span {
    margin-bottom: 3px;
    font-size: 0.66rem;
  }

  .mobile-inline-detail .info-grid strong,
  .mobile-inline-detail .planning-grid strong,
  .mobile-inline-detail .construction-summary strong {
    font-size: 0.78rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .mobile-inline-detail .planning-item,
  .mobile-inline-detail .task-card {
    gap: 8px;
    padding: 10px;
  }

  .mobile-inline-detail .task-title h4,
  .mobile-inline-detail .planning-item strong {
    font-size: 0.86rem;
  }

  .mobile-inline-detail .secondary-button,
  .mobile-inline-detail .ghost-button,
  .mobile-inline-detail .danger-button {
    min-height: 38px;
    padding: 0 10px;
    font-size: 0.76rem;
  }

  .mobile-inline-detail .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 6px;
  }

  .mobile-inline-detail .photo-thumb small,
  .mobile-inline-detail .photo-thumb span {
    font-size: 0.66rem;
  }
}

@media (max-width: 380px) {
  .mobile-inline-detail .info-grid,
  .mobile-inline-detail .planning-grid,
  .mobile-inline-detail .construction-summary {
    grid-template-columns: 1fr;
  }
}

.task-photo-section {
  margin-top: 10px;
}

.task-photo-toggle {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(179, 25, 42, 0.035);
  color: var(--ink);
  text-align: left;
}

.task-photo-toggle:hover {
  border-color: rgba(179, 25, 42, 0.3);
  background: #fff5f6;
}

.task-photo-toggle span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 700;
}

.task-photo-toggle strong {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 999px;
  background: rgba(179, 25, 42, 0.1);
  color: var(--accent-strong);
  font-size: 0.68rem;
}

.task-photo-toggle small {
  color: var(--muted);
  font-size: 0.74rem;
}

@media (max-width: 760px) {
  .mobile-inline-detail .task-photo-section {
    margin-top: 8px;
  }

  .mobile-inline-detail .task-photo-toggle {
    min-height: 36px;
    padding: 0 9px;
  }

  .mobile-inline-detail .task-photo-toggle span {
    font-size: 0.76rem;
  }
}

/* Construction items stay compact until the user opens the item. */
.task-card {
  grid-template-columns: minmax(0, 1fr) auto;
  cursor: pointer;
  border-left-width: 1px !important;
  border-left-color: var(--line) !important;
}

.task-card .progress-stack {
  display: flex;
  min-width: 62px;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 7px;
}

.task-card .progress-number {
  color: var(--accent-strong);
  font-size: 1.05rem;
  line-height: 1.1;
}

.task-card .progress-bar {
  display: none;
}

.task-card .progress-stack::after {
  content: "⌄";
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1;
  transition: transform 160ms ease;
}

.task-card.expanded .progress-stack::after {
  transform: rotate(180deg);
}

.task-card .progress-stack .secondary-button {
  display: none;
  min-height: 36px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.task-card.expanded .progress-stack .secondary-button {
  display: inline-flex;
}

.task-card:not(.expanded) .task-note,
.task-card:not(.expanded) .task-photo-section {
  display: none;
}

@media (max-width: 760px) {
  .mobile-inline-detail .task-card {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .mobile-inline-detail .task-card .progress-stack {
    min-width: 54px;
    gap: 6px;
  }

  .mobile-inline-detail .task-card .progress-number {
    font-size: 0.96rem;
  }

  .mobile-inline-detail .task-card .progress-stack .secondary-button {
    min-height: 34px;
    padding: 0 8px;
    font-size: 0.7rem;
  }
}

/* Three concise stage metrics and two-line task summaries. */
.summary-band {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.task-card:not(.expanded) .task-title {
  flex-wrap: nowrap;
  gap: 6px;
  margin-bottom: 4px;
}

.task-card:not(.expanded) .task-title h4 {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-card:not(.expanded) .task-title .badge:nth-of-type(2) {
  display: none;
}

.task-card:not(.expanded) .task-meta:not(.schedule-meta) {
  display: none;
}

.task-card:not(.expanded) .schedule-meta {
  margin-top: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .summary-band {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .metric {
    min-height: 60px;
    padding: 8px;
  }

  .metric span {
    min-height: 1.9em;
    font-size: 0.68rem;
    line-height: 1.28;
  }

  .metric strong {
    margin-top: 2px;
    font-size: 1.12rem;
  }

  .mobile-inline-detail .task-card:not(.expanded) {
    gap: 4px;
    padding: 9px 10px;
  }

  .mobile-inline-detail .task-card:not(.expanded) .task-title h4 {
    font-size: 0.82rem;
  }

  .mobile-inline-detail .task-card:not(.expanded) .badge {
    padding: 3px 6px;
    font-size: 0.64rem;
  }

  .mobile-inline-detail .task-card:not(.expanded) .schedule-meta {
    font-size: 0.7rem;
  }
}

/* Expanded tasks use the full panel width so construction photos stay in a grid. */
.task-card.expanded {
  grid-template-columns: minmax(0, 1fr);
}

.task-card.expanded .progress-stack {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
}

.task-card.expanded .progress-stack::after {
  order: -1;
}

.task-card.expanded .task-photo-section {
  margin-top: 14px;
}

.task-card.expanded .photo-grid {
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}

@media (max-width: 760px) {
  .mobile-inline-detail .task-card.expanded {
    grid-template-columns: minmax(0, 1fr);
  }

  .mobile-inline-detail .task-card.expanded .progress-stack {
    gap: 7px;
  }

  .mobile-inline-detail .task-card.expanded .photo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-inline-detail .task-card.expanded .photo-thumb img {
    aspect-ratio: 1;
  }
}
