:root {
  --blue: #1266c8;
  --blue-dark: #0b4d9b;
  --ink: #15345f;
  --muted: #64748b;
  --surface: #fff;
  --border: #d6e0ec;
  --danger: #b42318;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  background: #edf4fb;
  color: var(--ink);
  margin: 0;
}

button, input, select, textarea { font: inherit; }

.shell {
  margin: 0 auto;
  max-width: 1440px;
  padding: clamp(1.25rem, 3vw, 3rem);
}

.login { align-items: center; display: flex; min-height: 100vh; justify-content: center; }
.login .panel { max-width: 390px; width: 100%; }

.topbar, .section-heading, .actions, .gallery-toolbar {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.topbar { align-items: flex-start; margin-bottom: 1.5rem; }
.topbar h1, .panel h2 { margin: 0; }
.topbar h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
.subtitle, .hint { color: var(--muted); line-height: 1.5; margin: .45rem 0 0; }
.hint { font-size: .91rem; max-width: 52rem; }

.panel {
  background: var(--surface);
  border: 1px solid #e2eaf3;
  border-radius: 1.1rem;
  box-shadow: 0 .75rem 2rem rgba(20, 58, 93, .08);
  margin: 1.15rem 0;
  padding: clamp(1.25rem, 2.5vw, 1.8rem);
}

.panel.compact { max-width: 940px; }

.grid {
  display: grid;
  gap: 1rem 1.25rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1.1rem;
}

.field, .field label { display: grid; gap: .42rem; font-weight: 700; }
.field.full { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: 1.2rem; }
.checks label { display: inline-flex; gap: .5rem; }

input:not([type="checkbox"]):not([type="file"]), select, textarea {
  background: #fff;
  border: 1px solid #bfcddb;
  border-radius: .6rem;
  color: #173655;
  min-height: 2.8rem;
  padding: .65rem .8rem;
  width: 100%;
}

input[type="color"] { cursor: pointer; height: 2.8rem; padding: .25rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, .image-slot:focus-visible { outline: 3px solid rgba(18, 102, 200, .35); outline-offset: 2px; }
textarea { min-height: 5rem; resize: vertical; }

.button {
  background: var(--blue);
  border: 1px solid var(--blue);
  border-radius: .6rem;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  padding: .68rem 1rem;
  text-decoration: none;
  transition: background .15s, transform .15s;
}

.button:hover { background: var(--blue-dark); transform: translateY(-1px); }
.button.secondary { background: #fff; border-color: #b9c7d5; color: var(--ink); }
.button.secondary:hover { background: #f4f8fc; }
.button.danger { background: var(--danger); border-color: var(--danger); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }

.notice { background: #e5f5ec; border: 1px solid #9dd6b2; border-radius: .65rem; color: #176639; margin: 1rem 0; padding: .8rem 1rem; }
.notice.error { background: #fff0ef; border-color: #f1aaa3; color: #9d2118; }

.media-manager { background: linear-gradient(135deg, #fff, #f4f9ff); }
.upload-button { align-items: center; white-space: nowrap; }
.upload-button.is-uploading { cursor: wait; opacity: .8; pointer-events: none; }
.upload-button input { height: 1px; opacity: 0; overflow: hidden; position: absolute; width: 1px; }

.gallery-toolbar { background: #edf4fb; border-radius: .65rem; margin: 1rem 0; padding: .65rem .8rem; }
.gallery-toolbar span { color: var(--muted); font-size: .92rem; font-weight: 700; }

.gallery {
  display: grid;
  gap: .9rem;
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
}

.gallery-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: .65rem;
  cursor: grab;
  min-width: 0;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}

.gallery-item:hover { border-color: var(--blue); box-shadow: 0 .45rem 1rem rgba(18, 102, 200, .14); transform: translateY(-2px); }
.gallery-item.dragging { opacity: .5; }
.gallery-item img { background: #e8f0f8; display: block; height: 108px; object-fit: cover; width: 100%; }
.gallery-check { align-items: center; cursor: pointer; display: flex; font-size: .75rem; gap: .45rem; overflow: hidden; padding: .55rem; }
.gallery-check span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-gallery { color: var(--muted); grid-column: 1 / -1; margin: .5rem 0; }

.month-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  margin-top: 1.1rem;
}

.month-card { border: 1px solid var(--border); border-radius: .75rem; padding: .85rem; }
.month-card h3 { font-size: 1rem; margin: 0 0 .75rem; }
.orientation-slots { display: grid; gap: .7rem; grid-template-columns: 1fr 1fr; }
.orientation-slots > div > span { color: var(--muted); display: block; font-size: .75rem; font-weight: 700; margin: 0 0 .35rem; }

.image-slot {
  align-items: center;
  background: #f9fbfd;
  border: 2px dashed #a9bbce;
  border-radius: .65rem;
  cursor: pointer;
  display: grid;
  min-height: 115px;
  overflow: hidden;
  position: relative;
  text-align: center;
  transition: background .15s, border-color .15s, box-shadow .15s;
}

.image-slot:hover, .image-slot.active { border-color: var(--blue); }
.image-slot.active { box-shadow: 0 0 0 3px rgba(18, 102, 200, .15); }
.image-slot.active-drop { background: #e5f2ff; border-color: var(--blue); }
.slot-preview { align-items: center; color: var(--muted); display: flex; font-size: .76rem; height: 85px; justify-content: center; padding: .4rem; }
.slot-preview img { border-radius: .35rem; height: 100%; object-fit: cover; width: 100%; }
.image-slot small { background: rgba(255,255,255,.94); color: #42586f; font-size: .67rem; overflow: hidden; padding: .35rem .45rem; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.image-slot:not(.filled) small:empty { display: none; }

.period-list { display: grid; gap: .75rem; margin-top: 1.1rem; }
.period-row { align-items: stretch; background: #f8fbfe; border: 1px solid var(--border); border-radius: .75rem; display: grid; gap: .8rem; grid-template-columns: minmax(185px, .8fr) minmax(160px, 1fr) minmax(160px, 1fr) auto; padding: .8rem; }
.period-row .image-slot { min-height: 96px; }
.period-row .slot-preview { height: 67px; }
.date-fields { display: grid; gap: .55rem; grid-template-columns: .75fr 1.25fr; }
.date-fields label { display: grid; font-size: .78rem; font-weight: 700; gap: .3rem; }
.date-fields select { min-height: 2.5rem; }
.icon-button { align-self: center; background: #fff; border: 1px solid #e2a8a2; border-radius: 50%; color: var(--danger); cursor: pointer; font-size: 1.4rem; height: 2rem; line-height: 1; padding: 0; width: 2rem; }
.icon-button:hover { background: #fff0ef; }

@media (max-width: 760px) {
  .topbar, .section-heading { align-items: flex-start; flex-direction: column; }
  .grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .period-row { grid-template-columns: 1fr 1fr auto; }
  .date-fields { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .shell { padding: 1rem; }
  .topbar .actions { width: 100%; }
  .topbar .button { flex: 1; }
  .period-row { grid-template-columns: 1fr auto; }
  .period-row .image-slot { grid-column: span 1; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
