/* ═══════════════════════════════════════════════════════
   Milkosnamas CRM — Shared Styles
   ═══════════════════════════════════════════════════════ */

:root {
  --bg:           #f8f7f5;
  --bg2:          #f0ede8;
  --surface:      #ffffff;
  --border:       #e0dcd6;
  --text:         #1a1a1a;
  --text-muted:   #888880;
  --accent:       #1a1a1a;
  --accent-inv:   #f8f7f5;

  --sidebar-w:    240px;
  --sidebar-bg:   #111110;
  --sidebar-text: #d8d4ce;
  --sidebar-muted:#6e6c68;
  --sidebar-hover:#1f1e1c;
  --sidebar-active:#2a2927;
  --sidebar-border:#252422;

  --topbar-h:     56px;

  --green:  #2d6a4f;
  --green-bg: #e8f5ee;
  --yellow: #8a6d00;
  --yellow-bg: #fef9e0;
  --red:    #9b1c1c;
  --red-bg: #fde8e8;
  --blue:   #1a4a7a;
  --blue-bg:#e8f0fe;

  --shadow:    0 1px 3px rgba(0,0,0,0.06), 0 2px 12px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);

  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Fira Code", monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: var(--font); font-size: 14px; }
img { max-width: 100%; display: block; }

/* ── Layout ─────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-user {
  font-weight: 500;
  color: var(--text);
}

.content {
  flex: 1;
  padding: 32px 28px;
  max-width: 1200px;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar-logo {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-logo-main {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #f0ede8;
}
.sidebar-logo-sub {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  margin-top: 2px;
  font-weight: 400;
}

.sidebar-user-block {
  padding: 14px 20px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  margin-top: 2px;
}

.sidebar-nav {
  list-style: none;
  padding: 10px 0;
  flex: 1;
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 13px;
  color: var(--sidebar-text);
  transition: background 0.15s, color 0.15s;
  border-left: 2px solid transparent;
}
.sidebar-nav li a:hover { background: var(--sidebar-hover); }
.sidebar-nav li.active a {
  background: var(--sidebar-active);
  color: #f0ede8;
  border-left-color: #f0ede8;
  font-weight: 500;
}
.sidebar-nav li a .nav-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
}
.sidebar-nav li.active a .nav-icon { opacity: 1; }

.sidebar-section-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding: 14px 20px 4px;
}

.sidebar-bottom {
  padding: 14px 20px;
  border-top: 1px solid var(--sidebar-border);
}
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--sidebar-muted);
  transition: color 0.15s;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  padding: 0;
}
.sidebar-logout:hover { color: var(--sidebar-text); }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.card-body { padding: 20px; }

/* ── Stat cards ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}
.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--bg2); }
.btn-primary { background: var(--accent); color: var(--accent-inv); border-color: var(--accent); }
.btn-primary:hover { opacity: 0.85; }
.btn-sm { padding: 5px 11px; font-size: 10px; }
.btn-danger { border-color: #e74c3c; color: #e74c3c; }
.btn-danger:hover { background: #fde8e8; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg2); border-color: var(--border); }

/* ── Forms ───────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.form-full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.field input,
.field select,
.field textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--text); background: var(--surface); }
.field textarea { resize: vertical; min-height: 80px; }
.field-hint { font-size: 11px; color: var(--text-muted); }

.form-actions {
  display: flex;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
tbody tr { transition: background 0.1s; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-155 { background: #fef3e2; color: #8b6914; }
.badge-80  { background: var(--blue-bg); color: var(--blue); }
.badge-sauna { background: #fde8e8; color: var(--red); }
.badge-admin { background: var(--sidebar-bg); color: var(--sidebar-text); }
.badge-coordinator { background: #f3e8ff; color: #6b21a8; }
.badge-client { background: var(--bg2); color: var(--text-muted); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-red { background: var(--red-bg); color: var(--red); }

/* ── Progress ─────────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--bg2);
  height: 4px;
  width: 100%;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--text);
  transition: width 0.4s ease;
}
.progress-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Login page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 40px;
}
.login-logo {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 6px;
}
.login-logo span { font-weight: 300; }
.login-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 28px;
}
.login-error {
  background: var(--red-bg);
  color: var(--red);
  padding: 10px 14px;
  font-size: 12px;
  margin-bottom: 16px;
  border: 1px solid #f5c6c6;
}

/* ── Section header ──────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.section-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Alert / flash ───────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 18px;
  border: 1px solid;
}
.alert-success { background: var(--green-bg); color: var(--green); border-color: #b7dfc8; }
.alert-error   { background: var(--red-bg);   color: var(--red);   border-color: #f5c6c6; }
.alert-info    { background: var(--blue-bg);   color: var(--blue);  border-color: #c2d9f8; }

/* ── Project view ─────────────────────────────────────────── */
.project-hero {
  width: 100%;
  height: 260px;
  background: var(--bg2);
  overflow: hidden;
  position: relative;
  margin-bottom: 24px;
}
.project-hero img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.project-hero-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); flex-direction: column; gap: 10px;
}
.project-hero-placeholder svg { opacity: 0.2; }
.project-hero-placeholder span { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.5; }

