:root{
  --wine:#731927;
  --wine-dark:#54111c;
  --cream:#f6efe4;
  --paper:#fffdf9;
  --copper:#c7772c;
  --text:#2f2a27;
  --muted:#7b716b;
  --border:#e3d7cb;
  --success:#2f7d4a;
  --warning:#b37a1c;
  --danger:#b7473d;
  --shadow:0 12px 30px rgba(68,39,27,.08);
}

*{
  box-sizing:border-box;
}

html{
  scroll-behavior:smooth;
}

body{
  margin:0;
  font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  background:#f4efe9;
  color:var(--text);
}

button,
input,
select,
textarea{
  font:inherit;
}

button{
  cursor:pointer;
}

.hidden{
  display:none !important;
}

.login-view{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:
    radial-gradient(circle at top left,rgba(199,119,44,.12),transparent 35%),
    linear-gradient(135deg,#f7f0e8,#efe4d7);
}

.login-card{
  width:min(430px,100%);
  background:white;
  border-radius:22px;
  padding:30px;
  box-shadow:var(--shadow);
  border:1px solid var(--border);
}

.brand,
.side-brand{
  display:flex;
  flex-direction:column;
  gap:2px;
  letter-spacing:.05em;
}

.brand b,
.side-brand b{
  font-size:1.7rem;
  color:var(--wine);
}

.brand small,
.side-brand small{
  color:var(--muted);
  font-weight:600;
}

.login-card h1{
  margin:24px 0;
  font-size:1.7rem;
}

.login-card form{
  display:grid;
  gap:16px;
}

label{
  display:grid;
  gap:7px;
  font-size:.92rem;
  font-weight:600;
}

input,
select,
textarea{
  width:100%;
  border:1px solid var(--border);
  background:white;
  padding:11px 12px;
  border-radius:10px;
  color:var(--text);
  outline:none;
}

input:focus,
select:focus,
textarea:focus{
  border-color:var(--copper);
  box-shadow:0 0 0 3px rgba(199,119,44,.12);
}

textarea{
  resize:vertical;
}

.primary{
  background:var(--wine);
  color:white;
  border:none;
  border-radius:10px;
  padding:11px 15px;
  font-weight:700;
}

.primary:hover{
  background:var(--wine-dark);
}

.link{
  border:none;
  background:transparent;
  color:var(--wine);
  padding:8px 0;
  font-weight:700;
}

.app{
  min-height:100vh;
  display:grid;
  grid-template-columns:260px 1fr;
}

aside{
  min-height:100vh;
  background:#fffaf5;
  border-right:1px solid var(--border);
  padding:22px 18px;
  position:sticky;
  top:0;
  align-self:start;
  height:100vh;
  overflow-y:auto;
}

.side-brand{
  padding:8px 10px 22px;
}

nav{
  display:grid;
  gap:5px;
}

.nav{
  width:100%;
  text-align:left;
  border:none;
  background:transparent;
  border-radius:10px;
  padding:11px 12px;
  color:#4c4541;
  font-weight:600;
}

.nav:hover{
  background:#f2e7dc;
}

.nav.active{
  background:var(--wine);
  color:white;
}

.side-user{
  margin-top:28px;
  padding-top:18px;
  border-top:1px solid var(--border);
  display:grid;
  gap:5px;
}

.side-user small{
  color:var(--muted);
}

.side-user button{
  margin-top:8px;
  border:none;
  border-radius:9px;
  padding:9px;
  background:#eee2d8;
}

main{
  min-width:0;
}

header{
  position:sticky;
  top:0;
  z-index:20;
  background:rgba(255,253,249,.96);
  backdrop-filter:blur(8px);
  border-bottom:1px solid var(--border);
  padding:14px 24px;
  display:flex;
  align-items:center;
  gap:14px;
}

header h2{
  margin:0;
  font-size:1.15rem;
}

header small{
  color:var(--muted);
}

header .primary{
  margin-left:auto;
}

#mobileMenuBtn{
  display:none;
  border:none;
  background:#eee2d8;
  width:38px;
  height:38px;
  border-radius:9px;
}

.content{
  padding:24px;
}

.page{
  display:none;
}

.page.active{
  display:block;
}

.hero{
  background:
    linear-gradient(135deg,rgba(115,25,39,.97),rgba(84,17,28,.96)),
    var(--wine);
  color:white;
  border-radius:20px;
  padding:26px;
  display:flex;
  justify-content:space-between;
  gap:20px;
  align-items:flex-start;
  box-shadow:var(--shadow);
}

