:root {
  --wine: #7d130f;
  --wine-dark: #4b0a08;
  --gold: #d49a19;
  --gold-soft: #f0d28a;
  --ink: #1f1f22;
  --muted: #6f6a67;
  --line: #e8dfd7;
  --paper: #faf7f2;
  --white: #ffffff;
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(135deg, #f8f3eb 0%, #ffffff 48%, #f2e7d8 100%);
}

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

.app-shell {
  min-height: 100vh;
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 48px;
  align-items: center;
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 40px 0;
}

.brand-block {
  max-width: 620px;
}

.logo-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 220px;
  height: 220px;
  isolation: isolate;
  perspective: 1000px;
}

.brand-logo {
  position: relative;
  z-index: 2;
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(240, 210, 138, 0.55);
  box-shadow:
    0 8px 0 #4f0b08,
    0 28px 45px rgba(75, 10, 8, 0.26);
  animation: logoReveal 1.2s ease both, logoFloat 4.2s ease-in-out 1.2s infinite;
}

.logo-orbit {
  position: absolute;
  inset: 14px;
  z-index: 1;
  border: 1px solid rgba(212, 154, 25, 0.44);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(212, 154, 25, 0.18), transparent 55%),
    conic-gradient(from 0deg, transparent, rgba(212, 154, 25, 0.72), transparent 42%);
  filter: blur(0.2px);
  animation: orbitSpin 6s linear infinite, orbitReveal 1s ease both;
}

.logo-shine {
  position: absolute;
  z-index: 3;
  width: 180px;
  height: 180px;
  border-radius: 8px;
  overflow: hidden;
  pointer-events: none;
}

.logo-shine::after {
  content: "";
  position: absolute;
  top: -30%;
  left: -70%;
  width: 42%;
  height: 160%;
  background: linear-gradient(90deg, transparent, rgba(255, 224, 155, 0.72), transparent);
  transform: rotate(22deg);
  animation: shineSweep 2.8s ease-in-out 1s infinite;
}

@keyframes logoReveal {
  from {
    opacity: 0;
    transform: translateY(22px) rotateX(52deg) scale(0.82);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0deg) scale(1);
  }
}

@keyframes logoFloat {
  0%,
  100% {
    transform: translateY(0) rotateY(-4deg);
  }
  50% {
    transform: translateY(-8px) rotateY(4deg);
  }
}

@keyframes orbitReveal {
  from {
    opacity: 0;
    transform: scale(0.7);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes orbitSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shineSweep {
  0%,
  42% {
    left: -70%;
  }
  70%,
  100% {
    left: 130%;
  }
}

.eyebrow {
  margin: 24px 0 8px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 560px;
  margin-bottom: 14px;
  font-size: clamp(2.4rem, 5vw, 4.4rem);
  line-height: 1;
}

.lead {
  max-width: 520px;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.7;
}

.login-card {
  display: grid;
  gap: 12px;
  padding: 30px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(31, 31, 34, 0.12);
}

.login-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 6px;
  background: #f1e9df;
  border-radius: 8px;
}

.login-card .login-mode-button {
  min-height: 42px;
  color: var(--muted);
  background: transparent;
}

.login-card .login-mode-button.is-active {
  color: var(--white);
  background: var(--wine-dark);
  box-shadow: 0 5px 12px rgba(75, 10, 8, 0.18);
}

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

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 54px;
}

.login-card .password-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 40px;
  min-height: 40px;
  padding: 0;
  color: var(--wine-dark);
  background: transparent;
  border-radius: 6px;
}

.login-card .password-toggle:hover,
.login-card .password-toggle:focus-visible {
  background: #f4dfae;
}

.password-toggle svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.office-login-fields {
  display: none;
}

.login-card[data-login-mode="office"] .client-login-fields {
  display: none;
}

.login-card[data-login-mode="office"] .office-login-fields {
  display: grid;
}

.login-feedback {
  min-height: 20px;
  margin: 0;
  color: #a3221d;
  font-size: 0.84rem;
  font-weight: 800;
}

