:root {
  color-scheme: light;
  --ink: #182028;
  --muted: #687586;
  --line: #d9e0e8;
  --paper: #f7f9fb;
  --panel: #ffffff;
  --blue: #1769e0;
  --blue-dark: #0e4eaa;
  --green: #1d7f53;
  --red: #bf2d2d;
  --amber: #a35f00;
  --shadow: 0 14px 36px rgba(26, 37, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--blue);
}

h1,
h2,
p {
  margin: 0;
}

button,
input {
  font: inherit;
}

label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input:not([type]) {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

.password-wrap {
  position: relative;
  display: block;
}

.password-wrap input {
  padding-right: 48px;
}

.password-toggle {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  position: absolute;
  right: 2px;
  top: 2px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--ink);
  background: #eef3f8;
  outline: none;
}

.password-toggle svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

input[type="file"] {
  width: 100%;
  min-height: 42px;
  border: 1px dashed #b4bfcb;
  border-radius: 7px;
  background: #fff;
  padding: 9px;
}

small,
.meta-line {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(23, 105, 224, 0.10), transparent 46%),
    linear-gradient(315deg, rgba(29, 127, 83, 0.10), transparent 48%),
    var(--paper);
}

.login-shell {
  width: min(100%, 420px);
}

.login-panel,
.upload-panel,
.contract-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  padding: 32px;
}

.login-logo {
  width: 78px;
  height: 78px;
  display: block;
  object-fit: contain;
  margin: 0 0 18px;
}

.login-panel h1 {
  font-size: 32px;
  line-height: 1;
}

.login-panel p {
  margin-top: 8px;
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(14px);
}

.topbar h1 {
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.page {
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 32px) 56px;
}

.notice {
  border: 1px solid #bdd5ff;
  background: #eef5ff;
  color: #123f7f;
  border-radius: 7px;
  padding: 12px 14px;
  margin-bottom: 18px;
  font-weight: 700;
}

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

.stats-grid div {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.stats-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stats-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(260px, 0.7fr);
  gap: 18px;
  align-items: start;
}

.upload-panel,
.contract-panel {
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin-top: 4px;
  font-size: 22px;
  line-height: 1.1;
}

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

.date-row,
.ad-main,
.ad-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.toggle {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  font-weight: 800;
  white-space: nowrap;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #bfc8d3;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 14px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.button.primary:hover {
  background: var(--blue-dark);
}

.button.ghost {
  background: transparent;
}

.button.danger {
  border-color: #f0c4c4;
  color: var(--red);
}

.contract-panel p {
  color: var(--muted);
  line-height: 1.55;
}

.endpoint {
  display: block;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f0f4f8;
  padding: 12px;
  margin-bottom: 12px;
  color: #293440;
  font-size: 13px;
}

.list-section {
  margin-top: 26px;
}

.empty {
  border: 1px dashed #b4bfcb;
  border-radius: 8px;
  padding: 28px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.ad-list {
  display: grid;
  gap: 14px;
}

.ad-row {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.preview-wrap {
  aspect-ratio: 8 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101820;
  overflow: hidden;
}

.preview-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.ad-form {
  display: grid;
  gap: 12px;
}

.ad-controls {
  grid-template-columns: minmax(110px, auto) repeat(2, minmax(140px, 1fr)) auto;
  align-items: end;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.meta-line code {
  overflow-wrap: anywhere;
}

.delete-form {
  display: flex;
}

@media (max-width: 900px) {
  .stats-grid,
  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ad-row {
    grid-template-columns: 1fr;
  }

  .preview-wrap {
    max-width: 420px;
  }

  .delete-form {
    justify-content: flex-start;
  }
}

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

  .page {
    padding-top: 18px;
  }

  .stats-grid,
  .admin-grid,
  .date-row,
  .ad-main,
  .ad-controls {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 24px;
  }

  .section-head {
    flex-direction: column;
  }
}