.hero h2{
  margin:7px 0;
  font-size:1.7rem;
}

.hero p{
  margin:0;
  opacity:.88;
}

.hero span{
  background:rgba(255,255,255,.15);
  padding:7px 10px;
  border-radius:999px;
  font-size:.75rem;
  font-weight:700;
}

.stats{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:14px;
  margin:18px 0;
}

.stats article{
  background:white;
  border:1px solid var(--border);
  border-radius:14px;
  padding:17px;
  box-shadow:var(--shadow);
}

.stats span{
  color:var(--muted);
  font-size:.82rem;
}

.stats b{
  display:block;
  margin-top:5px;
  font-size:1.45rem;
  color:var(--wine);
}

.card{
  background:white;
  border:1px solid var(--border);
  border-radius:16px;
  padding:20px;
  box-shadow:var(--shadow);
}

.card + .card{
  margin-top:16px;
}

.card h3,
.card h4{
  margin-top:0;
}

.head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:18px;
}

.head.second{
  margin-top:26px;
}

.head h3,
.head h4{
  margin:0 0 4px;
}

.head p{
  margin:0;
  color:var(--muted);
  font-size:.9rem;
}

.buttons{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.buttons button,
.card button:not(.primary):not(.link):not(.nav){
  border:1px solid var(--border);
  background:#fffaf5;
  color:var(--text);
  border-radius:9px;
  padding:9px 12px;
  font-weight:600;
}

.buttons button:hover,
.card button:not(.primary):not(.link):not(.nav):hover{
  background:#f3e7dc;
}

.actions{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:12px;
}

.actions.three{
  grid-template-columns:repeat(3,minmax(0,1fr));
}

.actions button{
  min-height:104px;
  border:1px solid var(--border);
  border-radius:14px;
  background:#fffaf5;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  justify-content:center;
  gap:5px;
  padding:15px;
  text-align:left;
}

.actions button:hover{
  border-color:var(--copper);
  transform:translateY(-1px);
}

.actions b{
  font-size:.92rem;
}

.actions small{
  color:var(--muted);
}

.filters{
  display:flex;
  gap:10px;
  margin-bottom:14px;
}

.filters input{
  flex:1;
}

.filters select{
  width:240px;
}

.table{
  width:100%;
  overflow-x:auto;
}

table{
  width:100%;
  border-collapse:collapse;
  min-width:720px;
}

th,
td{
  border-bottom:1px solid #eee4da;
  padding:11px 10px;
  text-align:left;
  vertical-align:top;
}

th{
  background:#fbf5ef;
  font-size:.78rem;
  text-transform:uppercase;
  letter-spacing:.03em;
  color:#695f58;
}

td{
  font-size:.89rem;
}

td button{
  white-space:nowrap;
}

.grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:12px;
  margin-top:14px;
}

.grid > article,
.section-card{
  border:1px solid var(--border);
  border-radius:14px;
  padding:15px;
  background:#fffdf9;
}

.section-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
}

.section-header h3{
  margin:0;
}

.section-header p{
  margin:4px 0 0;
  color:var(--muted);
}

.badge,
.status-badge{
  display:inline-flex;
  align-items:center;
  border-radius:999px;
  padding:5px 9px;
  background:#efe4d9;
  font-size:.7rem;
  font-weight:800;
  color:#5b4f47;
}

.tabs{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  border-bottom:1px solid var(--border);
  margin-bottom:18px;
}

.tab{
  border:none;
  background:transparent;
  padding:10px 12px;
  font-weight:700;
  color:#746963;
  border-bottom:3px solid transparent;
}

.tab.active{
  color:var(--wine);
  border-bottom-color:var(--wine);
}

.panel{
  display:none;
}

.panel.active{
  display:block;
}

.form{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:14px;
}

.form .full{
  grid-column:1 / -1;
}

.selector{
  display:grid;
  grid-template-columns:2fr 1fr 1fr auto;
  gap:10px;
  align-items:end;
  margin:14px 0;
}

.results{
  border:1px solid var(--border);
  border-radius:10px;
  padding:8px;
  margin-bottom:12px;
  background:#fffaf5;
}

.results button{
  display:block;
  width:100%;
  text-align:left;
  margin:4px 0;
}

.subselector{
  border:1px dashed #d9c7b7;
  border-radius:12px;
  padding:14px;
  margin:12px 0;
}

.procedure-step{
  border:1px solid var(--border);
  border-radius:12px;
  padding:13px;
  margin:9px 0;
  background:#fffaf5;
}

