/* ==========================================================================
   Samaa Holding EDMS — Component layer
   --------------------------------------------------------------------------
   Plain, prefixed, global CSS so the backend team can lift components into a
   Django/Mayan template without a CSS-module build step.

   Rules:
   - Never write a literal color, size, radius, or shadow here. Use tokens.
   - Never use left/right. Use logical properties so RTL mirrors automatically.
   ========================================================================== */

/* ==========================================================================
   Layout utilities
   ========================================================================== */

/* Vertical rhythm for stacked form controls and list items. */
.edms-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ==========================================================================
   App shell
   ========================================================================== */

.edms-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--canvas);
}

.edms-shell__main {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.edms-shell__content {
  flex: 1;
  min-width: 0;
  padding: var(--space-6) var(--content-gutter) var(--space-12);
}

.edms-shell__content-inner {
  width: 100%;
  max-width: 1560px;
  margin-inline: auto;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.edms-sidebar {
  position: sticky;
  inset-block-start: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  border-inline-end: 1px solid var(--border-default);
  background: var(--surface-sidebar);
}

.edms-sidebar__brand {
  display: flex;
  height: var(--topbar-height);
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-3);
  padding-inline: var(--space-5);
  border-block-end: 1px solid var(--border-subtle);
}

.edms-sidebar__brand-mark {
  display: block;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}

.edms-sidebar__brand-text {
  min-width: 0;
}

.edms-sidebar__brand-name {
  overflow: hidden;
  color: var(--text-strong);
  font-size: var(--text-body-size);
  font-weight: var(--weight-semibold);
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edms-sidebar__brand-sub {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: var(--weight-medium);
  letter-spacing: 0.06em;
  line-height: 16px;
  text-transform: uppercase;
}

:root[lang='ar'] .edms-sidebar__brand-sub {
  letter-spacing: normal;
}

.edms-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
}

.edms-sidebar__group + .edms-sidebar__group {
  margin-block-start: var(--space-1);
}

.edms-sidebar__item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-default);
  font-size: var(--text-body-size);
  font-weight: var(--weight-medium);
  line-height: var(--text-body-line);
  text-align: start;
  transition: background var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

.edms-sidebar__item:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
  text-decoration: none;
}

.edms-sidebar__item[aria-current='page'],
.edms-sidebar__item--active {
  background: var(--surface-selected);
  color: var(--primary);
  font-weight: var(--weight-semibold);
}

.edms-sidebar__item-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--text-subtle);
}

.edms-sidebar__item:hover .edms-sidebar__item-icon {
  color: var(--text-muted);
}

.edms-sidebar__item[aria-current='page'] .edms-sidebar__item-icon,
.edms-sidebar__item--active .edms-sidebar__item-icon {
  color: var(--primary);
}

.edms-sidebar__item-label {
  overflow: hidden;
  flex: 1;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edms-sidebar__item-caret {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: var(--text-subtle);
  transition: transform var(--duration-base) var(--ease-standard);
}

.edms-sidebar__item-caret--open {
  transform: rotate(180deg);
}

/* Group whose label links to a page and whose caret expands children. */
.edms-sidebar__group-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.edms-sidebar__group-row .edms-sidebar__item {
  flex: 1;
  min-width: 0;
}

.edms-sidebar__caret-button {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
}

.edms-sidebar__caret-button:hover {
  background: var(--surface-hover);
}

.edms-sidebar__item:disabled {
  color: var(--text-subtle);
  cursor: not-allowed;
  opacity: 0.6;
}

.edms-sidebar__sublist {
  overflow: hidden;
  margin-block-start: var(--space-1);
  margin-inline-start: var(--space-5);
  padding-inline-start: var(--space-3);
  border-inline-start: 1px solid var(--border-default);
}

.edms-sidebar__subitem {
  display: flex;
  width: 100%;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  text-align: start;
  transition: background var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

.edms-sidebar__subitem:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
  text-decoration: none;
}

.edms-sidebar__subitem[aria-current='page'] {
  background: var(--surface-selected);
  color: var(--primary);
  font-weight: var(--weight-semibold);
}

.edms-sidebar__subitem-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: currentColor;
  opacity: 0.75;
}

.edms-sidebar__swatch {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border: 1px solid rgba(18, 25, 38, 0.12);
  border-radius: var(--radius-pill);
}

.edms-sidebar__subitem-bullet {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
}

.edms-sidebar__footer {
  flex: 0 0 auto;
  padding: var(--space-4) var(--space-5);
  border-block-start: 1px solid var(--border-subtle);
  color: var(--text-subtle);
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
}

.edms-sidebar__footer-product {
  color: var(--text-muted);
  font-weight: var(--weight-medium);
}

/* ==========================================================================
   Topbar
   ========================================================================== */

.edms-topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: var(--z-sticky);
  display: flex;
  height: var(--topbar-height);
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-4);
  padding-inline: var(--content-gutter);
  border-block-end: 1px solid var(--border-default);
  background: var(--surface-topbar);
}

.edms-topbar__search {
  display: flex;
  min-width: 0;
  max-width: 720px;
  flex: 1;
  align-items: stretch;
  gap: var(--space-2);
}

.edms-topbar__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-1);
  margin-inline-start: auto;
}

.edms-topbar__divider {
  width: 1px;
  height: 24px;
  margin-inline: var(--space-2);
  background: var(--border-default);
}

/* Scoped search cluster: select + input joined, buttons detached. */
.edms-search-cluster {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: stretch;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
}

.edms-search-cluster:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring-halo);
}

.edms-search-cluster__scope {
  flex: 0 0 auto;
  min-width: 132px;
  padding-block: 0;
  padding-inline: var(--space-3) var(--space-2);
  border: 0;
  border-inline-end: 1px solid var(--border-default);
  border-radius: 0;
  background: var(--surface-muted);
  border-start-start-radius: var(--radius-sm);
  border-end-start-radius: var(--radius-sm);
  color: var(--text-default);
  font-size: var(--text-body-size);
  font-weight: var(--weight-medium);
}

.edms-search-cluster__scope:focus-visible {
  outline-offset: -2px;
}

.edms-search-cluster__field {
  display: flex;
  /* Never collapse to nothing when the topbar gets tight. */
  min-width: 120px;
  flex: 1;
  align-items: center;
  gap: var(--space-2);
  padding-inline: var(--space-3);
}

.edms-search-cluster__icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: var(--text-subtle);
}

.edms-search-cluster__input {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 0;
  background: transparent;
  outline: none;
  font-size: var(--text-body-size);
}

.edms-search-cluster__input::placeholder {
  color: var(--text-subtle);
}

/* ==========================================================================
   Breadcrumb
   --------------------------------------------------------------------------
   Built as a shell primitive. NOT yet placed on any page — no capture in
   current-system/screenshots/ confirms a breadcrumb exists. See audit §7.
   ========================================================================== */

.edms-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-table-size);
  line-height: var(--text-table-line);
}

.edms-breadcrumb__item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.edms-breadcrumb__link {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.edms-breadcrumb__link:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
  text-decoration: none;
}

