/* Akreditacije — svijetla LabOS-inspirirana tema, HKD paleta.
   HKD boje: crvena #e60001, siva #8c8c8c. Sučelje u Outfitu (HKD primarni font). */
@font-face { font-family: "Outfit UI"; font-style: normal; font-weight: 400; font-display: swap; src: url("assets/fonts/Outfit-Regular.ttf") format("truetype"); }
@font-face { font-family: "Outfit UI"; font-style: normal; font-weight: 500; font-display: swap; src: url("assets/fonts/Outfit-Medium.ttf") format("truetype"); }
@font-face { font-family: "Outfit UI"; font-style: normal; font-weight: 700; font-display: swap; src: url("assets/fonts/Outfit-Bold.ttf") format("truetype"); }
@font-face { font-family: "Outfit UI"; font-style: normal; font-weight: 900; font-display: swap; src: url("assets/fonts/Outfit-Black.ttf") format("truetype"); }

:root {
  /* HKD brand */
  --hkd-red: #e60001;
  --hkd-red-600: #cc0001;
  --hkd-red-700: #a80001;
  --hkd-red-soft: #fdecec;
  --hkd-red-line: #f6c9c9;
  --hkd-gray: #8c8c8c;

  /* Surfaces (LabOS: clean white, light gray separation) */
  --page: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #f1f3f6;
  --line: #e6e8ec;
  --line-strong: #d6dae0;

  /* Text */
  --text: #1a1d22;
  --text-2: #4a5059;
  --muted: #7b828c;
  --faint: #a4abb4;

  /* Status */
  --ok: #12a150;
  --ok-soft: #e7f6ee;
  --warn: #b7791f;
  --warn-soft: #fbf1dc;
  --danger: #e60001;

  --accent: var(--hkd-red);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 20, 28, .05), 0 1px 3px rgba(16, 20, 28, .04);
  --shadow: 0 2px 6px rgba(16, 20, 28, .06), 0 8px 24px rgba(16, 20, 28, .06);
  --font: "Outfit UI", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--page);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- header */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .logo { width: 42px; height: 42px; display: block; }