.drop{
  border:2px dashed #d5c1b1;
  border-radius:14px;
  padding:28px;
  text-align:center;
  background:#fffaf5;
}

.notice{
  margin-top:14px;
  background:#f9f0dc;
  border:1px solid #e6cf9f;
  color:#71541f;
  padding:12px;
  border-radius:10px;
}

.info-banner{
  margin:8px 0;
  background:#fff4d9;
  border:1px solid #ecd398;
  color:#73561f;
  padding:10px 12px;
  border-radius:9px;
}

.empty-state{
  text-align:center;
  color:var(--muted);
  padding:30px 16px;
}

.empty-state span{
  font-size:1.7rem;
}

.menu-builder{
  display:grid;
  grid-template-columns:300px 1fr;
  gap:20px;
}

.menu-builder > div:first-child{
  display:grid;
  gap:12px;
  align-content:start;
}

.check{
  display:flex;
  align-items:center;
  gap:8px;
}

.check input{
  width:auto;
}

.menu-preview{
  min-height:600px;
  background:#f7efe4;
  border:1px solid var(--border);
  border-radius:16px;
  padding:20px;
}

.modal{
  position:fixed;
  inset:0;
  background:rgba(31,21,18,.58);
  display:flex;
  justify-content:center;
  align-items:center;
  padding:18px;
  z-index:100;
}

.modal-card{
  width:min(760px,100%);
  max-height:90vh;
  overflow:auto;
  background:white;
  border-radius:18px;
  padding:20px;
  box-shadow:0 30px 80px rgba(0,0,0,.25);
}

.modal-card .head{
  margin-bottom:14px;
}

#closeModalBtn{
  border:none;
  background:#f0e5dc;
  width:34px;
  height:34px;
  border-radius:50%;
  font-size:1.25rem;
}

#modalFooter{
  margin-top:18px;
  justify-content:flex-end;
}

#toastContainer{
  position:fixed;
  right:20px;
  bottom:20px;
  z-index:200;
  display:grid;
  gap:8px;
}

.toast{
  background:#2f2a27;
  color:white;
  padding:11px 14px;
  border-radius:9px;
  box-shadow:var(--shadow);
  max-width:330px;
}

.toast.success{
  background:var(--success);
}

.toast.warning{
  background:var(--warning);
}

.toast.error{
  background:var(--danger);
}

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

  .grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .stats{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

@media(max-width:850px){
  .app{
    display:block;
  }

  aside{
    position:fixed;
    left:-280px;
    top:0;
    z-index:80;
    width:260px;
    transition:.2s;
    box-shadow:10px 0 30px rgba(0,0,0,.12);
  }

  body.sidebar-open aside{
    left:0;
  }

  #mobileMenuBtn{
    display:inline-flex;
    align-items:center;
    justify-content:center;
  }

  .content{
    padding:14px;
  }

  header{
    padding:12px 14px;
  }

  .selector{
    grid-template-columns:1fr 1fr;
  }

  .menu-builder{
    grid-template-columns:1fr;
  }
}

@media(max-width:620px){
  .hero{
    flex-direction:column;
  }

  .stats,
  .actions,
  .actions.three,
  .grid,
  .form{
    grid-template-columns:1fr;
  }

  .filters{
    flex-direction:column;
  }

  .filters select{
    width:100%;
  }

  .selector{
    grid-template-columns:1fr;
  }

  .head{
    flex-direction:column;
  }
}
.final-photo-preview{min-height:220px;border:1px dashed #c8b7a4;border-radius:14px;display:flex;flex-direction:column;gap:8px;align-items:center;justify-content:center;margin:14px 0;background:#fffaf3;overflow:hidden}.engineering-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;margin-top:18px}.engineering-box{background:#fff;border:1px solid #eadfd3;border-radius:14px;padding:16px;min-height:170px}.engineering-item{display:flex;flex-direction:column;gap:3px;padding:10px 0;border-bottom:1px solid #eee3d8}.ai-chat-box{min-height:280px;max-height:460px;overflow:auto;border:1px solid #eadfd3;border-radius:14px;padding:14px;margin:14px 0;background:#fffaf5}.ai-line{max-width:86%;margin:8px 0;padding:10px 12px;border-radius:12px}.ai-line.user{margin-left:auto;background:#f0e5db}.ai-line.assistant{background:#fff;border:1px solid #eadfd3}.review-block{border:1px solid #eadfd3;background:#fff;border-radius:12px;padding:14px;margin-top:12px}@media(max-width:820px){.engineering-grid{grid-template-columns:1fr}}