.privacy-summary {
  padding-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.privacy-summary summary {
  color: var(--wine-dark);
  font-weight: 800;
  cursor: pointer;
}

.privacy-summary div {
  max-height: 190px;
  padding: 12px;
  margin-top: 8px;
  overflow-y: auto;
  background: #fff8ea;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.privacy-summary p:last-child {
  margin-bottom: 0;
}

label {
  color: var(--wine-dark);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #d8ccc0;
  border-radius: 6px;
  background: #fffdf9;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(212, 154, 25, 0.25);
  border-color: var(--gold);
}

textarea {
  min-height: 104px;
  padding-top: 12px;
  resize: vertical;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.login-card button,
.message-form button,
.table-like button,
.doc-link,
.upload-card button,
.report-grid button,
.form-actions button,
.deadline-form button {
  color: var(--wine-dark);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
}

.doc-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 6px;
  font-weight: 800;
  text-decoration: none;
}

.login-card a {
  justify-self: start;
  color: var(--wine);
  font-weight: 700;
  text-decoration: none;
}

.fine-print {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

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

.portal-panel {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.portal-panel.role-client .admin-link,
.portal-panel.role-client .office-only {
  display: none !important;
}

.portal-panel.role-office .leo-assistant {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 100vh;
  padding: 24px;
  color: var(--white);
  background: var(--wine-dark);
}

.sidebar-logo {
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: 8px;
  transform: perspective(700px) rotateX(5deg) rotateY(-8deg);
  border: 1px solid rgba(240, 210, 138, 0.42);
  box-shadow:
    0 2px 0 #1f0303,
    0 6px 0 #5d0e0b,
    12px 18px 28px rgba(0, 0, 0, 0.28);
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.logout {
  width: 100%;
  padding: 0 14px;
  color: #f7efe8;
  background: transparent;
  text-align: left;
}

.nav-item.is-active,
.nav-item:hover,
.logout:hover {
  background: rgba(212, 154, 25, 0.18);
}

.admin-link {
  margin-top: 8px;
  border: 1px solid rgba(212, 154, 25, 0.35);
}

.logout {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.content {
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 24px;
}

.topbar .eyebrow {
  margin-top: 0;
}

.topbar h2 {
  margin-bottom: 0;
  font-size: 2rem;
}

.secure-badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--wine-dark);
  background: #f4dfae;
  font-weight: 800;
}

.tab-section {
  display: none;
}

.tab-section.is-visible {
  display: block;
}

.hero-card {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 26px;
  color: var(--white);
  background: linear-gradient(135deg, var(--wine-dark), var(--wine));
  border-radius: 8px;
}

.hero-card .eyebrow,
.hero-card p {
  color: #f7dfb1;
}

.hero-card h3 {
  margin-bottom: 8px;
  font-size: 1.8rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.metric-grid article,
.date-grid article,
.case-info-grid article,
.party-grid article,
.qualification-grid article,
.admin-summary article,
.test-summary article,
.deadline-card,
.party-form-card,
.notice-card,
.table-like,
.message,
.platform-card,
.upload-card,
.about-card,
.contact-card,
.report-grid article,
.timeline li {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(31, 31, 34, 0.06);
}

.metric-grid article {
  padding: 20px;
}

.metric-grid span,
.date-grid span,
.case-info-grid span,
.test-summary span,
.qualification-grid span,
.admin-summary span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.metric-grid strong,
.date-grid strong,
.case-info-grid strong,
.test-summary strong,
.qualification-grid strong,
.admin-summary strong {
  display: block;
  margin-bottom: 8px;
  color: var(--wine-dark);
  font-size: 1.05rem;
}

.platform-card,
.upload-card {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-top: 16px;
  padding: 20px;
}

.platform-card span:first-child,
.upload-card span,
.about-card span,
.contact-card span,
.report-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.platform-card strong,
.upload-card strong,
.about-card strong,
.contact-card strong,
.report-grid strong {
  display: block;
  margin-bottom: 8px;
  color: var(--wine-dark);
  font-size: 1.05rem;
}

.upload-card {
  margin-bottom: 16px;
  background: #fff8ea;
}

.upload-card button {
  min-width: 160px;
  padding: 0 16px;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading h3 {
  margin-bottom: 6px;
  font-size: 1.6rem;
}

.section-heading p {
  color: var(--muted);
}

.timeline {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  position: relative;
  padding: 20px 20px 20px 34px;
}

.timeline li::before {
  content: "";
  position: absolute;
  top: 24px;
  left: 16px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.timeline time {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.timeline strong {
  color: var(--wine-dark);
}

.timeline p,
.notice-card p,
.message p,
.platform-card p,
.upload-card p,
.about-card p,
.contact-card p,
.report-grid p,
.admin-summary p,
.date-grid p,
.case-info-grid p,
.party-grid p,
.qualification-grid p,
.form-section-title p,
.test-summary p,
.case-date-list p,
.metric-grid p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.table-like {
  overflow: hidden;
}

.table-like div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px 120px;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.table-like div:last-child {
  border-bottom: 0;
}

.table-like span {
  color: var(--muted);
}

.document-list div {
  grid-template-columns: minmax(0, 1fr) 140px 120px;
}

.uploaded-file-actions {
  display: flex !important;
  grid-template-columns: none !important;
  gap: 8px !important;
  padding: 0 !important;
  border: 0 !important;
}

.uploaded-file-actions .doc-link,
.uploaded-file-actions button {
  min-height: 40px;
  padding: 0 11px;
  font-size: 0.82rem;
}

.uploaded-file-actions .remove-uploaded-file {
  color: #8f1f1a;
  background: #fff1ef;
  border: 1px solid #edc4bf;
}

.uploaded-file-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

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

.report-grid article {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.report-grid .uploaded-file-actions {
  margin-top: auto;
}

.document-upload-dialog {
  width: min(720px, calc(100% - 28px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(31, 31, 34, 0.28);
}

.document-upload-dialog::backdrop {
  background: rgba(31, 10, 9, 0.62);
}

.password-change-dialog {
  width: min(560px, calc(100% - 28px));
}

.document-preview-dialog {
  width: min(1000px, calc(100% - 28px));
  height: min(820px, calc(100vh - 32px));
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(31, 31, 34, 0.28);
}

.document-preview-dialog::backdrop {
  background: rgba(31, 10, 9, 0.72);
}

.document-preview-dialog > header,
.document-preview-dialog > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
}

.document-preview-dialog > header {
  color: var(--white);
  background: var(--wine);
}

.document-preview-dialog > header span {
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.document-preview-dialog > header h3 {
  margin: 2px 0 0;
}

.document-preview-dialog > footer {
  border-top: 1px solid var(--line);
}

.document-preview-body {
  height: calc(100% - 146px);
  min-height: 360px;
  background: #ececec;
}

.document-preview-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--white);
}

.document-external-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid #d8ccc0;
  border-radius: 6px;
}

.document-upload-form > header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 18px 20px;
  color: var(--white);
  background: var(--wine-dark);
}

.document-upload-form > header span {
  display: block;
  margin-bottom: 4px;
  color: var(--gold-soft);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.document-upload-form > header h3 {
  margin: 0;
}

.dialog-close {
  width: 40px;
  min-height: 40px;
  flex: 0 0 40px;
  color: var(--white);
  background: transparent;
  font-size: 1.7rem;
}

.upload-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
}

.upload-form-grid small {
  color: var(--muted);
  line-height: 1.4;
}

.document-upload-form > footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 20px;
}

.document-upload-form > footer button {
  min-width: 130px;
  padding: 0 14px;
  color: var(--wine-dark);
  background: var(--gold);
}

.document-upload-form > footer .secondary-action {
  background: var(--white);
  border: 1px solid #d8ccc0;
}

.dialog-feedback {
  min-height: 22px;
  margin: 0;
  padding: 0 20px;
  color: #176b45;
  font-weight: 800;
}

.dialog-feedback.is-error {
  color: #a3221d;
}

.role-real-client #clientQualificationHeading,
.role-real-client #clientQualificationGrid {
  display: none;
}

@media (max-width: 640px) {
  .document-preview-dialog {
    width: calc(100% - 16px);
    height: calc(100vh - 16px);
  }

  .document-preview-dialog > footer {
    align-items: stretch;
    flex-direction: column;
  }

  .document-preview-body {
    height: calc(100% - 204px);
  }
}

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

.date-grid article {
  padding: 18px;
}

.case-info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.case-info-grid article,
.party-grid article {
  padding: 18px;
}

.party-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.party-grid h4 {
  margin: 0 0 12px;
  color: var(--wine-dark);
  font-size: 1.05rem;
}

.party-grid ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.qualification-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.qualification-grid article {
  padding: 18px;
}

.qualification-grid dl {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.qualification-grid dl div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.qualification-grid dt {
  color: var(--muted);
  font-weight: 800;
}

.qualification-grid dd {
  margin: 0;
  color: var(--ink);
}

.case-date-list {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.case-date-list article {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 110px;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 12px 30px rgba(31, 31, 34, 0.06);
}

.case-date-list article.is-next {
  border-color: var(--gold);
  background: #fff8ea;
}

.case-date-list time {
  color: var(--wine-dark);
  font-weight: 900;
}

.case-date-list strong {
  display: block;
  margin-bottom: 6px;
  color: var(--wine-dark);
}

.case-date-list article > span {
  justify-self: end;
  min-width: 92px;
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--wine-dark);
  background: #f4dfae;
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
}

.deadline-card {
  padding: 20px;
}

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

.deadline-form button {
  padding: 0 16px;
}

.deadline-result {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  color: var(--wine-dark);
  background: #fff8ea;
  font-weight: 900;
}

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

.admin-summary article {
  padding: 18px;
}

.prototype-warning {
  margin-bottom: 16px;
  padding: 16px 18px;
  color: var(--wine-dark);
  background: #fff3d7;
  border: 1px solid #e5c26e;
  border-radius: 8px;
}

.prototype-warning strong {
  display: block;
  margin-bottom: 5px;
}

.prototype-warning p,
.client-list-heading p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.database-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px 24px;
  margin-bottom: 18px;
  padding: 20px;
  background: var(--white);
  border: 1px solid #b9d9ca;
  border-left: 5px solid #176b45;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(31, 31, 34, 0.06);
}

.database-panel span {
  display: block;
  margin-bottom: 5px;
  color: #176b45;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.database-panel h4 {
  margin: 0 0 6px;
  color: var(--wine-dark);
  font-size: 1.15rem;
}

.database-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.database-panel-actions {
  display: grid;
  gap: 10px;
  align-content: start;
  justify-items: end;
}

.database-panel-actions strong {
  color: #176b45;
}

.database-panel-actions button {
  padding: 0 16px;
  color: var(--white);
  background: #176b45;
}

.database-feedback,
.database-case-list {
  grid-column: 1 / -1;
}

.database-feedback {
  min-height: 20px;
  font-weight: 800;
}

.database-feedback.is-error {
  color: #a3221d;
}

.database-case-list {
  box-shadow: none;
}

.database-case-list div {
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px) 150px;
}

.database-case-list small {
  color: #176b45;
  font-weight: 800;
}

.access-management {
  margin-bottom: 18px;
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(31, 31, 34, 0.06);
}

.access-management > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  color: var(--white);
  background: var(--wine-dark);
}

.access-management > header span:first-child {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.access-management > header h4,
.access-management > header p {
  margin: 0;
}

.access-management > header h4 {
  font-size: 1.16rem;
}

.access-management > header p {
  margin-top: 5px;
  color: #eadbd8;
}

.access-security-badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  color: var(--wine-dark);
  background: var(--gold-soft);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
}

.access-management-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
}

.access-management-actions,
.access-privacy-note,
.access-management-form .admin-feedback {
  grid-column: 1 / -1;
}

.access-management-actions,
.access-delivery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.access-management-actions button,
.access-delivery-actions a,
.access-delivery-actions button {
  min-height: 44px;
  padding: 0 16px;
}

.access-management-actions .secondary-action,
.access-delivery-actions .secondary-action {
  color: var(--wine-dark);
  background: var(--white);
  border: 1px solid #d8ccc0;
}

.access-management-actions .danger-action {
  color: #8b1e1a;
  background: #fff1ef;
  border: 1px solid #e0aaa5;
}

.access-privacy-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.access-delivery {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  background: #f3faf6;
  border-top: 1px solid #b9d9ca;
}

.access-delivery[hidden] {
  display: none;
}

.access-delivery strong {
  color: #176b45;
}

.access-delivery p {
  margin: 4px 0 0;
  color: var(--muted);
}

.access-delivery-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 6px;
}