.app-header h1 { margin: 0; font-size: 19px; letter-spacing: -.2px; font-weight: 700; }
.tagline { margin: 1px 0 0; color: var(--muted); font-size: 12.5px; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* language toggle */
.lang-toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.lang-toggle button { border: none; background: transparent; color: var(--muted); padding: 6px 0; min-width: 46px; text-align: center; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit; }
.lang-toggle button.active { background: var(--hkd-red); color: #fff; }

.btn .ico { width: 16px; height: 16px; flex: 0 0 auto; }

main { max-width: 1200px; margin: 0 auto; padding: 26px 28px 8px; display: flex; flex-direction: column; gap: 18px; }

/* ---------------------------------------------------------------- steps */
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.step-head { display: flex; align-items: center; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--hkd-red); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 13.5px; flex: 0 0 auto; }
.step-head h2 { margin: 0; font-size: 15.5px; font-weight: 650; }
.step-status { margin-left: auto; color: var(--muted); font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.step-status.ok { color: var(--ok); }
.step-status.warn { color: var(--warn); }
.step-body { padding: 20px; }

/* ---------------------------------------------------------------- dropzone */
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 30px; text-align: center; transition: border-color .15s, background .15s; background: var(--surface-2); }
.dropzone.drag { border-color: var(--hkd-red); background: var(--hkd-red-soft); }
.dropzone p { margin: 0 0 14px; color: var(--muted); }
.dropzone code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; color: var(--text-2); }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; font-family: inherit; font-weight: 550; transition: background .12s, border-color .12s, box-shadow .12s, opacity .12s; }
.btn:hover { border-color: var(--hkd-gray); background: var(--surface-2); }
.btn.primary { background: var(--hkd-red); color: #fff; border-color: var(--hkd-red); }
.btn.primary:hover { background: var(--hkd-red-600); border-color: var(--hkd-red-600); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.big { padding: 12px 24px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.danger { border-color: var(--hkd-red-line); color: var(--hkd-red); background: var(--hkd-red-soft); }
.btn.danger:hover { background: #fbe0e0; }

/* ---------------------------------------------------------------- fields */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 0; }
.field label { color: var(--muted); font-size: 12px; font-weight: 550; }
.field.inline label { white-space: nowrap; }
input[type=text], input[type=number], input[type=search], select, textarea {
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 10px; font-family: inherit; font-size: 13.5px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--hkd-red); box-shadow: 0 0 0 3px var(--hkd-red-soft); }
input[type=color] { padding: 2px; height: 34px; width: 46px; cursor: pointer; }
input[type=range] { accent-color: var(--hkd-red); width: 100%; }
.chk { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12.5px; cursor: pointer; }
.chk input { accent-color: var(--hkd-red); }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- fonts */
.font-row { margin-bottom: 16px; }
.font-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.font-list { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.font-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 12.5px; }
.font-chip.variable { border-color: var(--hkd-red-line); background: var(--hkd-red-soft); }
.font-chip.bundled { border-style: solid; opacity: .95; }
.step-hint { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; line-height: 1.5; max-width: 900px; }
.font-chip .fc-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-chip .fc-tag { font-size: 9.5px; font-weight: 700; letter-spacing: .3px; color: var(--hkd-red); background: #fff; border: 1px solid var(--hkd-red-line); border-radius: 4px; padding: 0 3px; }
.font-chip .fc-del { border: none; background: transparent; color: var(--faint); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; border-radius: 50%; }
.font-chip .fc-del:hover { color: var(--hkd-red); }

/* ---------------------------------------------------------------- colmap + table */
.colmap { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 16px; }
.colmap .field { margin: 0; }
.table-wrap { max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { text-align: left; padding: 7px 11px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; font-weight: 600; color: var(--text-2); }
tbody tr:hover { background: var(--surface-2); }

/* ---------------------------------------------------------------- category cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; transition: box-shadow .12s, border-color .12s; }
.card:hover { box-shadow: var(--shadow-sm); }
.card h3 { margin: 0 0 3px; font-size: 14.5px; font-weight: 650; }
.card .count { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.card .tpl-status { font-size: 12px; margin-top: 8px; color: var(--muted); }
.card .tpl-status.ok { color: var(--ok); }

/* ---------------------------------------------------------------- editor */
.editor-body { padding: 0; }
.editor-toolbar { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.editor-toolbar .spacer { flex: 1; }
.add-field-menu { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.editor-main { display: grid; grid-template-columns: 1fr 340px; gap: 0; min-height: 470px; }
.canvas-col { padding: 22px; display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--surface-3); }
.canvas-stage { position: relative; display: inline-block; box-shadow: var(--shadow); background: #fff; border-radius: 2px; }
.canvas-stage canvas { display: block; }
.fields-layer { position: absolute; inset: 0; }

/* marquee selection rectangle */
.marquee { position: absolute; border: 1px solid var(--hkd-red); background: rgba(230,0,1,.08); pointer-events: none; z-index: 20; }

/* smart alignment guides (snap lines) */
.guides-layer { position: absolute; inset: 0; pointer-events: none; z-index: 30; overflow: visible; }
.guide-line { position: absolute; background: #ff2d9b; }
.guide-line.v { top: -6px; bottom: -6px; width: 1px; height: auto; }
.guide-line.h { left: -6px; right: -6px; height: 1px; width: auto; }
.guide-line::before, .guide-line::after { content: ""; position: absolute; width: 5px; height: 5px; border: 1px solid #ff2d9b; border-radius: 50%; background: #fff; }
.guide-line.v::before { left: -2px; top: -3px; } .guide-line.v::after { left: -2px; bottom: -3px; }
.guide-line.h::before { top: -2px; left: -3px; } .guide-line.h::after { top: -2px; right: -3px; }

.field-box { position: absolute; border: 1px solid var(--hkd-gray); background: rgba(140,140,140,.10); cursor: move; overflow: visible; box-sizing: border-box; border-radius: 2px; }
.field-box.selected { border-color: var(--hkd-red); background: rgba(230,0,1,.08); z-index: 5; box-shadow: 0 0 0 1px var(--hkd-red); }
.field-box .fb-label { position: absolute; top: -18px; left: -1px; font-size: 10px; background: var(--hkd-gray); color: #fff; padding: 1px 5px; border-radius: 4px 4px 0 0; white-space: nowrap; font-weight: 600; }
.field-box.selected .fb-label { background: var(--hkd-red); }
.field-box .fb-content { width: 100%; height: 100%; display: flex; overflow: hidden; }
.field-box .fb-text { width: 100%; line-height: 1.1; word-break: break-word; }
.field-box .fb-img { width: 100%; height: 100%; object-fit: contain; }
.field-box .handle { position: absolute; width: 11px; height: 11px; background: #fff; border: 1.5px solid var(--hkd-red); border-radius: 50%; right: -6px; bottom: -6px; cursor: nwse-resize; z-index: 6; }
/* dedicated font-size handle (top-right) */
.field-box .handle.size { right: -6px; top: -6px; bottom: auto; cursor: ns-resize; border-color: var(--hkd-gray); }
.field-box .handle.size::after { content: "A"; position: absolute; inset: 0; font-size: 8px; font-weight: 800; color: var(--hkd-gray); display: grid; place-items: center; }

.props-col { border-left: 1px solid var(--line); padding: 16px; background: var(--surface); overflow-y: auto; max-height: 720px; }
.props-col h3 { margin: 0 0 12px; font-size: 14px; font-weight: 650; display: flex; align-items: center; }
.props-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { flex: 1; background: var(--surface); border: none; color: var(--muted); padding: 7px 4px; cursor: pointer; font-size: 12px; font-family: inherit; font-weight: 550; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--hkd-red); color: #fff; }
.props-col .field { margin-bottom: 11px; }
.props-note { font-size: 11.5px; color: var(--faint); margin: 2px 0 0; }

/* align / distribute toolbar */
.align-bar { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 12px; background: var(--surface-2); }
.align-bar .ab-title { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.align-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.align-grid button { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 6px; padding: 6px; cursor: pointer; font-size: 15px; line-height: 1; color: var(--text-2); }
.align-grid button:hover { border-color: var(--hkd-red); color: var(--hkd-red); }
.align-grid button:disabled { opacity: .4; cursor: not-allowed; }

/* weight slider row */
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row output { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text-2); min-width: 30px; text-align: right; }

/* ---------------------------------------------------------------- export */
.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 18px; }
.export-actions { display: flex; align-items: center; gap: 14px; }

/* ---------------------------------------------------------------- toast + footer */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--line-strong); padding: 12px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow); z-index: 100; max-width: 480px; color: var(--text); }
.toast.err { border-color: var(--hkd-red); }
.toast.ok { border-color: var(--ok); }

.app-footer { max-width: 1200px; margin: 8px auto 0; padding: 20px 28px 30px; text-align: center; color: var(--muted); font-size: 12.5px; }
.app-footer .credit { font-weight: 550; }
.app-footer .credit .spark { color: var(--hkd-red); }
