@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700;900&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --gold:        #C9A84C;
  --gold-light:  #E8C97A;
  --gold-dark:   #9A7C2E;
  --cream:       #FAF6EE;
  --dark:        #1A1209;
  --dark2:       #2C1F0A;
  --mid:         #6B5B3E;
  --light:       #F0E8D6;
  --white:       #FFFFFF;
  --success:     #4CAF7A;
  --danger:      #E05252;
  --info:        #4A90D9;
  --shadow:      0 4px 20px rgba(26,18,9,.10);
  --shadow-lg:   0 12px 48px rgba(26,18,9,.20);
  --radius:      16px;
  --radius-sm:   8px;
  --transition:  all .25s cubic-bezier(.4,0,.2,1);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--dark);
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: 'Playfair Display', serif; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: 'DM Sans', sans-serif; border: none; outline: none; }
img { max-width: 100%; display: block; }

/* Prevent iOS zoom on inputs */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="date"],
select,
textarea { font-size: 16px !important; font-family: 'DM Sans', sans-serif; outline: none; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--cream); }
::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 4px; }

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden         { display: none !important; }
.text-gold      { color: var(--gold); }
.text-success   { color: var(--success); }
.text-danger    { color: var(--danger); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  letter-spacing: .3px;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px; /* accessible touch target */
}
.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--white);
  box-shadow: 0 4px 14px rgba(201,168,76,.35);
}
.btn-gold:hover, .btn-gold:active {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(201,168,76,.5);
}
.btn-outline {
  background: transparent;
  color: var(--gold);
  border: 2px solid var(--gold);
}
.btn-outline:hover, .btn-outline:active { background: var(--gold); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-sm  { padding: 7px 13px; font-size: 12px; min-height: 36px; }
.btn-lg  { padding: 15px 30px; font-size: 16px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(201,168,76,.08);
}

/* ============================================================
   BADGES & CHIPS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-active       { background: rgba(76,175,122,.15);  color: var(--success); }
.badge-pending      { background: rgba(201,168,76,.15);  color: var(--gold-dark); }
.badge-inactive     { background: rgba(224,82,82,.15);   color: var(--danger); }
.badge-contemplated { background: rgba(74,144,217,.15);  color: var(--info); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: var(--cream);
  border: 1px solid var(--light);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  color: var(--mid);
}
.chip.active { background: rgba(201,168,76,.1); border-color: var(--gold); color: var(--gold-dark); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--mid);
  margin-bottom: 5px;
  letter-spacing: .6px;
  text-transform: uppercase;
}
.form-control {
  width: 100%;
  padding: 11px 13px;
  border: 2px solid var(--light);
  border-radius: var(--radius-sm);
  color: var(--dark);
  background: var(--cream);
  transition: var(--transition);
  -webkit-appearance: none;
}
.form-control:focus {
  border-color: var(--gold);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(201,168,76,.12);
}
.form-control::placeholder { color: rgba(107,91,62,.4); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 520px;
}
.data-table th {
  background: var(--cream);
  padding: 11px 13px;
  text-align: left;
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--mid);
  border-bottom: 2px solid var(--light);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--light);
  color: var(--dark);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(201,168,76,.03); }

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: var(--white);
  flex-shrink: 0;
}

/* ============================================================
   STAT CARD
   ============================================================ */
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 18px 18px 22px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(201,168,76,.08);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: linear-gradient(180deg, var(--gold), var(--gold-dark));
}
.stat-label  { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--mid); margin-bottom: 6px; }
.stat-value  { font-family: 'Playfair Display', serif; font-size: 24px; font-weight: 900; color: var(--dark); line-height: 1.1; margin-bottom: 4px; }
.stat-change { font-size: 11px; font-weight: 500; }
.stat-icon   { position: absolute; top: 14px; right: 14px; font-size: 22px; opacity: .12; }

/* ============================================================
   PROGRESS
   ============================================================ */
.progress-bar {
  height: 8px;
  background: var(--light);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold-light));
  border-radius: 4px;
  transition: width .8s ease;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  top: max(16px, env(safe-area-inset-top, 16px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(calc(100vw - 32px), 400px);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  animation: toastIn .3s ease;
  background: var(--dark);
  color: var(--white);
  pointer-events: auto;
  border-left: 4px solid var(--gold);
}
.toast.success { background: #163d25; border-left-color: var(--success); }
.toast.error   { background: #5a1a1a; border-left-color: var(--danger);  }
.toast.warning { background: #4a3a10; border-left-color: var(--gold);    }
@keyframes toastIn  { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideOut { to   { transform: translateY(-14px); opacity: 0; } }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn .2s ease;
}
.modal-box {
  background: var(--white);
  border-radius: 24px 24px 0 0;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom, 0px)) 20px;
  width: 100%;
  max-width: 620px;
  max-height: min(93dvh, 93vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slideUp .3s cubic-bezier(.4,0,.2,1);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--light);
}
.modal-title { font-family: 'Playfair Display', serif; font-size: 17px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--light);
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.modal-close:hover { background: var(--gold); color: var(--white); }

@keyframes fadeIn  { from { opacity: 0; }   to { opacity: 1; }   }
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes scaleIn { from { transform: scale(.96); opacity: 0; }   to { transform: none; opacity: 1; } }
@keyframes fadeUp  { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ============================================================
   LAYOUT GRIDS
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ============================================================
   PAGE HEADER & SECTION TITLE
   ============================================================ */
.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title   { font-size: 26px; font-weight: 900; color: var(--dark); line-height: 1.1; }
.page-subtitle{ font-size: 13px; color: var(--mid); margin-top: 3px; }

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--light);
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ============================================================
   SPINNER
   ============================================================ */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--light);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet+ → centered modal */
@media (min-width: 769px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal-box { border-radius: var(--radius); animation: scaleIn .25s ease; padding-bottom: 28px; }
  .card { padding: 24px; }
}

/* Mobile medium (≤640px) */
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: 21px; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header > .btn { width: 100%; }
  .hide-mobile { display: none !important; }
}

/* Mobile small (≤400px) */
@media (max-width: 400px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .btn { font-size: 13px; }
  .btn-sm { font-size: 11px; padding: 6px 10px; }
  .stat-value { font-size: 20px; }
  .card { padding: 14px; }
}