.access-delivery-actions .whatsapp-action {
  color: var(--white);
  background: #176b45;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8ea;
  box-shadow: 0 12px 30px rgba(31, 31, 34, 0.06);
}

.form-field {
  display: grid;
  gap: 8px;
}

.form-section-title,
.party-form-card {
  grid-column: 1 / -1;
}

.form-section-title {
  padding-top: 8px;
  border-top: 1px solid rgba(75, 10, 8, 0.14);
}

.form-section-title:first-child {
  padding-top: 0;
  border-top: 0;
}

.form-section-title h4 {
  margin: 0 0 6px;
  color: var(--wine-dark);
  font-size: 1.08rem;
}

.form-field.wide,
.form-actions {
  grid-column: span 2;
}

.party-form-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(75, 10, 8, 0.14);
  border-radius: 8px;
  background: var(--white);
}

.party-form-card button {
  min-height: 46px;
  align-self: end;
  color: var(--wine-dark);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: end;
}

.form-actions button {
  min-width: 150px;
  padding: 0 16px;
}

.form-actions .secondary-action {
  color: var(--wine-dark);
  background: var(--white);
  border: 1px solid #d8ccc0;
}

.admin-feedback {
  grid-column: 1 / -1;
  min-height: 22px;
  margin: 0;
  color: #176b45;
  font-weight: 800;
}

