@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root{
  --bg:        #f6efdf;
  --card:      #f1e8d3;
  --card-deep: #e7d9b6;
  --rule:      #cdbb8e;

  --ink:      #262019;
  --ink-soft: #665a49;

  --brass:      #b8863b;
  --brass-deep: #8f6526;

  --pine:      #35594a;
  --pine-deep: #24402f;

  --rust:      #a8402a;
  --rust-soft: #f4e4de;
  --moss:      #4c7a5f;
  --moss-soft: #e3ede4;

  --sidebar:   #14211d;
  --sidebar-2: #0d1613;
  --chalk:     #ece7d8;
  --chalk-dim: #a9b3ac;

  --shadow: 0 14px 34px rgba(38,32,25,.10);
  --radius: 16px;

  --paper:      var(--card);
  --paper-deep: var(--card-deep);
  --bg-slate:   var(--sidebar);
  --bg-slate-2: var(--sidebar-2);
}

*{
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "IBM Plex Sans", Arial, sans-serif;
}
h1, h2, h3, h4{ font-family: "Fraunces", Georgia, serif; }
body{ color: var(--ink); min-height: 100vh; }
button, input, select, textarea{ font-family: inherit; }
button{ cursor: pointer; }

::selection{ background: rgba(184,134,59,.28); color: var(--ink); }

::-webkit-scrollbar{ width: 10px; height: 10px; }
::-webkit-scrollbar-track{ background: transparent; }
::-webkit-scrollbar-thumb{
  background: rgba(184,134,59,.35);
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover{ background: rgba(184,134,59,.55); background-clip: content-box; }

body.app-dashboard{ background: var(--bg); }
body.app-login{
  background:
    radial-gradient(circle at 15% 20%, rgba(184,134,59,.08), transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(76,122,95,.10), transparent 45%),
    var(--sidebar-2);
}

body.dark{
  --bg:        #0d1613;
  --card:      #14211d;
  --card-deep: #182922;
  --rule:      rgba(236,231,216,.16);
  --ink:       #ece7d8;
  --ink-soft:  #a9b3ac;
  --shadow:    0 14px 34px rgba(0,0,0,.45);
}

.sidebar{
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 255px;
  background:
    radial-gradient(circle at 20% 10%, rgba(184,134,59,.14), transparent 32%),
    linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: var(--chalk);
  padding: 24px 16px;
  z-index: 100;
  overflow-y: auto;
}

.logo{ display: flex; align-items: center; gap: 12px; padding: 0 8px; margin-bottom: 24px; }
.logo-icon{
  width: 42px; height: 42px;
  border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--brass);
  font-family: "Fraunces", serif; font-weight: 600; font-size: 16px;
  color: var(--brass);
}
.logo h2{ font-size: 18px; font-weight: 500; }

.profile{
  display: flex; align-items: center; gap: 12px;
  padding: 14px; margin-bottom: 22px;
  border-radius: 13px;
  background: rgba(236,231,216,.06);
  border-top: 2px solid var(--brass);
}
.avatar{
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(184,134,59,.14);
  border: 1px solid rgba(184,134,59,.4);
  font-family: "Fraunces", serif; font-weight: 600; font-size: 13px;
  color: var(--brass);
  flex-shrink: 0;
  background-size: cover; background-position: center;
  overflow: hidden;
}
.profile strong{ display: block; font-size: 12.5px; font-weight: 600; }
.profile span{ color: var(--chalk-dim); font-size: 10px; }

.menu-title{
  color: var(--brass);
  font-size: 10.5px; font-weight: 600; letter-spacing: .3px;
  padding: 0 8px 8px; margin: 20px 0 8px;
  border-bottom: 1px solid rgba(236,231,216,.1);
}
.menu-button{
  width: 100%; height: 42px;
  border: none; border-left: 3px solid transparent;
  background: transparent;
  color: var(--chalk-dim);
  display: flex; align-items: center; gap: 12px;
  padding: 0 11px; margin: 3px 0;
  border-radius: 9px;
  text-align: left; font-size: 12.5px;
  transition: .18s;
}
.menu-button:hover{ background: rgba(236,231,216,.06); color: var(--chalk); }
.menu-button.active{
  background: rgba(184,134,59,.14);
  border-left-color: var(--brass);
  color: var(--chalk);
  font-weight: 600;
}
.menu-icon{ width: 20px; text-align: center; font-size: 14px; color: var(--brass); }

