:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --bg-strong: #e8edf3;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-tint: #edf7f5;
  --ink: #17202a;
  --ink-soft: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #dbe3ea;
  --line-strong: #c6d1dc;
  --primary: #0f766e;
  --primary-hover: #0b625b;
  --primary-ink: #ffffff;
  --secondary: #be3b62;
  --accent: #b7791f;
  --blue: #4057c8;
  --danger: #c24135;
  --ok: #15803d;
  --warn: #b7791f;
  --sidebar-bg: #151b24;
  --sidebar-bg-2: #1c2531;
  --sidebar-ink: #eef5f7;
  --sidebar-muted: #9fb0c2;
  --shadow: 0 18px 46px rgba(15, 23, 42, 0.11);
  --shadow-soft: 0 9px 24px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar: 272px;
  --topbar: 76px;
  --page-gutter: clamp(16px, 2.2vw, 32px);
  --content-max: 1600px;
  font-family:
    Inter,
    "Segoe UI",
    "Microsoft YaHei UI",
    "PingFang SC",
    Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  overflow-x: hidden;
}

body {
  background:
    linear-gradient(180deg, #f8fafc 0, var(--bg) 340px),
    var(--bg);
  color: var(--ink);
  letter-spacing: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.font-large {
  font-size: 17px;
}

body.font-small {
  font-size: 15px;
}

body.density-compact .section,
body.density-compact .panel,
body.density-compact .item {
  padding: 12px;
}

body.density-compact .item-list,
body.density-compact .grid,
body.density-compact .stat-grid {
  gap: 9px;
}

body.density-spacious .section,
body.density-spacious .panel,
body.density-spacious .item {
  padding: 22px;
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
  background:
    linear-gradient(180deg, #f8fafc 0, var(--bg) 340px),
    var(--bg);
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 38%),
    linear-gradient(315deg, rgba(190, 59, 98, 0.11), transparent 36%),
    linear-gradient(180deg, #f8fafc, #edf2f7);
}

.auth-panel {
  position: relative;
  width: min(460px, 100%);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(219, 227, 234, 0.9);
  border-radius: var(--radius);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.16);
  padding: 30px;
}

.auth-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
}

.brand-lockup,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: 0;
}

.brand-lockup p,
.sidebar-brand span,
.eyebrow,
.muted {
  margin: 0;
  color: var(--muted);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent),
    var(--primary);
  color: #fff;
  font-weight: 850;
  font-size: 24px;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.28);
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  box-shadow: none;
}

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

label {
  display: grid;
  gap: 7px;
}

label span,
.field-label {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 720;
}

.field-with-picker {
  position: relative;
}

.field-with-picker input {
  padding-right: 72px;
}

.date-picker-trigger {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.inline-date-picker {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  left: 0;
  width: min(320px, 86vw);
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.inline-date-picker-header,
.inline-date-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.inline-date-weekdays,
.inline-date-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-top: 8px;
  text-align: center;
}

.inline-date-weekdays span {
  font-size: 12px;
  color: var(--muted);
}

.inline-date-grid button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 760;
}

.inline-date-grid button.is-other {
  color: var(--muted-2);
  background: #fff;
}

.inline-date-grid button.is-selected {
  border-color: var(--primary);
  background: var(--surface-tint);
  color: var(--primary);
}

.time-picker-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.inline-date-actions {
  margin-top: 10px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease,
    background-color 120ms ease;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  background: #edf2f7;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.segment {
  min-height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 760;
}

.segment.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.workspace {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(64, 87, 200, 0.18), transparent 34%),
    var(--sidebar-bg);
  color: var(--sidebar-ink);
}

.sidebar::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  min-height: 46px;
  padding: 4px 4px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand strong {
  color: var(--sidebar-ink);
}

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

.sidebar-brand > div:last-child {
  display: grid;
}

.main-nav {
  display: grid;
  gap: 5px;
  overflow: auto;
  padding-right: 2px;
}

.mobile-tab-nav {
  display: none;
}

.main-nav::-webkit-scrollbar,
.message-list::-webkit-scrollbar,
.modal::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.main-nav::-webkit-scrollbar-thumb,
.message-list::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--sidebar-muted);
  background: transparent;
  text-align: left;
  font-weight: 760;
  transition:
    color 120ms ease,
    background-color 120ms ease,
    transform 120ms ease;
}

