/* Phase 4 - Offline SmartDispatch App Styles */

:root {
  --primary: #667eea;
  --primary-dark: #764ba2;
  --primary-soft: rgba(102, 126, 234, 0.12);
  --accent: #20c997;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #16a34a;
  --info: #2563eb;
  --bg: #f5f7ff;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --text: #20233a;
  --muted: #697089;
  --line: rgba(118, 75, 162, 0.16);
  --line-strong: rgba(102, 126, 234, 0.26);
  --shadow: 0 20px 52px rgba(31, 38, 135, 0.13), 0 8px 22px rgba(17, 24, 39, 0.06);
  --shadow-soft: 0 10px 28px rgba(102, 126, 234, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --nav-height: 74px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 16% 8%, rgba(102, 126, 234, 0.22), transparent 32%),
    radial-gradient(circle at 88% 2%, rgba(118, 75, 162, 0.18), transparent 30%),
    linear-gradient(135deg, #f9fbff 0%, #eef1ff 46%, #f7f2ff 100%);
  font-family: "Inter", "MiSans", "HarmonyOS Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

[hidden] {
  display: none !important;
}

.app {
  position: relative;
  min-height: 100vh;
  padding: 24px 24px calc(var(--nav-height) + 28px);
}

.app::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(135deg, rgba(102, 126, 234, 0.07), rgba(118, 75, 162, 0.07)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 1px, transparent 1px 88px);
  pointer-events: none;
}

main {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 16px;
  z-index: 20;
  width: min(1180px, calc(100% - 0px));
  margin: 0 auto 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: calc(var(--radius) + 4px);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
}

.brand {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.brand strong {
  overflow: hidden;
  color: #171a30;
  font-size: 18px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand span,
.subtle,
.meta {
  color: var(--muted);
}

.brand span {
  font-size: 13px;
}

.user-chip {
  flex: 0 0 auto;
  max-width: 42%;
  overflow: hidden;
  padding: 9px 13px;
  border: 1px solid rgba(102, 126, 234, 0.16);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.13), rgba(118, 75, 162, 0.12));
  color: #4f46a4;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fade-up 0.28s ease-out;
}

.page-head,
.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-head {
  margin-bottom: 18px;
}

.panel .page-head {
  margin-bottom: 14px;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

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

.subtle {
  margin-bottom: 0;
  font-size: 14px;
  line-height: 1.65;
}

.grid,
.detail-layout {
  display: grid;
  gap: 18px;
}

.grid {
  grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.1fr);
  align-items: start;
}

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

.detail-layout {
  grid-template-columns: minmax(300px, 0.82fr) minmax(420px, 1.18fr);
  align-items: start;
}

.panel,
.ticket-card,
.metric-card,
.detail-panel {
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
}

.panel {
  padding: 18px;
}

.detail-panel {
  min-height: 520px;
}

.form,
.inline-form {
  display: grid;
  gap: 14px;
}

.inline-form {
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: end;
}

.inline-form.active {
  display: grid;
}

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

.field label {
  color: #343850;
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(102, 126, 234, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input,
select {
  padding: 0 12px;
}

textarea {
  min-height: 118px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(102, 126, 234, 0.62);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.13);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 12px 24px rgba(102, 126, 234, 0.24);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(118, 75, 162, 0.28);
  filter: saturate(1.05);
}

.btn:active {
  transform: translateY(0);
}

.btn.secondary {
  border: 1px solid rgba(102, 126, 234, 0.16);
  background: rgba(255, 255, 255, 0.84);
  color: #5756b3;
  box-shadow: 0 8px 18px rgba(102, 126, 234, 0.1);
}

.btn.complete {
  margin-top: 14px;
  background: linear-gradient(135deg, #22c55e 0%, #0f9f6e 100%);
  box-shadow: 0 12px 24px rgba(34, 197, 94, 0.2);
}

.btn:focus-visible,
.nav-btn:focus-visible,
.ticket-card:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(102, 126, 234, 0.25);
  outline-offset: 2px;
}

.ticket-list {
  display: grid;
  gap: 12px;
}

.ticket-card {
  width: 100%;
  display: block;
  padding: 15px;
  color: inherit;
  text-align: left;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.ticket-card:hover,
.ticket-card.active-card {
  transform: translateY(-2px);
  border-color: rgba(102, 126, 234, 0.34);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 20px 42px rgba(102, 126, 234, 0.17), 0 8px 20px rgba(17, 24, 39, 0.07);
}

.ticket-card.active-card {
  box-shadow: inset 4px 0 0 var(--primary), var(--shadow);
}

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

.ticket-title {
  margin-bottom: 7px;
  color: #20233a;
  font-size: 16px;
  font-weight: 850;
  line-height: 1.38;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.45;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.tag.pending,
.pending {
  background: #fff7ed;
  color: #c2410c;
}

.tag.processing,
.processing {
  background: #eaf0ff;
  color: #4357d6;
}

.tag.completed,
.completed {
  background: #dcfce7;
  color: #15803d;
}

.tag.urgent,
.urgent {
  background: #fee2e2;
  color: #dc2626;
}

.empty {
  display: grid;
  min-height: 138px;
  place-items: center;
  border: 1px dashed rgba(102, 126, 234, 0.28);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.46);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.metric-card {
  min-height: 126px;
  display: grid;
  align-content: space-between;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.62)),
    linear-gradient(135deg, rgba(102, 126, 234, 0.12), rgba(118, 75, 162, 0.1));
}

.metric-card strong {
  font-size: 38px;
  line-height: 1;
}

.data-table {
  width: 100%;
  overflow: hidden;
  border-collapse: collapse;
  border: 1px solid rgba(102, 126, 234, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.78);
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(102, 126, 234, 0.12);
  color: #2d3148;
  font-size: 14px;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: rgba(102, 126, 234, 0.08);
  color: #545a75;
  font-size: 12px;
  font-weight: 850;
}

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

.data-table td:last-child {
  text-align: right;
}

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

.info-item {
  display: grid;
  gap: 7px;
  padding: 13px;
  border: 1px solid rgba(102, 126, 234, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.58);
}

.info-item span {
  color: var(--muted);
  font-size: 12px;
}

.info-item strong {
  color: #22263e;
  font-size: 14px;
  line-height: 1.35;
}

.section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(102, 126, 234, 0.14);
}

.description {
  margin: 14px 0 0;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.58);
  color: #363b54;
  line-height: 1.7;
}

