* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f8;
  color: #1f2937;
}

a {
  color: #2563eb;
  text-decoration: none;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.65rem 1rem;
  border: 0;
  border-radius: 0.5rem;
  background: #2563eb;
  color: #fff;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.button-link {
  text-decoration: none;
}

.button-secondary {
  background: #4b5563;
}

.button-danger,
.button-link-danger {
  background: #b91c1c;
}

input,
select {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.45rem;
  background: #fff;
  color: #111827;
  font: inherit;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  color: #374151;
  font-weight: 700;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(420px, calc(100vw - 2rem));
  padding: 2rem;
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.app-header {
  flex: 0 0 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  background: #172033;
  color: #fff;
}

.app-title {
  flex: 0 0 auto;
  font-weight: 800;
}

.app-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  min-width: 0;
}

.header-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.25rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.header-button-back {
  min-width: 5.7rem;
  border-color: rgba(203, 213, 225, 0.65);
  background: #64748b;
}

.header-button:hover,
.user-menu__trigger:hover,
.user-menu__trigger:focus-visible,
.user-menu.is-open .user-menu__trigger {
  transform: translateY(-1px);
}

.header-button-back:hover {
  background: #475569;
}

.user-menu {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
}

.user-menu__trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 3rem;
  max-width: 18rem;
  padding: 0.35rem 1rem 0.35rem 0.35rem;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #fff;
  color: #111827;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(26, 42, 68, 0.12);
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.user-menu__trigger:hover,
.user-menu__trigger:focus-visible,
.user-menu.is-open .user-menu__trigger {
  border-color: #93c5fd;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.18);
  outline: none;
}

.user-menu__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  flex-shrink: 0;
}

.user-menu__avatar-icon {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
}

.user-menu__copy {
  display: grid;
  min-width: 0;
  text-align: left;
}

.user-menu__copy strong {
  overflow: hidden;
  max-width: 12rem;
  font-size: 0.9rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu__dropdown {
  position: absolute;
  top: calc(100% + 0.65rem);
  right: 0;
  z-index: 20;
  display: grid;
  gap: 0.5rem;
  min-width: 280px;
  padding: 0.75rem;
  border: 1px solid #d8e0ea;
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 22px 54px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.user-menu.is-open .user-menu__dropdown {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.user-menu__item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 1rem;
  background: transparent;
  color: #1f2937;
  text-align: left;
}

.user-menu__item:hover,
.user-menu__item:focus-visible {
  border-color: rgba(37, 99, 235, 0.18);
  background: #eff6ff;
  outline: none;
}

.user-menu__item--info:hover {
  border-color: transparent;
  background: transparent;
}

.user-menu__item-icon {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.12rem;
  flex-shrink: 0;
}

.user-menu__item-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.25rem;
  margin-top: 0.12rem;
  border-radius: 0.3rem;
  background: #2563eb;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
}

.user-menu__item span:not(.user-menu__item-badge) {
  display: grid;
  min-width: 0;
  gap: 0.25rem;
}

.user-menu__item strong,
.user-menu__item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu__item strong {
  font-size: 0.9rem;
}

.user-menu__item small {
  color: #64748b;
  font-size: 0.78rem;
  line-height: 1.45;
}

.app-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 1.5rem;
}

