:root{
  --bg:#f3f6fa;
  --surface:#ffffff;
  --surface-soft:#f7fafc;
  --border:#d6e1ea;
  --border-strong:#c5d3df;
  --text:#10243b;
  --muted:#617286;
  --primary:#15b5c4;
  --primary-dark:#0c7a84;
  --primary-soft:#dff6f9;
  --green:#1c985f;
  --green-soft:#e7f7ee;
  --amber:#d58a00;
  --amber-soft:#fff3d8;
  --rose:#d63b5c;
  --rose-soft:#fdeaf0;
  --blue-soft:#eaf1ff;
  --shadow:0 18px 42px rgba(10,33,54,.08);
  --shadow-soft:0 10px 26px rgba(10,33,54,.06);
  --radius:24px;
}

*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{
  margin:0;
  min-height:100vh;
  background:linear-gradient(180deg,#f7f9fc 0%,#f2f5f9 100%);
  color:var(--text);
  font:15px/1.5 Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
}
a{color:inherit}
code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}

.wrap{
  width:min(1240px,calc(100% - 56px));
  margin:0 auto;
  padding:36px 0 56px;
}

.top,.app-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:24px;
  margin-bottom:20px;
}

.brand h1,.app-title h1{
  margin:0;
  font-size:clamp(28px,2.4vw,40px);
  line-height:1.05;
  letter-spacing:-.04em;
  font-weight:850;
}

.brand p,.app-title p{
  margin:8px 0 0;
  color:var(--muted);
  font-size:14px;
}

.version-chip{
  display:inline-flex;
  align-items:center;
  margin-top:10px;
  padding:7px 12px;
  border-radius:999px;
  background:var(--primary-soft);
  color:var(--primary-dark);
  font-size:12px;
  font-weight:800;
}

.header-actions{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:wrap;
}

.grid,.page-grid,.stack{
  margin-top:18px;
}

.grid,.page-grid{
  display:grid;
  gap:18px;
}

.page-grid--2,.grid2{grid-template-columns:repeat(2,minmax(0,1fr))}
.page-grid--3,.grid3{grid-template-columns:repeat(3,minmax(0,1fr))}
.page-grid--4,.grid4{grid-template-columns:repeat(4,minmax(0,1fr))}
.stack{display:grid;gap:18px}

.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:24px;
  box-shadow:var(--shadow);
}

.card.compact{padding:18px}
.section-card{padding:20px 22px}
.action-card{
  display:flex;
  flex-direction:column;
  gap:14px;
  justify-content:space-between;
  min-height:188px;
}

h1,h2,h3{margin:0;color:var(--text)}
h2{font-size:24px;letter-spacing:-.025em}
h3{font-size:18px;letter-spacing:-.02em}
p{margin:0}
.muted{color:var(--muted)}

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

.section-head > div{max-width:780px}
.section-head p{margin-top:6px}

label{
  display:block;
  margin:14px 0 7px;
  color:var(--text);
  font-size:12px;
  font-weight:800;
}

input,select,textarea{
  width:100%;
  border:1px solid #cfdae5;
  border-radius:14px;
  padding:12px 14px;
  background:#fff;
  color:var(--text);
  font:inherit;
  outline:none;
  transition:border-color .15s ease,box-shadow .15s ease,background .15s ease;
}

input:focus,select:focus,textarea:focus{
  border-color:var(--primary);
  box-shadow:0 0 0 4px rgba(21,181,196,.14);
}

textarea{min-height:110px;resize:vertical}

button,.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-height:44px;
  border:0;
  border-radius:14px;
  padding:11px 16px;
  background:var(--primary);
  color:#fff;
  cursor:pointer;
  text-decoration:none;
  font-weight:850;
  box-shadow:0 8px 20px rgba(21,181,196,.18);
  transition:transform .12s ease,box-shadow .12s ease,opacity .12s ease,background .12s ease;
}

button:hover,.btn:hover{
  transform:translateY(-1px);
  box-shadow:0 10px 24px rgba(21,181,196,.22);
}

button.secondary,.btn.secondary,
.modal__close{
  background:#eff4f8;
  color:#10243b;
  box-shadow:none;
}

button.danger,.btn.danger{
  background:var(--rose);
  box-shadow:0 8px 20px rgba(214,59,92,.18);
}

.btnrow{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  margin-top:14px;
}

.notice{
  margin:14px 0;
  padding:14px 16px;
  border-radius:16px;
  border:1px solid #c7d8ff;
  background:var(--blue-soft);
  color:#2556a9;
}