.nav-item:hover {
  color: var(--sidebar-ink);
  background: rgba(255, 255, 255, 0.08);
}

.nav-item.is-active {
  color: #fff;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.9), rgba(64, 87, 200, 0.74));
  box-shadow: 0 10px 24px rgba(2, 8, 23, 0.24);
}

.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -8px;
  width: 3px;
  height: 22px;
  border-radius: 999px;
  background: #f7c66a;
}

.nav-icon,
.button-icon {
  width: 22px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar .button.ghost {
  color: var(--sidebar-ink);
  border-color: rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar .button.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.main-area {
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 15;
  top: 0;
  min-height: var(--topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px var(--page-gutter);
  border-bottom: 1px solid rgba(219, 227, 234, 0.86);
  background: rgba(248, 250, 252, 0.88);
  backdrop-filter: blur(16px);
}

.topbar h2 {
  margin: 2px 0 0;
  font-size: 25px;
  line-height: 1.1;
  letter-spacing: 0;
}

.eyebrow {
  font-size: 12px;
  font-weight: 820;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.content {
  width: 100%;
  max-width: var(--content-max);
  min-width: 0;
  margin: 0 auto;
  padding: 24px var(--page-gutter) 40px;
}

.content:focus {
  outline: none;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 13px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 780;
  white-space: nowrap;
  max-width: 100%;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background-color 120ms ease,
    border-color 120ms ease;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.button.primary {
  background: var(--primary);
  color: var(--primary-ink);
}

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

.button.secondary {
  border-color: rgba(15, 118, 110, 0.22);
  background: #e9f7f4;
  color: var(--primary);
}

.button.warn {
  background: #fff6e7;
  color: var(--warn);
  border-color: #f5d9a2;
}

.button.danger {
  color: var(--danger);
}

.button.danger:not(.ghost) {
  background: var(--danger);
  color: #fff;
}

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

.button.wide {
  width: 100%;
}

.button.compact,
.icon-button.compact {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.icon-button {
  width: 40px;
  padding: 0;
}

.icon-button.subtle {
  color: var(--muted);
  background: transparent;
}

.only-mobile {
  display: none;
}

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

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

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

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

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.section,
.panel {
  min-width: 0;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(219, 227, 234, 0.92);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.section {
  padding: 16px;
}

.section + .section {
  margin-top: 16px;
}

.section-header,
.list-header,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-header h3,
.list-header h3,
.modal-header h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.25;
}

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

.stat {
  position: relative;
  display: grid;
  gap: 7px;
  min-height: 96px;
  overflow: hidden;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}

.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}

.stat strong {
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat.teal {
  background: #effaf7;
}

.stat.rose {
  background: #fff0f4;
}

.stat.rose::before {
  background: var(--secondary);
}

.stat.amber {
  background: #fff8e8;
}

.stat.amber::before {
  background: var(--accent);
}

.stat.blue {
  background: #f0f4ff;
}

.stat.blue::before {
  background: var(--blue);
}

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

.toolbar-left,
.toolbar-right,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  white-space: nowrap;
  max-width: 100%;
}

.chip.is-active,
.chip.good {
  color: var(--primary);
  border-color: rgba(15, 118, 110, 0.24);
  background: #e8f7f4;
}

.chip.warn {
  color: var(--warn);
  border-color: #f0d49b;
  background: #fff7e8;
}

.chip.danger {
  color: var(--danger);
  border-color: #f0b7ae;
  background: #fff0ee;
}

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

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

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

.my-route-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.my-route-card:hover {
  border-color: rgba(15, 118, 110, 0.32);
  background: #fbfdfc;
}

.my-route-card strong,
.my-route-card small {
  display: block;
  overflow-wrap: anywhere;
}

.my-route-card small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.subpage-shell {
  display: grid;
  gap: 16px;
}

.subpage-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.subpage-header h3,
.subpage-header p {
  margin: 0;
}

.group-tree {
  display: grid;
  gap: 12px;
}

.group-block {
  margin-left: calc(var(--group-depth, 0) * 18px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.02);
}

.group-block.is-ungrouped {
  background: var(--surface-soft);
}

.group-header {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
}

.group-toggle {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
}

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

.group-title > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.group-title strong {
  overflow-wrap: anywhere;
}

.group-title span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.group-content {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px 56px;
}

.group-children {
  display: grid;
  gap: 10px;
}

.item {
  display: grid;
  gap: 9px;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.02);
}

.item.compact {
  padding: 11px;
}

.compact-help {
  padding: 10px 13px;
  background: var(--surface-soft);
}

.home-hero {
  position: relative;
  overflow: hidden;
}

.home-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.76)),
    var(--home-bg, linear-gradient(90deg, transparent, transparent));
  background-position: center;
  background-size: cover;
  opacity: var(--home-bg-opacity, 1);
}

.home-hero > * {
  position: relative;
  z-index: 1;
}

.drag-handle {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--surface-soft);
  cursor: grab;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 900;
  user-select: none;
  touch-action: none;
}

