/* Xani ERP — Modernes, klares Admin-Theme. Mobile-first. */
:root {
  --bg: #0f172a;
  --bg-2: #111827;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #f59e0b;
  --accent-2: #fbbf24;
  --primary: #1e293b;
  --primary-text: #ffffff;
  --ok: #16a34a;
  --err: #dc2626;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 8px 24px -12px rgba(15,23,42,.18);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "DejaVu Sans", sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--panel-2);
  line-height: 1.4;
}
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 13px; background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--panel-2); font-weight: 600; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.r { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 16px; }

/* Layout */
body.with-nav { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
body.no-nav { display: block; }
nav.side {
  background: var(--bg);
  color: white;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
nav.side a { color: #e2e8f0; padding: 10px 12px; border-radius: 8px; font-weight: 500; }
nav.side a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
nav.side a.on { background: var(--accent); color: #1f2937; }
nav.side .brand { font-size: 22px; font-weight: 800; padding: 8px 12px 16px; color: white; }
nav.side .brand span { color: var(--accent-2); }
nav.side .spacer { flex: 1; }
nav.side .userbox { padding: 8px 12px; border-top: 1px solid rgba(255,255,255,.1); margin-top: 12px; display: flex; align-items: center; gap: 8px; justify-content: space-between; font-size: 13px; }
main { padding: 24px clamp(16px, 4vw, 32px); max-width: 1400px; }

@media (max-width: 720px) {
  body.with-nav { grid-template-columns: 1fr; }
  nav.side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  nav.side .brand { padding: 6px 10px; }
  nav.side .spacer, nav.side .userbox { display: none; }
}

/* Login */
.login-card {
  max-width: 380px; margin: 8vh auto; background: var(--panel); padding: 36px;
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.login-card .logo { font-size: 32px; margin: 0 0 4px; font-weight: 800; }
.login-card .logo span { color: var(--accent); }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 120px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: white; color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn {
  font: inherit; cursor: pointer; padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: white; color: var(--text); font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, transform .12s;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn.primary:hover { background: #334155; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: #fecaca; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: flex-start; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; margin-left: 4px; }
.hidden { display: none !important; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; padding: 12px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); }
.toolbar input { flex: 1 1 250px; }
.toolbar .spacer { flex: 1; }
.err { color: var(--err); }
.ok { color: var(--ok); }

/* Cards / Stats */
.page-title { font-size: 26px; font-weight: 800; margin: 0 0 20px; display: flex; align-items: center; gap: 10px; }
.page-title .back { color: var(--muted); font-weight: 400; font-size: 24px; }
.page-title .badge { font-size: 14px; padding: 3px 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-weight: 600; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 20px; }
.stat-card {
  background: var(--panel); padding: 18px; border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px; color: var(--text);
}
.stat-card:hover { text-decoration: none; transform: translateY(-1px); }
.stat-card .num { font-size: 28px; font-weight: 800; }
.stat-card .num.small { font-size: 14px; }
.stat-card .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }

.card { background: var(--panel); padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); }
.card h2 { margin: 0 0 12px; font-size: 18px; }
.card h3 { margin: 12px 0 8px; font-size: 15px; }

.check-list { padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.check-list li { padding: 8px 12px; background: var(--panel-2); border-radius: var(--radius-sm); }

table.products tbody tr:hover { background: #fffbeb; }
table.mini th, table.mini td { padding: 6px 8px; font-size: 13px; }
table.mini tr.err td { color: var(--err); }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 500; }
.alert.ok { background: #dcfce7; color: #166534; }
.alert.err { background: #fee2e2; color: #991b1b; }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 16px 0; }

/* Designer */
#designer { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.designer-toolbar { display: flex; gap: 8px; align-items: center; padding: 12px; background: var(--panel-2); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.designer-toolbar input, .designer-toolbar select { width: auto; min-width: 80px; }
.designer-toolbar #d-name { min-width: 200px; flex: 1; }
.designer-toolbar .spacer { flex: 1; }
.designer-body { display: grid; grid-template-columns: 220px 1fr 280px; min-height: 540px; }
@media (max-width: 1100px) { .designer-body { grid-template-columns: 1fr; } }
.designer-fields, .designer-props { padding: 16px; border-right: 1px solid var(--border); background: var(--panel-2); }
.designer-props { border-right: 0; border-left: 1px solid var(--border); }
.designer-fields h3, .designer-props h3 { font-size: 13px; text-transform: uppercase; color: var(--muted); margin: 16px 0 6px; letter-spacing: .04em; }
.designer-fields h3:first-child, .designer-props h3:first-child { margin-top: 0; }
.tokens { list-style: none; padding: 0; font-size: 12px; line-height: 1.8; }
.designer-canvas { padding: 16px; background: repeating-conic-gradient(#f1f5f9 0% 25%, #e2e8f0 0% 50%) 0 0/16px 16px; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 12px; overflow: hidden; min-height: 540px; max-height: calc(100vh - 220px); }
.canvas-scroll { flex: 1; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 12px; background: rgba(255,255,255,.3); border-radius: 6px; }
.canvas { background: white; box-shadow: 0 10px 30px rgba(0,0,0,.18); position: relative; flex-shrink: 0; }
.canvas .el { position: absolute; outline: 1px dashed transparent; cursor: move; user-select: none; }
.canvas .el:hover { outline-color: rgba(245,158,11,.7); }
.canvas .el.selected { outline: 2px solid var(--accent); }
.canvas .el .handle { position: absolute; right: -5px; bottom: -5px; width: 10px; height: 10px; background: var(--accent); cursor: nwse-resize; border-radius: 2px; }
.zoom { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.zoom input { width: 200px; }
.preview-frame { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; }
.preview-frame iframe { border: 0; background: white; }

/* Drucken / Vorschau */
.preview-page { display: flex; flex-wrap: wrap; gap: 6mm; padding: 6mm; background: var(--panel-2); }
.preview-cell { background: white; border: 1px dashed var(--border); }
.preview-cell svg { display: block; width: 100%; height: 100%; }