.edms-breadcrumb__current {
  padding: var(--space-1) var(--space-2);
  color: var(--text-strong);
  font-weight: var(--weight-medium);
}

.edms-breadcrumb__separator {
  width: 14px;
  height: 14px;
  color: var(--text-subtle);
}

/* ==========================================================================
   Page header
   ========================================================================== */

.edms-page-header__breadcrumb {
  margin-block-end: var(--space-3);
}

.edms-page-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding-block-end: var(--space-4);
  border-block-end: 1px solid var(--border-default);
}

.edms-page-header__lead {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: var(--space-4);
}

.edms-page-header__icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary);
}

.edms-page-header__icon svg {
  width: 22px;
  height: 22px;
}

.edms-page-header__titles {
  min-width: 0;
}

.edms-page-header__title {
  overflow-wrap: anywhere;
  color: var(--text-strong);
  font-size: var(--text-page-title-size);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  line-height: var(--text-page-title-line);
}

:root[lang='ar'] .edms-page-header__title {
  letter-spacing: normal;
}

.edms-page-header__subtitle {
  margin-block-start: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
}

.edms-page-header__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-2);
  padding-block-start: var(--space-1);
}

.edms-page-header__meta {
  padding-block: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
}

.edms-page-header__meta strong {
  color: var(--text-strong);
  font-weight: var(--weight-semibold);
}

/* ==========================================================================
   Button
   ========================================================================== */

.edms-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding-inline: var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--text-body-size);
  font-weight: var(--weight-semibold);
  line-height: 20px;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

.edms-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.edms-button:disabled {
  opacity: 0.55;
}

.edms-button--sm {
  min-height: 32px;
  padding-inline: var(--space-3);
  font-size: var(--text-table-size);
}

.edms-button--lg {
  min-height: 44px;
  padding-inline: var(--space-5);
}

.edms-button--block {
  width: 100%;
}

/* Router <Link> styled as a button keeps the same metrics and hover states. */
a.edms-button:hover {
  text-decoration: none;
}

.edms-button--primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--text-on-primary);
}

.edms-button--primary:hover:not(:disabled) {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.edms-button--primary:active:not(:disabled) {
  background: var(--primary-active);
}

.edms-button--secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text-default);
}

.edms-button--secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-strong);
}

.edms-button--secondary:active:not(:disabled) {
  background: var(--surface-active);
}

.edms-button--ghost {
  background: transparent;
  color: var(--text-default);
}

.edms-button--ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-strong);
}

.edms-button--danger {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--text-on-primary);
}

.edms-button--danger:hover:not(:disabled) {
  border-color: var(--danger-hover);
  background: var(--danger-hover);
}

.edms-button--danger-outline {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

.edms-button--danger-outline:hover:not(:disabled) {
  border-color: var(--danger);
}

.edms-button__spinner {
  width: 16px;
  height: 16px;
  animation: edms-spin 900ms linear infinite;
}

@keyframes edms-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Icon-only button */
.edms-icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  transition: background var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

.edms-icon-button svg {
  width: 18px;
  height: 18px;
}

.edms-icon-button:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-strong);
}

.edms-icon-button:disabled {
  opacity: 0.5;
}

.edms-icon-button--bordered {
  border-color: var(--border-default);
  background: var(--surface);
}

.edms-icon-button--active {
  background: var(--surface-selected);
  color: var(--primary);
}

.edms-icon-button--sm {
  width: 32px;
  height: 32px;
}

.edms-icon-button--sm svg {
  width: 16px;
  height: 16px;
}

.edms-icon-button__badge {
  position: absolute;
  inset-block-start: 6px;
  inset-inline-end: 6px;
  min-width: 8px;
  height: 8px;
  border: 2px solid var(--surface-topbar);
  border-radius: var(--radius-pill);
  background: var(--danger);
}

.edms-icon-button--has-badge {
  position: relative;
}

/* ==========================================================================
   Fields
   ========================================================================== */

.edms-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.edms-field__label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--text-strong);
  font-size: var(--text-body-size);
  font-weight: var(--weight-semibold);
  line-height: 20px;
}

.edms-field__requirement {
  color: var(--text-muted);
  font-weight: var(--weight-regular);
}

.edms-field__help {
  color: var(--text-muted);
  font-size: var(--text-table-size);
  line-height: var(--text-table-line);
}

.edms-field__error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  color: var(--danger);
  font-size: var(--text-table-size);
  line-height: var(--text-table-line);
}

.edms-field__error svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  margin-block-start: 3px;
}

.edms-input,
.edms-select,
.edms-textarea {
  width: 100%;
  min-height: 40px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-strong);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  transition: border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
}

.edms-textarea {
  min-height: 96px;
  resize: vertical;
}

.edms-input::placeholder,
.edms-textarea::placeholder {
  color: var(--text-subtle);
}

.edms-input:hover:not(:disabled),
.edms-select:hover:not(:disabled),
.edms-textarea:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.edms-input:focus,
.edms-select:focus,
.edms-textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring-halo);
}

.edms-input:disabled,
.edms-select:disabled,
.edms-textarea:disabled {
  background: var(--surface-sunken);
  color: var(--text-subtle);
}

.edms-input[aria-invalid='true'],
.edms-select[aria-invalid='true'],
.edms-textarea[aria-invalid='true'] {
  border-color: var(--danger);
}

.edms-input[aria-invalid='true']:focus,
.edms-select[aria-invalid='true']:focus,
.edms-textarea[aria-invalid='true']:focus {
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.edms-select {
  padding-inline-end: var(--space-8);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 17px, calc(100% - 13px) 17px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

:root[dir='rtl'] .edms-select {
  background-position: 13px 17px, 18px 17px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
}

/* Input with a leading icon */
.edms-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.edms-input-group__icon {
  position: absolute;
  inset-inline-start: var(--space-3);
  width: 16px;
  height: 16px;
  color: var(--text-subtle);
  pointer-events: none;
}

.edms-input-group .edms-input {
  padding-inline-start: var(--space-8);
}

.edms-input-group__clear {
  position: absolute;
  inset-inline-end: var(--space-2);
}

/* Checkbox */
.edms-checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-height: 24px;
  cursor: pointer;
}

.edms-checkbox__control {
  display: grid;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin: 0;
  margin-block-start: 3px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  appearance: none;
  background: var(--surface);
  transition: background var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard);
}

.edms-checkbox__control::after {
  width: 10px;
  height: 10px;
  background: var(--text-on-primary);
  clip-path: polygon(14% 47%, 0 60%, 39% 100%, 100% 22%, 85% 9%, 37% 71%);
  content: '';
  opacity: 0;
}

.edms-checkbox__control:checked {
  border-color: var(--primary);
  background: var(--primary);
}

.edms-checkbox__control:checked::after {
  opacity: 1;
}

.edms-checkbox__control:indeterminate {
  border-color: var(--primary);
  background: var(--primary);
}