.order-button {
  min-width: 38px;
  padding-right: 10px;
  padding-left: 10px;
}

.drag-handle.sample {
  width: 22px;
  height: 24px;
}

.draggable-item.is-dragging {
  opacity: 0.42;
}

.draggable-item.is-drop-target {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.14);
}

.item-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.item-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.item-title strong {
  overflow-wrap: anywhere;
}

.item-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: #e8f7f4;
  color: var(--primary);
  font-weight: 850;
  flex: 0 0 auto;
}

.meta-row,
.mini-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 168px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

.empty.compact {
  min-height: 70px;
  padding: 12px;
}

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

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  touch-action: pan-y;
}

.calendar-toolbar {
  margin-bottom: 10px;
}

.calendar-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.calendar-year-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  touch-action: pan-y;
}

.month-card {
  display: grid;
  gap: 6px;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.month-card:hover,
.month-card.is-selected {
  border-color: var(--primary);
  background: #f3fbf9;
}

.month-card strong {
  font-size: 16px;
}

.month-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.month-mini-dots {
  display: flex;
  gap: 4px;
  min-height: 10px;
}

.weekday {
  color: var(--muted);
  font-weight: 840;
  text-align: center;
  font-size: 12px;
  padding: 4px;
}

.day-cell {
  min-height: 88px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 8px;
  text-align: left;
  transition:
    border-color 120ms ease,
    background-color 120ms ease,
    transform 120ms ease;
}

.day-cell:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.day-cell.is-other {
  opacity: 0.48;
}

.day-cell.is-today {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(64, 87, 200, 0.18);
}

.day-cell.is-selected {
  background: #e8f7f4;
  border-color: var(--primary);
}

.day-num {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  font-weight: 850;
}

.day-sub {
  display: block;
  min-height: 18px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 740;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-dots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
}

.dot.reward {
  background: var(--secondary);
}

.dot.plan {
  background: var(--accent);
}

.dot.anniversary {
  background: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.14);
}

.dot.record {
  background: var(--blue);
}

.dot.fortune {
  background: #7c2d12;
}

.dot.transfer {
  background: #7c3aed;
}

.fortune-poem {
  margin: 8px 0 0;
  white-space: pre-wrap;
  font-family: inherit;
  line-height: 1.75;
  color: var(--ink);
}

.danger-text {
  color: var(--danger);
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(15, 23, 42, 0.44);
  backdrop-filter: blur(3px);
}

.modal {
  width: min(760px, 100%);
  max-height: min(86vh, 820px);
  max-height: min(86dvh, 820px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.28);
}

.modal.compact {
  width: min(520px, 100%);
}

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

.modal-body {
  padding: 16px;
}

.form-grid {
  display: grid;
  gap: 12px;
  min-width: 0;
}

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

.form-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 13px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.toast.error {
  border-left-color: var(--danger);
}

.pwa-banner {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: min(520px, calc(100vw - 36px));
  border: 1px solid rgba(198, 209, 220, 0.92);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 44px rgba(15, 23, 42, 0.17);
  backdrop-filter: blur(18px);
}

.pwa-banner.is-hidden {
  display: none;
}

