* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

body {
  background: #d9d4c5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: 400;
}

/* iOS font weight fix */
* {
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
}

/* ========== ЕКРАН ПОМИЛКИ ========== */
.error-screen {
  position: fixed;
  inset: 0;
  background: #d9d4c5;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.error-screen.hidden {
  display: none;
}

.error-inner {
  width: 100%;
  max-width: 390px;
  text-align: center;
}

.error-icon {
  font-size: 72px;
  margin-bottom: 24px;
}

.error-title {
  font-size: 26px;
  font-weight: 400;
  color: #1a1a1a;
  margin-bottom: 16px;
  letter-spacing: -0.3px;
}

.error-text {
  font-size: 17px;
  color: #6a6a6a;
  line-height: 1.5;
  margin-bottom: 32px;
}

.error-steps {
  background: rgba(255, 255, 255, 0.5);
  border-radius: 16px;
  padding: 20px;
  text-align: left;
}

.error-step {
  font-size: 16px;
  color: #1a1a1a;
  margin-bottom: 12px;
  line-height: 1.5;
}

.error-step:last-child {
  margin-bottom: 0;
}

/* ========== PIN-ЕКРАН ========== */
.pin-screen {
  position: fixed;
  inset: 0;
  background: #d9d4c5;
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 80px;
  transform: translateX(0);
  transition: transform 0.45s cubic-bezier(0.77, 0, 0.18, 1);
}

.pin-screen.slide-out {
  transform: translateX(-100%);
}

.pin-screen.hidden {
  display: none;
}

.pin-inner {
  width: 100%;
  max-width: 390px;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pin-title {
  font-size: 28px;
  font-weight: 400;
  color: #1a1a1a;
  text-align: center;
  margin-bottom: 48px;
  letter-spacing: -0.3px;
}

/* Крапки-індикатори */
.pin-dots {
  display: flex;
  gap: 20px;
  margin-bottom: 56px;
}

.pin-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  transition: background 0.15s ease, transform 0.15s ease;
}

.pin-dot.filled {
  background: #1a1a1a;
  transform: scale(1.1);
}

.pin-dot.shake {
  animation: dotShake 0.4s ease;
}

@keyframes dotShake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-6px); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

/* Сітка кнопок */
.pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 280px;
  margin-bottom: 36px;
}

.pin-key {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  background: #ffffff;
  font-size: 28px;
  font-weight: 300;
  color: #1a1a1a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, transform 0.1s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  -webkit-user-select: none;
  user-select: none;
}

.pin-key:active {
  background: #e8e4da;
  transform: scale(0.93);
}

/* Face ID — без фону, але з розміром */
.pin-key--faceid {
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

.pin-key--faceid svg {
  width: 48px;
  height: 48px;
}

.pin-key--faceid:active {
  background: rgba(255,255,255,0.2);
  transform: scale(0.93);
}

/* Кнопка видалення */
.pin-key--delete {
  background: transparent;
  box-shadow: none;
}

.pin-key--delete svg {
  width: 44px;
  height: 28px;
}

.pin-key--delete:active {
  background: rgba(255,255,255,0.4);
  transform: scale(0.93);
}

/* Посилання "Не пам'ятаю" */
.pin-forgot {
  background: none;
  border: none;
  font-size: 15px;
  color: #1a1a1a;
  cursor: pointer;
  text-align: center;
  padding: 8px;
  opacity: 0.7;
}

.pin-forgot:active {
  opacity: 0.4;
}

/* ========== ГОЛОВНИЙ ДОДАТОК ========== */
.app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  transform: translateX(100%);
  transition: transform 0.45s cubic-bezier(0.77, 0, 0.18, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.app.visible {
  transform: translateX(0);
}

#mainNav {
  transform: translateX(100%);
  transition: transform 0.45s cubic-bezier(0.77, 0, 0.18, 1);
}

#mainNav.visible {
  transform: translateX(0);
}

/* верхня панель */
.top {
  display: flex;
  justify-content: flex-end;
  padding: 12px;
  flex-shrink: 0;
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  z-index: 10;
}

