:root {
  --bg: #f4f5f7;
  --panel-bg: #ffffff;
  --border: #d9dce1;
  --accent: #0a5c9c;
  --accent-hover: #084a7d;
  --text: #1c2733;
  --muted: #8a94a3;
  --header-h: 48px;
  --print-h: 60px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
}

/* HEADER */
#header {
  height: var(--header-h);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 20px;
}
#header .brand { font-weight: 700; font-size: 18px; letter-spacing: 0.5px; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.header-actions button {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.header-actions button:hover { background: rgba(255, 255, 255, 0.28); }
#design-name-label { margin-left: 12px; font-size: 13px; opacity: 0.9; }

/* LAYOUT */
#main {
  display: grid;
  grid-template-columns: 230px 1fr 300px;
  height: calc(100vh - var(--header-h));
}
#sidebar, #toolbar {
  background: var(--panel-bg);
  overflow-y: auto;
  border-right: 1px solid var(--border);
}
#toolbar { border-right: none; border-left: 1px solid var(--border); }

.panel { padding: 14px; border-bottom: 1px solid var(--border); }
.panel h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.5px; }

.list { list-style: none; margin: 0 0 8px; padding: 0; }
.list li {
  padding: 7px 9px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.list li:hover { background: #eef2f6; }
.list li.active { background: var(--accent); color: #fff; }
.list li .sub { font-size: 11px; color: var(--muted); }
.list li.active .sub { color: rgba(255,255,255,0.8); }
.list li .del { opacity: 0; color: #c0392b; font-weight: bold; padding: 0 4px; }
.list li:hover .del { opacity: 1; }
.list li.active .del { color: #fff; }

/* BUTTONS */
button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 6px 12px;
  border-radius: 5px;
  font-size: 13px;
}
button:hover { background: #f0f2f5; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: #084a7d; }
.add-btn { width: 100%; font-size: 13px; color: var(--accent); border-style: dashed; }

/* CANVAS */
#canvas-area { display: flex; flex-direction: column; background: #e7ebef; }
#canvas-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: var(--panel-bg); border-bottom: 1px solid var(--border);
  font-size: 13px;
}
#canvas-toolbar .spacer { flex: 1; }
#canvas-wrapper {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: auto; padding: 20px;
}
#label-canvas { background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,0.15); }
.canvas-container { box-shadow: 0 2px 12px rgba(0,0,0,0.15); }

/* PRINT AREA */
#print-area {
  height: var(--print-h);
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  font-size: 13px;
}
#print-area label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 2px; }
#print-area select, #print-area input { padding: 5px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; }
#print-count { width: 70px; }
#print-status { font-size: 13px; margin-left: auto; }
#print-status.ok { color: #1e8449; }
#print-status.err { color: #c0392b; }

/* TOOLBAR RIGHT */
.tool-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tool-buttons button { width: 100%; }

#properties-content .prop-row { margin-bottom: 8px; display: flex; flex-direction: column; gap: 3px; }
#properties-content label { font-size: 11px; color: var(--muted); }
#properties-content input, #properties-content select, #properties-content textarea {
  padding: 5px 7px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; width: 100%;
}
#properties-content .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#properties-content button.danger { color: #c0392b; border-color: #e6b0aa; width: 100%; margin-top: 6px; }

.muted { color: var(--muted); font-size: 13px; }

/* MODAL */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
#modal-overlay.hidden, .hidden { display: none; }
#modal { background: #fff; border-radius: 8px; width: 440px; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; }
#modal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; }
#modal-header button { border: none; background: none; font-size: 22px; line-height: 1; padding: 0 4px; }
#modal-body { padding: 18px; overflow-y: auto; }
#modal-body .form-row { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
#modal-body label { font-size: 12px; color: var(--muted); }
#modal-body input, #modal-body select, #modal-body textarea {
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 5px; font-size: 14px; width: 100%;
}
#modal-body textarea { min-height: 70px; font-family: monospace; }
#modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
#modal-body .preview-img { max-width: 100%; border: 1px solid var(--border); }
#modal-body .hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
#modal-body .test-result { font-size: 13px; margin-top: 8px; padding: 8px; border-radius: 4px; background: #f4f5f7; }
