/* STEP Kalkulator — app styles */
:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --border: #dde2ea;
  --text: #1c2430;
  --muted: #647081;
  --accent: #0f5cc0;
  --accent-hover: #0c4a9a;
  --accent-soft: #e6effb;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --success: #1e7e46;
  --success-soft: #e6f4ec;
  --warning: #b26a00;
  --warning-soft: #fff3e0;
  --sb-bg: #14202e;
  --sb-text: #cdd6e1;
  --sb-text-strong: #ffffff;
  --sb-muted: #8b98a9;
  --sb-hover: rgba(255, 255, 255, .06);
  --sb-border: rgba(255, 255, 255, .08);
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --sidebar-w: 240px;
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--sb-bg);
  color: var(--sb-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; font-weight: 600; color: var(--sb-text-strong); font-size: 1.05rem; }
.sidebar-logo { max-width: 100%; max-height: 56px; object-fit: contain; display: block; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 700;
}
.sidebar-nav { display: flex; flex-direction: column; padding: 8px; gap: 2px; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--sb-text); font-size: .95rem;
}
.sidebar-nav a:hover { background: var(--sb-hover); text-decoration: none; }
.sidebar-nav a.active { background: var(--accent); color: #fff; }
.ni { width: 18px; text-align: center; opacity: .8; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--sb-border); display: flex; flex-direction: column; gap: 10px; }
.lang-switch { display: flex; gap: 6px; }
.lang-switch a {
  padding: 3px 10px; border-radius: 6px; font-size: .8rem; font-weight: 600;
  color: var(--sb-muted); border: 1px solid var(--sb-border);
}
.lang-switch a.active { background: var(--sb-text-strong); color: var(--sb-bg); border-color: var(--sb-text-strong); }
.lang-switch a:hover { text-decoration: none; color: var(--sb-text-strong); }
.lang-switch a.active:hover { color: var(--sb-bg); }
.sidebar-user { display: flex; align-items: center; gap: 10px; color: var(--sb-text-strong); }
.sidebar-user:hover { text-decoration: none; }
.sidebar-user-name { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-initials { display: inline-flex; align-items: center; justify-content: center; background: #2c3e50; color: #fff; font-size: .8rem; font-weight: 600; }
.avatar-lg { width: 84px; height: 84px; font-size: 1.6rem; }
.logout-link { color: var(--sb-muted); font-size: .85rem; }
.main { flex: 1; padding: 28px 32px; max-width: 1400px; min-width: 0; }

/* ---------- Auth ---------- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 36px; width: 100%; max-width: 440px; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .brand-mark { width: 48px; height: 48px; font-size: 1.4rem; border-radius: 12px; }
.auth-brand h1 { margin-top: 12px; font-size: 1.3rem; }
.auth-lang { text-align: center; margin-top: 18px; }
.auth-lang a { margin: 0 6px; font-size: .85rem; }

/* ---------- Cards / panels ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card h2 { margin-bottom: 14px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.field { margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }
.hint { font-size: .8rem; color: var(--muted); margin-top: 3px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
  background: var(--accent); color: #fff; text-decoration: none;
  transition: background .15s;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #992d22; }
.btn-sm { padding: 5px 12px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Badges / flash ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-created { background: #e8eaf0; color: #45526b; }
.badge-in_progress { background: var(--warning-soft); color: var(--warning); }
.badge-finalized { background: var(--success-soft); color: var(--success); }
.badge-sent { background: var(--accent-soft); color: var(--accent); }
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: .92rem; }
.flash-success { background: var(--success-soft); color: var(--success); border: 1px solid #bfe3cd; }
.flash-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f3c1ba; }

/* ---------- Tables ---------- */
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }

/* ---------- Stats / dashboard ---------- */
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.7rem; font-weight: 700; margin-top: 4px; }
.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 48px; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 2px; }
.bar-alt { background: #7fa8dd; }
.bar-label { font-size: .72rem; color: var(--muted); }
.bar-value { font-size: .75rem; font-weight: 600; }
.status-list { display: flex; flex-direction: column; gap: 10px; }
.status-row { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.status-row .track { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.status-row .fill { height: 100%; background: var(--accent); border-radius: 4px; }
.status-row .num { width: 30px; text-align: right; font-weight: 600; }

/* ---------- Project cards ---------- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.project-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.project-card .pc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.project-card h3 { margin: 0; font-size: 1.05rem; }
.project-card .pc-meta { font-size: .83rem; color: var(--muted); }
.project-card .pc-price { font-size: 1.15rem; font-weight: 700; }
.project-card .pc-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; align-items: center; }
.filter-bar input, .filter-bar select { width: auto; min-width: 160px; }

/* ---------- Workflow / project detail ---------- */
.wf-steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.wf-step { display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: .85rem; font-weight: 600; color: var(--muted); }
.wf-step.done { border-color: var(--success); color: var(--success); background: var(--success-soft); }
.wf-step.current { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.wf-num { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; align-items: center; justify-content: center; background: currentColor; font-size: .7rem; }
.wf-num span { color: #fff; }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; color: var(--muted);
  cursor: pointer; transition: all .15s; background: #fafbfc;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

#viewer-container { position: relative; width: 100%; height: 420px; background: #1a2433; border-radius: var(--radius); overflow: hidden; }
#viewer-container canvas { display: block; }
.viewer-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #8b98a9; font-size: .95rem; pointer-events: none; }
.viewer-hint { position: absolute; bottom: 10px; left: 12px; color: #5b6b80; font-size: .75rem; pointer-events: none; }

.analysis-table td:first-child { color: var(--muted); }
.analysis-table td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.calc-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.calc-total-row td { font-size: 1.15rem; font-weight: 700; border-top: 2px solid var(--text); }

.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
.spinner-dark { border-color: rgba(0,0,0,.15); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Branding settings ---------- */
.logo-preview {
  width: 150px; height: 90px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); overflow: hidden; padding: 8px;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
input.color-input {
  width: 100%; height: 42px; padding: 4px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; cursor: pointer;
}

/* ---------- Danger zone ---------- */
.danger-zone { border: 1px solid var(--danger); border-radius: var(--radius); background: var(--danger-soft); padding: 20px; }
.danger-zone h2 { color: var(--danger); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.5); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.25); width: 100%; max-width: 520px; padding: 24px; max-height: 90vh; overflow: auto; }
.modal h2 { margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Version credit ---------- */
.app-credit {
  position: fixed; bottom: 10px; right: 14px;
  font-size: .72rem; color: #a8b2bf;
  pointer-events: auto; z-index: 10;
}
.app-credit a { color: #a8b2bf; text-decoration: none; }
.app-credit a:hover { color: var(--muted); text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-footer { border-top: none; flex-direction: row; align-items: center; margin-left: auto; }
  .sidebar-user-name { display: none; }
  .main { padding: 18px 14px; }
}
