:root {
  --hema-red: #e30613;
  --ink: #202124;
  --muted: #6b7280;
  --line: #d9dde3;
  --panel: #f6f7f9;
  --slot: #ffffff;
  --focus: #006fb9;
}

* {
  box-sizing: border-box;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 14px 22px;
  color: #fff;
  background: var(--hema-red);
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

#userLabel {
  margin: 4px 0 0;
  font-size: 13px;
}

button,
select,
input {
  font: inherit;
}

button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #fff;
  background: #111827;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: .55;
}

.hidden {
  display: none !important;
}

.login-view {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: #e9edf2;
}

.login-panel {
  display: grid;
  gap: 14px;
  width: min(360px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
}

.login-panel h1 {
  color: var(--hema-red);
}

.login-status {
  min-height: 20px;
  color: var(--hema-red);
  font-size: 13px;
}

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

.language-select {
  width: auto;
  min-width: 132px;
}

.workspace {
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: calc(100vh - 72px);
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 22px;
  border-bottom: 1px solid #bfc7d2;
  background: #f5f5f6;
}

.nav-tab {
  min-height: 30px;
  padding: 0 12px;
  color: var(--ink);
  border-radius: 0;
  background: transparent;
}

.nav-tab.active {
  font-weight: 700;
  border-bottom: 3px solid var(--hema-red);
}

.admin-view {
  padding: 16px 22px 40px;
  background: #fff;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  margin: -16px -22px 12px;
  padding: 10px 22px;
  border-bottom: 1px solid #c9ccd1;
  background: #d8d6d6;
}

.admin-toolbar h2 {
  min-width: 130px;
  margin: 0;
  font-size: 24px;
  font-weight: 400;
}

.admin-toolbar input {
  width: 220px;
}

.admin-toolbar select {
  width: auto;
  min-width: 150px;
}

.import-button {
  display: inline-grid;
  place-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  color: #fff;
  background: #111827;
  cursor: pointer;
  text-transform: none;
}

.import-button input {
  display: none;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  padding: 7px 8px;
  text-align: left;
  font-weight: 700;
  background: #fff;
}

td {
  padding: 6px 8px;
  white-space: nowrap;
}

tbody tr:nth-child(odd) {
  background: #eef1f5;
}

tbody tr:nth-child(even) {
  background: #fff;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 10px;
}

.settings-grid .wide {
  grid-column: span 3;
}

.users-editor {
  display: grid;
  gap: 10px;
}

.user-row {
  display: grid;
  grid-template-columns: 95px 1fr 1.25fr .9fr 90px 95px 1.25fr 120px 38px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.user-row button {
  min-height: 34px;
  padding: 0 8px;
}

.asset-panel {
  border-right: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}

.filters {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

select,
input {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
}

.asset-count,
.status {
  min-height: 30px;
  padding: 8px 14px;
  color: var(--muted);
  font-size: 13px;
}

.asset-list {
  height: calc(100vh - 252px);
  overflow: auto;
  padding: 10px 14px 18px;
}

.asset {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 12px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  cursor: grab;
}

.asset img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid #cdd3dc;
  background: #fff;
}

.asset-title {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-area {
  overflow: auto;
  padding: 18px 24px 40px;
}

.pages {
  display: flex;
  align-items: flex-start;
  gap: 22px;
}

.page-wrap {
  display: grid;
  gap: 8px;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.page-title .download {
  margin-left: auto;
}

.created-at {
  margin-left: auto;
  color: var(--ink);
  font-size: 12px;
}

.created-at + .download {
  margin-left: 0;
}

.remove-page {
  min-height: 28px;
  padding: 0 9px;
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.page {
  width: 420px;
  aspect-ratio: 210 / 297;
  padding: 39px 21px;
  border: 1px solid #bfc7d2;
  background: #fff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .12);
}

.slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1093 / 159;
  margin-bottom: 20px;
  border: 1px dashed #9aa4b2;
  color: var(--muted);
  background: var(--slot);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.slot:last-child {
  margin-bottom: 0;
}

.slot.drag-over {
  border-color: var(--focus);
  outline: 3px solid rgba(0, 111, 185, .16);
}

.slot-label {
  position: absolute;
  left: 4px;
  right: 4px;
  top: -17px;
  overflow: hidden;
  color: var(--ink);
  font-size: 10px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.download {
  color: var(--focus);
  font-weight: 700;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .asset-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    height: auto;
    max-height: 45vh;
  }

  .page {
    width: min(420px, calc(100vw - 48px));
  }
}
