:root {
  color-scheme: light;
  --blue: #0088e8;
  --blue-dark: #0068b2;
  --blue-soft: #d7eeff;
  --lime: #b2f500;
  --lime-soft: #e3ff96;
  --ink: #17212b;
  --muted: #5c6770;
  --warm-white: #fcf9fb;
  --surface: #ffffff;
  --surface-muted: #f5f7f9;
  --surface-strong: #e7ecf0;
  --line: #d4dbe0;
  --line-strong: #7a858e;
  --teal: #006b61;
  --teal-soft: #b4f0e6;
  --warning: #8a4f00;
  --warning-soft: #ffe1b7;
  --danger: #ba1a1a;
  --danger-soft: #ffdad6;
  --shadow: 0 10px 28px rgb(23 33 43 / 10%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--surface-muted);
  color: var(--ink);
  line-height: 1.45;
}

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

button,
select {
  cursor: pointer;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgb(0 136 232 / 24%);
  outline-offset: 2px;
}

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

h1,
h2,
h3 {
  line-height: 1.18;
}

h1 {
  font-size: 1.65rem;
}

h2 {
  margin-bottom: 0;
  font-size: 1.65rem;
}

h3 {
  margin-bottom: 1rem;
  font-size: 1.05rem;
}

svg {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 auto;
  stroke-width: 2;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  background: var(--warm-white);
}

.auth-panel {
  width: min(100%, 25rem);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-logo {
  width: 8rem;
  height: 8rem;
  margin-bottom: 1rem;
  object-fit: contain;
}

.auth-panel h1 {
  margin-bottom: 0.35rem;
  font-size: 2rem;
}

.auth-subtitle {
  margin-bottom: 1.6rem;
  color: var(--muted);
}

.form-stack {
  width: 100%;
  display: grid;
  gap: 0.9rem;
}

.field {
  min-width: 0;
  display: grid;
  gap: 0.4rem;
}

.field > span,
.workspace-picker > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.workspace-picker select {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  padding: 0.7rem 0.8rem;
}

.field textarea {
  resize: vertical;
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.workspace-picker select:hover {
  border-color: var(--blue-dark);
}

.button {
  min-height: 2.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.65rem 1rem;
  font-weight: 750;
  text-decoration: none;
}

.button-primary {
  background: var(--blue-dark);
  color: #fff;
}

.button-primary:hover:not(:disabled) {
  background: #005891;
}

.button-secondary {
  border-color: var(--line);
  background: var(--surface);
}

.button-secondary:hover:not(:disabled) {
  background: var(--surface-muted);
}

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

.button-danger-outline {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}

.button-danger-outline:hover:not(:disabled) {
  background: var(--danger-soft);
}

.text-button {
  border: 0;
  background: transparent;
  padding: 0.25rem;
  color: var(--blue-dark);
  font-weight: 700;
}

.auth-email-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.inline-message {
  width: 100%;
  margin-top: 1rem;
  border-radius: 6px;
  background: var(--blue-soft);
  padding: 0.75rem 0.85rem;
  color: #00304d;
  font-size: 0.88rem;
}

.inline-message.is-error {
  background: var(--danger-soft);
  color: #65000a;
}

.portal-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 1.15rem 0.9rem;
  overflow-y: auto;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.25rem;
}

.brand-row div {
  min-width: 0;
  display: grid;
}

.brand-row strong {
  font-size: 1.12rem;
}

.brand-row span {
  color: var(--muted);
  font-size: 0.76rem;
}

.brand-mark {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 7px;
}

.workspace-picker {
  display: grid;
  gap: 0.4rem;
  padding: 0 0.25rem;
}

.workspace-picker select {
  min-width: 0;
  height: 2.55rem;
  padding: 0.45rem 2rem 0.45rem 0.65rem;
  font-size: 0.9rem;
  font-weight: 650;
}

.primary-nav {
  display: grid;
  gap: 0.3rem;
}

.nav-button {
  width: 100%;
  min-height: 2.65rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 0.65rem 0.75rem;
  color: #43505a;
  font-weight: 700;
  text-align: left;
}

.nav-button:hover {
  background: var(--surface-muted);
}

.nav-button.is-active {
  background: var(--lime-soft);
  color: #1d2a00;
}

.sign-out-button {
  margin-top: auto;
}

.workspace-shell {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  background: rgb(252 249 251 / 94%);
  padding: 0.75rem clamp(1rem, 3vw, 2.5rem);
  backdrop-filter: blur(10px);
}

.topbar-title {
  min-width: 0;
}

.topbar h1 {
  max-width: 48rem;
  margin: 0;
  overflow: hidden;
  font-size: 1.25rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.icon-button {
  width: 2.65rem;
  height: 2.65rem;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.icon-button:hover {
  border-color: var(--blue-dark);
  color: var(--blue-dark);
}

.content {
  width: min(100%, 78rem);
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.5rem);
}

.view-section {
  display: grid;
  gap: 2rem;
}

.section-heading,
.subsection-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  margin-bottom: 0.2rem;
  color: var(--blue-dark);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-badge,
.count-label {
  border-radius: 6px;
  background: var(--teal-soft);
  padding: 0.35rem 0.65rem;
  color: #003c36;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: capitalize;
}

.status-badge.is-parked {
  background: var(--warning-soft);
  color: #542d00;
}

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

.metric-card {
  min-height: 8rem;
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: center;
  gap: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 1.15rem;
}

.metric-card svg {
  grid-row: 1 / 3;
  width: 1.5rem;
  height: 1.5rem;
  color: var(--blue-dark);
}

.metric-card span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.metric-card strong {
  min-width: 0;
  overflow: hidden;
  font-size: 1.28rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(15rem, 0.7fr);
  gap: 2rem;
}

.plain-section {
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 1.25rem;
}

.detail-list {
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: minmax(8rem, 0.5fr) minmax(0, 1fr);
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 0;
}

.detail-list dt {
  color: var(--muted);
}

.detail-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.workspace-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

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

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

.field-full,
.form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.plan-card {
  min-width: 0;
  display: grid;
  gap: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 1rem;
}

.plan-card.is-current {
  border: 2px solid var(--blue-dark);
  padding: calc(1rem - 1px);
}

.plan-card h4 {
  margin: 0;
  font-size: 1rem;
}

.plan-card .plan-price {
  font-size: 1.2rem;
  font-weight: 800;
}

.plan-card .plan-storage {
  color: var(--muted);
  font-size: 0.85rem;
}

.plan-card .button {
  width: 100%;
  margin-top: auto;
}

.storage-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 1.25rem;
}

.cleanup-list {
  display: grid;
}

.cleanup-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  border-bottom: 1px solid var(--line);
  padding: 0.85rem 0;
}