.edms-checkbox__control:indeterminate::after {
  width: 9px;
  height: 2px;
  border-radius: 1px;
  clip-path: none;
  opacity: 1;
}

.edms-checkbox__control:hover:not(:disabled) {
  border-color: var(--primary);
}

.edms-checkbox__control:disabled {
  background: var(--surface-sunken);
  cursor: not-allowed;
}

.edms-checkbox__label {
  color: var(--text-default);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
}

/* ==========================================================================
   Card
   ========================================================================== */

.edms-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.edms-card--flat {
  box-shadow: none;
}

.edms-card--muted {
  background: var(--surface-muted);
}

.edms-card__header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) 0;
}

.edms-card__header--bordered {
  padding-block-end: var(--space-4);
  border-block-end: 1px solid var(--border-subtle);
}

.edms-card__titles {
  min-width: 0;
  flex: 1;
}

.edms-card__title {
  color: var(--text-strong);
  font-size: var(--text-section-title-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-section-title-line);
}

.edms-card__description {
  margin-block-start: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
}

.edms-card__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-2);
}

.edms-card__body {
  padding: var(--space-5);
}

.edms-card__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-block-start: 1px solid var(--border-subtle);
  background: var(--surface-muted);
  border-end-start-radius: var(--radius-md);
  border-end-end-radius: var(--radius-md);
}

/* ==========================================================================
   List toolbar / filter bar
   ========================================================================== */

.edms-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.edms-toolbar__filter {
  min-width: 0;
  flex: 1 1 260px;
  max-width: 360px;
}

.edms-toolbar__spacer {
  flex: 1;
}

.edms-toolbar__group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Segmented list/grid control */
.edms-segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}

.edms-segmented__option {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  padding-inline: var(--space-3);
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-table-size);
  font-weight: var(--weight-medium);
  transition: background var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

.edms-segmented__option svg {
  width: 16px;
  height: 16px;
}

.edms-segmented__option:hover {
  color: var(--text-strong);
}

.edms-segmented__option[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text-strong);
  box-shadow: var(--shadow-xs);
}

/* ==========================================================================
   Badge
   ========================================================================== */

.edms-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: var(--text-label-size);
  font-weight: var(--weight-medium);
  line-height: var(--text-label-line);
  white-space: nowrap;
}

.edms-badge__dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: var(--radius-pill);
  background: currentColor;
}

/* Lets a long tag label truncate instead of pushing the column wider. */
.edms-badge__text {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edms-badge--neutral {
  border-color: var(--border-default);
  background: var(--surface-sunken);
  color: var(--text-default);
}

.edms-badge--info {
  border-color: var(--info-border);
  background: var(--info-soft);
  color: var(--info);
}

.edms-badge--success {
  border-color: var(--success-border);
  background: var(--success-soft);
  color: var(--success);
}

.edms-badge--warning {
  border-color: var(--warning-border);
  background: var(--warning-soft);
  color: var(--warning);
}

.edms-badge--danger {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

.edms-badge--count {
  min-width: 20px;
  justify-content: center;
  border-radius: var(--radius-pill);
}

/* ==========================================================================
   Tabs
   ========================================================================== */

.edms-tabs {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  border-block-end: 1px solid var(--border-default);
}

.edms-tabs__tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 42px;
  padding-inline: var(--space-3);
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-body-size);
  font-weight: var(--weight-medium);
  transition: color var(--duration-fast) var(--ease-standard);
}

.edms-tabs__tab svg {
  width: 16px;
  height: 16px;
}

.edms-tabs__tab::after {
  position: absolute;
  inset-block-end: -1px;
  inset-inline: var(--space-2);
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
  content: '';
}

.edms-tabs__tab:hover {
  color: var(--text-strong);
}

.edms-tabs__tab[aria-selected='true'] {
  color: var(--primary);
  font-weight: var(--weight-semibold);
}

.edms-tabs__tab[aria-selected='true']::after {
  background: var(--primary);
}

.edms-tabs__tab:disabled {
  color: var(--text-subtle);
  opacity: 0.6;
}

.edms-tabs__panel {
  padding-block-start: var(--space-5);
}

/* ==========================================================================
   Table
   --------------------------------------------------------------------------
   Structural primitives only. Column definitions for product tables are
   blocked pending evidence — see docs/audit-report.md §6.
   ========================================================================== */

.edms-table-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
}

/* `position: relative` is load-bearing, not decoration.
   Screen-reader-only labels inside the table use `position: absolute`. Without
   a positioned ancestor their containing block is the initial containing block,
   so they escape this scroll container's clipping and sit at the table's full
   layout width — which made the whole PAGE scroll horizontally on wide tables.
   Making this element the containing block clips them with everything else. */
.edms-table-scroll {
  position: relative;
  overflow-x: auto;
}

.edms-table {
  width: 100%;
  font-size: var(--text-table-size);
  line-height: var(--text-table-line);
}

.edms-table__head {
  background: var(--surface-muted);
}

.edms-table__th {
  padding: var(--space-3) var(--space-4);
  border-block-end: 1px solid var(--border-default);
  color: var(--text-muted);
  font-size: var(--text-label-size);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.04em;
  line-height: var(--text-label-line);
  text-align: start;
  text-transform: uppercase;
  white-space: nowrap;
}

:root[lang='ar'] .edms-table__th {
  letter-spacing: normal;
  text-transform: none;
}

.edms-table__th--numeric {
  text-align: end;
}

.edms-table__th--select,
.edms-table__td--select {
  width: 48px;
  padding-inline-end: 0;
}

.edms-table__th--actions,
.edms-table__td--actions {
  width: 56px;
  text-align: end;
}

.edms-table__sort {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  margin-inline-start: calc(var(--space-2) * -1);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

.edms-table__sort:hover {
  background: var(--surface-active);
  color: var(--text-strong);
}

.edms-table__sort svg {
  width: 14px;
  height: 14px;
  opacity: 0.5;
}

.edms-table__sort[data-sort='asc'] svg,
.edms-table__sort[data-sort='desc'] svg {
  color: var(--primary);
  opacity: 1;
}

.edms-table__row {
  border-block-end: 1px solid var(--border-subtle);
  transition: background var(--duration-fast) var(--ease-standard);
}

.edms-table__row:last-child {
  border-block-end: 0;
}

.edms-table__row--clickable {
  cursor: pointer;
}

.edms-table__row:hover {
  background: var(--surface-hover);
}

.edms-table__row[data-selected='true'] {
  background: var(--surface-selected);
}

.edms-table__row[data-selected='true']:hover {
  background: var(--primary-soft-hover);
}

.edms-table__td {
  padding: var(--space-3) var(--space-4);
  color: var(--text-default);
  vertical-align: middle;
}

.edms-table__td--strong {
  color: var(--text-strong);
  font-weight: var(--weight-medium);
}

.edms-table__td--numeric {
  font-variant-numeric: tabular-nums;
  text-align: end;
  white-space: nowrap;
}

/* Dates must not wrap mid-value — "4 Aug 2026, 10:48" reads as one token. */
.edms-table__td time {
  white-space: nowrap;
}

.edms-table__td--muted {
  color: var(--text-muted);
}

/* Bulk-action bar shown when rows are selected */
.edms-bulk-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-block-end: 1px solid var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--text-table-size);
  font-weight: var(--weight-medium);
}

