:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #687684;
  --line: #d7dde3;
  --accent: #087f8c;
  --accent-dark: #066873;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
.display-link {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 10px 14px;
  text-decoration: none;
}

button:hover,
.display-link:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: #e8edf1;
  color: var(--text);
}

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

button.warning {
  background: #b7791f;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  padding: 10px 12px;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  padding: 10px 12px;
  background: #fff;
}

.login-page {
  min-height: 100vh;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(10, 31, 68, 0.10), rgba(190, 24, 32, 0.06)),
    #e7eaee;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(340px, 1.1fr) minmax(320px, 430px);
  min-height: calc(100vh - 56px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(10, 15, 25, 0.18);
}

.login-brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 5vw, 64px);
  background:
    linear-gradient(135deg, rgba(8, 18, 36, 0.96), rgba(10, 31, 68, 0.96) 56%, rgba(166, 24, 35, 0.92)),
    #0a1f44;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.login-brand-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, transparent 0 56%, rgba(255, 255, 255, 0.10) 56% 58%, transparent 58%),
    linear-gradient(125deg, transparent 0 68%, rgba(190, 24, 32, 0.42) 68% 76%, transparent 76%);
  pointer-events: none;
}

.login-brand-panel > * {
  position: relative;
  z-index: 1;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(135deg, #ffffff 0 48%, #be1820 48% 58%, #0f4c9a 58% 100%);
  color: #071427;
  font-size: 26px;
  font-weight: 800;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
}

.system-label {
  margin: 28px 0 8px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-brand-panel h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(40px, 6.3vw, 78px);
  line-height: 1;
}

.brand-copy {
  max-width: 620px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 18px;
  line-height: 1.55;
}

.login-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 34px;
}

.login-status-grid span {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  padding: 12px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 700;
}

.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(26px, 4vw, 46px);
  background:
    linear-gradient(180deg, #ffffff, #f8fafc);
  border-left: 6px solid #be1820;
}

.login-mini-brand {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  background: #0a1f44;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
  margin-bottom: 18px;
}

.login-card-head h2 {
  margin: 0;
  font-size: 30px;
  color: #101828;
}

.login-card-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.login-form input {
  padding: 13px 14px;
  background: #ffffff;
  border-color: #cbd5e1;
}

.login-form input:focus {
  border-color: #0f4c9a;
  box-shadow: 0 0 0 3px rgba(15, 76, 154, 0.14);
  outline: none;
}

.login-form button {
  margin-top: 4px;
  padding: 13px 14px;
  background: #0f4c9a;
}

.login-form button:hover {
  background: #0a1f44;
}

.login-footnote {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.error-message {
  color: var(--danger);
}

.display-page {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #000;
}

.display-stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000;
}

.display-stage img,
.display-stage iframe,
.display-stage canvas {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
  background: #000;
}

.display-stage canvas {
  width: auto;
  height: auto;
  max-width: 100vw;
  max-height: 100vh;
}

.empty-state {
  display: grid;
  gap: 8px;
  color: #dce3ea;
  text-align: center;
}

.empty-state strong {
  font-size: 30px;
}

.display-meta {
  position: fixed;
  left: 18px;
  bottom: 14px;
  max-width: min(620px, calc(100vw - 36px));
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  font-size: 14px;
  padding: 8px 11px;
}

.display-meta:empty {
  display: none;
}

.fullscreen-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 5;
  background: rgba(8, 127, 140, 0.88);
}

:fullscreen .fullscreen-btn {
  display: none;
}


.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.secondary-link {
  background: #e8edf1;
  color: var(--text);
}

.topbar h1,
.topbar p,
.panel h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 24px;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
}

.control-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(320px, 460px) 1fr;
  gap: 16px;
  padding: 16px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 16px;
  padding: 16px;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.inline-check input {
  width: auto;
}

.user-list {
  display: grid;
  gap: 10px;
}

.user-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr 120px 90px 80px 92px 80px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.freeze-grid {
  display: grid;
  gap: 8px;
}

.freeze-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  background: #dff7e8;
  color: #075e27;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.off {
  background: #fde8e8;
  color: #9b1c1c;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.panel h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

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

.panel-title-row h2 {
  margin-bottom: 0;
}

.small-btn {
  padding: 7px 10px;
  font-size: 13px;
}