.ok{background:var(--green-soft);color:#176d43;border-color:#bfead0}
.warn{background:var(--amber-soft);color:#805400;border-color:#f4d48d}
.err{background:var(--rose-soft);color:#9c2540;border-color:#f3b8c4}

.pill{
  display:inline-flex;
  align-items:center;
  border-radius:999px;
  padding:6px 10px;
  font-size:12px;
  font-weight:850;
  background:var(--primary-soft);
  color:var(--primary-dark);
}

.pill.green{background:var(--green-soft);color:#176d43}
.pill.amber{background:var(--amber-soft);color:#805400}
.pill.rose{background:var(--rose-soft);color:#9c2540}

.header-nav-bar{
  position:sticky;
  top:12px;
  z-index:30;
  margin:24px 0 24px;
}

.header-nav{
  display:flex;
  align-items:center;
  gap:10px;
  padding:12px;
  border:1px solid var(--border);
  border-radius:20px;
  background:rgba(255,255,255,.92);
  box-shadow:var(--shadow-soft);
  backdrop-filter:blur(10px);
}

.menu-group{position:relative}

.menu-trigger{
  min-height:42px;
  padding:10px 15px;
  border-radius:14px;
  background:transparent;
  color:var(--text);
  box-shadow:none;
}

.menu-trigger::after{
  content:'▾';
  margin-left:2px;
  font-size:12px;
  color:var(--muted);
}

.menu-trigger:hover,
.menu-group.is-open .menu-trigger,
.menu-trigger.is-current{
  background:var(--primary-soft);
  color:var(--primary-dark);
}

.menu-group.is-open .menu-trigger::after,
.menu-trigger.is-current::after{color:var(--primary-dark)}

.submenu{
  position:absolute;
  top:calc(100% + 10px);
  left:0;
  min-width:250px;
  display:none;
  gap:6px;
  padding:12px;
  border:1px solid var(--border);
  border-radius:18px;
  background:#fff;
  box-shadow:0 18px 38px rgba(10,33,54,.14);
}

.menu-group.is-open .submenu{display:grid}

.submenu-link{
  display:flex;
  align-items:center;
  min-height:40px;
  padding:10px 12px;
  border-radius:12px;
  text-decoration:none;
  color:var(--text);
  font-weight:750;
}

.submenu-link:hover{background:#f4fafc}
.submenu-link.active{background:var(--primary-soft);color:var(--primary-dark)}

@media (hover:hover){
  .menu-group:hover .submenu,
  .menu-group:focus-within .submenu{display:grid}
}

.kpi{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  min-height:104px;
}

.kpi span{color:var(--muted);font-weight:700}
.kpi b{font-size:32px;letter-spacing:-.03em}

.table-scroll{
  overflow:auto;
  border:1px solid var(--border);
  border-radius:18px;
}

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

th,td{
  padding:13px 14px;
  border-bottom:1px solid var(--border);
  text-align:left;
  vertical-align:top;
  font-size:14px;
}

th{
  background:#f3f7fb;
  color:var(--muted);
  font-size:12px;
  letter-spacing:.03em;
  text-transform:uppercase;
}

tr:last-child td{border-bottom:0}

.log{
  margin-top:18px;
  min-height:84px;
  padding:16px;
  border-radius:18px;
  background:#0d1726;
  color:#e8f2ff;
  overflow:auto;
  white-space:pre-wrap;
  font:13px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}

.hidden{display:none}
.tabs{display:flex;gap:8px;flex-wrap:wrap}
.tab{padding:10px 13px;border-radius:14px;background:#eef3f7;cursor:pointer;font-weight:800}
.tab.active{background:var(--primary);color:#fff}

.empty-state{
  padding:22px;
  border:1px dashed var(--border-strong);
  border-radius:18px;
  background:var(--surface-soft);
  color:var(--muted);
  text-align:center;
}

.qr-card{
  width:min(420px,100%);
  border:1px solid #111;
  border-radius:14px;
  padding:18px;
  background:#fff;
  color:#111;
}

.qr-card h2{margin-bottom:4px}
.qrbox svg{width:180px;height:180px}

.modal{
  position:fixed;
  inset:0;
  display:none;
  padding:34px 16px;
  background:rgba(8,17,30,.52);
  z-index:90;
  overflow-y:auto;
}

.modal.is-open{display:block}
body.modal-open{overflow:hidden}

.modal__panel{
  width:min(720px,100%);
  margin:0 auto;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:24px;
  box-shadow:0 30px 70px rgba(8,17,30,.24);
}

.modal__header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:20px 22px;
  border-bottom:1px solid var(--border);
}

.modal__close{
  min-width:44px;
  padding:0;
  font-size:26px;
  line-height:1;
}

.modal-form{padding:6px 22px 22px}

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

.col-span-2{grid-column:1 / -1}

.modal__footer{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:18px;
}

@media (max-width:1180px){
  .page-grid--4,.grid4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .page-grid--3,.grid3{grid-template-columns:repeat(2,minmax(0,1fr))}
}

@media (max-width:920px){
  .wrap{width:min(100% - 24px,1240px);padding:24px 0 40px}
  .top,.app-top,.section-head{flex-direction:column}
  .header-actions{justify-content:flex-start}
  .page-grid--2,.page-grid--3,.page-grid--4,.grid2,.grid3,.grid4,
  .modal-form-grid{grid-template-columns:1fr}
  .col-span-2{grid-column:auto}
  .card{padding:20px}
  .header-nav{overflow-x:auto}
}

@media (max-width:760px){
  .header-nav{flex-wrap:nowrap;align-items:stretch}
  .menu-group{position:static}
  .submenu{
    left:12px;
    right:12px;
    min-width:0;
  }
  .kpi b{font-size:28px}
}

@media print{
  body{background:#fff}
  .no-print,.header-nav-bar,.btnrow,button,.header-actions,.modal{display:none !important}
  .card{box-shadow:none;border:none}
  .qr-card{page-break-inside:avoid}
}