.pwa-banner-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.pwa-banner-copy strong {
  font-size: 14px;
  line-height: 1.25;
}

.pwa-banner-copy span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

.pull-refresh-indicator {
  position: fixed;
  top: calc(env(safe-area-inset-top) - 46px);
  left: 50%;
  z-index: 70;
  min-width: 112px;
  border: 1px solid rgba(198, 209, 220, 0.9);
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--muted);
  box-shadow: var(--shadow-soft);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.pull-refresh-indicator.is-visible {
  opacity: 1;
}

.pull-refresh-indicator.is-ready {
  color: var(--primary);
  border-color: rgba(15, 118, 110, 0.28);
}

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(12px);
}

.call-overlay.is-minimized {
  inset: auto max(16px, env(safe-area-inset-right)) max(88px, calc(18px + env(safe-area-inset-bottom))) auto;
  display: block;
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  background: transparent;
  backdrop-filter: none;
}

.call-overlay-card {
  display: grid;
  gap: 16px;
  width: min(460px, 100%);
  border: 1px solid rgba(198, 209, 220, 0.9);
  border-radius: var(--radius);
  padding: 20px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 26px 80px rgba(15, 23, 42, 0.28);
}

.call-overlay-card h3 {
  margin: 3px 0;
  font-size: 24px;
}

.call-overlay-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.call-overlay.is-minimized .call-overlay-card {
  width: 100%;
  padding: 14px;
}

.call-overlay.is-minimized .call-overlay-card h3 {
  font-size: 18px;
}

.chat-layout,
.ai-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
  gap: 16px;
  align-items: start;
  min-width: 0;
}

.message-list {
  display: grid;
  gap: 9px;
  max-height: 58vh;
  overflow: auto;
  padding-right: 4px;
}

.message {
  max-width: 78%;
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
}