.timeline {
  position: relative;
  display: grid;
  gap: 12px;
  padding-left: 18px;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 5px;
  width: 2px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
}

.timeline-item {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 11px 13px;
  border: 1px solid rgba(102, 126, 234, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.62);
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 15px;
  left: -18px;
  width: 10px;
  height: 10px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.18);
}

.timeline-item strong {
  color: #2a2e45;
  font-size: 14px;
  line-height: 1.45;
}

.ai-box {
  display: grid;
  gap: 10px;
  padding: 15px;
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(102, 126, 234, 0.13), rgba(118, 75, 162, 0.12)),
    rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

.ai-box p {
  margin: 0;
  color: #30354e;
  font-size: 14px;
  line-height: 1.75;
}

.checklist {
  display: grid;
  gap: 10px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid rgba(102, 126, 234, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.62);
  color: #333750;
  font-weight: 700;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.check-row.done {
  border-color: rgba(34, 197, 94, 0.25);
  background: rgba(220, 252, 231, 0.72);
  color: #166534;
}

.check-row input {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--success);
}

.bottom-nav {
  position: fixed;
  right: 24px;
  bottom: 18px;
  left: 24px;
  z-index: 30;
  width: min(620px, calc(100% - 48px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 18px 44px rgba(31, 38, 135, 0.18), 0 6px 16px rgba(17, 24, 39, 0.08);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
}

.nav-btn {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.nav-btn:hover {
  color: #4f46a4;
  background: rgba(102, 126, 234, 0.08);
}

.nav-btn.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 10px 22px rgba(102, 126, 234, 0.24);
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 920px) {
  .grid,
  .detail-layout,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr 1fr;
  }

  .inline-form .btn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 14px 12px calc(var(--nav-height) + 22px);
  }

  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
    border-radius: var(--radius);
  }

  .brand strong {
    white-space: normal;
  }

  .user-chip {
    max-width: none;
    width: 100%;
  }

  .page-head,
  .toolbar,
  .ticket-top {
    flex-direction: column;
    align-items: stretch;
  }

  h1 {
    font-size: 28px;
  }

  .panel {
    padding: 14px;
  }

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

  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .bottom-nav {
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: calc(100% - 24px);
    border-radius: 24px;
  }

  .nav-btn {
    min-height: 44px;
    padding: 0 10px;
    font-size: 13px;
  }
}

/* [CSS_PHASE4_REWRITE_DONE] */