.cleanup-item svg {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.15rem;
  color: var(--blue-dark);
}

.cleanup-item strong,
.cleanup-item span {
  display: block;
}

.cleanup-item span {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.storage-value-row,
.storage-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.storage-value-row strong {
  font-size: 1.5rem;
}

.storage-value-row span,
.storage-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.progress-track {
  height: 0.75rem;
  margin: 1rem 0 0.65rem;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-strong);
}

.progress-track span {
  width: 0;
  height: 100%;
  display: block;
  background: var(--blue);
  transition: width 180ms ease;
}

.progress-track span.is-warning {
  background: var(--warning);
}

.progress-track span.progress-0 { width: 0; }
.progress-track span.progress-5 { width: 5%; }
.progress-track span.progress-10 { width: 10%; }
.progress-track span.progress-15 { width: 15%; }
.progress-track span.progress-20 { width: 20%; }
.progress-track span.progress-25 { width: 25%; }
.progress-track span.progress-30 { width: 30%; }
.progress-track span.progress-35 { width: 35%; }
.progress-track span.progress-40 { width: 40%; }
.progress-track span.progress-45 { width: 45%; }
.progress-track span.progress-50 { width: 50%; }
.progress-track span.progress-55 { width: 55%; }
.progress-track span.progress-60 { width: 60%; }
.progress-track span.progress-65 { width: 65%; }
.progress-track span.progress-70 { width: 70%; }
.progress-track span.progress-75 { width: 75%; }
.progress-track span.progress-80 { width: 80%; }
.progress-track span.progress-85 { width: 85%; }
.progress-track span.progress-90 { width: 90%; }
.progress-track span.progress-95 { width: 95%; }
.progress-track span.progress-100 { width: 100%; }

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.88rem;
}

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