.message.mine {
  margin-left: auto;
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.message.mine small {
  color: rgba(255, 255, 255, 0.78);
}

.message.ai {
  background: #f0f4ff;
  border-color: #d6dfff;
}

.message small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.chat-media-image,
.chat-media-video {
  display: block;
  max-width: min(300px, 100%);
  max-height: 240px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.chat-media-audio {
  width: min(320px, 100%);
}

.media-preview-shell {
  display: grid;
  gap: 12px;
}

.chat-media-preview {
  display: block;
  width: 100%;
  max-height: 56vh;
  max-height: 56dvh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f172a;
  object-fit: contain;
}

.call-media {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.call-media > div {
  display: grid;
  gap: 6px;
}

.call-media video {
  width: 100%;
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #0f172a;
  object-fit: cover;
}

.call-media audio {
  width: 100%;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
  min-width: 0;
}

.composer.triple {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

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

.progress {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
}

.progress > span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  background: var(--primary);
}

.progress.secondary > span {
  background: var(--secondary);
}

.calendar-trend {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.trend-row {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.trend-lines {
  display: grid;
  grid-template-columns: auto minmax(72px, 1fr);
  gap: 6px 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.payload-box {
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink-soft);
  white-space: pre-wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

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

tbody tr:hover {
  background: #fbfdff;
}

.code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  background: #eef2f7;
  border-radius: var(--radius-sm);
  padding: 2px 5px;
}

.mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(15, 23, 42, 0.44);
}

.mobile-tab-item {
  position: relative;
  display: grid;
  place-items: center;
  gap: 3px;
  min-width: 0;
  min-height: 50px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}

.mobile-tab-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 20px;
  font-size: 18px;
  line-height: 1;
}

.mobile-tab-item.is-active {
  color: var(--primary);
  background: #e8f7f4;
}

.mobile-tab-item span:not(.mobile-tab-icon):not(.mobile-tab-badge) {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-tab-badge {
  position: absolute;
  top: 4px;
  right: max(8px, 18%);
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  padding: 0 4px;
  background: var(--secondary);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}

.state-watermark {
  position: fixed;
  right: 12px;
  bottom: 8px;
  z-index: 5;
  max-width: min(520px, calc(100vw - 24px));
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  opacity: 0.36;
  pointer-events: none;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-dock {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(78px, calc(18px + env(safe-area-inset-bottom)));
  z-index: 32;
}

.voice-dock-button {
  display: grid;
  place-items: center;
  gap: 2px;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 16px 38px rgba(15, 118, 110, 0.28);
  font-weight: 820;
}

.voice-dock-button span {
  line-height: 1;
  font-size: 20px;
}

.voice-dock-button small {
  font-size: 10px;
}

.qr-card,
.qr-scanner {
  display: grid;
  gap: 12px;
}

.qr-card img {
  width: min(280px, 100%);
  height: auto;
  justify-self: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
}

.qr-scanner video {
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f172a;
  object-fit: cover;
}

.timeline-list {
  display: grid;
  gap: 0;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  padding-bottom: 12px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 16px;
  bottom: -4px;
  width: 1px;
  background: var(--line);
}

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

.timeline-dot {
  position: relative;
  z-index: 1;
  width: 15px;
  height: 15px;
  margin-top: 13px;
  border-radius: 999px;
  background: var(--muted-2);
  box-shadow: 0 0 0 4px var(--surface);
}

.timeline-dot.good {
  background: var(--ok);
}

.timeline-dot.warn {
  background: var(--warn);
}

.timeline-dot.blue {
  background: var(--blue);
}

.timeline-dot.rose {
  background: var(--secondary);
}

.timeline-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.toolbox-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

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

.toolbox-template {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.toolbox-template:hover {
  border-color: var(--primary);
  background: #f3fbf9;
}

.toolbox-template span:last-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.toolbox-template small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.calendar-month-detail {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.stat-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat-grid.compact .stat {
  min-height: 78px;
  padding: 12px;
}

@media (max-width: 1120px) {
  .dashboard-grid,
  .calendar-layout,
  .toolbox-layout,
  .chat-layout,
  .ai-layout {
    grid-template-columns: 1fr;
  }

  .stat-grid,
  .grid.four,
  .my-route-grid,
  .my-route-grid.compact,
  .toolbox-template-grid,
  .calendar-year-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  :root {
    --sidebar: 236px;
    --page-gutter: 18px;
  }

  .workspace {
    grid-template-columns: var(--sidebar) 1fr;
  }

  .sidebar {
    padding: 16px 12px;
  }

  .nav-item {
    padding-right: 10px;
    padding-left: 10px;
  }

  .stat-grid,
  .grid.three,
  .grid.four,
  .form-grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  :root {
    --topbar: 68px;
    --page-gutter: 14px;
  }

  .workspace {
    display: block;
    min-height: 100dvh;
    padding-bottom: 0;
  }

  .sidebar {
    display: none;
  }

  .only-mobile {
    display: inline-flex;
  }

  .mobile-backdrop {
    display: none;
  }

  .mobile-tab-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 55;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 6px max(10px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    border: 1px solid rgba(198, 209, 220, 0.88);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 14px 42px rgba(15, 23, 42, 0.17);
    backdrop-filter: blur(18px);
  }

  .pwa-banner {
    right: 12px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    left: 12px;
    grid-template-columns: minmax(0, 1fr);
    width: auto;
  }

  .pwa-banner-actions {
    justify-content: flex-end;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: calc(var(--topbar) + env(safe-area-inset-top));
    padding: calc(13px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 13px max(14px, env(safe-area-inset-left));
    overflow: hidden;
  }

  .topbar h2 {
    font-size: 21px;
  }

  .topbar > div:not(.topbar-actions) {
    min-width: 0;
  }

  .topbar-actions {
    display: flex;
    justify-self: end;
    gap: 6px;
  }

  #quickCreateButton {
    width: 40px;
    padding: 0;
  }

  #quickCreateButton .button-icon {
    width: auto;
  }

  #quickCreateButton span:last-child {
    display: none;
  }

  .content {
    padding: 14px max(14px, env(safe-area-inset-right)) calc(82px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    width: 100%;
    overflow-x: hidden;
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .form-grid.two,
  .form-grid.four,
  .stat-grid,
  .stat-grid.compact,
  .my-route-grid,
  .my-route-grid.compact,
  .toolbox-template-grid,
  .admin-metrics,
  .calendar-year-grid {
    grid-template-columns: 1fr;
  }

  .item-main,
  .section-header,
  .list-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .row-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(112px, 100%), 1fr));
  }

  .row-actions .button,
  .row-actions a.button,
  .row-actions .icon-button {
    width: 100%;
    min-width: 0;
    font-size: 14px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .group-block {
    margin-left: calc(var(--group-depth, 0) * 10px);
  }

  .group-header {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .group-header .row-actions {
    grid-column: 1 / -1;
  }

  .group-content {
    padding-left: 12px;
  }

  .day-cell {
    min-height: 66px;
    padding: 6px;
  }

  .modal-root {
    align-items: end;
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .modal {
    width: 100%;
    max-height: calc(100dvh - 16px);
  }

  .modal-header,
  .modal-body {
    padding: 14px;
  }

  .message-list {
    max-height: 52vh;
    max-height: 52dvh;
  }

  .voice-dock {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(86px, calc(72px + env(safe-area-inset-bottom)));
  }

  .message {
    max-width: 92%;
  }

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

  .composer.triple {
    grid-template-columns: 1fr;
  }

  .call-media {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  :root {
    --topbar: 62px;
    --page-gutter: 12px;
  }

  .auth-view {
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .auth-panel {
    padding: 22px 18px;
  }

  .brand-lockup h1 {
    font-size: 26px;
  }

  .topbar {
    gap: 8px;
    padding: calc(10px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  }

  .topbar h2 {
    font-size: 19px;
  }

  .eyebrow {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .section,
  .panel,
  .item {
    padding: 12px;
  }

  .section + .section {
    margin-top: 12px;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
  }

  .toolbar-left > *,
  .toolbar-right > * {
    min-width: 0;
  }

  .stat-grid,
  .grid.two,
  .grid.three,
  .grid.four,
  .form-grid.two,
  .form-grid.four,
  .admin-metrics,
  .stat-grid.compact,
  .my-route-grid,
  .my-route-grid.compact,
  .toolbox-template-grid,
  .calendar-year-grid {
    grid-template-columns: 1fr;
  }

  .stat {
    min-height: 82px;
  }

  .stat strong {
    font-size: 24px;
  }

  .calendar-layout {
    gap: 12px;
  }

  .calendar-layout .section-header .row-actions:first-of-type {
    grid-template-columns: 40px minmax(72px, 1fr) 40px;
  }

  .calendar-grid {
    gap: 4px;
  }

  .weekday {
    font-size: 11px;
    padding: 2px;
  }

  .day-cell {
    min-height: 58px;
    padding: 5px 4px;
  }

  .day-num {
    font-size: 12px;
  }

  .day-sub {
    min-height: 14px;
    margin-top: 2px;
    font-size: 10px;
  }

  .day-dots {
    gap: 3px;
    margin-top: 5px;
  }

  .dot {
    width: 6px;
    height: 6px;
  }

  .calendar-legend,
  .filters {
    gap: 6px;
  }

  .chip {
    min-height: 26px;
    padding: 3px 8px;
  }

  .inline-date-picker {
    width: min(320px, calc(100vw - 32px));
  }

  .message {
    max-width: 96%;
  }

  .call-media video {
    min-height: 180px;
  }

  .toast-root {
    right: 10px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    left: 10px;
  }

  .toast {
    max-width: none;
  }

  .call-overlay {
    align-items: end;
  }

  .call-overlay.is-minimized {
    right: 10px;
    bottom: calc(86px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
  }

  .state-watermark {
    right: 8px;
    bottom: calc(74px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 16px);
  }
}

@media (max-width: 380px) {
  .content {
    padding-right: 8px;
    padding-left: 8px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-right: max(8px, env(safe-area-inset-right));
    padding-left: max(8px, env(safe-area-inset-left));
  }

  .icon-button,
  #quickCreateButton {
    width: 38px;
  }

  .button {
    padding-right: 9px;
    padding-left: 9px;
  }

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

  .calendar-layout .section-header .row-actions:first-of-type {
    grid-template-columns: 38px minmax(64px, 1fr) 38px;
  }

  .day-cell {
    min-height: 52px;
  }

  .day-sub {
    display: none;
  }

  .group-block {
    margin-left: 0;
  }
}