.edms-bulk-bar__spacer {
  flex: 1;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.edms-pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-block-start: 1px solid var(--border-default);
  background: var(--surface-muted);
}

.edms-pagination__summary {
  color: var(--text-muted);
  font-size: var(--text-table-size);
  font-variant-numeric: tabular-nums;
}

.edms-pagination__pages {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-inline-start: auto;
}

.edms-pagination__page {
  display: inline-grid;
  min-width: 32px;
  height: 32px;
  place-items: center;
  padding-inline: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-default);
  font-size: var(--text-table-size);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-medium);
}

.edms-pagination__page:hover:not(:disabled) {
  background: var(--surface-active);
}

.edms-pagination__page[aria-current='page'] {
  border-color: var(--primary-border);
  background: var(--surface);
  color: var(--primary);
}

.edms-pagination__page:disabled {
  color: var(--text-subtle);
  opacity: 0.6;
}

.edms-pagination__ellipsis {
  padding-inline: var(--space-1);
  color: var(--text-subtle);
}

/* ==========================================================================
   Dropdown menu
   ========================================================================== */

.edms-dropdown {
  position: relative;
  display: inline-flex;
}

.edms-dropdown__menu {
  position: absolute;
  inset-block-start: calc(100% + var(--space-2));
  z-index: var(--z-menu);
  min-width: 220px;
  padding: var(--space-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: edms-menu-in var(--duration-base) var(--ease-standard);
}

.edms-dropdown__menu--start {
  inset-inline-start: 0;
}

.edms-dropdown__menu--end {
  inset-inline-end: 0;
}

@keyframes edms-menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.edms-dropdown__item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-default);
  font-size: var(--text-body-size);
  text-align: start;
}

.edms-dropdown__item svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--text-subtle);
}

.edms-dropdown__item:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-strong);
  text-decoration: none;
}

.edms-dropdown__item:hover:not(:disabled) svg {
  color: var(--text-muted);
}

.edms-dropdown__item:disabled {
  color: var(--text-subtle);
  opacity: 0.6;
}

.edms-dropdown__item--danger {
  color: var(--danger);
}

.edms-dropdown__item--danger svg {
  color: var(--danger);
}

.edms-dropdown__item--danger:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger-hover);
}

.edms-dropdown__separator {
  height: 1px;
  margin: var(--space-2) 0;
  background: var(--border-subtle);
}

.edms-dropdown__label {
  padding: var(--space-2) var(--space-3);
  color: var(--text-subtle);
  font-size: var(--text-label-size);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

:root[lang='ar'] .edms-dropdown__label {
  letter-spacing: normal;
  text-transform: none;
}

/* ==========================================================================
   Overlay, modal, drawer
   ========================================================================== */

.edms-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  padding: var(--space-6);
  background: var(--surface-overlay);
  place-items: center;
  animation: edms-fade-in var(--duration-base) var(--ease-standard);
}

.edms-overlay--drawer {
  padding: 0;
  place-items: stretch;
}

@keyframes edms-fade-in {
  from {
    opacity: 0;
  }
}

.edms-modal {
  display: flex;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - var(--space-12));
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  animation: edms-modal-in var(--duration-slow) var(--ease-standard);
}

.edms-modal--lg {
  max-width: 800px;
}

.edms-modal--sm {
  max-width: 440px;
}

@keyframes edms-modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.edms-modal__header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-block-end: 1px solid var(--border-subtle);
}

.edms-modal__icon {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary);
}

.edms-modal__icon--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.edms-modal__icon svg {
  width: 20px;
  height: 20px;
}

.edms-modal__titles {
  min-width: 0;
  flex: 1;
}

.edms-modal__title {
  color: var(--text-strong);
  font-size: var(--text-section-title-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-section-title-line);
}

.edms-modal__description {
  margin-block-start: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
}

.edms-modal__body {
  overflow-y: auto;
  flex: 1;
  padding: var(--space-5);
}

.edms-modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-block-start: 1px solid var(--border-subtle);
  background: var(--surface-muted);
  border-end-start-radius: var(--radius-lg);
  border-end-end-radius: var(--radius-lg);
}

.edms-drawer {
  display: flex;
  width: min(480px, 100%);
  height: 100vh;
  flex-direction: column;
  margin-inline-start: auto;
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  animation: edms-drawer-in var(--duration-slow) var(--ease-standard);
}

@keyframes edms-drawer-in {
  from {
    transform: translateX(100%);
  }
}

:root[dir='rtl'] .edms-drawer {
  animation-name: edms-drawer-in-rtl;
}

@keyframes edms-drawer-in-rtl {
  from {
    transform: translateX(-100%);
  }
}

.edms-drawer__header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-5);
  border-block-end: 1px solid var(--border-subtle);
}

.edms-drawer__body {
  overflow-y: auto;
  flex: 1;
  padding: var(--space-5);
}

.edms-drawer__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-block-start: 1px solid var(--border-subtle);
  background: var(--surface-muted);
}

/* ==========================================================================
   Toast
   ========================================================================== */

.edms-toast-region {
  position: fixed;
  inset-block-end: var(--space-6);
  inset-inline-end: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  width: min(400px, calc(100vw - var(--space-12)));
  flex-direction: column;
  gap: var(--space-3);
}

.edms-toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: edms-toast-in var(--duration-slow) var(--ease-standard);
}

@keyframes edms-toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.edms-toast__icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-block-start: 1px;
}

.edms-toast--success .edms-toast__icon {
  color: var(--success);
}

.edms-toast--error .edms-toast__icon {
  color: var(--danger);
}

.edms-toast--warning .edms-toast__icon {
  color: var(--warning);
}

.edms-toast--info .edms-toast__icon {
  color: var(--info);
}

.edms-toast__content {
  min-width: 0;
  flex: 1;
}

.edms-toast__title {
  color: var(--text-strong);
  font-size: var(--text-body-size);
  font-weight: var(--weight-semibold);
  line-height: 20px;
}

.edms-toast__description {
  margin-block-start: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-table-size);
  line-height: var(--text-table-line);
}

/* ==========================================================================
   Uploader
   ========================================================================== */

.edms-dropzone {
  display: grid;
  padding: var(--space-10) var(--space-6);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
  place-items: center;
  text-align: center;
  transition: border-color var(--duration-base) var(--ease-standard),
    background var(--duration-base) var(--ease-standard);
}

.edms-dropzone--active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.edms-dropzone--disabled {
  opacity: 0.6;
}

.edms-dropzone__icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin-block-end: var(--space-4);
  place-items: center;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow-xs);
}

.edms-dropzone--active .edms-dropzone__icon {
  border-color: var(--primary-border);
  color: var(--primary);
}