.admin-feedback.is-error {
  color: #a3221d;
}

.client-list-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin: 24px 0 12px;
}

.client-list-heading h4 {
  margin: 0 0 5px;
  color: var(--wine-dark);
  font-size: 1.1rem;
}

.client-list-heading > span {
  padding: 8px 12px;
  color: var(--wine-dark);
  background: #f4dfae;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.client-list div {
  grid-template-columns: minmax(0, 1fr) minmax(180px, 230px) 160px 180px;
}

.client-list small {
  color: var(--wine-dark);
  font-weight: 800;
}

.client-actions {
  display: flex !important;
  grid-template-columns: none !important;
  gap: 8px !important;
  flex-wrap: wrap;
  padding: 0 !important;
  border: 0 !important;
}

.client-actions button {
  min-height: 38px;
  padding: 0 12px;
  color: var(--wine-dark);
  background: #f4dfae;
}

.client-actions .delete-record {
  color: #8f1f1a;
  background: #fff1ef;
  border: 1px solid #edc4bf;
}

.client-actions .archive-record {
  color: var(--white);
  background: var(--wine);
}

.client-actions .reopen-record {
  color: var(--white);
  background: #176b45;
}

.client-list-empty {
  display: block !important;
  padding: 24px !important;
  color: var(--muted);
  text-align: center;
}

