:root {
    --pink: #e4007c;
    --blue: #29abe2;
    --teal: #3bb4b6;
    --yellow: #ffd400;
    --bg: #f4f5f7;
    --text: #222;
    --muted: #8a8f98;
    --border: #e2e5ea;
    --danger: #d33;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}
main { max-width: 1200px; margin: 24px auto; padding: 0 16px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .5px; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: 12px; }
.center { text-align: center; }
.error { color: var(--danger); }
.ok-text { color: #1a9e4b; font-weight: 600; }
.hidden { display: none !important; }

/* --- Topbar --- */
.topbar {
    background: #fff;
    border-bottom: 3px solid var(--pink);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
}
.topbar nav { display: flex; gap: 8px; align-items: center; }
.topbar nav a {
    text-decoration: none;
    color: var(--text);
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
}
.topbar nav a.active { background: var(--pink); color: #fff; }
.topbar nav a:hover:not(.active) { background: var(--bg); }
.btn-logout { color: var(--muted) !important; }

/* --- Login --- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
    width: 340px;
    text-align: center;
    border-top: 4px solid var(--pink);
}
.login-box input { width: 100%; margin: 16px 0; }
.login-box .btn { width: 100%; }

/* --- Cards / forms --- */
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 20px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.actions { display: flex; gap: 8px; align-items: center; }

input[type=text], input[type=password], input[type=number] {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}
input:focus { outline: 2px solid var(--blue); border-color: transparent; }
.w-small { width: 110px; }
.w-num { width: 70px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.file-label {
    display: inline-block;
    padding: 8px 12px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--muted);
}
.file-label:hover { border-color: var(--pink); color: var(--pink); }
.file-label input { display: none; }

/* --- Buttons --- */
.btn {
    padding: 9px 16px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
    display: inline-block;
}
.btn:hover { border-color: var(--pink); color: var(--pink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--pink); border-color: var(--pink); color: #fff; }
.btn-primary:hover { background: #c4006c; color: #fff; }
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--danger); }
.btn-mini {
    border: none; background: none; color: var(--muted);
    cursor: pointer; font-size: 14px; padding: 0 4px;
}
.btn-mini:hover { color: var(--danger); }

/* --- Notices --- */
.notice { padding: 10px 14px; border-radius: 8px; font-size: 14px; }
.notice.ok { background: #e6f7ec; color: #1a9e4b; }
.notice.error { background: #fdeaea; color: var(--danger); }
.notice.warn { background: #fff8e0; color: #8a6d00; }
.notice a { color: inherit; font-weight: 700; }

/* --- Table --- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 8px; border-bottom: 2px solid var(--border); font-size: 12px; text-transform: uppercase; color: var(--muted); }
.table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.logo-thumb { width: 36px; height: 36px; object-fit: contain; border-radius: 50%; border: 1px solid var(--border); background: #fff; }
.badge {
    background: var(--bg);
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
}
.edit-row td { background: #fafbfc; }
.warn-icon { cursor: help; }

/* --- Progress --- */
.progress { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.progress-bar { flex: 1; height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--pink), var(--blue)); transition: width .3s; }
#progress-label { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* --- Templates page --- */
.tpl-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.tpl-list ul { list-style: none; padding: 0; margin: 0 0 12px; }
.tpl-list li {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 8px; border-radius: 6px; font-size: 13px;
}
.tpl-list li.active { background: #fde8f3; }
.tpl-list li a { text-decoration: none; color: var(--text); flex: 1; word-break: break-all; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.dot.ok { background: #1a9e4b; }
.upload-form { margin-bottom: 20px; }

.toolbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 0; font-size: 13px;
}
.toolbar label { display: flex; align-items: center; gap: 5px; }
.toolbar .sep { width: 1px; height: 22px; background: var(--border); }
.tool.active { background: var(--blue); border-color: var(--blue); color: #fff; }

.canvas-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border: 1px solid var(--border);
    cursor: crosshair;
    line-height: 0;
    background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/20px 20px;
}
.canvas-wrap img { max-width: 100%; max-height: 70vh; display: block; }
.canvas-wrap { touch-action: none; user-select: none; }
.marker { position: absolute; line-height: 1; cursor: grab; pointer-events: auto; }
.marker:active { cursor: grabbing; }
.marker-logo { border: 2px dashed var(--pink); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.marker-logo span { color: var(--pink); font-size: 11px; font-weight: 700; background: rgba(255,255,255,.7); padding: 1px 4px; border-radius: 3px; pointer-events: none; }
.marker-text { transform: translate(-50%, -50%); font-weight: 800; font-family: Arial, sans-serif; text-shadow: 0 0 3px rgba(0,0,0,.4); padding: 6px; }
.marker-text span { border-bottom: 2px dashed currentColor; pointer-events: none; }

/* Boite de texte redimensionnable (style Illustrator) */
.marker-box {
    border: 1.5px solid var(--blue);
    background: rgba(41, 171, 226, .08);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-family: Arial, sans-serif;
    text-shadow: 0 0 3px rgba(0,0,0,.4);
    overflow: visible;
}
.marker-box span { pointer-events: none; white-space: nowrap; }
.handle {
    position: absolute; width: 6px; height: 6px;
    background: #fff; border: 1px solid var(--blue); border-radius: 1px;
    pointer-events: auto; z-index: 6;
    display: none;
}
.marker.active .handle { display: block; }
.handle[data-dir=nw] { top: -4px; left: -4px; cursor: nwse-resize; }
.handle[data-dir=n]  { top: -4px; left: calc(50% - 3px); cursor: ns-resize; }
.handle[data-dir=ne] { top: -4px; right: -4px; cursor: nesw-resize; }
.handle[data-dir=e]  { top: calc(50% - 3px); right: -4px; cursor: ew-resize; }
.handle[data-dir=se] { bottom: -4px; right: -4px; cursor: nwse-resize; }
.handle[data-dir=s]  { bottom: -4px; left: calc(50% - 3px); cursor: ns-resize; }
.handle[data-dir=sw] { bottom: -4px; left: -4px; cursor: nesw-resize; }
.handle[data-dir=w]  { top: calc(50% - 3px); left: -4px; cursor: ew-resize; }

/* Panneau de coordonnees */
.coords-panel {
    display: flex; flex-direction: column; gap: 6px;
    padding: 10px 12px; margin-bottom: 12px;
    background: #fafbfc; border: 1px solid var(--border); border-radius: 8px;
}
.coord-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.coord-name { width: 60px; font-weight: 700; color: var(--pink); }
.coord-row label { display: flex; align-items: center; gap: 4px; color: var(--muted); }

#preview-box { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
#preview-img { max-width: 100%; border: 1px solid var(--border); }

@media (max-width: 900px) {
    .tpl-layout { grid-template-columns: 1fr; }
}