.edms-dropzone__icon svg {
  width: 22px;
  height: 22px;
}

.edms-dropzone__title {
  color: var(--text-strong);
  font-size: var(--text-body-size);
  font-weight: var(--weight-semibold);
  line-height: 20px;
}

.edms-dropzone__hint {
  margin-block-start: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-table-size);
  line-height: var(--text-table-line);
}

.edms-dropzone__action {
  margin-block-start: var(--space-4);
}

.edms-file-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-block-start: var(--space-4);
}

.edms-file-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.edms-file-row--error {
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

.edms-file-row--success {
  border-color: var(--success-border);
}

.edms-file-row__icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--text-muted);
}

.edms-file-row--success .edms-file-row__icon {
  background: var(--success-soft);
  color: var(--success);
}

.edms-file-row--error .edms-file-row__icon {
  background: var(--surface);
  color: var(--danger);
}

.edms-file-row__icon svg {
  width: 18px;
  height: 18px;
}

.edms-file-row__main {
  min-width: 0;
  flex: 1;
}

.edms-file-row__name {
  overflow: hidden;
  color: var(--text-strong);
  font-size: var(--text-body-size);
  font-weight: var(--weight-medium);
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edms-file-row__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-block-start: 2px;
  color: var(--text-muted);
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
}

.edms-file-row--error .edms-file-row__meta {
  color: var(--danger);
}

.edms-file-row__progress {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-block-start: var(--space-2);
}

.edms-progress {
  overflow: hidden;
  height: 6px;
  flex: 1;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
}

.edms-progress__value {
  /* Must be block: an inline span ignores inline-size and height. */
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--primary);
  transition: inline-size var(--duration-slow) var(--ease-standard);
}

.edms-progress__value--success {
  background: var(--success);
}

.edms-progress__value--error {
  background: var(--danger);
}

.edms-file-row__percent {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: var(--text-label-size);
  font-variant-numeric: tabular-nums;
}

.edms-file-row__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-1);
}

/* ==========================================================================
   Skeleton
   ========================================================================== */

.edms-skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--color-neutral-100) 25%,
    var(--color-neutral-200) 37%,
    var(--color-neutral-100) 63%
  );
  background-size: 400% 100%;
  animation: edms-shimmer 1.4s ease infinite;
}

@keyframes edms-shimmer {
  from {
    background-position: 100% 50%;
  }
  to {
    background-position: 0 50%;
  }
}

.edms-skeleton--text {
  height: 12px;
}

.edms-skeleton--circle {
  border-radius: var(--radius-pill);
}

.edms-skeleton-table__row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-block-end: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Status states: empty, error, access denied
   ========================================================================== */

.edms-state {
  display: grid;
  padding: var(--space-12) var(--space-6);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
  place-items: center;
  text-align: center;
}

.edms-state--bare {
  border: 0;
  background: transparent;
}

.edms-state__icon {
  display: grid;
  width: 56px;
  height: 56px;
  margin-block-end: var(--space-5);
  place-items: center;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  color: var(--text-muted);
  box-shadow: var(--shadow-xs);
}

.edms-state__icon svg {
  width: 26px;
  height: 26px;
}

.edms-state--error .edms-state__icon {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

.edms-state--denied .edms-state__icon {
  border-color: var(--warning-border);
  background: var(--warning-soft);
  color: var(--warning);
}

.edms-state__title {
  max-width: 62ch;
  color: var(--text-strong);
  font-size: var(--text-section-title-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-section-title-line);
}

.edms-state__description {
  max-width: 68ch;
  margin-block-start: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
}

.edms-state__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-block-start: var(--space-6);
}

.edms-state__detail {
  max-width: 68ch;
  margin-block-start: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  text-align: start;
  word-break: break-word;
}

/* ==========================================================================
   Document list
   ========================================================================== */

.edms-list-body {
  margin-block-start: var(--space-4);
}

.edms-list-body__pagination {
  margin-block-start: var(--space-4);
}

/* Label cell: icon + name + optional secondary line */
.edms-doc-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  /* Claims width from the auto table layout so the document name — the column
     users actually scan — is never squeezed by the metadata columns. */
  min-width: 240px;
}

.edms-doc-cell__icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-subtle);
}

.edms-doc-cell__icon svg {
  width: 16px;
  height: 16px;
}

.edms-doc-cell__text {
  display: grid;
  min-width: 0;
}

.edms-doc-cell__label {
  overflow: hidden;
  color: var(--text-strong);
  font-weight: var(--weight-medium);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The label is the row's link target — the whole row is not clickable, so
   checkbox, star, and menu stay independently operable. */
.edms-doc-cell__link {
  display: block;
  color: inherit;
}

.edms-doc-cell__link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.edms-doc-cell__meta {
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edms-doc-cell__file {
  display: inline-block;
  overflow: hidden;
  max-width: 24ch;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: start;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.edms-doc-cell__tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1);
  /* Bilingual tag labels are long. Capping the column makes them wrap and
     truncate instead of pushing the whole table past the viewport. */
  max-width: 200px;
}

/* `min-width: 0` overrides the flex default of `auto`, without which the badge
   cannot shrink below its content and overflows the capped column. */
.edms-doc-cell__tags .edms-badge {
  min-width: 0;
  max-width: 100%;
}

.edms-favorite--on {
  color: var(--color-warning-600);
}

/* --------------------------------------------------------- Grid variant */

.edms-doc-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.edms-doc-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
}

.edms-doc-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.edms-doc-card[data-selected='true'] {
  border-color: var(--primary);
  background: var(--surface-selected);
}

.edms-doc-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.edms-doc-card__top-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.edms-doc-card__preview {
  position: relative;
  display: grid;
  height: 128px;
  place-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-subtle);
}

.edms-doc-card__preview svg {
  width: 34px;
  height: 34px;
}

.edms-doc-card__ext {
  position: absolute;
  inset-block-end: var(--space-2);
  inset-inline-end: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.04em;
}

.edms-doc-card__label {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-strong);
  font-size: var(--text-table-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-table-line);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.edms-doc-card__type {
  margin-block-start: 2px;
  color: var(--text-muted);
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
}

.edms-doc-card__meta {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding-block-start: var(--space-3);
  border-block-start: 1px solid var(--border-subtle);
  grid-template-columns: 1fr auto;
}

.edms-doc-card__meta div {
  min-width: 0;
}

.edms-doc-card__meta dt {
  color: var(--text-subtle);
  font-size: 11px;
  line-height: 16px;
}

.edms-doc-card__meta dd {
  margin: 0;
  color: var(--text-default);
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
}

.edms-doc-card__meta div:last-child {
  text-align: end;
}

.edms-doc-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

/* ==========================================================================
   Simple reference lists (cabinets, indexes, tags, checkouts)
   ========================================================================== */

.edms-swatch-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(18, 25, 38, 0.12);
  border-radius: var(--radius-pill);
  vertical-align: -1px;
}