.upload-form {
  display: grid;
  gap: 14px;
}

.upload-form label,
.seconds-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.message {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
}

.progress-wrap {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.progress-wrap[hidden] {
  display: none;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.progress-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe6ec;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 160ms ease;
}

.current-preview {
  display: grid;
  place-items: center;
  position: relative;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #111;
  color: #fff;
}

.annotation-toolbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.annotation-toolbar button.active {
  background: #0f4c9a;
  color: #fff;
}

.current-preview.cursor-active {
  cursor: grab;
}

.current-preview.cursor-active:active {
  cursor: grabbing;
}

.view-transform-target {
  transition: transform 90ms ease;
  transform-origin: center center;
}

.annotation-canvas {
  touch-action: none;
}

.control-annotation-canvas {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.current-preview.annotation-active .control-annotation-canvas {
  pointer-events: auto;
  cursor: crosshair;
}

.display-annotation-canvas {
  position: fixed;
  inset: 0;
  z-index: 4;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

.current-preview img,
.current-preview iframe,
.current-preview canvas {
  width: 100%;
  height: 260px;
  border: 0;
  object-fit: contain;
}

.pdf-preview {
  display: grid;
  place-items: center;
  gap: 10px;
  width: 100%;
  min-height: 260px;
  padding: 12px;
  text-align: center;
}

.pdf-preview canvas {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 220px;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.26);
}

.pdf-preview-meta {
  display: grid;
  gap: 4px;
}

.pdf-preview-meta span {
  max-width: 100%;
  color: #fff;
  font-weight: 700;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.pdf-preview-meta em {
  color: #d8e0e7;
  font-style: normal;
  font-size: 12px;
}

.control-row {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.control-row > * {
  flex: 1;
}

.slides-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 150px);
  overflow: auto;
}

.slide-item {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.slide-item.active {
  border-color: #169b45;
  background: #dff7e8;
  box-shadow: 0 0 0 2px rgba(22, 155, 69, 0.18);
}

.slide-item.active .slide-title {
  color: #075e27;
}

.slide-item.active .slide-file {
  color: #1f6f3b;
}

.thumb {
  display: grid;
  place-items: center;
  width: 96px;
  height: 58px;
  border-radius: 5px;
  overflow: hidden;
  background: #111;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slide-title {
  margin: 0 0 4px;
  font-weight: 700;
}

.slide-file {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

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

@media (max-width: 1100px) {
  .control-layout {
    grid-template-columns: 1fr;
  }

  .admin-layout,
  .user-row {
    grid-template-columns: 1fr;
  }

  .slides-list {
    max-height: none;
  }
}

@media (max-width: 820px) {
  .login-page {
    padding: 14px;
  }

  .login-shell {
    grid-template-columns: 1fr;
    min-height: calc(100vh - 28px);
  }

  .login-brand-panel {
    min-height: 300px;
  }

  .login-status-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar,
  .control-row {
    align-items: stretch;
    flex-direction: column;
  }

  .slide-item {
    grid-template-columns: 72px 1fr;
  }

  .thumb {
    width: 72px;
    height: 48px;
  }

  .slide-actions {
    grid-column: 1 / -1;
  }
}

/* Mobile enhancements */
@media (max-width: 480px) {
  .admin-layout,
  .control-row {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    padding: 8px !important;
  }

  .topbar h1 { font-size: 1rem !important; }
  .topbar p { font-size: .75rem !important; }

  .top-actions {
    flex-wrap: wrap;
    gap: 4px;
  }
  .top-actions .display-link {
    font-size: .75rem !important;
    padding: 4px 10px !important;
  }

  .panel { padding: 12px !important; }

  .upload-form label,
  .admin-layout label {
    font-size: .85rem !important;
  }

  input, select, button {
    font-size: .9rem !important;
    padding: 10px 12px !important;
  }

  .freeze-grid {
    grid-template-columns: 1fr !important;
  }

  .user-row {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
  }

  .login-card {
    padding: 24px !important;
  }

  h2 { font-size: 1rem !important; }

  .slide-item {
    font-size: .8rem !important;
  }

  .display-link {
    white-space: nowrap;
  }
}

@media (max-width: 360px) {
  .top-actions .display-link {
    font-size: .7rem !important;
    padding: 3px 8px !important;
  }
  
  .panel { padding: 8px !important; }
}
