:root {
  --purple-dark: #211543;
  --purple-mid: #5c3df5;
  --purple-light: #9272ff;
  --purple-soft: #efe9ff;
  --gold: #f9a633;
  --card-bg: #ffffff;
  --surface: rgba(255, 255, 255, 0.75);
  --text-strong: #1f1b2e;
  --text-muted: #5c6073;
  --border-soft: rgba(255, 255, 255, 0.25);
  --border-card: rgba(47, 43, 67, 0.06);
  --shadow: 0 12px 32px rgba(31, 27, 46, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-strong);
  background: linear-gradient(130deg, var(--purple-dark) 0%, var(--purple-mid) 50%, #372369 100%);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  color: #fff;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.35rem;
}

.topbar img {
  width: 30px;
  height: 30px;
  filter: brightness(0) invert(1);
}

nav {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

nav .nav-link,
button.ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

button.ghost {
  cursor: not-allowed;
}

.container {
  width: min(1260px, 92vw);
  margin: 0 auto 3rem;
}

.page-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2.25rem;
}

@media (max-width: 1000px) {
  .page-layout {
    grid-template-columns: 1fr;
  }
}

.filter-panel {
  background: var(--surface);
  border-radius: 24px;
  padding: 1.75rem;
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-soft);
  color: var(--text-strong);
  box-shadow: 0 18px 42px rgba(12, 5, 26, 0.18);
}

.filter-panel header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.filter-panel header p {
  margin: 0.3rem 0 1.4rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

#filter-form {
  display: grid;
  gap: 1.1rem;
}

#filter-form label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

#filter-form input,
#filter-form select {
  width: 100%;
  border: 1px solid rgba(94, 104, 133, 0.18);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}

#filter-form input:focus,
#filter-form select:focus {
  outline: none;
  border-color: var(--purple-mid);
  box-shadow: 0 0 0 3px rgba(92, 61, 245, 0.18);
}

.records-panel {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.6rem;
  color: #fff;
}

.panel-header p {
  margin: 0.4rem 0 0;
  color: rgba(255, 255, 255, 0.78);
}

.records-card {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-card);
  backdrop-filter: blur(12px);
}

.records-grid {
  width: 100%;
  border-collapse: collapse;
}

.records-grid thead {
  background: var(--purple-soft);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.records-grid th,
.records-grid td {
  padding: 0.75rem 0.65rem;
  text-align: left;
}

.records-grid th.numeric,
.records-grid td.numeric {
  text-align: right;
}

.record-row {
  cursor: pointer;
  border-bottom: 1px solid rgba(125, 132, 152, 0.12);
  transition: background 0.2s, transform 0.2s;
}

.record-row:hover {
  background: rgba(146, 114, 255, 0.08);
}

.records-pagination {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.records-pagination__info {
  display: flex;
  justify-content: flex-start;
}

.records-pagination__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.pagination-status {
  flex: 1;
  text-align: center;
  font-weight: 600;
  color: var(--text-strong);
}

.pagination-btn {
  border: none;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  background: var(--purple-mid);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s ease;
  min-width: 90px;
}

.pagination-btn:hover:not(:disabled) {
  filter: brightness(1.05);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.record-row--selected {
  background: rgba(92, 61, 245, 0.09);
  border-bottom-color: rgba(92, 61, 245, 0.22);
}

.doc-primary {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-strong);
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-secondary {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(92, 61, 245, 0.1);
  color: var(--purple-mid);
}

.pill--category {
  background: rgba(249, 166, 51, 0.16);
  color: var(--gold);
}

.record-details-row td {
  padding: 0;
}

.detail-card {
  padding: 1.25rem 1.4rem 1.8rem;
  background: linear-gradient(180deg, rgba(146, 114, 255, 0.14) 0%, rgba(255, 255, 255, 0.92) 45%, #fff 100%);
  border-radius: 18px;
  border: 1px solid rgba(92, 61, 245, 0.18);
  margin-bottom: 0.8rem;
  box-shadow: 0 18px 28px rgba(31, 27, 46, 0.12);
}

.detail-card header {
  display: flex;
  justify-content: space-between;
  gap: 1.2rem;
  align-items: flex-start;
}

.detail-card header h4 {
  margin: 0;
  font-size: 1.1rem;
}

.detail-card header p {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  max-width: 620px;
}

.detail-actions {
  display: flex;
  gap: 0.6rem;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--purple-mid);
  color: #fff;
  cursor: pointer;
}

.btn--ghost {
  background: rgba(92, 61, 245, 0.12);
  color: var(--purple-mid);
}

.btn:hover {
  filter: brightness(1.05);
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.8rem;
  margin: 1.25rem 0;
}

.detail-meta .label {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.detail-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.1rem;
  font-size: 0.85rem;
}

.detail-sections h5 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
}

.detail-sections ul {
  margin: 0;
  padding-left: 1rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state h4 {
  margin-bottom: 0.4rem;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(13, 9, 25, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-in-out;
}

.modal--open {
  opacity: 1;
  pointer-events: auto;
}

.modal__dialog {
  background: #ffffff;
  border-radius: 16px;
  width: min(92vw, 860px);
  max-height: 90vh;
  padding: 1.25rem;
  position: relative;
  overflow: auto;
  box-shadow: var(--shadow);
}

.modal__close {
  position: absolute;
  top: 0.6rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
}

.pdf-frame {
  width: 100%;
  height: 75vh;
  border: 1px solid rgba(94, 104, 133, 0.18);
  border-radius: 12px;
}

.text-block {
  background: #13102b;
  color: #f1f5ff;
  padding: 1.1rem;
  border-radius: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: 0.84rem;
  max-height: 72vh;
  overflow-y: auto;
}


.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.0);
  background: rgba(92, 61, 245, 0.12);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  background: rgba(92, 61, 245, 0.22);
}

.icon-btn img {
  filter: none;
}


.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.user-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
}

.user-greeting {
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.user-trigger img {
  width: 20px;
  height: 20px;
}

.user-trigger__chevron {
  width: 12px;
  height: 12px;
  opacity: 0.8;
}

.user-menu__dropdown {
  position: absolute;
  top: 110%;
  right: 0;
  background: #1f1f3d;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 30px rgba(18, 18, 43, 0.25);
  padding: 0.6rem 0;
  min-width: 190px;
  display: none;
  flex-direction: column;
  z-index: 10;
}

.user-menu__dropdown a,
.user-menu__dropdown button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  background: transparent;
  border: none;
  color: #f0f5ff;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.user-menu__dropdown a:hover,
.user-menu__dropdown button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.user-menu--open .user-menu__dropdown {
  display: flex;
}

.account-layout {
  display: grid;
  gap: 2.5rem;
  grid-template-columns: 260px 1fr;
}

.account-nav {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: rgba(24, 36, 92, 0.35);
  padding: 1.2rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
}

.account-nav h2 {
  font-size: 1.35rem;
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
}

.account-nav nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.account-nav__link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}

.account-nav__link--active {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.account-nav__link:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.85);
}