.edms-cell-stack {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.edms-cell-stack__primary {
  color: var(--text-strong);
  font-weight: var(--weight-medium);
}

.edms-cell-stack__secondary {
  color: var(--text-muted);
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
}

/* ==========================================================================
   Login
   ========================================================================== */

.edms-login {
  display: grid;
  min-height: 100vh;
  padding: var(--space-6);
  background:
    radial-gradient(circle at 12% 8%, rgba(11, 70, 190, 0.08), transparent 38%),
    var(--canvas);
  place-items: center;
}

.edms-login__panel {
  width: min(420px, 100%);
}

.edms-login__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-3);
  margin-block-end: var(--space-6);
  text-align: center;
}

.edms-login__brand img {
  width: 168px;
}

.edms-login__title {
  color: var(--text-strong);
  font-size: var(--text-page-title-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-page-title-line);
}

.edms-login__subtitle {
  color: var(--text-muted);
}

.edms-login__form {
  display: grid;
  gap: var(--space-4);
}

.edms-login__notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-block-start: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-sm);
  background: var(--info-soft);
  color: var(--color-primary-800);
  font-size: var(--text-table-size);
  line-height: var(--text-table-line);
}

.edms-login__notice svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-block-start: 3px;
}

.edms-login__footer {
  margin-block-start: var(--space-5);
  color: var(--text-subtle);
  font-size: var(--text-label-size);
  text-align: center;
}

/* ==========================================================================
   Home — the user dashboard (capture 10)
   ========================================================================== */

.edms-dashboard__heading {
  margin-block-end: var(--space-4);
  color: var(--text-strong);
  font-size: var(--text-section-title-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-section-title-line);
}

.edms-dashboard {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-5);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  align-items: start;
}

.edms-widget {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.edms-widget__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
}

.edms-widget__icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
}

.edms-widget__icon svg {
  width: 18px;
  height: 18px;
}

.edms-widget__title {
  color: var(--text-strong);
  font-size: var(--text-body-size);
  font-weight: var(--weight-semibold);
  line-height: 20px;
}

.edms-widget__body {
  display: grid;
  gap: var(--space-2);
  flex: 1;
  padding-inline: var(--space-5);
  padding-block-end: var(--space-4);
}

.edms-widget__rows {
  display: grid;
  gap: var(--space-1);
}

.edms-widget__row {
  display: grid;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  align-items: baseline;
}

.edms-widget__when {
  color: var(--text-muted);
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  white-space: nowrap;
}

.edms-widget__link {
  overflow: hidden;
  font-size: var(--text-table-size);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edms-widget__empty {
  color: var(--text-subtle);
  font-size: var(--text-table-size);
  font-style: italic;
}

.edms-widget__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-block-start: 1px solid var(--border-subtle);
  font-size: var(--text-table-size);
  font-weight: var(--weight-medium);
}

.edms-widget__footer:hover {
  background: var(--surface-hover);
  text-decoration: none;
}

.edms-widget__footer svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

@media (max-width: 767px) {
  .edms-widget__row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ==========================================================================
   Home shortcuts (legacy — retained for reuse elsewhere)
   ========================================================================== */

.edms-shortcuts {
  display: grid;
  gap: var(--space-4);
  margin-block-start: var(--space-6);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.edms-shortcut {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-5);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  color: inherit;
  text-align: start;
  transition: border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard),
    transform var(--duration-fast) var(--ease-standard);
}

.edms-shortcut:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transform: translateY(-1px);
}

.edms-shortcut__icon {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
}

.edms-shortcut__icon svg {
  width: 20px;
  height: 20px;
}

.edms-shortcut__title {
  color: var(--text-strong);
  font-size: var(--text-body-size);
  font-weight: var(--weight-semibold);
  line-height: 20px;
}

.edms-shortcut__description {
  margin-block-start: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-table-size);
  line-height: var(--text-table-line);
}

/* ==========================================================================
   Wizard
   ========================================================================== */

.edms-wizard__steps {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-block-end: var(--space-5);
}

.edms-wizard__step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--text-label-size);
  font-weight: var(--weight-medium);
}

/* A connector line makes the sequence read as a progression, not as chips. */
.edms-wizard__step + .edms-wizard__step::before {
  width: 18px;
  height: 1px;
  margin-inline-start: calc(var(--space-2) * -1);
  background: var(--border-strong);
  content: '';
}

.edms-wizard__step[data-state='current'] {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
}

.edms-wizard__step[data-state='done'] {
  border-color: var(--success-border);
  background: var(--success-soft);
  color: var(--success);
}

.edms-wizard__step-index {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

.edms-wizard__step-index svg {
  width: 13px;
  height: 13px;
}

.edms-wizard__step[data-state='current'] .edms-wizard__step-index {
  background: var(--primary);
  color: var(--text-on-primary);
}

.edms-wizard__step[data-state='done'] .edms-wizard__step-index {
  background: var(--success);
  color: var(--text-on-primary);
}

.edms-wizard__subtitle {
  margin-block-end: var(--space-5);
  color: var(--text-strong);
  font-size: var(--text-section-title-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-section-title-line);
}

.edms-wizard__nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-block-start: var(--space-5);
  padding-block-start: var(--space-5);
  border-block-start: 1px solid var(--border-subtle);
}

.edms-wizard__nav-end {
  margin-inline-start: auto;
}

.edms-option-list {
  display: grid;
  gap: var(--space-2);
  max-height: 320px;
  overflow-y: auto;
  padding: var(--space-1);
}

/* Upload page: form + sources rail */
.edms-upload-layout {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: minmax(0, 1fr) 240px;
  align-items: start;
}

@media (max-width: 1023px) {
  .edms-upload-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.edms-source-rail__title {
  margin-block-end: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-label-size);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

:root[lang='ar'] .edms-source-rail__title {
  letter-spacing: normal;
  text-transform: none;
}

.edms-source-rail__item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-default);
  font-size: var(--text-body-size);
  text-align: start;
}

.edms-source-rail__item[aria-current='true'] {
  border-color: var(--primary);
  background: var(--surface-selected);
  color: var(--primary);
  font-weight: var(--weight-semibold);
}

.edms-source-rail__item svg {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   Advanced search
   ========================================================================== */

.edms-search-form {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.edms-search-form__wide {
  grid-column: 1 / -1;
}

@media (max-width: 767px) {
  .edms-search-form {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ==========================================================================
   Document detail
   ========================================================================== */

.edms-detail__back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  margin-inline-start: calc(var(--space-2) * -1);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--text-table-size);
}

.edms-detail__back svg {
  width: 15px;
  height: 15px;
}

.edms-detail__back:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
  text-decoration: none;
}

.edms-detail__banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-block-end: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: var(--text-table-size);
  line-height: var(--text-table-line);
}

.edms-detail__banner svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.edms-detail__banner--danger {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--color-danger-700);
}

.edms-detail__banner--warning {
  border-color: var(--warning-border);
  background: var(--warning-soft);
  color: var(--color-warning-700);
}

.edms-detail__banner--info {
  border-color: var(--info-border);
  background: var(--info-soft);
  color: var(--color-primary-800);
}

