* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: #f6f2ec;
  color: #111;
  font-family: Arial, sans-serif;
}

.app-wrap {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 430px;
  margin-top: 12px;
  padding: 28px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.08);
}

.wide {
  max-width: 620px;
}

.wide.list-mode {
  height: calc((100svh - 48px) * 0.97);
  max-height: 740px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wide.list-mode #listView {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.wide.list-mode .giftcard-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.wide.detail-mode {
  height: calc((100svh - 48px) * 0.97);
  max-height: 740px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wide.detail-mode #detailView {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.wide.detail-mode .big-status {
  flex: 0 0 auto;
}

.wide.detail-mode .info-list {
  min-height: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  overflow: hidden;
  margin-top: 24px;
  padding-right: 4px;
  padding-bottom: 0;
  margin-bottom: 8px;
}

.wide.detail-mode #adminControls {
  flex: 0 0 auto;
  padding-top: 0;
  background: #fff;
}

.wide.edit-mode,
.wide.add-mode {
  height: calc((100svh - 48px) * 0.97);
  max-height: 740px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 12px;
}

.wide.edit-mode #editView,
.wide.add-mode #addView {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.form-scroll {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  margin-top: 26px;
  padding-left: 8px;
  padding-right: 8px;
  padding-bottom: 24px;
  -webkit-overflow-scrolling: touch;
}

.wide.edit-mode #saveBtn,
.wide.edit-mode #saveMsg,
.wide.add-mode #addSaveBtn,
.wide.add-mode #addMsg {
  flex: 0 0 auto;
}

.wide.edit-mode .form-scroll label,
.wide.edit-mode .form-scroll input,
.wide.edit-mode .form-scroll select,
.wide.edit-mode .form-scroll textarea,
.wide.add-mode .form-scroll label,
.wide.add-mode .form-scroll input,
.wide.add-mode .form-scroll select,
.wide.add-mode .form-scroll textarea {
  width: calc(100% - 36px);
  margin-left: 18px;
  margin-right: 18px;
}

.wide.edit-mode .form-scroll input[type="date"] {
  width: calc(100% - 36px);
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  overflow: hidden;
}

#editDate {
  width: calc(100% - 36px) !important;
  margin-left: 18px !important;
  margin-right: 18px !important;
}

.wide.edit-mode #saveBtn,
.wide.add-mode #addSaveBtn {
  width: calc(100% - 28px);
  margin: 10px auto 4px;
  padding-top: 13px;
  padding-bottom: 13px;
  display: block;
}

.wide.edit-mode #saveMsg,
.wide.add-mode #addMsg {
  display: none;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.status-title {
  font-size: 38px;
  font-weight: bold;
}

#loginScreen h1 {
  margin-bottom: 60px;
  text-align: center;
}

label {
  display: block;
  margin: 16px 0 6px;
  font-weight: bold;
  font-size: 14px;
}

.hidden-label {
  visibility: hidden;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 15px;
  border-radius: 14px;
  border: 1px solid #ddd;
  font-size: 16px;
  background: #fff;
}

select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 44px;
  background-image:
    linear-gradient(45deg, transparent 50%, #555 50%),
    linear-gradient(135deg, #555 50%, transparent 50%);
  background-position:
    calc(100% - 23px) 50%,
    calc(100% - 16px) 50%;
  background-size:
    7px 7px,
    7px 7px;
  background-repeat: no-repeat;
  color: #111;
  line-height: 1.2;
}

input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  height: 52px;
  line-height: 20px;
}

input[type="date"]::-webkit-date-and-time-value {
  min-height: 20px;
  text-align: left;
}

#pin {
  text-align: center;
  letter-spacing: 8px;
  font-size: 22px;
}

textarea {
  min-height: 105px;
  font-family: Arial, sans-serif;
  resize: vertical;
}

button {
  width: 100%;
  margin-top: 20px;
  padding: 15px;
  border: 0;
  border-radius: 14px;
  background: #111;
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  font-family: Arial, sans-serif;
}

button:hover {
  opacity: 0.9;
}

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

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.small-btn {
  width: auto;
  margin: 0;
  padding: 10px 14px;
  background: #eee;
  color: #111;
  font-size: 13px;
}

.light-btn {
  background: #eee;
  color: #111;
}

.danger-btn {
  margin-top: 10px;
  background: #fdecec;
  color: #b00020;
}

.list-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.compact-btn {
  margin-top: 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
}

#error {
  display: none;
  margin-top: 16px;
  padding: 12px;
  border-radius: 12px;
  background: #fdecec;
  color: #b00020;
  text-align: center;
}

.welcome-box {
  margin-top: 24px;
  padding: 20px;
  border-radius: 18px;
  background: #f6f2ec;
}

.welcome-box p {
  margin: 0;
  color: #666;
  line-height: 1.5;
}

.giftcard-list {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.giftcard-item {
  padding: 15px;
  border: 1px solid #e9e9e9;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04);
  cursor: pointer;
}

.giftcard-number {
  color: #111;
  font-size: 22px;
  font-weight: bold;
}

.giftcard-status {
  margin-top: 5px;
  font-size: 32px;
  font-weight: bold;
  text-align: center;
}

.active {
  color: green;
}

.used {
  color: red;
}

.big-status {
  margin: 28px 0 34px;
  font-size: 52px;
  font-weight: bold;
  text-align: center;
}

.info-list {
  margin-bottom: 34px;
}

.info-row {
  display: flex;
  min-height: 0;
  flex: 1 1 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #e4e4e4;
  font-size: 17px;
  line-height: 1.25;
}

.info-row span {
  flex: 0 0 40%;
  color: #777;
}

.info-row strong {
  min-width: 0;
  flex: 1;
  color: #111;
  font-weight: normal;
  text-align: right;
  overflow-wrap: anywhere;
  overflow: hidden;
}

.info-row:last-child {
  flex: 1.8 1 0;
  align-items: flex-start;
}

.info-row:last-child strong {
  max-height: 4.8em;
}

.two-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

#saveMsg,
#addMsg {
  color: #666;
  font-size: 14px;
  text-align: center;
}

.save-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(120, 120, 120, 0.35);
  backdrop-filter: blur(4px);
  z-index: 999;
}

.save-overlay.show {
  display: flex;
}

.save-box {
  min-width: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 28px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
}

.save-box p {
  margin: 0;
  color: #111;
  font-size: 15px;
  font-weight: bold;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 4px solid #e6e0d8;
  border-top-color: #111;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 520px) {
  .app-wrap {
    min-height: 100svh;
    padding: 16px;
  }

  .card {
    margin-top: 0;
    padding: 22px;
    border-radius: 22px;
  }

  .wide.list-mode {
    height: calc((100svh - 32px) * 0.97);
    max-height: none;
  }

  .wide.detail-mode {
    height: calc((100svh - 32px) * 0.97);
    max-height: none;
  }

  .wide.edit-mode,
  .wide.add-mode {
    height: calc((100svh - 32px) * 0.97);
    max-height: none;
  }

  h1 {
    font-size: 24px;
  }

  .giftcard-status {
    font-size: 30px;
  }

  .big-status {
    font-size: 46px;
  }

  .info-row {
    gap: 10px;
    padding: 8px 0;
    font-size: 16px;
  }
}