.internal-documents-section,
.archived-cases-section {
  margin-top: 28px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.archived-list {
  background: #f7f4ef;
}

.archived-list > div:not(.client-list-empty) {
  opacity: 0.9;
}

.closure-case-summary {
  margin: 20px 20px 0;
  padding: 14px 16px;
  color: var(--wine-dark);
  background: #fff3d7;
  border: 1px solid #e5c26e;
  border-radius: 8px;
  line-height: 1.5;
}

.closure-case-summary strong,
.closure-case-summary span {
  display: block;
}

.closure-case-summary span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
}

.closure-notice {
  margin: 0;
  padding: 0 20px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.test-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.test-summary article {
  padding: 18px;
}

.test-checklist {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 12px 30px rgba(31, 31, 34, 0.06);
}

.test-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 120px 120px minmax(220px, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.test-row:last-child {
  border-bottom: 0;
}

.test-head {
  color: var(--wine-dark);
  background: #fff8ea;
}

.test-row label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-weight: 800;
}

.test-row input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--gold);
}

.notice-card {
  padding: 22px;
}

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

.about-card {
  padding: 20px;
}

.section-heading.compact {
  margin-top: 24px;
  margin-bottom: 12px;
}

.practice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.practice-grid span {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--wine-dark);
  background: #fff8ea;
  font-weight: 800;
}

.contact-card {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 16px;
  padding: 20px;
}

.contact-card a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  min-width: 180px;
  padding: 0 16px;
  border-radius: 6px;
  color: var(--wine-dark);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  font-weight: 800;
  text-decoration: none;
}

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

.message {
  max-width: 680px;
  padding: 16px;
}

.message.client {
  justify-self: end;
  background: #fff8ea;
}

.message-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
  margin-top: 16px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.leo-assistant {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
}

.leo-launcher {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 6px 16px 6px 6px;
  color: var(--white);
  background: var(--wine-dark);
  border: 1px solid rgba(240, 210, 138, 0.7);
  border-radius: 999px;
  box-shadow: 0 16px 36px rgba(75, 10, 8, 0.3);
}

.leo-launcher:hover,
.leo-launcher:focus-visible {
  background: var(--wine);
  transform: translateY(-2px);
}

.leo-launcher img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  object-position: 50% 17%;
  border: 2px solid var(--gold-soft);
  border-radius: 50%;
}

.leo-launcher span {
  display: grid;
  gap: 2px;
  text-align: left;
}

.leo-launcher small {
  color: #f0d28a;
  font-weight: 600;
}