.edms-detail__banner-link {
  margin-inline-start: auto;
  font-weight: var(--weight-semibold);
}

/* Content + trailing-edge navigation, matching the current system's layout. */
.edms-detail__layout {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: minmax(0, 1fr) 232px;
  align-items: start;
}

@media (max-width: 1023px) {
  .edms-detail__layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.edms-detail__panel {
  padding: var(--space-5);
}

/* --------------------------------------------- Document secondary nav */

.edms-doc-nav {
  position: sticky;
  inset-block-start: calc(var(--topbar-height) + var(--space-4));
}

.edms-doc-nav__heading {
  padding-inline: var(--space-3);
  margin-block-end: var(--space-2);
  color: var(--text-subtle);
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  text-align: end;
}

.edms-doc-nav ul {
  display: grid;
  gap: 2px;
}

.edms-doc-nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-default);
  font-size: var(--text-table-size);
  line-height: var(--text-table-line);
}

.edms-doc-nav__item svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: var(--text-subtle);
}

.edms-doc-nav__item:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
  text-decoration: none;
}

.edms-doc-nav__item--active {
  border-color: var(--primary-border);
  background: var(--surface-selected);
  color: var(--primary);
  font-weight: var(--weight-semibold);
}

.edms-doc-nav__item--active svg {
  color: var(--primary);
}

/* --------------------------------------------------------- Definition list */

.edms-definition {
  display: grid;
  gap: 0;
  margin: 0;
}

.edms-definition__row {
  display: grid;
  gap: var(--space-4);
  padding-block: var(--space-3);
  border-block-end: 1px solid var(--border-subtle);
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
}

.edms-definition__row:last-child {
  border-block-end: 0;
}

.edms-definition__term {
  color: var(--text-muted);
  font-size: var(--text-table-size);
  line-height: var(--text-table-line);
}

.edms-definition__required {
  color: var(--danger);
}

.edms-definition__value {
  overflow-wrap: anywhere;
  margin: 0;
  color: var(--text-strong);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
}

.edms-definition__value--mono {
  font-family: var(--font-mono);
  font-size: var(--text-table-size);
}

.edms-definition__empty {
  color: var(--text-subtle);
  font-style: italic;
}

@media (max-width: 767px) {
  .edms-definition__row {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-1);
  }
}

/* ------------------------------------------------------------ Tab toolbar */

.edms-tab-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-block-end: var(--space-4);
}

.edms-tab-toolbar--end {
  justify-content: flex-end;
  margin-block: var(--space-2) 0;
}

.edms-tab-toolbar__end {
  margin-inline-start: auto;
}

.edms-section-heading {
  color: var(--text-strong);
  font-size: var(--text-body-size);
  font-weight: var(--weight-semibold);
  line-height: 20px;
}

.edms-section-subheading {
  margin-block: var(--space-4) var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-label-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-label-line);
}

.edms-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* --------------------------------------------------------------- Preview */

.edms-preview-pane {
  display: grid;
  gap: var(--space-4);
  justify-items: center;
}

.edms-preview-pane__stage {
  display: grid;
  width: 100%;
  padding: var(--space-6);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  place-items: center;
}

.edms-preview-pane__sheet {
  position: relative;
  display: grid;
  width: min(460px, 100%);
  min-height: 420px;
  padding: var(--space-8);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  place-content: center;
  text-align: center;
}

.edms-preview-pane__sheet > svg {
  width: 40px;
  height: 40px;
  margin-inline: auto;
  margin-block-end: var(--space-4);
  color: var(--text-subtle);
}

.edms-preview-pane__title {
  color: var(--text-strong);
  font-weight: var(--weight-semibold);
}

.edms-preview-pane__help {
  max-width: 34ch;
  margin-block-start: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-table-size);
  line-height: var(--text-table-line);
}

.edms-preview-pane__ext {
  position: absolute;
  inset-block-start: var(--space-3);
  inset-inline-end: var(--space-3);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: var(--weight-semibold);
}

.edms-preview-pane__controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.edms-preview-pane__caption {
  color: var(--text-muted);
  font-size: var(--text-table-size);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- Chips */

.edms-chip-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.edms-chip-link:hover {
  text-decoration: none;
}

.edms-cabinet-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-default);
  font-size: var(--text-table-size);
}

.edms-cabinet-chip svg {
  width: 15px;
  height: 15px;
  color: var(--text-subtle);
}

.edms-cabinet-chip:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
  text-decoration: none;
}

/* -------------------------------------------------------------- Comments */

.edms-comment-form {
  padding: var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.edms-comment-list {
  display: grid;
  gap: var(--space-3);
}

.edms-comment {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.edms-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--text-label-size);
  font-weight: var(--weight-semibold);
}

.edms-avatar--sm {
  width: 28px;
  height: 28px;
  font-size: 10px;
}

.edms-comment__body {
  min-width: 0;
  flex: 1;
}

.edms-comment__head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.edms-comment__author {
  color: var(--text-strong);
  font-size: var(--text-table-size);
  font-weight: var(--weight-semibold);
}

.edms-comment__time {
  color: var(--text-subtle);
  font-size: var(--text-label-size);
}

.edms-comment__text {
  margin-block-start: var(--space-1);
  overflow-wrap: anywhere;
  color: var(--text-default);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
}

/* ------------------------------------------------------------ Signatures */

.edms-signature {
  padding: var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.edms-signature__head {
  margin-block-end: var(--space-3);
}

/* -------------------------------------------------------------- Timeline */

.edms-timeline {
  display: grid;
  gap: var(--space-1);
}

.edms-timeline__item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
}

.edms-timeline__item:not(:last-child)::before {
  position: absolute;
  inset-block-start: 44px;
  inset-block-end: -4px;
  inset-inline-start: 14px;
  width: 1px;
  background: var(--border-default);
  content: '';
}

.edms-timeline__body {
  min-width: 0;
  flex: 1;
}

.edms-timeline__head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.edms-timeline__actor {
  color: var(--text-strong);
  font-size: var(--text-table-size);
  font-weight: var(--weight-semibold);
}

.edms-timeline__description {
  color: var(--text-default);
  font-size: var(--text-table-size);
}

.edms-timeline__time {
  display: block;
  margin-block-start: 2px;
  color: var(--text-subtle);
  font-size: var(--text-label-size);
}

/* ==========================================================================
   Notifications panel
   ========================================================================== */

.edms-notification-list {
  display: grid;
  gap: var(--space-2);
}

.edms-notification {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: start;
  width: 100%;
}

.edms-notification[data-unread='true'] {
  border-color: var(--primary-border);
  background: var(--primary-soft);
}

.edms-notification:hover {
  border-color: var(--border-strong);
}

.edms-notification__body {
  min-width: 0;
  flex: 1;
}

.edms-notification__target {
  overflow: hidden;
  color: var(--text-strong);
  font-size: var(--text-table-size);
  font-weight: var(--weight-medium);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edms-notification__meta {
  margin-block-start: 2px;
  color: var(--text-muted);
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
}

.edms-notification__dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin-block-start: 6px;
  border-radius: var(--radius-pill);
  background: var(--primary);
}

