/* Brand / sidebar */
.brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.brand__link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}

.brand__link:hover {
  text-decoration: none;
}

.brand__logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand__name {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  line-height: 1.15;
}

.brand__title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #3d4654;
}

.brand__byline {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.brand__device {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.4rem;
  padding-left: 50px;
}

.nav {
  flex: 1;
  padding: 0.5rem 0;
  overflow-y: auto;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border-right: 3px solid transparent;
}

.nav__item:hover {
  background: var(--brand-muted);
  color: var(--brand);
  text-decoration: none;
}

.nav__item.is-active {
  background: var(--brand-muted);
  color: var(--brand);
  border-right-color: var(--brand);
}

.nav__icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  opacity: 0.85;
}

.storage-panel {
  margin: 0.75rem 1rem 1rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.storage-panel__title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.storage-panel__title + .storage-panel__title {
  margin-top: 0.85rem;
}

.progress {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 0.4rem 0;
}

.progress__bar {
  height: 100%;
  background: var(--brand);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress--warn .progress__bar {
  background: var(--warning);
}

.progress__meta {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Topbar */
.menu-toggle {
  display: none;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.menu-toggle:hover {
  background: var(--bg);
}

@media (max-width: 900px) {
  .menu-toggle {
    display: flex;
  }
}

.search-field {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.search-field__input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-field__input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
  background: var(--surface);
}

.search-field__icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: var(--text-tertiary);
  pointer-events: none;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

.status-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 0.35rem 0.75rem;
  background: var(--bg);
  border-radius: 999px;
  border: 1px solid var(--border);
}

.status-chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px var(--success-bg);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background var(--transition), transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--brand);
  color: #fff;
}

.btn--primary:hover {
  background: var(--brand-hover);
}

.btn--ghost {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
}

.btn--ghost:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.btn--icon {
  padding: 0.45rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.btn--icon:hover {
  background: var(--bg);
  color: var(--brand);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #3b9ddd);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Page */
.page-header {
  margin-bottom: 1.25rem;
}

.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-bottom: 0.25rem;
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--brand);
}

.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.breadcrumb a {
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.page-title {
  font-size: 1.625rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Cards */
.pipeline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.pipeline strong {
  color: var(--brand);
  font-weight: 600;
}

.pipeline__sep {
  color: var(--border-strong);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
}

.stat-card__label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  font-weight: 600;
}

.stat-card__value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--brand);
  margin-top: 0.2rem;
  letter-spacing: -0.02em;
}

.stat-card__hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.section-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
}

.section-bar__title {
  font-size: 1rem;
  font-weight: 600;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.segmented__btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
}

.segmented__btn.is-active {
  background: var(--brand);
  color: #fff;
}

.segmented__btn:not(.is-active):hover {
  background: var(--bg);
}

/* Media grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  grid-auto-rows: 118px;
  gap: 8px;
  margin-bottom: 2rem;
}

.media-grid.is-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.media-tile {
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  background: var(--border);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}

.media-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.media-tile--wide {
  grid-column: span 2;
}

.media-tile--tall {
  grid-row: span 2;
}

.media-tile__thumb {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: linear-gradient(145deg, var(--brand-muted), #d4e8f7);
}

.media-tile--folder .media-tile__thumb {
  background: var(--surface);
  font-size: 2.25rem;
}

.media-tile__label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 0.6rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
  color: #fff;
  font-size: 0.7rem;
  font-weight: 500;
}

.media-grid.is-list .media-tile {
  display: flex;
  align-items: center;
  height: auto;
  min-height: 52px;
}

.media-grid.is-list .media-tile__thumb {
  width: 48px;
  height: 48px;
  font-size: 1.25rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.media-grid.is-list .media-tile__label {
  position: static;
  background: none;
  color: var(--text);
  padding: 0 1rem;
  flex: 1;
}

/* Table */
.data-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1.25rem;
  background: var(--bg);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table td {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
}

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover td {
  background: var(--brand-muted);
}

.data-table tr.is-hidden {
  display: none;
}

.file-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.file-cell__icon {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

.badge--success {
  background: var(--success-bg);
  color: var(--success);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  padding: 0.75rem 1.1rem;
  background: var(--text);
  color: var(--surface);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--transition), transform var(--transition);
  z-index: 100;
  pointer-events: none;
}

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

.info-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  line-height: 1.6;
}

.info-box h3 {
  margin-bottom: 0.5rem;
  color: var(--brand);
}

.info-box code {
  background: var(--bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.settings-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.settings-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.settings-list span {
  color: var(--text-secondary);
}

.settings-list strong {
  text-align: right;
  font-weight: 500;
}

.live-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  background: var(--border);
  color: var(--text-secondary);
}

.live-badge.is-on {
  background: var(--success-bg);
  color: var(--success);
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.login-hero {
  background: linear-gradient(160deg, var(--brand) 0%, #003d7a 55%, #002952 100%);
  color: #fff;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-hero__logo {
  width: 72px;
  height: 72px;
  margin-bottom: 2rem;
  filter: brightness(0) invert(1);
}

.login-hero h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  max-width: 320px;
}

.login-hero p {
  margin-top: 1rem;
  opacity: 0.9;
  max-width: 380px;
  line-height: 1.6;
  font-size: 0.95rem;
}

.login-hero__features {
  margin-top: 2.5rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.login-hero__features li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.login-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--surface);
}

.login-form {
  width: 100%;
  max-width: 380px;
}

.login-form__brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 2rem;
}

.login-form__brand img {
  width: 48px;
  height: 48px;
}

.login-form h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.login-form__sub {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}

.field {
  margin-bottom: 1.1rem;
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-secondary);
}

.field input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

#user-access-field.is-disabled .user-volume-list {
  opacity: 0.55;
  pointer-events: none;
}

.user-volume-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 180px;
  overflow-y: auto;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle, var(--bg));
}

.user-volume-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.35rem 0.4rem;
  border-radius: var(--radius-sm);
}

.user-volume-item:hover {
  background: var(--brand-muted);
}

.user-volume-item.is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.user-volume-item__tag {
  font-size: 0.7rem;
  color: var(--warning);
  font-style: normal;
  margin-left: auto;
}

.settings-subtitle {
  font-size: 0.85rem;
  font-weight: 700;
  margin: 1.25rem 0 0.65rem;
  color: var(--text);
}

.vol-settings-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.vol-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle, var(--bg));
}

.vol-settings-row__id {
  display: block;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 0.15rem;
}

.login-form .btn--primary {
  width: 100%;
  justify-content: center;
  padding: 0.7rem;
  margin-top: 0.5rem;
}

.login-form__footer {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

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

  .login-hero {
    padding: 2rem;
    min-height: auto;
  }

  .login-hero__logo {
    width: 56px;
    height: 56px;
    margin-bottom: 1rem;
  }
}