.main{ margin-left: 255px; min-height: 100vh; }
.header{
  height: 70px;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px;
  position: sticky; top: 0;
  z-index: 50;
}
.search{
  width: 320px; height: 40px;
  display: flex; align-items: center; gap: 9px;
  padding: 0 4px 6px;
  border-bottom: 1.5px solid var(--rule);
}
.search span{ color: var(--ink-soft); font-size: 13px; }
.search input{
  width: 100%; border: none; outline: none;
  background: transparent; color: var(--ink); font-size: 12.5px;
}
.header-actions{ display: flex; align-items: center; gap: 9px; }
.header-button{
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  background: var(--card-deep);
  color: var(--ink);
  font-size: 14px;
  transition: .18s;
}
.header-button:hover{ border-color: var(--brass); }
.header-profile{ display: flex; align-items: center; gap: 10px; margin-left: 6px; }
.header-profile .avatar{ width: 36px; height: 36px; }
.mobile-menu{ display: none; }

/* 6. CONTENT AREA */
.content{ padding: 32px; }
.page{ display: none; animation: fade .25s ease; }
.page.active{ display: block; }
@keyframes fade{
  from{ opacity: 0; transform: translateY(6px); }
  to{ opacity: 1; transform: translateY(0); }
}

.page-header{
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 22px; gap: 14px; flex-wrap: wrap;
}
.page-header small{ color: var(--brass-deep); font-size: 10.5px; font-weight: 600; letter-spacing: .3px; }
.page-header h1{ font-size: 27px; font-weight: 500; margin-top: 6px; }
.page-header p{ color: var(--ink-soft); font-size: 12px; margin-top: 5px; }

.primary-button{
  border: none;
  padding: 12px 18px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--pine), var(--pine-deep));
  color: var(--chalk);
  font-weight: 700; font-size: 12px;
  box-shadow: 0 10px 22px rgba(36,64,47,.25);
  transform: rotate(-1deg);
  transition: transform .2s cubic-bezier(.34,1.4,.6,1);
}
.primary-button:hover{ transform: rotate(0deg) scale(1.02); }
.reset-button{
  background: var(--card-deep);
  border: 1.5px solid var(--rule);
  color: var(--ink);
  border-radius: 9px;
  padding: 12px 18px;
  font-weight: 700; font-size: 12px;
}