/* ==========================================================================
   CRUD form — the create/edit template (capture 51)
   ========================================================================== */

.edms-crud-form {
  padding: var(--space-5);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.edms-crud-form__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-block-start: var(--space-5);
}

/* Content beside a trailing-edge secondary nav. */
.edms-with-nav {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: minmax(0, 1fr) 232px;
  align-items: start;
}

@media (max-width: 1023px) {
  .edms-with-nav {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ==========================================================================
   Tile grid — Setup and Tools index pages
   --------------------------------------------------------------------------
   The current system renders these as large dark blocks with heavy white
   icons. That is deliberately NOT carried over: docs/02-design-direction.md
   asks for a calm neutral canvas with white elevated surfaces and soft
   borders. Copying the dark blocks would have imported the old system's
   weight into the redesign — see docs/12-foundation-decisions.md (D16).

   Compact rows also scan far better at 20 tiles than 20 large blocks do.
   ========================================================================== */

.edms-tiles {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.edms-tile {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 68px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  color: var(--text-strong);
  transition: border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard),
    transform var(--duration-fast) var(--ease-standard);
}

.edms-tile__icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
}

/* Light strokes, not the heavy filled glyphs of the old tiles. */
.edms-tile__icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

.edms-tile__label {
  min-width: 0;
  font-size: var(--text-body-size);
  font-weight: var(--weight-medium);
  line-height: var(--text-body-line);
}

a.edms-tile:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transform: translateY(-1px);
}

a.edms-tile:hover .edms-tile__icon {
  border-color: var(--primary);
  background: var(--primary-soft-hover);
}

/* Destination has no screenshot — present, but not linked. */
.edms-tile--pending {
  border-style: dashed;
  background: var(--surface-muted);
  box-shadow: none;
  color: var(--text-muted);
  cursor: not-allowed;
}

.edms-tile--pending .edms-tile__icon {
  border-color: var(--border-default);
  background: var(--surface-sunken);
  color: var(--text-subtle);
}

/* ==========================================================================
   Announcements and system info
   ========================================================================== */

.edms-announcement {
  padding: var(--space-5);
  border: 1px solid var(--border-default);
  border-inline-start: 3px solid var(--primary);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.edms-announcement__title {
  color: var(--text-strong);
  font-size: var(--text-section-title-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-section-title-line);
}

.edms-announcement__meta {
  margin-block-start: var(--space-1);
  color: var(--text-subtle);
  font-size: var(--text-label-size);
}

.edms-announcement__text {
  margin-block-start: var(--space-3);
  color: var(--text-default);
  line-height: var(--text-body-line);
}

.edms-stat-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.edms-stat {
  padding: var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.edms-stat__label {
  color: var(--text-muted);
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
}

.edms-stat__value {
  margin-block-start: var(--space-1);
  color: var(--text-strong);
  font-size: 24px;
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  line-height: 32px;
}

/* ==========================================================================
   Index nodes
   ========================================================================== */

.edms-node-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.edms-node {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-default);
  font-size: var(--text-table-size);
}

.edms-node:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.edms-node[aria-pressed='true'] {
  border-color: var(--primary);
  background: var(--surface-selected);
  color: var(--primary);
  font-weight: var(--weight-semibold);
}

.edms-node__count {
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.edms-node[aria-pressed='true'] .edms-node__count {
  color: inherit;
}

/* ==========================================================================
   Assumption notice (development aid, removable at handoff)
   ========================================================================== */

.edms-assumption {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-block-end: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--warning-border);
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  color: var(--color-warning-700);
  font-size: var(--text-table-size);
  line-height: var(--text-table-line);
}

.edms-assumption svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-block-start: 3px;
}

.edms-assumption code {
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ==========================================================================
   Responsive behavior
   --------------------------------------------------------------------------
   Desktop-first per docs/CLAUDE.md: 1440 / 1280 / 1024 are the design targets.
   Below 1024 the sidebar collapses to an off-canvas drawer.
   ========================================================================== */

@media (max-width: 1280px) {
  :root {
    --sidebar-width: 240px;
    --content-gutter: var(--space-6);
  }

  /* The topbar carries 10 controls. At 1280 and below they must all still fit
     with a usable search field, so the chrome tightens rather than dropping
     anything: no control is hidden and no label is removed. */
  .edms-topbar {
    gap: var(--space-3);
  }

  .edms-topbar__actions .edms-icon-button {
    width: 36px;
    height: 36px;
  }

  .edms-topbar__divider {
    margin-inline: var(--space-1);
  }

  .edms-search-cluster__scope {
    min-width: 104px;
  }
}

/* Below 1120 the two search buttons collapse to icons so the search field
   itself stays usable. Their accessible names remain on the buttons. */
@media (max-width: 1120px) {
  .edms-topbar__button-label {
    display: none;
  }

  .edms-topbar__search .edms-button {
    padding-inline: var(--space-3);
  }
}

/* The primary action keeps its label longest — it is the one users aim for. */
@media (min-width: 941px) and (max-width: 1120px) {
  .edms-topbar__button-label--primary {
    display: inline;
  }

  .edms-topbar__search .edms-button--primary {
    padding-inline: var(--space-4);
  }
}

@media (max-width: 1023px) {
  :root {
    --content-gutter: var(--space-4);
  }

  .edms-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .edms-shell__sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: var(--z-drawer);
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform var(--duration-slow) var(--ease-standard);
  }

  :root[dir='rtl'] .edms-shell__sidebar {
    transform: translateX(100%);
  }

  .edms-shell__sidebar[data-open='true'] {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .edms-shell__scrim {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-drawer) - 1);
    border: 0;
    background: var(--surface-overlay);
  }

  .edms-topbar__search {
    max-width: none;
  }

  .edms-search-cluster__scope {
    min-width: 104px;
  }
}

@media (min-width: 1024px) {
  .edms-shell__menu-toggle {
    display: none;
  }
}

@media (max-width: 767px) {
  .edms-page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .edms-page-header__actions {
    justify-content: flex-start;
  }

  .edms-toolbar__filter {
    max-width: none;
  }

  .edms-toast-region {
    inset-inline: var(--space-4);
    width: auto;
  }
}

/* ==========================================================================
   Boolean cell — the check/cross pair used across the Tools tables
   ========================================================================== */

.edms-bool {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
}

.edms-bool svg {
  width: 16px;
  height: 16px;
}

.edms-bool--yes {
  color: var(--success);
}

.edms-bool--no {
  color: var(--danger);
}

/* Long machine strings must not stretch a table past the viewport. */
.edms-truncate {
  display: inline-block;
  overflow: hidden;
  max-width: 34ch;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

/* Django's password rules, listed under the new-password field (capture 38). */
.edms-password-rules {
  margin-block-start: var(--space-3);
  padding-inline-start: var(--space-5);
  color: var(--text-default);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  list-style: disc;
}