.notify {
  background: #eeeeee;
  padding: 8px 14px 8px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #1c1c1c;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* Іконка колокольчика */
.bell-icon {
  width: 24px;
  height: 24px;
  background-image: url('icons/bell.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  mix-blend-mode: multiply;
  background-color: transparent;
  flex-shrink: 0;
}

/* ========== ПЕРЕВОРОТ КАРТКИ ========== */
.card-flip-container {
  margin: 0 16px;
  perspective: 1000px;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(15px);
}

.card-flipper {
  position: relative;
  width: 100%;
  height: 540px;
  transition: transform 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
  transform-style: preserve-3d;
  cursor: pointer;
}

.card-flipper.flipped {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  width: 100%;
}

.card-front {
  position: relative;
  z-index: 2;
  transform: rotateY(0deg);
}

.card-back {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  transform: rotateY(180deg);
  background: #ffffff !important;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  border: 1px solid rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 540px;
  transition: box-shadow 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* картка */
.card {
  background: #d3cfbd;
  border-radius: 18px;
  padding: 18px 16px 22px;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  overflow: hidden;
  width: 100%;
  max-width: 420px;
  height: 540px;
  position: relative;
  transition: box-shadow 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.card-header {
  position: absolute;
  top: 45px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.card-header h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.5px;
  color: #1a1a1a;
}

/* Іконка справа (герб) - тепер в profile-section */
.header-icon {
  display: none;
}

/* блок дати */
.info {
  margin-top: 16px;
}

.info span {
  font-size: 13px;
  color: #6a6a6a;
  letter-spacing: 0px;
  font-weight: 400;
}

.info p {
  margin-top: 5px;
  font-size: 21px;
  font-weight: 400;
  margin-bottom: 0;
  color: #1a1a1a;
  letter-spacing: -0.3px;
}

/* Профіль з фото */
.profile-section {
  position: absolute;
  top: 95px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.profile-photo {
  width: 170px;
  height: 220px;
  background: #c5c1af;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.profile-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.profile-icon {
  width: 58px;
  height: 58px;
  background-image: url('icons/logo.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  mix-blend-mode: multiply;
  background-color: transparent;
  flex-shrink: 0;
  margin-top: -67px;
}

.profile-date {
  text-align: right;
}

.profile-date span {
  font-size: 13px;
  color: #6a6a6a;
  letter-spacing: 0px;
  font-weight: 400;
  display: block;
}

.profile-date p {
  margin-top: 5px;
  font-size: 21px;
  font-weight: 400;
  margin-bottom: 0;
  color: #1a1a1a;
  letter-spacing: -0.3px;
}

/* область под фото */
.photo-area {
  height: 195px;
  background: #d3cfbd;
  margin: 18px 0;
  border-radius: 0px;
  border: none;
}

/* бегущая строка */
.divider {
  position: absolute;
  top: 360px;
  left: 0;
  right: 0;
  height: 30px;
  background: #7a5618;
  margin: 0 -20px;
  padding: 0 20px;
  overflow: hidden;
  display: flex;
  align-items: center;
  color: #fff;
  font-size: 12.5px;
  font-weight: 400;
  letter-spacing: 0.15px;
}

.marquee-inner {
  display: flex;
  animation: marquee 8s linear infinite;
  white-space: nowrap;
}

.marquee-inner span {
  padding-right: 80px;
}

@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* блок призовника */
.bottom {
  position: absolute;
  bottom: 17px;
  left: 16px;
  right: 16px;
}

.label {
  font-size: 13px;
  color: #6a6a6a;
  letter-spacing: 0px;
  font-weight: 400;
}

.name-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 5px;
}

.name-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0px;
}

.name-stack div {
  font-size: 25px;
  font-weight: 400;
  line-height: 1.12;
  color: #1a1a1a;
  text-transform: uppercase;
  letter-spacing: -0.4px;
}

/* Кнопка-іконка замість "+" */
.plus-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #f5a623;
  box-shadow: 0 2px 10px rgba(245, 166, 35, 0.4);
  cursor: pointer;
  flex-shrink: 0;
  background-image: url('icons/plus.png');
  background-size: 155%;
  background-repeat: no-repeat;
  background-position: center;
  mix-blend-mode: multiply;
  background-color: #f5a623;
}

.plus-btn:hover {
  opacity: 0.9;
}

/* ========== НИЖНЯ НАВІГАЦІЯ ========== */
.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #efefef;
  display: flex;
  justify-content: space-around;
  padding: 12px 0 16px;
  border-top: 1px solid #cccccc;
  z-index: 100;
}

.nav-item {
  text-align: center;
  font-size: 11px;
  color: #7a7a7a;
  transition: color 0.15s;
  cursor: pointer;
  flex: 1;
  font-weight: 500;
  letter-spacing: -0.1px;
}

.nav-item.active {
  color: #000000;
  font-weight: 400;
}

.icon {
  width: 28px;
  height: 28px;
  margin: 0 auto 6px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.icon-doc {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%231C1C1C' viewBox='0 0 24 24'%3E%3Cpath d='M6 2c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6H6zm0 18V4h7v5h5v11H6z'/%3E%3C/svg%3E");
}

.icon-grid {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%231C1C1C' viewBox='0 0 24 24'%3E%3Cpath d='M4 4h4v4H4zm6 0h4v4h-4zm6 0h4v4h-4zM4 10h4v4H4zm6 0h4v4h-4zm6 0h4v4h-4zM4 16h4v4H4zm6 0h4v4h-4zm6 0h4v4h-4z'/%3E%3C/svg%3E");
}

.icon-card {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%231C1C1C' viewBox='0 0 24 24'%3E%3Cpath d='M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4v-6h16v6z'/%3E%3C/svg%3E");
}

.icon-menu {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%231C1C1C' viewBox='0 0 24 24'%3E%3Cpath d='M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z'/%3E%3C/svg%3E");
}

.nav-item.active .icon {
  filter: brightness(0);
}

/* ========== МОДАЛЬНЕ ВІКНО ========== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  width: 100%;
  padding: 28px 20px 32px;
  border-radius: 28px 28px 0 0;
  text-align: center;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-content h3 {
  margin-top: 0;
  margin-bottom: 20px;
  font-weight: 500;
  font-size: 20px;
}

input {
  width: 100%;
  padding: 14px;
  margin-bottom: 12px;
  border-radius: 14px;
  border: 1px solid #ccc;
  font-size: 16px;
  font-family: inherit;
  background: #f9f9f9;
}

.save-btn, .close-modal {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  border-radius: 14px;
  border: none;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
}

.save-btn {
  background: #7a5618;
  color: white;
}

.close-modal {
  background: #e0e0e0;
  color: #333;
}

/* ========== ПАНЕЛЬ ДІЙ (ACTION SHEET) ========== */
.action-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.action-sheet-overlay.active {
  opacity: 1;
  visibility: visible;
  background: rgba(0, 0, 0, 0.5);
}

.action-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: transparent;
  padding: 0 12px 16px;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 2001;
}

.action-sheet-overlay.active .action-sheet {
  transform: translateY(0);
}

.action-sheet-buttons {
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.action-btn {
  width: 100%;
  padding: 18px 16px;
  border: none;
  background: #ffffff;
  font-size: 18px;
  font-weight: 400;
  color: #1c1c1c;
  cursor: pointer;
  border-bottom: 0.5px solid #d1d1d6;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  letter-spacing: -0.2px;
}

.action-btn:last-child {
  border-bottom: none;
}

.action-btn:active {
  background: #f0f0f0;
}

.action-btn-danger {
  color: #ff3b30;
  font-weight: 400;
}

/* ========== QR-КОД ========== */
.qr-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 25px 10px 20px;
}

.qr-title {
  font-size: 17px;
  font-weight: 500;
  color: #1a1a1a;
  text-align: center;
  margin-bottom: 25px;
  letter-spacing: -0.1px;
  margin-top: -20px;
}

.qr-code {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1;
  background: #ffffff;
  border: none;
  border-radius: 0px;
  padding: 0px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-svg {
  width: 100%;
  height: 100%;
  display: block;
}
