:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1b2e2c;
  background: #f4f6f5;
  font-synthesis: none;
  --forest-950: #0c2a27;
  --forest-900: #123b37;
  --forest-800: #184b45;
  --forest-700: #21655d;
  --teal-600: #2f7e74;
  --teal-500: #3f9387;
  --teal-100: #dcece8;
  --teal-50: #eef6f4;
  --ink: #1b2e2c;
  --ink-soft: #536865;
  --line: #dce4e2;
  --line-strong: #c9d5d2;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --canvas: #f4f6f5;
  --amber: #d99a2b;
  --amber-soft: #fff4dc;
  --red: #ae3428;
  --red-soft: #fff0ee;
  --green: #15735f;
  --green-soft: #e3f4ed;
  --shadow-sm: 0 1px 2px rgba(12, 42, 39, .04), 0 3px 10px rgba(12, 42, 39, .035);
  --shadow-md: 0 12px 35px rgba(12, 42, 39, .07);
  --radius-sm: .55rem;
  --radius-md: .8rem;
  --radius-lg: 1rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 20rem; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button, .button-link { transition: background .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: 1px solid transparent;
  border-radius: .65rem;
  padding: .72rem 1rem;
  background: var(--forest-700);
  color: #fff;
  font-weight: 700;
  line-height: 1.15;
  cursor: pointer;
}
button:hover { background: var(--forest-800); box-shadow: 0 4px 12px rgba(18, 59, 55, .14); transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(217, 154, 43, .45);
  outline-offset: 2px;
}
button:disabled { cursor: not-allowed; opacity: .5; transform: none; box-shadow: none; }
button.secondary { border-color: var(--line); background: var(--surface); color: var(--forest-800); }
button.secondary:hover { border-color: #afc2bd; background: var(--teal-50); }
button.danger { background: var(--red); }
button.danger:hover { background: #92271e; }
button.compact { padding: .58rem .8rem; font-size: .9rem; }
button svg, .logout-button svg, .icon-button svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.button-link { display: inline-block; border: 1px solid var(--line); border-radius: .65rem; padding: .72rem 1rem; background: var(--surface); color: var(--forest-800); font-weight: 700; line-height: 1.15; text-decoration: none; }
.button-link:hover { border-color: #afc2bd; background: var(--teal-50); }
.button-link.compact { padding: .58rem .8rem; font-size: .9rem; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: .65rem;
  padding: .72rem .8rem;
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 1px 1px rgba(12, 42, 39, .02);
}
input:hover, select:hover, textarea:hover { border-color: #9fb6b1; }
input:focus, select:focus, textarea:focus { border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(63, 147, 135, .1); }
textarea { min-height: 6rem; resize: vertical; line-height: 1.5; }
label { display: grid; gap: .38rem; color: #2c4340; font-size: .9rem; font-weight: 700; }
hr { height: 1px; margin: 1.35rem 0; border: 0; background: var(--line); }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3, h4 { color: var(--ink); letter-spacing: -.025em; }
h1 { margin-bottom: 0; font-size: clamp(1.55rem, 4vw, 2.05rem); line-height: 1.08; }
h2 { margin-bottom: .45rem; font-size: clamp(1.55rem, 3vw, 2.15rem); line-height: 1.15; }
h3 { margin-bottom: .45rem; font-size: 1.16rem; line-height: 1.25; }
h4 { margin-bottom: .35rem; font-size: 1rem; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.shell { min-height: 100vh; }
.environment-banner { position: sticky; z-index: 80; top: 0; padding: .48rem 1rem; text-align: center; background: var(--red); color: #fff; font-size: .8rem; font-weight: 800; letter-spacing: .08em; }
.eyebrow { margin-bottom: .28rem; color: var(--teal-600); font-size: .69rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--ink-soft); line-height: 1.5; }
.small { font-size: .82rem; }

/* Login */
.login-layout { display: grid; align-content: center; min-height: 100vh; width: min(100% - 2rem, 64rem); margin: 0 auto; padding: 3rem 0; }
.login-brand { display: flex; align-items: center; gap: .95rem; margin: 0 auto 1.5rem; width: min(100%, 31rem); }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 3.15rem; height: 3.15rem; border-radius: .95rem; background: linear-gradient(145deg, var(--teal-500), var(--forest-800)); color: #fff; font-size: 1.05rem; font-weight: 900; letter-spacing: -.02em; box-shadow: 0 9px 22px rgba(18, 59, 55, .19); }
.login-card { display: grid; gap: 1.5rem; width: min(100%, 31rem); margin: 0 auto; padding: clamp(1.4rem, 4vw, 2rem); }
.login-card form, .stack { display: grid; gap: .9rem; }
.login-card .message { margin-bottom: 0; }

/* Main application shell */
.dashboard-shell { display: grid; grid-template-columns: 16.5rem minmax(0, 1fr); min-height: 100vh; }
.app-sidebar {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 1.2rem .9rem 1rem;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--forest-900), var(--forest-950));
  color: #fff;
  box-shadow: 8px 0 30px rgba(12, 42, 39, .08);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}
.app-sidebar::-webkit-scrollbar { width: .35rem; }
.app-sidebar::-webkit-scrollbar-track { background: transparent; }
.app-sidebar::-webkit-scrollbar-thumb { border-radius: 1rem; background: rgba(255,255,255,.18); }
.sidebar-brand { display: flex; align-items: center; gap: .78rem; padding: .15rem .45rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand .brand-mark { width: 2.65rem; height: 2.65rem; border-radius: .78rem; background: rgba(255,255,255,.13); box-shadow: none; }
.sidebar-brand p { margin: 0 0 .08rem; color: #9fd0c9; font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.sidebar-brand strong { display: block; color: #fff; font-size: .98rem; letter-spacing: -.01em; }
.main-nav { display: flex; flex: 1; flex-direction: column; gap: .2rem; padding-top: .75rem; }
.nav-label { margin: .8rem .65rem .25rem; color: rgba(255,255,255,.45); font-size: .62rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.nav-item {
  position: relative;
  justify-content: flex-start;
  width: 100%;
  min-height: 2.6rem;
  border: 0;
  border-radius: .58rem;
  padding: .65rem .7rem;
  background: transparent;
  color: rgba(255,255,255,.75);
  font-size: .88rem;
  font-weight: 650;
  text-align: left;
}
.nav-item svg { flex: 0 0 auto; width: 1.08rem; height: 1.08rem; opacity: .83; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; box-shadow: none; transform: none; }
.nav-item.active { background: rgba(255,255,255,.13); color: #fff; box-shadow: inset 3px 0 0 var(--amber); }
.nav-item.active svg { color: #f3c776; opacity: 1; }
.nav-item.emphasized { margin: .35rem 0 .2rem; background: var(--teal-500); color: #fff; }
.nav-item.emphasized:hover { background: #4a9e92; }
.nav-item.emphasized.active { background: var(--teal-500); box-shadow: inset 3px 0 0 #ffd887; }
.nav-item .badge { margin-left: auto; }
.sidebar-footer { display: flex; align-items: center; gap: .5rem; margin-top: .8rem; padding: .85rem .65rem .15rem; border-top: 1px solid rgba(255,255,255,.1); color: rgba(255,255,255,.52); font-size: .72rem; }
.system-dot { width: .46rem; height: .46rem; border-radius: 50%; background: #5ac69f; box-shadow: 0 0 0 4px rgba(90,198,159,.12); }
.app-main { min-width: 0; }
.app-topbar {
  position: sticky;
  z-index: 35;
  top: 0;
  display: flex;
  align-items: center;
  gap: .9rem;
  min-height: 5rem;
  padding: .9rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  box-shadow: 0 1px 8px rgba(12,42,39,.025);
  backdrop-filter: blur(14px);
}
.topbar-copy { min-width: 0; }
.topbar-copy h2 { margin: 0; font-size: 1.22rem; }
.topbar-copy .eyebrow { margin-bottom: .12rem; }
.logout-button { margin-left: auto; border: 1px solid var(--line); padding: .55rem .75rem; background: var(--surface); color: var(--ink-soft); font-size: .85rem; }
.logout-button:hover { border-color: var(--line-strong); background: var(--surface-soft); color: var(--forest-800); }
.icon-button { display: none; width: 2.55rem; height: 2.55rem; padding: 0; border: 1px solid var(--line); background: var(--surface); color: var(--forest-800); }
.content-shell { width: min(100%, 100rem); margin: 0 auto; padding: clamp(1.25rem, 2.6vw, 2.2rem); }
.view { margin-top: 0; }
.view > .toolbar:first-child { margin-bottom: 1.25rem; }
.sidebar-backdrop { display: none; }

/* General content */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.toolbar > div:first-child { min-width: 0; }
.toolbar p:last-child { margin-bottom: 0; }
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 2vw, 1.35rem);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.card:hover { border-color: #d2ddda; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 1rem; }
.grid.wide { grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
.two-col { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1.15fr) minmax(18rem, .85fr); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.back { border: 0; padding: .35rem 0; background: none; color: var(--teal-600); font-size: .88rem; }
.back:hover { background: none; color: var(--forest-800); box-shadow: none; transform: none; text-decoration: underline; }
.message { margin: 0 0 1rem; border: 1px solid #cfe2dd; border-radius: var(--radius-md); padding: .75rem .9rem; background: var(--teal-50); color: var(--forest-800); font-size: .9rem; }
.message.error { border-color: #f0c7c2; background: var(--red-soft); color: #8f241b; }
.stat { margin: .1rem 0 .22rem; color: var(--forest-950); font-size: clamp(1.8rem, 4vw, 2.45rem); font-weight: 800; letter-spacing: -.05em; line-height: 1; }
.badge { display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .33rem; border-radius: 2rem; background: #c4493c; color: #fff; font-size: .68rem; font-weight: 800; }
.status-card { border-top: 3px solid var(--amber); }
.status-card.safe { border-top-color: var(--green); }
.group-card { display: flex; flex-direction: column; justify-content: space-between; gap: .9rem; min-height: 10rem; }
.group-card h3 { overflow-wrap: anywhere; }
.group-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; color: var(--ink-soft); font-size: .84rem; }
.pill { display: inline-flex; align-items: center; width: fit-content; border-radius: 2rem; padding: .24rem .55rem; background: #eef3f2; color: #355a55; font-size: .72rem; font-weight: 800; line-height: 1.2; }
.pill.warn { background: var(--amber-soft); color: #80500b; }
.pill.error { background: var(--red-soft); color: #992b21; }
.pill.ok { background: var(--green-soft); color: #0b624f; }
.helper { border: 1px solid #cfe4de; border-left: 3px solid var(--teal-600); border-radius: .6rem; padding: .75rem .9rem; background: var(--teal-50); color: #285c55; line-height: 1.48; }
.warning-box { border-color: #eed4a6; border-left-color: var(--amber); background: #fff9ed; color: #735017; }
.danger-box { border-color: #efc6c1; border-left-color: var(--red); background: var(--red-soft); color: #8c241b; }
.empty { padding: 2rem 1rem; color: var(--ink-soft); text-align: center; }
.empty p:last-child { margin-bottom: 0; }

/* Homepage */
#view-home > .grid:first-child { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#view-home > .grid:first-child .card { position: relative; min-height: 11.2rem; overflow: hidden; }
#view-home > .grid:first-child .card::after { position: absolute; right: -1.4rem; bottom: -1.7rem; width: 6rem; height: 6rem; border-radius: 50%; background: var(--teal-50); content: ""; }
#view-home > .grid:first-child .card > * { position: relative; z-index: 1; }
#view-home > .toolbar { margin-top: 1.8rem !important; padding-top: .2rem; }
#view-home > .card:last-child { margin-top: 1rem !important; }

/* Tables and forms */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff; }
.data-table { width: 100%; min-width: 40rem; border-collapse: separate; border-spacing: 0; }
.data-table th, .data-table td { padding: .78rem .85rem; border-bottom: 1px solid #e7ecea; text-align: left; vertical-align: top; }
.data-table th { position: sticky; z-index: 1; top: 0; background: #f7f9f8; color: #56706c; font-size: .68rem; font-weight: 800; letter-spacing: .075em; text-transform: uppercase; }
.data-table tbody tr { transition: background .14s ease; }
.data-table tbody tr:hover { background: #fafcfb; }
.data-table tr:last-child td { border-bottom: 0; }
.row-warning { background: #fffaf1; }
.row-error { background: #fff6f5; }
.row-ok { background: #f5fbf8; }
.checkbox-line { display: flex; align-items: center; gap: .55rem; font-weight: 650; }
.checkbox-line input, .confirm-check input { flex: 0 0 auto; width: auto; accent-color: var(--teal-600); }
.step { display: flex; align-items: center; gap: .55rem; margin-bottom: .9rem; color: var(--ink-soft); font-size: .86rem; }
.step-number { display: grid; place-items: center; width: 1.55rem; height: 1.55rem; border-radius: 50%; background: var(--forest-700); color: #fff; font-size: .72rem; font-weight: 900; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); align-items: end; gap: .75rem; }
.filters button { align-self: end; }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: .65rem; }
.inline-form > label { flex: 1 1 12rem; }
.upload-status { display: grid; gap: .35rem; font-size: .86rem; }
.upload-status progress { width: 100%; accent-color: var(--teal-600); }
.upload-report-list { display: grid; gap: .28rem; margin: .55rem 0 0; padding-left: 1.1rem; font-size: .82rem; }
.card-file-requirement { margin: .7rem 0 1rem; }
.card-reading-action { align-items: center; margin: -.25rem 0 1rem; }
.association-retry { align-items: center; margin: -.25rem 0 1rem; }
.card-association-map { margin-top: 1rem; }

/* Upload and previews */
.file-input { position: relative; border: 1.5px dashed #8db9b1; border-radius: var(--radius-md); padding: 1rem; background: #f8fcfb; text-align: center; transition: border-color .15s ease, background .15s ease, transform .15s ease; }
.file-input.dragging { border-color: var(--teal-600); background: #e5f4f0; transform: scale(1.002); }
.file-input label { cursor: pointer; padding: .65rem; }
.file-input input { border: 0; padding: .4rem 0; background: transparent; cursor: pointer; box-shadow: none; }
.drop-title { display: block; color: var(--forest-800); font-size: 1rem; font-weight: 800; }
.preview { border: 1px solid #e1e8e6; border-radius: .65rem; padding: .85rem; background: #f7f9f8; white-space: pre-wrap; line-height: 1.55; }
.association-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; margin-top: 1rem; }
.association-stat { display: flex; flex-direction: column; gap: .12rem; border-radius: .65rem; padding: .75rem; background: var(--green-soft); color: #0b624f; font-size: .78rem; }
.association-stat strong { font-size: 1.28rem; }
.association-stat.warn { background: var(--amber-soft); color: #735017; }
.file-cell { display: flex; align-items: flex-start; gap: .75rem; min-width: 17rem; }
.card-thumbnail { display: block; width: 5rem; height: 4rem; border: 1px solid var(--line-strong); border-radius: .45rem; background: #fff; object-fit: contain; }
.pdf-preview { display: grid; place-items: center; flex: 0 0 5rem; width: 5rem; height: 4rem; border-radius: .45rem; background: var(--red-soft); color: #982c23; font-size: 1rem; font-weight: 900; text-align: center; text-decoration: none; }
.pdf-preview span { font-size: .62rem; }
.file-preview-button { display: block; width: fit-content; margin: .55rem 0 .3rem; border-radius: .55rem; padding: .5rem .65rem; background: var(--forest-700); color: #fff; font-size: .76rem; font-weight: 800; text-decoration: none; }
.file-preview-button:hover { background: var(--forest-800); }
.assigned-file-name { display: block; max-width: 19rem; overflow: hidden; color: var(--ink-soft); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.visual-check { margin-top: .55rem; border: 1px solid var(--line); border-radius: .5rem; padding: .55rem; background: #fff; color: var(--ink); }

/* Templates, alerts and costs */
.template-library { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 28rem), 1fr)); gap: 1rem; }
.template-card { display: grid; align-content: start; gap: .8rem; }
.template-card .toolbar { margin-bottom: 0; }
.template-section { border-top: 1px solid var(--line); padding-top: .75rem; }
.template-section .eyebrow { margin-bottom: .4rem; }
.template-text { border: 1px solid #e4eae8; border-radius: .62rem; padding: .8rem; background: #f8faf9; color: var(--ink); white-space: pre-wrap; line-height: 1.55; }
.template-variables { display: grid; gap: .55rem; margin: 0; padding-left: 1.15rem; }
.cost-summary { display: grid; grid-template-columns: repeat(6, minmax(8rem, 1fr)); gap: .7rem; margin: 1rem 0; }
.cost-stat { border: 1px solid var(--line); border-radius: .8rem; padding: 1rem; background: var(--surface); box-shadow: var(--shadow-sm); }
.cost-stat .stat { font-size: 1.65rem; }
.alert-list { display: grid; gap: .8rem; }
.alert-card { border-left: 4px solid var(--teal-600); }
.alert-card.atencao { border-left-color: var(--amber); }
.alert-card.critico { border-left-color: var(--red); }

/* Birthdays */
.birthday-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.birthday-preview-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 25rem); align-items: center; gap: 1.4rem; }
.birthday-card-image { display: block; width: 100%; max-height: 42rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--forest-900); box-shadow: var(--shadow-md); object-fit: contain; }

/* Dialog */
.confirm-dialog { width: min(calc(100% - 2rem), 34rem); border: 1px solid var(--line); border-radius: 1rem; padding: 0; background: #fff; box-shadow: 0 28px 80px rgba(9, 34, 31, .3); }
.confirm-dialog::backdrop { background: rgba(7, 27, 25, .64); backdrop-filter: blur(3px); }
.confirm-dialog form { padding: 1.5rem; }
.confirm-check { display: flex; grid-template-columns: none; align-items: flex-start; gap: .6rem; margin: 1rem 0; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; }
.schedule-options { display: grid; gap: .65rem; margin: 1rem 0; border: 1px solid var(--line); border-radius: .7rem; padding: .9rem; background: var(--surface-soft); }
.schedule-options p { margin: 0; }
.service-rules-dialog { width: min(calc(100% - 2rem), 42rem); }
.service-rules-content { padding: 1.5rem; }
.service-rules-content > .toolbar { align-items: flex-start; margin-bottom: .8rem; }
.service-rules-content > .toolbar h2 { margin-bottom: 0; }
.service-rule-section { margin-top: 1rem; border: 1px solid var(--line); border-radius: .75rem; padding: .9rem 1rem; background: var(--surface-soft); }
.service-rule-section h3 { margin-bottom: .42rem; font-size: 1rem; }
.service-rules-list { display: grid; gap: .48rem; margin: 0; padding-left: 1.15rem; color: var(--ink-soft); font-size: .88rem; line-height: 1.45; }
.service-rule-warning { border-color: #eed4a6; background: #fff9ed; color: #735017; }
.service-rule-warning p { margin: 0; font-size: .88rem; line-height: 1.5; }

/* Inbox */
.message-item { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.message-item:last-child { border-bottom: 0; }
.message-item.unread { border-left: 3px solid var(--teal-600); padding-left: .8rem; }
.message-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.conversation-search { margin-bottom: 1rem; }
.conversation-list { overflow: hidden; border: 1px solid var(--line); border-radius: .8rem; }
.conversation-row { display: grid; grid-template-columns: 2.55rem minmax(0,1fr) auto; align-items: center; gap: .75rem; width: 100%; border: 0; border-bottom: 1px solid #e7ecea; border-radius: 0; padding: .82rem; background: #fff; color: var(--ink); text-align: left; }
.conversation-row:last-child { border-bottom: 0; }
.conversation-row:hover { background: #f7fbfa; box-shadow: none; transform: none; }
.conversation-row.unread { background: #f0f8f6; }
.conversation-avatar { display: grid; place-items: center; width: 2.55rem; height: 2.55rem; border-radius: 50%; background: var(--teal-100); color: var(--forest-700); font-weight: 900; }
.conversation-main, .conversation-meta { display: flex; flex-direction: column; min-width: 0; }
.conversation-title { overflow: hidden; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.conversation-preview, .conversation-context { overflow: hidden; color: var(--ink-soft); font-size: .82rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.conversation-meta { align-items: flex-end; gap: .25rem; color: var(--ink-soft); font-size: .72rem; font-weight: 650; }
.conversation-badge { display: grid; place-items: center; min-width: 1.3rem; height: 1.3rem; border-radius: 1rem; padding: 0 .35rem; background: var(--teal-600); color: #fff; }
.conversation-header .eyebrow { margin-top: .7rem; }
.chat-panel { padding: .7rem; }
.chat-timeline { display: flex; flex-direction: column; gap: .65rem; min-height: 12rem; max-height: 68vh; overflow-y: auto; border-radius: .7rem; padding: .8rem; background: #e8f0ed; scroll-behavior: smooth; }
.chat-entry { display: flex; justify-content: flex-start; }
.chat-entry.outgoing { justify-content: flex-end; }
.chat-bubble { max-width: min(88%, 38rem); border-radius: .25rem .9rem .9rem .9rem; padding: .68rem .78rem .42rem; background: #fff; box-shadow: 0 2px 8px rgba(15,85,78,.07); }
.chat-entry.outgoing .chat-bubble { border-radius: .9rem .25rem .9rem .9rem; background: #dff3ec; }
.chat-bubble p { margin: .35rem 0; white-space: pre-wrap; line-height: 1.45; }
.chat-time { display: block; margin-top: .25rem; color: #6d807d; font-size: .67rem; text-align: right; }
.chat-image, .chat-video { display: block; max-width: min(100%, 24rem); max-height: 26rem; border-radius: .6rem; object-fit: contain; }
.chat-sticker { display: block; width: min(100%, 10rem); max-height: 10rem; object-fit: contain; }
.chat-audio { width: min(100%, 24rem); }
.chat-notice { margin-top: .7rem; border: 1px solid #eed4a6; border-radius: .6rem; padding: .65rem .8rem; background: #fff9ed; color: #735017; font-size: .78rem; line-height: 1.4; }
.service-window { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; border: 1px solid var(--line); border-left: 4px solid var(--teal-600); border-radius: .8rem; padding: .9rem 1rem; background: #fff; }
.service-window.window-open { background: #f3faf7; }
.service-window.window-closed { border-left-color: var(--red); background: var(--red-soft); }
.service-window p { margin: .25rem 0 0; color: var(--ink-soft); font-size: .82rem; }
.service-reply { margin-top: .8rem; border-top: 1px solid var(--line); padding: 1rem .2rem .2rem; }
.service-reply h3 { margin: .1rem 0; }
.quick-replies { display: flex; flex-wrap: wrap; gap: .45rem; }
.quick-replies button { max-width: 100%; white-space: normal; text-align: left; }
.reply-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.chat-outgoing-meta { display: flex; align-items: center; justify-content: flex-end; gap: .45rem; color: var(--ink-soft); font-size: .68rem; }
.chat-delivery { font-size: .65rem; }
.chat-error { border-top: 1px solid rgba(163,49,35,.18); padding-top: .4rem; color: #8f241b; font-size: .76rem; }
.closed-window-action { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-top: .7rem; }
.closed-window-action .chat-notice { flex: 1; margin: 0; }

@media (max-width: 78rem) {
  .cost-summary { grid-template-columns: repeat(3, minmax(8rem, 1fr)); }
}

@media (max-width: 60rem) {
  .dashboard-shell { display: block; }
  .app-sidebar { position: fixed; left: 0; width: min(18rem, calc(100vw - 3rem)); transform: translateX(-105%); transition: transform .22s ease; }
  .dashboard-shell.sidebar-open .app-sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; z-index: 45; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; padding: 0; background: rgba(7, 27, 25, .55); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
  .sidebar-backdrop:hover { background: rgba(7, 27, 25, .55); box-shadow: none; transform: none; }
  .dashboard-shell.sidebar-open .sidebar-backdrop { display: block; opacity: 1; pointer-events: auto; }
  .icon-button { display: inline-flex; }
  .app-topbar { min-height: 4.5rem; }
  .two-col { grid-template-columns: 1fr; }
  .birthday-preview-card { grid-template-columns: 1fr; }
  .birthday-card-image { max-width: 28rem; margin: 0 auto; }
  #view-home > .grid:first-child { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 42rem) {
  .content-shell { padding: 1rem; }
  .app-topbar { padding: .75rem 1rem; }
  .topbar-copy h2 { font-size: 1.05rem; }
  .topbar-copy .eyebrow { display: none; }
  .logout-button span { display: none; }
  .logout-button { width: 2.55rem; height: 2.55rem; padding: 0; }
  .toolbar { align-items: flex-start; }
  .toolbar:not(.conversation-header) { flex-direction: column; }
  .toolbar:not(.conversation-header) > button, .toolbar:not(.conversation-header) > .actions { width: 100%; }
  .toolbar:not(.conversation-header) > button { justify-content: center; }
  #view-home > .grid:first-child { grid-template-columns: 1fr; }
  #view-home > .grid:first-child .card { min-height: auto; }
  #view-home > .toolbar { margin-top: 1.25rem !important; }
  .grid, .grid.wide { grid-template-columns: 1fr; }
  .birthday-summary { grid-template-columns: 1fr; }
  .cost-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .association-summary { grid-template-columns: 1fr; }
  .conversation-row { grid-template-columns: 2.35rem minmax(0,1fr); }
  .conversation-avatar { width: 2.35rem; height: 2.35rem; }
  .conversation-meta { grid-column: 2; flex-direction: row; align-items: center; }
  .conversation-header { align-items: flex-start; }
  .service-window, .reply-actions, .closed-window-action { align-items: stretch; flex-direction: column; }
  .reply-actions button, .closed-window-action button { width: 100%; justify-content: center; }
  .service-rules-content > .toolbar { flex-direction: column; }
  .service-rules-content > .toolbar > button { width: 100%; justify-content: center; }
  .dialog-actions button { flex: 1 1 10rem; }
}

@media (max-width: 28rem) {
  .cost-summary { grid-template-columns: 1fr; }
  .actions > button { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