.project-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

.info-rows { display: flex; flex-direction: column; }
.info-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.info-row:last-child { border-bottom: none; }
.info-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-muted);
  width: 110px; flex-shrink: 0; padding-top: 1px;
}
.info-value { font-size: 13px; color: var(--text); flex: 1; line-height: 1.5; }
.info-value a { text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.info-value a:hover { text-decoration-color: var(--text); }

/* ── Stage checklist ─────────────────────────────────────── */
.stage-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.stage-item:last-child { border-bottom: none; }
.stage-check {
  width: 20px; height: 20px;
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer; transition: all 0.15s;
  background: var(--surface);
}
.stage-check.done {
  background: var(--text);
  border-color: var(--text);
}
.stage-check.done svg { display: block; }
.stage-check svg { display: none; }
.stage-info { flex: 1; min-width: 0; }
.stage-name {
  font-size: 13px; color: var(--text);
}
.stage-name.done { color: var(--text-muted); text-decoration: line-through; }
.stage-meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.stage-num {
  width: 22px; height: 22px;
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text-muted);
  flex-shrink: 0;
}
.stage-num.done { background: var(--text); border-color: var(--text); color: white; }

/* ── Client portal ───────────────────────────────────────── */
.portal-page {
  min-height: 100vh;
  background: var(--bg);
}
.portal-topbar {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px;
}
.portal-topbar-logo {
  font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
}
.portal-topbar-logo span { font-weight: 300; }

.portal-hero {
  width: 100%;
  height: 360px;
  background: var(--bg2);
  overflow: hidden;
  position: relative;
}
.portal-hero img { width: 100%; height: 100%; object-fit: cover; }
.portal-hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 60%);
  display: flex; align-items: flex-end;
  padding: 32px;
}
.portal-hero-title { color: white; font-size: 32px; font-weight: 600; letter-spacing: -0.02em; }
.portal-hero-badge {
  display: inline-flex; align-items: center;
  background: rgba(255,255,255,0.2); color: white;
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 12px; margin-bottom: 8px; backdrop-filter: blur(4px);
}

.portal-content {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 24px;
}

.portal-progress-block {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 28px;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
}
.portal-progress-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.portal-progress-pct {
  font-size: 40px; font-weight: 600; letter-spacing: -0.03em; color: var(--text);
}
.portal-progress-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted);
}
.portal-progress-bar {
  height: 6px; background: var(--bg2); position: relative; margin-bottom: 10px;
}
.portal-progress-bar-fill {
  height: 100%; background: var(--text); transition: width 0.8s cubic-bezier(.4,0,.2,1);
}

.portal-timeline { margin-top: 28px; }
.timeline-item {
  display: flex; gap: 14px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.timeline-dot.done { background: var(--text); border-color: var(--text); }
.timeline-dot.done svg { display: block; }
.timeline-dot svg { display: none; }
.timeline-dot.current { border-color: var(--text); }
.timeline-body { flex: 1; }
.timeline-name { font-size: 13px; font-weight: 500; color: var(--text); }
.timeline-name.done { color: var(--text-muted); }
.timeline-name.pending { color: var(--text-muted); font-weight: 400; }
.timeline-date { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.portal-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 28px;
}
.portal-info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
}
.portal-info-label {
  font-size: 9px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px;
}
.portal-info-value {
  font-size: 14px; color: var(--text); line-height: 1.4;
}
.portal-info-value a { text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.portal-info-value a:hover { text-decoration-color: var(--text); }

.portal-cloud-btn {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 16px;
  padding: 12px 24px;
  background: var(--accent); color: var(--accent-inv);
  font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  border: none; cursor: pointer; text-decoration: none;
  transition: opacity 0.2s;
}
.portal-cloud-btn:hover { opacity: 0.82; }

/* ── Filters bar ─────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar select,
.filter-bar input[type=text] {
  padding: 7px 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  outline: none;
}
.filter-bar select:focus,
.filter-bar input:focus { border-color: var(--text); }

/* ── Misc ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 16px; opacity: 0.2; }
.empty-state p { font-size: 13px; }

.page-back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 20px; transition: color 0.15s;
}
.page-back:hover { color: var(--text); }

.actions-col { display: flex; gap: 6px; justify-content: flex-end; }

.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 11px; }

/* Coordinator simplified sidebar */
.sidebar-coord { background: #1a1918; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 200px; }
  .project-grid { grid-template-columns: 1fr; }
  .portal-info-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; min-width: unset; }
  .main { margin-left: 0; }
  .content { padding: 20px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
