:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --border: #d9e1ec;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 280px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  background: #101828;
  color: #f8fafc;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: #cbd5e1;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.side-link {
  padding: 11px 12px;
  border-radius: 8px;
  color: #e2e8f0;
}

.side-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  color: #cbd5e1;
  font-size: 14px;
}

.main {
  width: calc(100% - 280px);
  padding: 34px;
}

.auth-main {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card,
.file-panel,
.file-detail {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(460px, 100%);
  display: grid;
  gap: 26px;
  padding: 32px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 8px;
  font-size: 32px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

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

.form {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

.code-input {
  font-size: 24px;
  font-weight: 800;
  text-align: center;
}

.primary-button,
.small-button,
.link-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button.compact {
  min-height: 40px;
}

.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  background: #e6f4f1;
  color: var(--accent-strong);
  font-weight: 700;
}

.link-button {
  width: fit-content;
  padding: 0;
  background: transparent;
  color: #fff;
  font-weight: 700;
}

.secondary-link {
  color: var(--accent-strong);
  font-weight: 700;
}

.flash {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
}

.flash.alert {
  color: var(--danger);
  border-color: #fecdca;
  background: #fffbfa;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-header h1 {
  max-width: 760px;
}

.search-form {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(430px, 100%);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 14px;
}

.breadcrumbs a {
  color: var(--accent-strong);
  font-weight: 700;
}

.file-panel,
.file-detail {
  padding: 18px;
}

.parent-link {
  display: inline-flex;
  margin-bottom: 12px;
  color: var(--accent-strong);
  font-weight: 800;
}

.file-table {
  display: grid;
  width: 100%;
  overflow-x: auto;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 140px 170px 130px;
  align-items: center;
  min-width: 780px;
  min-height: 54px;
  gap: 14px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
}

.file-row:last-child {
  border-bottom: 0;
}

.file-row-head {
  min-height: 40px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.file-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 750;
}

.file-name span:last-child,
.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-kind {
  width: 44px;
  min-width: 44px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

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

.empty-state {
  padding: 42px 16px;
  text-align: center;
  background: var(--panel-soft);
  border-radius: 8px;
}

.metadata-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.metadata-strip span {
  display: grid;
  gap: 4px;
  min-width: 160px;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.metadata-strip strong {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.preview-frame {
  width: 100%;
  height: min(72vh, 820px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
}

.image-preview {
  display: grid;
  place-items: center;
  overflow: auto;
}

.image-preview img {
  max-width: 100%;
  max-height: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-card strong {
  font-size: 30px;
}

.stat-card span {
  color: var(--muted);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.section-title h2 {
  margin: 0;
}

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

  .sidebar {
    width: 100%;
    min-height: auto;
    position: static;
  }

  .main {
    width: 100%;
    padding: 18px;
  }

  .page-header,
  .search-form {
    display: grid;
  }

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

@media (max-width: 560px) {
  h1 {
    font-size: 26px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
