:root{
  --plc-blue:#4f6eac;
  --ink:#1b1b1f;
  --muted:#6b6b76;
  --bg:#f6f7fb;
  --radius:16px;
}

*{ box-sizing:border-box; }
body{
  margin:0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color:var(--ink);
  background:var(--bg);
}

/* ===== Header ===== */
.topbar{
  position:sticky; top:0; z-index:10;
  display:flex; justify-content:space-between; align-items:center;
  gap:16px;
  padding:14px 18px;
  background:#fff;
  border-bottom:1px solid #e7e8ef;
}
.brand{ display:flex; gap:12px; align-items:center; }
.brandmark{
  width:38px; height:38px;
  border-radius:10px;
  background:linear-gradient(135deg, var(--plc-blue), #7b8fd2);
}
.brandname{ font-weight:800; font-size:18px; line-height:1; }
.brandsub{ font-size:12px; color:var(--muted); margin-top:2px; }
.top-actions{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }

.btn{
  border:1px solid #dfe1ec;
  background:#fff;
  color:var(--ink);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:700;
}
.btn-primary{ background:var(--plc-blue); color:#fff; border-color:var(--plc-blue); }
.btn-danger{ border-color:#f1c7c7; color:#b22; }
.file-btn input{ display:none; }

/* ===== Layout ===== */
.layout{
  display:grid;
  grid-template-columns: 420px 1fr;
  gap:18px;
  padding:18px;
}
.panel,.preview{
  background:#fff;
  border:1px solid #e7e8ef;
  border-radius:var(--radius);
  box-shadow:0 10px 20px rgba(20,20,40,.06);
}
.panel{ padding:16px; }
.preview{ padding:16px; }

h2{ margin:8px 0 12px; font-size:16px; }
hr{ border:0; border-top:1px solid #ececf3; margin:14px 0; }

/* ===== Form ===== */
.form{ display:grid; gap:12px; }
.field label{ display:block; font-size:12px; color:var(--muted); margin-bottom:6px; }
.field input{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid #dfe1ec;
  outline:none;
}
.field input:focus{
  border-color:var(--plc-blue);
  box-shadow:0 0 0 3px rgba(79,110,172,.15);
}
.hint{ font-size:12px; color:var(--muted); margin-top:6px; }

.row3{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap:10px;
}
@media (max-width:520px){
  .row3{ grid-template-columns:1fr; }
}

.panel-head{ display:flex; justify-content:space-between; gap:10px; align-items:baseline; }

/* ===== Table ===== */
.table-wrap{
  overflow:auto;
  border:1px solid #ececf3;
  border-radius:12px;
}
.table{ width:100%; border-collapse:collapse; font-size:13px; }
.table th, .table td{
  padding:10px 12px;
  border-bottom:1px solid #f0f1f6;
  text-align:left;
  vertical-align:top;
}
.table th{ font-size:12px; color:var(--muted); background:#fbfbfe; }
.table tr:last-child td{ border-bottom:0; }
.table td.actions{ white-space:nowrap; }
.table td.actions .btn{ padding:7px 10px; font-size:12px; margin-right:6px; }

/* ===== Preview ===== */
.preview-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
.preview-actions{ display:flex; gap:10px; flex-wrap:wrap; }

.cards{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:16px;
  margin-top:10px;
}
.card-shell{
  border:1px dashed #d6d8e6;
  border-radius:16px;
  padding:12px;
  background:#fcfcff;
}
.shell-title{ font-size:12px; color:var(--muted); margin-bottom:8px; }

/* ===== CARD (CR80 portrait) ===== */
.idcard{
  width: 54mm;
  height: 85.6mm;
  background:#fff;
  border-radius: 3.8mm;
  position:relative;
  overflow:hidden;
  border:1px solid #e9eaf2;
}
.idcard .bg{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
  pointer-events:none;
  user-select:none;
}

/* ===== Photo slot =====
   Blue frame visible, photo centered.
   Adjust only if your PNG slot differs.
*/
.photo-slot{
  position:absolute;
  left: 5mm;
  top: 13mm;
  width: 24mm;
  height: 24mm;
  border-radius: 4mm;
  background: var(--plc-blue);
  padding: 2.2mm;
  overflow:hidden;
}
.photo-slot img{
  width:100%;
  height:100%;
  object-fit:cover;
  object-position:center;
  border-radius: 4mm;
  background:#fff;
  display:block;
}

/* ===== Values (text sits on template underline) ===== */
.val{
  position:absolute;
  font-size: 3.0mm;
  font-weight: 600;
  color:#4a4a4a;
  line-height: 1;
  background: transparent;
  padding:0;
  margin:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  pointer-events:none;
}

/* These positions work well for your current template look.
   If your underline starts a bit earlier/later, change only LEFT.
*/
.v-name{ left: 19mm; top: 43.5mm; width: 22mm; }
.v-title{ left: 21mm; top: 53.5mm; width: 22mm; }
.v-id{ left: 19mm; top: 63.6mm; width: 22mm; }

.note,.note-small{ color:var(--muted); font-size:12px; margin-top:12px; }
.footer{ padding:14px 18px 22px; color:var(--muted); font-size:12px; }

/* ===== Responsive ===== */
@media (max-width:1100px){
  .layout{ grid-template-columns:1fr; }
  .cards{ grid-template-columns:1fr; }
}

/* ===== Print rules (exact card size) ===== */
@media print{
  body{ background:#fff; }
}