.card {
  min-width: 0;
  padding: 1.25rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: #fff;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

.card-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-header h1,
.card-header h2 {
  margin: 0;
  color: #111827;
  font-size: 1.15rem;
  line-height: 1.3;
}

pre {
  max-height: 12rem;
  overflow: auto;
  padding: 1rem;
  background: #f3f4f6;
  border-radius: 0.5rem;
  white-space: pre-wrap;
}

.alert {
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.alert-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.dashboard-page,
.folder-detail-page {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.dashboard-page {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 1.5rem;
}

.create-folder-card {
  flex: 0 0 auto;
}

.create-folder-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-start;
}

.create-folder-form .form-field-wide {
  width: min(100%, calc(50em + 1.4rem + 2px));
}

.create-folder-form button {
  align-self: flex-start;
}

.form-field {
  min-width: 0;
  margin-bottom: 1rem;
}

.form-field-wide {
  margin-bottom: 0;
}

.field-help {
  margin: 0.45rem 0 0;
  color: #64748b;
  font-size: 0.9rem;
}

.folder-list-card,
.shared-items-card {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.folder-list-card .card-header,
.shared-items-card .card-header {
  flex: 0 0 auto;
}

.scroll-list-area {
  flex: 1 1 auto;
  min-height: min(280px, 45vh);
  overflow-y: auto;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
}

.items-table th,
.items-table td {
  padding: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: top;
}

.items-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  color: #4b5563;
  font-size: 0.9rem;
}

.table-row-clickable:hover,
.table-row-clickable:focus {
  background: #f5f7fa;
  cursor: pointer;
  outline: none;
}

.folder-detail-page {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.page-messages:empty {
  display: none;
}

.detail-top-grid {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 4fr 6fr;
  gap: 1.5rem;
  min-height: 0;
}

.folder-detail-page .shared-items-card {
  flex: 1 1 auto;
}

.detail-list {
  display: grid;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.detail-list div {
  min-width: 0;
}

.detail-list dt {
  margin-bottom: 0.2rem;
  color: #64748b;
  font-size: 0.84rem;
  font-weight: 700;
}

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

.long-url {
  overflow-wrap: anywhere;
}

.shared-link-card {
  padding-bottom: 1rem;
}

.shared-link-card .alert {
  margin-bottom: 0.85rem;
  padding: 0.65rem 0.85rem;
}

.shared-link-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0 0 0.75rem;
}

.status-tile {
  min-width: 0;
  padding: 0.7rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  background: #f8fafc;
}

.status-tile dt,
.compact-label {
  display: block;
  margin-bottom: 0.22rem;
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 800;
}

.status-tile dd {
  min-width: 0;
  margin: 0;
  color: #111827;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.shared-link-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: end;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: #fff;
}

.shared-link-url-main {
  min-width: 0;
}

.shared-link-url-main .long-url {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shared-link-url-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.shared-link-secret-row {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  padding: 0.45rem 0.65rem;
  border-radius: 0.5rem;
  background: #f1f5f9;
}

.shared-link-secret-row .compact-label {
  margin-bottom: 0;
}

.masked-password {
  min-width: 7.5rem;
  letter-spacing: 0;
}

.password-toggle-button {
  min-height: 1.9rem;
  width: 2.1rem;
  padding: 0;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.button-row form {
  margin: 0;
}

.shared-link-form {
  display: grid;
  grid-template-columns: minmax(9rem, 1fr) minmax(9rem, 1fr);
  gap: 0.75rem;
  align-items: end;
  margin-top: 0.75rem;
}

.shared-link-form .form-field {
  margin-bottom: 0;
}

.shared-link-action-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.shared-link-action-row form {
  margin: 0;
}

.notification-action-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.app-modal {
  width: min(100% - 32px, 720px);
  padding: 0;
  border: 0;
  background: transparent;
}

.app-modal::backdrop {
  background: rgba(17, 24, 39, 0.36);
  backdrop-filter: blur(2px);
}

.app-modal--large {
  width: min(100% - 32px, 860px);
}

.app-modal__surface {
  position: relative;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  background: #fff;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.24);
}

.app-modal__header,
.app-modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
}

.app-modal__header {
  padding-right: 4rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.app-modal__footer {
  justify-content: flex-end;
  flex-wrap: wrap;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.app-modal__title {
  margin: 0;
  color: #111827;
  font-size: 1.2rem;
}

.app-modal__description {
  margin: 0.35rem 0 0;
  color: #64748b;
}

.app-modal__body {
  padding: 1.25rem;
}

.app-modal__icon-button {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  z-index: 1;
  width: 2.25rem;
  min-height: 2.25rem;
  padding: 0;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  font-size: 1.3rem;
}

.notification-text-preview {
  max-height: min(60vh, 520px);
  margin: 0;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 0.92rem;
}

.copy-button {
  background: #0f766e;
}

.app-toast-stack {
  position: fixed;
  top: 1rem;
  left: 50%;
  z-index: 1200;
  display: grid;
  gap: 0.75rem;
  width: min(calc(100vw - 2rem), 620px);
  transform: translateX(-50%);
  pointer-events: none;
}

.app-toast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 1rem 1rem 1rem 0.9rem;
  border: 1px solid #d8e0ea;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  pointer-events: auto;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.app-toast.is-leaving {
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
}

.app-toast__body {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  min-width: 0;
}

.app-toast__badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
}

.app-toast__copy {
  min-width: 0;
}

.app-toast__title {
  display: block;
  color: #111827;
}

.app-toast__message {
  margin: 0.2rem 0 0;
  color: #475569;
  line-height: 1.55;
}

.app-toast__close {
  flex: 0 0 auto;
  width: 2rem;
  min-height: 2rem;
  padding: 0;
  border: 1px solid #d8e0ea;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-size: 1.1rem;
}

.app-toast--success {
  border-color: rgba(15, 118, 110, 0.22);
  background: #f4fffb;
}

.app-toast--success .app-toast__badge {
  background: #daf7ee;
  color: #0f766e;
}

.app-toast--error {
  border-color: rgba(185, 28, 28, 0.22);
  background: #fff7f7;
}

.app-toast--error .app-toast__badge {
  background: #fee2e2;
  color: #b91c1c;
}

.app-toast--info {
  border-color: rgba(37, 99, 235, 0.2);
  background: #f6f9ff;
}

.app-toast--info .app-toast__badge {
  background: #dbeafe;
  color: #2563eb;
}

@media (max-width: 840px) {
  .app-header {
    align-items: stretch;
    flex-basis: auto;
    height: auto;
    min-height: 64px;
    padding: 0.75rem;
  }

  .app-header-actions {
    gap: 0.5rem;
  }

  .user-menu__trigger {
    max-width: 12rem;
  }

  .user-menu__copy strong {
    max-width: 7rem;
  }

  .user-menu__dropdown {
    width: min(280px, calc(100vw - 1.5rem));
    min-width: 0;
  }

  .main-content {
    padding: 1rem;
  }

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

  .detail-top-grid {
    grid-template-columns: 1fr;
  }

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

  .shared-link-url-row {
    grid-template-columns: 1fr;
  }

  .shared-link-url-actions {
    justify-content: flex-start;
  }

  .app-modal__footer {
    justify-content: flex-start;
  }

  .app-toast-stack {
    top: 0.75rem;
    width: min(calc(100vw - 1.5rem), 620px);
  }
}

@media (max-width: 520px) {
  .shared-link-status-grid {
    grid-template-columns: 1fr;
  }
}