.account-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(17, 24, 39, 0.08);
  border: 1px solid rgba(17, 24, 39, 0.06);
  margin-bottom: 1.5rem;
}

.account-card__header h3 {
  margin: 0;
  font-size: 1.28rem;
}

.account-card__header p {
  color: #65708a;
  margin-top: 0.15rem;
}

.account-card__header--with-icon {
  display: flex;
  align-items: center;
}

.account-card__title {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.account-card__title img {
  width: 36px;
  height: 36px;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.2rem;
  margin-top: 1.4rem;
}

.account-grid__full {
  grid-column: 1 / -1;
}

.account-grid .label {
  display: block;
  color: #8089a6;
  margin-bottom: 0.3rem;
}

.activity-list {
  list-style: none;
  padding: 0;
  margin: 1.2rem 0 0;
}

.activity-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(17, 24, 39, 0.06);
}

.activity-list li:last-child {
  border-bottom: none;
}

.muted {
  color: #8089a6;
}

.flash {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 18px 38px rgba(17, 24, 39, 0.22);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1100;
  min-width: min(430px, 90vw);
  backdrop-filter: blur(18px);
  pointer-events: auto;
}

.flash__message {
  flex: 1;
}

.flash--success {
  background: rgba(34, 197, 94, 0.42);
  color: #ffffff;
  border: 1px solid rgba(34, 197, 94, 0.5);
}

.flash--error {
  background: rgba(239, 68, 68, 0.42);
  color: #ffffff;
  border: 1px solid rgba(239, 68, 68, 0.5);
}

.flash--info {
  background: rgba(59, 130, 246, 0.42);
  color: #ffffff;
  border: 1px solid rgba(59, 130, 246, 0.5);
}

.flash--hidden {
  opacity: 0;
  transform: translate(-50%, -10px);
  pointer-events: none;
}

.flash__close {
  border: none;
  background: transparent;
  font-size: 1.1rem;
  line-height: 1;
  color: inherit;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.connector-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.04);
  margin-top: 1.4rem;
}

.connector-status--active {
  background: rgba(66, 114, 255, 0.12);
  border: 1px solid rgba(66, 114, 255, 0.2);
}

.connector-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-align: right;
  color: #65708a;
}

.connector-actions {
  margin-top: 1.2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: #365cff;
  color: #fff;
  border-radius: 999px;
  padding: 0.55rem 1.3rem;
  font-weight: 600;
}

.btn:hover {
  background: #2446f2;
}

.btn--danger {
  background: #f2545b;
}

.btn--danger:hover {
  background: #dd3e46;
}

.btn img {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(1);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.2rem;
}

.template-card {
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 16px;
  background: rgba(17, 24, 39, 0.02);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease;
}

.template-card input[type="radio"] {
  align-self: flex-end;
}

.template-card__body h4 {
  margin: 0;
  font-size: 1rem;
}

.template-card__body p {
  margin: 0;
  color: #65708a;
  font-size: 0.9rem;
}

.template-card__body code {
  display: inline-block;
  padding: 0.35rem 0.5rem;
  background: rgba(66, 114, 255, 0.12);
  color: #2446f2;
  border-radius: 8px;
  font-size: 0.85rem;
}

.template-card input[type="radio"]:checked + .template-card__body,
.template-card:has(input[type="radio"]:checked) {
  border: 1px solid rgba(66, 114, 255, 0.4);
  background: rgba(66, 114, 255, 0.1);
}

.template-actions {
  grid-column: 1 / -1;
  margin-top: 0.5rem;
}

.mono {
  font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@media (max-width: 1024px) {
  .account-layout {
    grid-template-columns: 1fr;
  }

  .account-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: flex-start;
  }

  .account-nav nav {
    display: flex;
    gap: 0.6rem;
  }

  .account-nav__link {
    margin-bottom: 0;
  }
}
