:root {
  color-scheme: light;
  --gold: #dd9f1b;
  --gold-dark: #9b6c0c;
  --charcoal: #252525;
  --ink: #171717;
  --muted: #6d675f;
  --paper: #f7f4ed;
  --white: #ffffff;
  --line: rgba(37, 37, 37, 0.14);
  --line-dark: rgba(255, 255, 255, 0.14);
  --danger: #9f2525;
  --danger-bg: #fff1f1;
  --shadow: 0 22px 70px rgba(18, 18, 18, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

.page-shell {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(37, 37, 37, 0.96) 0, rgba(37, 37, 37, 0.96) 330px, transparent 330px),
    linear-gradient(135deg, rgba(221, 159, 27, 0.12), transparent 42%);
}

main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 4vw, 42px);
}

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

h1 {
  color: var(--white);
  font-size: clamp(1.85rem, 4.2vw, 3.45rem);
  line-height: 0.95;
  text-transform: uppercase;
  margin-bottom: 14px;
}

h2 {
  color: var(--charcoal);
  font-size: clamp(1.35rem, 3vw, 2.2rem);
  line-height: 1.05;
}

h3 {
  color: var(--charcoal);
  font-size: 1.04rem;
}

h4 {
  color: var(--white);
  font-size: clamp(1.35rem, 3vw, 2.2rem);
  line-height: 0.95;
  text-transform: uppercase;
}

.hidden, [hidden] { display: none !important; }

.logo { width: 240px; margin-bottom: 34px; }

.auth-card,
.topbar,
.panel,
.tabs {
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.auth-card {
  max-width: 520px;
  margin: 8vh auto 0;
  border-top: 6px solid var(--gold);
  padding: clamp(24px, 5vw, 34px);
  background: var(--charcoal);
  color: var(--white);
}

.topbar {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  min-height: 144px;
  margin-bottom: 18px;
  padding: clamp(18px, 4vw, 28px);
  background: var(--charcoal);
  color: var(--white);
}

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

.brand img { width: 205px; flex: 0 0 auto; }

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.panel {
  border: 1px solid var(--line);
  background: var(--white);
  padding: clamp(18px, 4vw, 28px);
}

.admin-panel {
  margin-bottom: 18px;
  border-top: 6px solid var(--gold);
}

.section-head,
.file-row,
.comment-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.settings-grid,
.comments-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.settings-grid label:first-child,
.settings-grid button,
.upload-box,
.comments-grid > .panel {
  grid-column: span 2;
}

.upload-box {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.upload-box label:last-of-type,
.upload-box button {
  grid-column: span 2;
}

.danger-zone {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  border-top: 1px solid rgba(159, 37, 37, 0.25);
  padding-top: 18px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.muted, small {
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.5;
}

.topbar .muted,
.auth-card .muted { color: rgba(255, 255, 255, 0.72); }

.auth-card .muted { margin: 12px 0 22px; }

#loginTitle,
#packageTitle {
  max-width: 760px;
  overflow-wrap: anywhere;
}

.topbar .muted {
  margin-top: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(221, 159, 27, 0.14);
  color: var(--gold-dark);
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

label {
  display: block;
  margin-top: 14px;
  color: var(--charcoal);
  font-size: 0.86rem;
  font-weight: 850;
}

.auth-card label { color: var(--white); }

input, textarea {
  display: block;
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfaf6;
  color: var(--ink);
  font: inherit;
  padding: 13px 12px;
}

.auth-card input {
  border-color: var(--line-dark);
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}

textarea { resize: vertical; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--gold);
  color: #171717;
  font: inherit;
  font-weight: 900;
  padding: 12px 16px;
  cursor: pointer;
}

button.secondary,
.tab {
  border-color: var(--line-dark);
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}

button.subtle,
a.subtle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
  color: var(--charcoal);
  font: inherit;
  font-weight: 850;
  padding: 9px 11px;
  text-decoration: none;
}

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

button:disabled { opacity: 0.65; cursor: wait; }

#loginButton { width: 100%; margin-top: 18px; }

.error {
  border-radius: 4px;
  padding: 11px 12px;
  margin-top: 14px;
  background: var(--danger-bg);
  border: 1px solid rgba(159, 37, 37, 0.35);
  color: var(--danger);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  padding: 8px;
  background: var(--charcoal);
}

.tab {
  flex: 1;
}

.tab.active {
  background: var(--gold);
  color: #171717;
}

.revision-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.drawing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.revision-list,
.comment-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.drawing-card,
.revision-card,
.comment-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfaf6;
  padding: 14px;
}

.file-preview {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
  aspect-ratio: 16 / 10;
}

.file-preview img,
.file-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
}

.file-preview-fallback {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-weight: 850;
}

.file-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.file-actions > * {
  flex: 1;
}

.file-row span {
  color: var(--gold-dark);
  font-weight: 900;
}

.empty {
  text-align: left;
}

.comment-card.master {
  border-left: 5px solid var(--gold);
}

.comment-card.client {
  border-left: 5px solid var(--charcoal);
}

@media (max-width: 880px) {
  .topbar,
  .brand {
    align-items: flex-start;
    flex-direction: column;
  }

  .revision-layout,
  .settings-grid,
  .upload-box,
  .comments-grid {
    grid-template-columns: 1fr;
  }

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

  .settings-grid label:first-child,
  .settings-grid button,
  .upload-box,
  .upload-box label:last-of-type,
  .upload-box button,
  .comments-grid > .panel {
    grid-column: auto;
  }

  .brand img { width: 220px; }
}

@media (max-width: 560px) {
  main { padding: 12px; }
  .page-shell {
    background:
      linear-gradient(180deg, rgba(37, 37, 37, 0.96) 0, rgba(37, 37, 37, 0.96) 260px, transparent 260px),
      linear-gradient(135deg, rgba(221, 159, 27, 0.12), transparent 44%);
  }
  .logo,
  .brand img { width: 190px; }
  .top-actions,
  .tabs { width: 100%; }
  .drawing-grid { grid-template-columns: 1fr; }
  .tabs { flex-direction: column; }
  .top-actions button { flex: 1; }
  .section-head,
  .file-row,
  .comment-meta,
  .danger-zone {
    align-items: flex-start;
  }

  .danger-zone {
    flex-direction: column;
  }
}