.stats{ display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.stat-card{
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
  transition: .2s;
}
.stat-card:hover{ transform: translateY(-3px); }
.stat-icon{
  width: 42px; height: 42px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-size: 16px;
  flex-shrink: 0;
}
.icon-blue{   background: rgba(53,89,74,.12);   color: var(--pine); }
.icon-purple{ background: rgba(184,134,59,.14); color: var(--brass-deep); }
.icon-green{  background: rgba(76,122,95,.14);  color: var(--moss); }
.icon-orange{ background: rgba(168,64,42,.12);  color: var(--rust); }
.stat-card span{ display: block; color: var(--ink-soft); font-size: 10px; font-weight: 600; }
.stat-card strong{ display: block; margin-top: 4px; font-size: 19px; font-weight: 600; }

.grid-2{ display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; margin-bottom: 20px; }
.card{
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-header{
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; gap: 10px; flex-wrap: wrap;
}
.card-header h3{ font-size: 14.5px; font-weight: 600; }
.card-header span{ color: var(--ink-soft); font-size: 9.5px; }
.text-link{ border: none; background: none; color: var(--pine); font-size: 10px; font-weight: 700; }
.text-link:hover{ text-decoration: underline; }

.field{ margin-bottom: 14px; }
.field label{ display: block; font-size: 11px; color: var(--ink-soft); font-weight: 600; margin-bottom: 6px; }
.field input,
.field select,
.field textarea{
  width: 100%;
  border: none;
  border-bottom: 1.5px solid var(--rule);
  background: transparent;
  padding: 8px 2px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  resize: vertical;
  transition: border-color .2s;
}
.field input:focus,
.field select:focus,
.field textarea:focus{ border-color: var(--pine); }
.field input:disabled{ color: var(--ink-soft); }
.field-row{ display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.wizard-nav{ display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 22px; }
.wizard-nav.single{ grid-template-columns: 1fr; }

.modal{
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(13,22,19,.7);
  backdrop-filter: blur(6px);
  z-index: 999;
  animation: modalFadeIn .18s ease;
}
@keyframes modalFadeIn{ from{ opacity: 0; } to{ opacity: 1; } }
.modal.show{ display: flex; }

.modal-box{
  width: min(460px,100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
  border-top: 3px solid var(--brass);
  animation: modalIn .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes modalIn{
  from{ opacity: 0; transform: translateY(14px) scale(.98); }
  to{ opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head{ display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.modal-head h3{ font-size: 21px; font-weight: 500; margin-top: 4px; }
.eyebrow{ font-size: 10.5px; color: var(--brass-deep); font-weight: 600; }
.x-btn{
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--card-deep);
  color: var(--ink-soft);
  font-size: 16px;
}
.x-btn:hover{ background: var(--rule); color: var(--ink); }

.modal-btns{ display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; margin-top: 6px; }
.btn-cancel{
  height: 46px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--card-deep);
  color: var(--ink);
  font-weight: 600; font-size: 11.5px;
}
.btn-submit{
  height: 46px;
  border: none;
  border-radius: 8px;
  font-weight: 700; font-size: 11.5px;
  color: var(--chalk);
  background: linear-gradient(135deg, var(--pine), var(--pine-deep));
}
.help-text{ color: var(--ink-soft); font-size: 12px; line-height: 1.6; margin-bottom: 18px; }

/* 11. ID CARD */
.id-card{
  border: 1.5px solid var(--brass);
  border-radius: 12px;
  padding: 20px;
  background: linear-gradient(155deg, var(--sidebar), var(--sidebar-2));
  color: var(--chalk);
}
.id-card-top{ display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.brass-sub{ color: var(--chalk-dim); font-size: 9.5px; letter-spacing: .8px; }
.id-card-photo{
  width: 46px; height: 46px;
  border-radius: 10px;
  border: 1.5px solid var(--brass);
  display: grid; place-items: center;
  font-family: "Fraunces", serif; font-weight: 600; font-size: 15px;
  color: var(--brass);
  background: rgba(184,134,59,.1);
  flex-shrink: 0;
}
.id-card-name{ font-family: "Fraunces", serif; font-size: 17px; margin-top: 10px; }
.id-card-meta{
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed rgba(236,231,216,.25);
}
.id-card-meta .k{ display: block; font-size: 8.5px; color: var(--chalk-dim); letter-spacing: .4px; margin-bottom: 2px; }
.id-card-meta .v{ display: block; font-size: 11.5px; font-weight: 600; }

/* 12. TOAST */
.toast{
  position: fixed; right: 24px; bottom: 24px;
  padding: 13px 17px;
  background: var(--sidebar);
  color: var(--chalk);
  border-left: 3px solid var(--brass);
  border-radius: 10px;
  font-size: 11.5px;
  box-shadow: 0 18px 45px rgba(0,0,0,.35);
  transform: translateY(100px);
  opacity: 0;
  transition: .3s;
  z-index: 999;
}
.toast.show{ transform: translateY(0); opacity: 1; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible{ outline: 2px solid var(--brass); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

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

@media (max-width: 850px){
  .sidebar{ transform: translateX(-100%); transition: .3s; }
  .sidebar.open{ transform: translateX(0); }
  .main{ margin-left: 0; }
  .mobile-menu{ display: block; }
  .header{ padding: 0 18px; }
  .search{ width: 200px; }
  .field-row{ grid-template-columns: 1fr; }
  .grid-2{ grid-template-columns: 1fr; }
}

@media (max-width: 650px){
  .content{ padding: 18px; }
  .search{ display: none; }
  .stats{ grid-template-columns: 1fr; }
  .page-header{ align-items: flex-start; gap: 14px; flex-direction: column; }
}

.header-profile{
  position:relative;
  cursor:pointer;
  padding:4px;
  border-radius:50%;
  transition:background .15s;
}
.header-profile:hover{
  background:rgba(184,134,59,.12);
}

.header-profile{
  position:relative;
  cursor:pointer;
  padding:4px;
  border-radius:50%;
  transition:background .15s;
}
.header-profile:hover{ background:rgba(184,134,59,.12); }

.profile-menu{
  position:absolute;
  top:calc(100% + 10px);
  right:0;
  width:240px;
  background:var(--card);
  border:1px solid var(--rule);
  border-radius:14px;
  box-shadow:0 20px 50px rgba(0,0,0,.2);
  padding:8px;
  display:none;
  z-index:200;
  animation:profileMenuIn .18s ease;
  cursor:default;
}
.profile-menu.open{ display:block; }

@keyframes profileMenuIn{
  from{ opacity:0; transform:translateY(-6px); }
  to{ opacity:1; transform:translateY(0); }
}

.profile-menu-head{
  padding:10px 12px 12px;
  border-bottom:1px dashed var(--rule);
  margin-bottom:6px;
}
.profile-menu-head strong{
  display:block;
  font-size:12.5px;
  font-weight:600;
  color:var(--ink);
}
.profile-menu-head span{
  display:block;
  font-size:10px;
  color:var(--ink-soft);
  margin-top:3px;
}

.profile-menu-item{
  width:100%;
  text-align:left;
  display:flex;
  align-items:center;
  gap:10px;
  padding:9px 12px;
  border:none;
  background:transparent;
  color:var(--ink);
  font-size:12px;
  font-weight:500;
  border-radius:8px;
  cursor:pointer;
  transition:background .15s;
}
.profile-menu-item:hover{ background:var(--card-deep); }
.profile-menu-item .menu-icon{
  color:var(--brass-deep);
  width:18px;
  text-align:center;
  font-size:13px;
}
.profile-menu-item.danger{ color:var(--rust); }
.profile-menu-item.danger .menu-icon{ color:var(--rust); }
.profile-menu-item.danger:hover{ background:var(--rust-soft); }