th {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.user-cell {
  min-width: 12rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-avatar {
  width: 2rem;
  height: 2rem;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: #00304d;
  font-size: 0.72rem;
  font-weight: 800;
}

.user-cell strong,
.user-cell span,
.contact-cell span {
  display: block;
}

.user-cell span,
.contact-cell span {
  color: var(--muted);
  font-size: 0.78rem;
}

.table-badge {
  display: inline-block;
  border-radius: 5px;
  background: var(--surface-strong);
  padding: 0.2rem 0.45rem;
  font-size: 0.76rem;
  font-weight: 750;
  text-transform: capitalize;
}

.table-badge.is-available,
.table-badge.is-active {
  background: var(--teal-soft);
  color: #003c36;
}

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

.inline-form {
  display: flex;
  align-items: end;
  gap: 0.8rem;
}

.inline-field {
  width: min(100%, 28rem);
}

.danger-section {
  border-top-color: #e7aaa5;
}

.export-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 1.25rem;
}

.archive-section {
  display: grid;
  gap: 1rem;
}

.archive-controls {
  display: flex;
  align-items: end;
  gap: 0.75rem;
}

.archive-date-field {
  width: min(100%, 15rem);
}

.archive-preview {
  border-left: 3px solid var(--blue-dark);
  background: var(--blue-soft);
  padding: 0.75rem 0.9rem;
  color: #00304d;
  font-size: 0.88rem;
}

.archive-download {
  margin-left: auto;
}

.export-icon {
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.export-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.export-copy h3 {
  margin-bottom: 0.4rem;
}

.compact-list div {
  grid-template-columns: 8rem 1fr;
  border-bottom: 0;
  padding: 0.15rem 0;
  font-size: 0.84rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
}

.empty-workspaces {
  min-height: 65vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.empty-logo {
  width: 5rem;
  height: 5rem;
  margin-bottom: 1rem;
}

.empty-workspaces p {
  color: var(--muted);
}

.toast-region {
  position: fixed;
  z-index: 50;
  top: 1rem;
  right: 1rem;
  width: min(calc(100% - 2rem), 24rem);
  display: grid;
  gap: 0.6rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 0.8rem;
  pointer-events: auto;
}

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

.confirm-dialog {
  width: min(calc(100% - 2rem), 28rem);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 0;
}

.confirm-dialog::backdrop {
  background: rgb(23 33 43 / 42%);
}

.confirm-dialog form {
  padding: 1.4rem;
}

.dialog-icon {
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
}

.confirm-dialog h2 {
  margin: 1rem 0 0.55rem;
  font-size: 1.25rem;
}

.confirm-dialog p {
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1.3rem;
}

.loading-overlay {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(252 249 251 / 64%);
}

.spinner {
  width: 2.4rem;
  height: 2.4rem;
  border: 4px solid var(--blue-soft);
  border-top-color: var(--blue-dark);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

@media (max-width: 980px) {
  .portal-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    z-index: 10;
    height: auto;
    gap: 0.8rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.7rem 1rem;
    overflow: visible;
  }

  .brand-row {
    display: none;
  }

  .workspace-picker {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .primary-nav {
    display: flex;
    gap: 0.3rem;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .primary-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-button {
    width: auto;
    flex: 0 0 auto;
    padding: 0.55rem 0.7rem;
  }

  .sign-out-button {
    position: absolute;
    top: 0.7rem;
    right: 1rem;
  }

  .workspace-picker {
    padding-right: 7.5rem;
  }

  .topbar {
    position: static;
  }

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

@media (max-width: 680px) {
  .content {
    padding: 1.25rem 1rem 2rem;
  }

  .metrics-grid,
  .overview-grid,
  .form-grid,
  .plan-grid {
    grid-template-columns: 1fr;
  }

  .field-wide,
  .field-full {
    grid-column: auto;
  }

  .metric-card {
    min-height: 6.5rem;
  }

  .inline-form,
  .export-panel,
  .archive-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form {
    display: flex;
  }

  .archive-controls {
    display: flex;
  }

  .inline-field {
    width: 100%;
  }

  .archive-date-field,
  .archive-controls .button {
    width: 100%;
  }

  .export-panel {
    display: flex;
  }

  .export-panel .button {
    width: 100%;
  }

  .detail-list div {
    grid-template-columns: 7rem minmax(0, 1fr);
  }

  .primary-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.15rem;
    overflow: visible;
  }

  .primary-nav .nav-button {
    width: 100%;
    min-width: 0;
    min-height: 3.25rem;
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.4rem 0.1rem;
    text-align: center;
  }

  .primary-nav .nav-button span {
    width: 100%;
    overflow: hidden;
    font-size: 0.7rem;
    text-overflow: ellipsis;
  }
}

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