.leo-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  display: grid;
  grid-template-rows: auto minmax(150px, 1fr) auto auto auto;
  width: min(380px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 120px));
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(31, 31, 34, 0.24);
  animation: leoOpen 180ms ease-out;
}

.leo-panel[hidden] {
  display: none;
}

.leo-header {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  color: var(--white);
  background: var(--wine-dark);
}

.leo-header-avatar {
  width: 48px;
  height: 48px;
  object-fit: cover;
  object-position: 50% 17%;
  border: 2px solid var(--gold-soft);
  border-radius: 50%;
}

.leo-header strong,
.leo-header span {
  display: block;
}

.leo-header strong {
  color: var(--gold-soft);
  font-size: 1.08rem;
}

.leo-header span {
  margin-top: 2px;
  color: #f7efe8;
  font-size: 0.78rem;
}

.leo-close {
  min-height: 36px;
  color: var(--white);
  background: transparent;
  font-size: 1.7rem;
  line-height: 1;
}

.leo-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.leo-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 190px;
  padding: 14px;
  overflow-y: auto;
  background: var(--paper);
}

.leo-message {
  max-width: 88%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.leo-message strong {
  display: block;
  margin-bottom: 4px;
  color: var(--wine-dark);
  font-size: 0.78rem;
}

.leo-message p {
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.45;
}

.leo-message-user {
  justify-self: end;
  background: #fff3d7;
}

.leo-shortcuts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.leo-shortcuts button,
.leo-shortcuts a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 7px 9px;
  color: var(--wine-dark);
  background: #fff8ea;
  border: 1px solid #ead29c;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.leo-shortcuts a {
  grid-column: 1 / -1;
  color: var(--white);
  background: #176b45;
  border-color: #176b45;
}

.leo-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 8px;
  padding: 0 12px 10px;
}

.leo-form input {
  min-height: 42px;
}

.leo-form button {
  min-height: 42px;
  color: var(--wine-dark);
  background: var(--gold);
}

.leo-disclaimer {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
}

@keyframes leoOpen {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 840px) {
  .login-panel,
  .portal-panel {
    grid-template-columns: 1fr;
  }

  .login-panel {
    gap: 28px;
  }

  .logo-stage {
    width: 170px;
    height: 170px;
  }

  .brand-logo,
  .logo-shine {
    width: 140px;
    height: 140px;
  }

  .sidebar {
    min-height: auto;
  }

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

  .metric-grid,
  .date-grid,
  .case-info-grid,
  .admin-summary,
  .test-summary,
  .admin-form,
  .deadline-form {
    grid-template-columns: 1fr;
  }

  .hero-card,
  .topbar,
  .platform-card,
  .upload-card,
  .contact-card,
  .table-like div,
  .message-form {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

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

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

  .upload-form-grid .wide {
    grid-column: auto;
  }

  .document-upload-form > footer {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .uploaded-file-actions {
    flex-wrap: wrap;
  }

  .about-grid,
  .practice-grid,
  .party-grid,
  .qualification-grid,
  .party-form-card {
    grid-template-columns: 1fr;
  }

  .case-date-list article {
    grid-template-columns: 1fr;
  }

  .case-date-list article > span {
    justify-self: start;
  }

  .form-field.wide,
  .party-form-card,
  .form-actions {
    grid-column: auto;
  }

  .qualification-grid dl div {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

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

  .test-head {
    display: none;
  }

  .client-list-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .database-panel {
    grid-template-columns: 1fr;
  }

  .database-panel-actions {
    justify-items: stretch;
  }

  .access-management > header,
  .access-delivery {
    align-items: stretch;
    flex-direction: column;
  }

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

  .access-management-form .wide,
  .access-management-actions,
  .access-privacy-note,
  .access-management-form .admin-feedback {
    grid-column: auto;
  }

  .access-management-actions,
  .access-delivery-actions {
    flex-direction: column;
  }

  .client-actions {
    justify-content: flex-start;
  }

  .leo-assistant {
    right: 12px;
    bottom: 12px;
  }

  .leo-panel {
    position: fixed;
    right: 12px;
    bottom: 84px;
    width: calc(100vw - 24px);
    max-height: calc(100vh - 100px);
  }

  .leo-launcher {
    min-height: 58px;
    padding-right: 12px;
  }

  .leo-launcher img {
    width: 44px;
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .leo-panel,
  .leo-launcher {
    animation: none;
    transition: none;
  }
}
