:root{
  --navy:#173a5e;
  --navy-2:#214d75;
  --blue:#3f73a8;
  --blue-2:#5d8fc1;
  --teal:#3e8c84;
  --teal-2:#58a39c;
  --amber:#d9822b;
  --amber-soft:#fff2e4;
  --red:#b54f4f;
  --yellow:#fff6d8;
  --yellow-border:#e2cf97;
  --line:#d7e1ea;
  --line-2:#e6edf3;
  --muted:#5f7080;
  --muted-2:#7a8a98;
  --bg:#f4f7fa;
  --card:#ffffff;
  --card-soft:#fbfcfd;
  --text:#1f2a35;
  --shadow-card:0 10px 28px rgba(18, 40, 63, .08);
  --shadow-soft:0 6px 16px rgba(18, 40, 63, .07);
  --shadow-focus:0 0 0 3px rgba(63, 115, 168, .15);
}

*{box-sizing:border-box}

html{
  scroll-behavior:smooth;
}

body{
  margin:0;
  font-family:Inter,Segoe UI,Arial,sans-serif;
  background:
    radial-gradient(circle at top right, rgba(63,115,168,.06), transparent 22%),
    linear-gradient(180deg, #f7f9fc 0%, var(--bg) 100%);
  color:var(--text);
}

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

.app{
  max-width:1460px;
  margin:auto;
  padding:20px 22px 28px;
}

.header{
  background:linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color:#fff;
  padding:20px 26px;
  border-radius:22px;
  box-shadow:0 14px 34px rgba(23,58,94,.16);
  border:1px solid rgba(255,255,255,.10);
}

.header h1{
  margin:0;
  font-size:clamp(26px, 3vw, 38px);
  letter-spacing:.2px;
  line-height:1.15;
}

.toolbar{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  flex-wrap:wrap;
  margin:14px 2px 0;
}

.btn{
  border:0;
  border-radius:12px;
  padding:10px 16px;
  font-weight:700;
  cursor:pointer;
  box-shadow:var(--shadow-soft);
  transition:.18s ease;
}

.btn:disabled{
  opacity:.62;
  cursor:not-allowed;
}

.btn:active:not(:disabled){
  transform:translateY(1px);
}

.btn:hover:not(:disabled){
  transform:translateY(-1px);
  box-shadow:0 8px 18px rgba(18,40,63,.11);
}

.primary{
  background:linear-gradient(180deg, var(--blue-2), var(--blue));
  color:#fff;
}

.danger{
  background:linear-gradient(180deg, #c96767, var(--red));
  color:#fff;
}

.greenbtn{
  background:linear-gradient(180deg, var(--teal-2), var(--teal));
  color:#fff;
}

.light{
  background:#fff;
  border:1px solid var(--line);
  color:var(--text);
}

.grid{
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(370px,.92fr);
  gap:22px;
  margin-top:16px;
}

.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:22px;
  box-shadow:var(--shadow-card);
  overflow:hidden;
}

.head{
  padding:14px 18px;
  color:#fff;
  font-weight:800;
  letter-spacing:.15px;
}

.blue{
  background:linear-gradient(180deg, #4f83b7, var(--blue));
}

.green{
  background:linear-gradient(180deg, #57a49c, var(--teal));
}

.orange{
  background:linear-gradient(180deg, #e2974e, var(--amber));
}

.decision-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
}

.head-clear{
  background:rgba(255,255,255,.96);
  color:var(--red);
  border:1px solid rgba(181,79,79,.18);
  border-radius:10px;
  padding:7px 13px;
  font-weight:800;
  cursor:pointer;
  box-shadow:0 3px 10px rgba(16,24,40,.08);
  transition:.18s ease;
}

.head-clear:hover{
  transform:translateY(-1px);
}

.body{
  padding:20px;
}

.instructions-card{
  box-shadow:none;
  margin-top:20px;
  border-radius:18px;
}

.search-panel{
  border:1px solid #d8e3ed;
  background:linear-gradient(180deg, #fdfefe 0%, #f7fbff 100%);
  border-radius:18px;
  padding:18px 18px 16px;
  margin-bottom:20px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.7);
}

.search-title{
  font-weight:800;
  font-size:18px;
  margin-bottom:5px;
  color:#203247;
}

.search-help{
  font-size:13px;
  line-height:1.55;
  color:var(--muted);
  margin-bottom:11px;
}

.search-input-wrap{
  position:relative;
}

.public-search{
  width:100%;
  border:1px solid #b3c6d8;
  border-radius:14px;
  padding:14px 46px 14px 15px;
  background:#fff;
  outline:none;
  box-shadow:inset 0 1px 1px rgba(0,0,0,.02);
}

.public-search:focus{
  border-color:var(--blue);
  box-shadow:var(--shadow-focus);
}

.search-icon{
  position:absolute;
  right:15px;
  top:12px;
  color:#66798b;
  font-size:20px;
}

.suggestions{
  display:grid;
  gap:10px;
  margin-top:12px;
}

.suggestions:empty{
  display:none;
}

.suggestion{
  display:grid;
  grid-template-columns:78px 1fr;
  gap:12px;
  align-items:center;
  border:1px solid var(--line);
  background:linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  border-radius:14px;
  padding:10px;
  cursor:pointer;
  text-align:left;
  width:100%;
  transition:.16s ease;
}

.suggestion:hover,
.suggestion:focus{
  border-color:var(--blue);
  box-shadow:0 7px 18px rgba(63,115,168,.12);
  outline:none;
  transform:translateY(-1px);
}

.suggestion-thumb{
  width:78px;
  height:55px;
  border:1px solid var(--line);
  border-radius:9px;
  object-fit:cover;
  background:#eef3f8;
}

.suggestion-placeholder{
  width:78px;
  height:55px;
  border:1px solid var(--line);
  border-radius:9px;
  background:#eef3f8;
  display:grid;
  place-items:center;
  color:#63778a;
  font-size:11px;
  font-weight:700;
  text-align:center;
}

.suggestion-name{
  display:block;
  font-weight:800;
  color:#203247;
}

.suggestion-meta{
  display:block;
  font-size:12px;
  color:var(--muted);
  margin-top:3px;
}

.suggestion-label{
  display:block;
  font-size:12px;
  color:#38536f;
  margin-top:3px;
}

.no-results{
  padding:12px 13px;
  color:var(--muted);
  font-size:13px;
  background:#fff;
  border-radius:12px;
  border:1px solid var(--line);
}

.step{
  display:grid;
  grid-template-columns:44px 1fr;
  gap:12px;
  align-items:start;
  margin-bottom:18px;
}

.num{
  width:44px;
  height:44px;
  border-radius:50%;
  display:grid;
  place-items:center;
  background:linear-gradient(180deg, #5e90c0, var(--blue));
  color:#fff;
  font-weight:800;
  box-shadow:0 5px 12px rgba(63,115,168,.18);
}

label{
  display:block;
  font-weight:800;
  margin-bottom:8px;
  color:#24384b;
}

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

select,
input[type=text],
input[type=password],
textarea{
  width:100%;
  border:1px solid #c1ced9;
  border-radius:13px;
  padding:12px;
  background:#fff;
  outline:none;
  color:var(--text);
}

input[type=file]{
  width:100%;
  padding:9px;
  border:1px solid #c1ced9;
  border-radius:13px;
  background:#fff;
}

select:focus,
input:focus,
textarea:focus{
  border-color:var(--blue);
  box-shadow:var(--shadow-focus);
}

.yellow{
  background:var(--yellow);
  border-color:var(--yellow-border);
  font-weight:700;
}

.info{
  display:grid;
  grid-template-columns:155px 1fr;
  border:1px solid var(--line);
  border-radius:15px;
  overflow:hidden;
  background:#fff;
}

.info div{
  padding:13px 14px;
  border-bottom:1px solid var(--line);
}

.info div:nth-child(odd){
  font-weight:800;
  background:#f0f5fa;
  color:#28415a;
}

.info div:nth-last-child(-n+2){
  border-bottom:0;
}

.preview{
  min-height:430px;
  display:grid;
  place-items:center;
  background:linear-gradient(180deg, #fbfdfe 0%, #f6fafc 100%);
  border:2px dashed #b3c5d4;
  border-radius:16px;
  padding:18px;
  overflow:hidden;
}

.preview img{
  max-width:100%;
  max-height:520px;
  object-fit:contain;
  border-radius:10px;
  box-shadow:0 10px 26px rgba(0,0,0,.10);
  cursor:zoom-in;
}

.empty{
  color:var(--muted);
  text-align:center;
  line-height:1.5;
}

.preview-note{
  font-size:12px;
  color:var(--muted);
  margin:12px 2px 0;
  text-align:left;
  background:#f7fafc;
  border:1px solid var(--line-2);
  padding:10px 12px;
  border-radius:12px;
}

.admin{
  margin-top:22px;
}

.hidden{
  display:none!important;
}

.admin-top{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:space-between;
  align-items:center;
  margin-bottom:14px;
}

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

.admin-search{
  max-width:390px;
}

.table-wrap{
  overflow:auto;
  border:1px solid var(--line);
  border-radius:15px;
  background:#fff;
}

table{
  border-collapse:collapse;
  width:100%;
  min-width:1120px;
  background:#fff;
}

th,td{
  padding:10px 12px;
  border-bottom:1px solid var(--line);
  text-align:left;
  vertical-align:top;
}

th{
  position:sticky;
  top:0;
  background:#eff5fa;
  color:#27415b;
  z-index:1;
}

tr:hover td{
  background:#fafcfe;
}

.thumb{
  width:76px;
  height:48px;
  object-fit:cover;
  border-radius:7px;
  border:1px solid var(--line);
}

.acts{
  display:flex;
  gap:6px;
}

.mini{
  border:1px solid var(--line);
  background:#fff;
  border-radius:8px;
  padding:7px 9px;
  cursor:pointer;
}

.system-banner,
.migration-status{
  padding:12px 15px;
  border-radius:13px;
  margin:12px 0;
  border:1px solid #e6c57b;
  background:#fff8e7;
  color:#6d5000;
}

.system-banner.error{
  border-color:#e1abab;
  background:#fff1f1;
  color:#842020;
}

dialog{
  border:0;
  border-radius:20px;
  padding:0;
  width:min(760px,94vw);
  box-shadow:0 26px 80px rgba(0,0,0,.28);
}

dialog::backdrop{
  background:rgba(16,32,45,.52);
  backdrop-filter:blur(2px);
}

.dialog-head{
  padding:16px 20px;
  background:linear-gradient(135deg, var(--navy), var(--navy-2));
  color:#fff;
  font-weight:800;
}

.dialog-body{
  padding:20px;
}

.form-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
  padding:20px;
}

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

.form-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  padding:0 20px 20px;
}

.note{
  font-size:13px;
  color:var(--muted);
  margin-top:6px;
}

.admin-security{
  margin-top:14px;
  padding:12px 14px;
  border:1px solid var(--line);
  background:#f8fbfd;
  border-radius:13px;
  font-size:12px;
  color:var(--muted);
  line-height:1.55;
}

.error{
  color:#a61b1b;
  font-size:13px;
  min-height:18px;
  margin-top:8px;
}

.zoom-dialog{
  width:min(1200px,96vw);
  height:min(90vh,900px);
  background:#10151b;
  border-radius:16px;
  overflow:hidden;
}

.zoom-shell{
  height:100%;
  display:flex;
  flex-direction:column;
}

.zoom-bar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:10px 14px;
  background:#17222e;
  color:#fff;
}

.zoom-title{
  font-weight:800;
}

.zoom-close{
  background:#fff;
  color:#17222e;
  border:0;
  border-radius:8px;
  padding:7px 12px;
  font-weight:800;
  cursor:pointer;
}

.zoom-body{
  flex:1;
  overflow:auto;
  display:grid;
  place-items:center;
  padding:20px;
}

.zoom-body img{
  max-width:none;
  width:auto;
  height:auto;
  min-width:min(900px,90vw);
  max-height:none;
  cursor:zoom-out;
}

.editor-image{
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap:wrap;
}

.editor-image img{
  max-width:260px;
  max-height:170px;
  border:1px solid #ccd7e1;
  border-radius:8px;
  box-shadow:0 4px 12px rgba(0,0,0,.07);
}

.toast{
  position:fixed;
  right:22px;
  bottom:22px;
  background:#1f2a35;
  color:#fff;
  padding:12px 16px;
  border-radius:11px;
  opacity:0;
  transition:.2s;
  pointer-events:none;
  z-index:50;
  box-shadow:0 10px 24px rgba(0,0,0,.18);
}

.toast.show{
  opacity:1;
}

footer{
  color:var(--muted-2);
  text-align:center;
  padding:24px 10px 8px;
  font-size:12px;
}

.ai-search-status{
  font-size:12px;
  color:var(--muted);
  padding:8px 4px 2px;
  font-style:italic;
}

.suggestions[aria-busy="true"]{
  opacity:.98;
}

@media(max-width:900px){
  .grid{
    grid-template-columns:1fr;
  }
  .preview{
    min-height:320px;
  }
}

@media(max-width:640px){
  .app{
    padding:12px;
  }
  .header{
    padding:18px 18px;
    border-radius:18px;
  }
  .body{
    padding:16px;
  }
  .form-grid{
    grid-template-columns:1fr;
  }
  .full{
    grid-column:auto;
  }
  .info{
    grid-template-columns:112px 1fr;
  }
  .suggestion{
    grid-template-columns:62px 1fr;
  }
  .suggestion-thumb,
  .suggestion-placeholder{
    width:62px;
    height:48px;
  }
}
