/* ================== Neela Studio · Espai 3D — App ================== */

:root {
  --color-bg: #faf7f3;
  --color-surface: #ffffff;
  --color-text: #2a1d17;
  --color-muted: #857062;
  --color-primary: #c04f2c;          /* terracota */
  --color-primary-dark: #9b3d1f;
  --color-accent: #d9a066;
  --color-border: #e5ddd3;
  --color-sidebar: #2a1d17;
  --color-sidebar-active: #c04f2c;
  --color-success: #4a8f5b;
  --color-warning: #d98a2c;
  --color-danger:  #c73a3a;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(42,29,23,.08);
  --shadow-md: 0 4px 16px rgba(42,29,23,.12);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

/* ================== Login ================== */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #3a2a22 0%, #c04f2c 100%);
  padding: 20px;
}
.login-card {
  background: white;
  padding: 40px;
  border-radius: 12px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.login-card .brand {
  text-align: center;
  margin-bottom: 10px;
}
.login-card .brand h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.15em;
  color: var(--color-primary);
}
.login-card .brand p {
  margin: 4px 0 0;
  color: var(--color-muted);
  font-size: 13px;
}
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--color-muted);
}
.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
}
.login-card input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(192,79,44,.15);
}
.login-card button {
  padding: 12px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.login-card button:hover { background: var(--color-primary-dark); }
.login-card button:disabled { opacity: .6; cursor: not-allowed; }
.login-card .err {
  color: var(--color-danger);
  font-size: 13px;
  margin: 0;
  text-align: center;
}

/* ================== App layout ================== */

.app-wrap {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* -------- Sidebar -------- */

.sidebar {
  background: var(--color-sidebar);
  color: #e5ddd3;
  display: flex;
  flex-direction: column;
}
.sidebar .logo {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2em;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .logo .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-primary);
}
.sidebar nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: #e5ddd3;
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.05); }
.sidebar nav a.active {
  background: rgba(192,79,44,.15);
  border-left-color: var(--color-primary);
  color: white;
}
.sidebar nav a .icon {
  width: 20px;
  text-align: center;
  opacity: .8;
}

.user-box {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-box .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: white;
}
.user-box .name { font-weight: 600; font-size: 13px; }
.user-box .role { font-size: 11px; color: var(--color-muted); text-transform: uppercase; }
.user-box .logout {
  margin-left: auto;
  background: none;
  border: none;
  color: #e5ddd3;
  cursor: pointer;
  font-size: 18px;
  opacity: .6;
}
.user-box .logout:hover { opacity: 1; color: var(--color-danger); }

/* -------- Content -------- */

.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  padding: 16px 28px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  gap: 20px;
}
.topbar h2 {
  margin: 0;
  font-size: 20px;
  color: var(--color-text);
  flex: 1;
}
.topbar .actions input[type="search"] {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  min-width: 280px;
  font-size: 13px;
}

.view-body {
  padding: 28px;
  flex: 1;
  overflow-y: auto;
}

/* ================== KPI cards ================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kpi {
  background: var(--color-surface);
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--color-primary);
}
.kpi .label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--color-muted);
  letter-spacing: 0.05em;
}
.kpi .value {
  font-size: 26px;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 4px;
}
.kpi.warn { border-left-color: var(--color-warning); }
.kpi.danger { border-left-color: var(--color-danger); }
.kpi.success { border-left-color: var(--color-success); }

/* ================== Tables ================== */

table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table.data th,
table.data td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
  vertical-align: middle;
}
table.data th {
  background: #f1ebe3;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #faf7f3; }

/* ================== Cards / sections ================== */

.section {
  background: var(--color-surface);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.section h3 {
  margin: 0 0 16px;
  font-size: 14px;
  text-transform: uppercase;
  color: var(--color-muted);
  letter-spacing: 0.05em;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.card {
  background: var(--color-surface);
  padding: 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}
.card .title { font-weight: 600; margin-bottom: 6px; }
.card .meta  { font-size: 12px; color: var(--color-muted); }

/* ================== Badges ================== */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.pendent    { background: #fef2e6; color: #b36b17; }
.badge.en_curs    { background: #e6f2fb; color: #1565a3; }
.badge.acabat,
.badge.completat  { background: #e6f5ea; color: #2d6b3d; }
.badge.cancel    { background: #fbe6e6; color: #a12929; }
.badge.stand_by   { background: #f2f0ec; color: #7c6a5c; }

/* ================== Buttons ================== */

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--color-primary);
  color: white;
  transition: background .15s;
}
button:hover { background: var(--color-primary-dark); }
button.secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
button.secondary:hover { background: #f1ebe3; }

/* ================== Toast ================== */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--color-text);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  z-index: 9999;
}

/* ================== Empty state ================== */

.empty {
  text-align: center;
  padding: 40px;
  color: var(--color-muted);
  font-size: 14px;
}

/* ================== Responsive ================== */

@media (max-width: 760px) {
  .app-wrap { grid-template-columns: 1fr; }
  .sidebar { position: fixed; bottom: 0; left: 0; right: 0; flex-direction: row; height: 60px; z-index: 100; }
  .sidebar .logo, .user-box { display: none; }
  .sidebar nav { display: flex; padding: 0; overflow-x: auto; }
  .sidebar nav a { border-left: none; border-top: 3px solid transparent; padding: 8px 12px; white-space: nowrap; }
  .sidebar nav a.active { border-top-color: var(--color-primary); border-left-color: transparent; }
  .content { padding-bottom: 80px; }
}

/* ================== Modal ================== */

.modal-wrap {
  position: fixed;
  inset: 0;
  background: rgba(42, 29, 23, 0.5);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 20px;
}
.modal-card {
  background: var(--color-surface);
  border-radius: 12px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.modal-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
}
.modal-head h3 { margin: 0; flex: 1; font-size: 17px; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--color-muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
}
.modal-close:hover { color: var(--color-danger); background: transparent; }
.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ================== Form grid ================== */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--color-muted);
  font-weight: 500;
}
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label .req { color: var(--color-danger); }

.form-grid input,
.form-grid select,
.form-grid textarea {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text);
  background: white;
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(192,79,44,.12);
}

/* ================== View headers ================== */

.view-head {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}
.view-head .title {
  font-size: 14px;
  color: var(--color-muted);
  text-transform: uppercase;
  font-weight: 600;
  flex: 1;
}

/* ================== Clickable rows ================== */

table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #f7f1e9; }

/* ================== Detail pane ================== */

.detail-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.detail-panel .info-block {
  background: var(--color-surface);
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.detail-panel h4 {
  margin: 0 0 12px;
  color: var(--color-muted);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.05em;
}
.detail-panel dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0;
}
.detail-panel dt { color: var(--color-muted); font-size: 12px; }
.detail-panel dd { margin: 0; font-size: 13px; font-weight: 500; }


/* ================== Kanban 3D ================== */

.kanban-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.kanban-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-muted);
}
.kanban-toolbar select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  background: white;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 10px;
}
.kanban-col {
  background: #f1ebe3;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 200px;
  max-height: calc(100vh - 240px);
}
.kanban-col.drag-over {
  background: #ede3d1;
  box-shadow: inset 0 0 0 2px var(--color-primary);
}
.kanban-col-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  background: rgba(255,255,255,0.5);
  border-radius: var(--radius) var(--radius) 0 0;
  position: sticky;
  top: 0;
  z-index: 1;
}
.kanban-col-head .count {
  background: var(--color-primary);
  color: white;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  min-width: 20px;
  text-align: center;
}
.kanban-col-body {
  padding: 8px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kanban-card {
  background: var(--color-surface);
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--color-primary);
  cursor: grab;
  transition: box-shadow .15s, transform .15s;
  user-select: none;
}
.kanban-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; }

.kanban-card.stand-by { border-left-color: var(--color-muted); }
.kanban-card.completat { border-left-color: var(--color-success); }

.kanban-card .kc-head {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}
.kanban-card .kc-ref {
  font-family: monospace;
  font-size: 10px;
  color: var(--color-muted);
}
.kanban-card .kc-estat {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #fef2e6;
  color: #b36b17;
  font-weight: 700;
}
.kanban-card .kc-estat.en_curs  { background: #e6f2fb; color: #1565a3; }
.kanban-card .kc-estat.stand_by { background: #f2f0ec; color: #7c6a5c; }
.kanban-card .kc-estat.completat{ background: #e6f5ea; color: #2d6b3d; }

.kanban-card .kc-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text);
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kanban-card .kc-client {
  font-size: 11px;
  color: var(--color-muted);
  margin-bottom: 6px;
}
.kanban-card .kc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.kanban-card .kc-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: #f1ebe3;
  color: var(--color-muted);
}
.kanban-card .kc-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  border-top: 1px solid var(--color-border);
  padding-top: 5px;
  margin-top: 5px;
}
.kanban-card .kc-pvp {
  font-weight: 700;
  color: var(--color-primary);
}
.kanban-card .kc-pendent {
  color: var(--color-warning);
  font-weight: 600;
}
.kanban-card .kc-cobrat {
  color: var(--color-success);
  font-weight: 600;
}

.kanban-empty {
  text-align: center;
  color: var(--color-muted);
  font-size: 11px;
  padding: 20px 10px;
  font-style: italic;
}

/* ================== Charts ================== */

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.chart-box {
  margin-bottom: 0 !important;
}
.chart-box canvas {
  max-height: 280px;
}

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

/* ================== Calendari mensual ================== */

.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.cal-toolbar h3 {
  margin: 0;
  font-size: 18px;
  min-width: 180px;
}
.cal-toolbar .spacer { flex: 1; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-head {
  background: #f1ebe3;
  padding: 10px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-muted);
  letter-spacing: 0.05em;
}
.cal-cell {
  background: var(--color-surface);
  min-height: 100px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
  transition: background .15s;
  position: relative;
}
.cal-cell:hover { background: #faf7f3; }
.cal-cell.other-month {
  background: #fafaf8;
  color: var(--color-muted);
  cursor: default;
}
.cal-cell.today { background: #fff6ed; }
.cal-cell.today .cal-num {
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.cal-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  display: inline-block;
  margin-bottom: 2px;
}
.cal-event {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--color-primary);
  color: white;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
}
.cal-event:hover { filter: brightness(0.9); }
.cal-event.ev-sessio_foto       { background: #4a8f5b; }
.cal-event.ev-lliurament_3d     { background: #c04f2c; }
.cal-event.ev-presentacio_editorial { background: #2a1d17; }
.cal-event.ev-manteniment       { background: #d98a2c; }
.cal-event.ev-reunio            { background: #857062; }
.cal-event.ev-esdeveniment      { background: #9b3d1f; }
.cal-event.ev-altre             { background: #7c6a5c; }

.cal-more {
  font-size: 10px;
  color: var(--color-muted);
  padding: 0 6px;
}

@media (max-width: 680px) {
  .cal-cell { min-height: 60px; font-size: 11px; }
  .cal-event { font-size: 9px; padding: 1px 4px; }
}

/* ================== Upload widget ================== */

.docs-block {
  background: var(--color-surface);
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.docs-block h4 {
  margin: 0 0 12px;
  color: var(--color-muted);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.05em;
}

.upload-drop {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  font-size: 13px;
  color: var(--color-muted);
  background: #faf7f3;
}
.upload-drop:hover,
.upload-drop.dragover {
  border-color: var(--color-primary);
  background: #fff6ed;
  color: var(--color-primary);
}
.upload-drop input[type=file] { display: none; }
.upload-drop .upload-icon { font-size: 22px; display: block; margin-bottom: 4px; }

.docs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}
.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #faf7f3;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  font-size: 13px;
}
.doc-item .doc-icon { font-size: 18px; width: 24px; text-align: center; }
.doc-item .doc-name  { flex: 1; font-weight: 500; color: var(--color-text); word-break: break-word; }
.doc-item .doc-meta  { font-size: 11px; color: var(--color-muted); }
.doc-item .doc-actions { display: flex; gap: 6px; }
.doc-item .doc-actions a,
.doc-item .doc-actions button {
  padding: 4px 8px;
  font-size: 11px;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  text-decoration: none;
  border-radius: 4px;
  cursor: pointer;
}
.doc-item .doc-actions a:hover { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.doc-item .doc-actions button:hover { background: var(--color-danger); color: white; border-color: var(--color-danger); }

.upload-progress {
  margin-top: 8px;
  font-size: 11px;
  color: var(--color-muted);
}

/* ================== Reserves foto ================== */

.foto-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.foto-toolbar h3 {
  margin: 0;
  font-size: 17px;
  min-width: 240px;
}
.foto-toolbar .spacer { flex: 1; }

.foto-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 11px;
}
.foto-head-hour, .foto-head-day {
  background: #f1ebe3;
  padding: 6px;
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-muted);
  letter-spacing: 0.05em;
  font-size: 10px;
}
.foto-head-day.today {
  background: var(--color-primary);
  color: white;
}
.foto-head-day .dnum { display: block; font-size: 13px; margin-top: 2px; }
.foto-hour {
  background: #faf7f3;
  padding: 4px 6px;
  text-align: right;
  color: var(--color-muted);
  font-family: monospace;
  font-size: 10px;
  border-top: 1px solid transparent;
}
.foto-hour.hour-mark { border-top-color: var(--color-border); }

.foto-slot {
  background: var(--color-surface);
  min-height: 22px;
  cursor: pointer;
  position: relative;
  transition: background .15s;
  border-top: 1px solid transparent;
}
.foto-slot.hour-mark { border-top-color: var(--color-border); }
.foto-slot:hover { background: #fff6ed; }
.foto-slot.past { background: #fafaf8; color: var(--color-muted); cursor: default; }
.foto-slot.today-col { background: #fffdf9; }

.foto-session {
  position: absolute;
  top: 1px;
  left: 1px;
  right: 1px;
  background: var(--color-primary);
  color: white;
  border-radius: 3px;
  padding: 3px 6px;
  font-size: 10px;
  cursor: pointer;
  overflow: hidden;
  z-index: 2;
  line-height: 1.3;
  transition: filter .15s;
}
.foto-session:hover { filter: brightness(1.1); box-shadow: var(--shadow-sm); }
.foto-session.s-maternitat  { background: #d9a066; }
.foto-session.s-familia     { background: #c04f2c; }
.foto-session.s-corporativa { background: #2a1d17; }
.foto-session.s-amics       { background: #4a8f5b; }
.foto-session.s-nadal       { background: #c73a3a; }
.foto-session.s-casament    { background: #9b3d1f; }
.foto-session.s-producte    { background: #857062; }
.foto-session.s-premsa      { background: #d98a2c; }
.foto-session .fs-time { font-weight: 700; }
.foto-session .fs-client { font-size: 9px; opacity: .9; }

/* ================== Gantt impressora ================== */

.gantt { margin-top: 8px; }
.gantt-track {
  position: relative;
  height: 240px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px 8px 8px;
  overflow: hidden;
}
.gantt-grid {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--color-border);
}
.gantt-grid span {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 10px;
  color: var(--color-muted);
  font-family: monospace;
  white-space: nowrap;
}
.gantt-now {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--color-primary);
  box-shadow: 0 0 6px rgba(192,79,44,.5);
  z-index: 3;
}
.gantt-bar {
  position: absolute;
  height: 26px;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 11px;
  color: #fff;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: filter .15s, transform .15s;
  background: var(--color-accent);
}
.gantt-bar.pendent { background: var(--color-muted); top: 34px; }
.gantt-bar.en_curs { background: var(--color-primary); top: 70px; }
.gantt-bar.acabat  { background: var(--color-success); top: 106px; }
.gantt-bar:hover   { filter: brightness(1.1); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.gantt-legend {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.gantt-legend .gantt-bar {
  position: static;
  top: auto;
  height: auto;
  padding: 3px 10px;
  font-size: 10px;
}
.gantt-now-label { font-size: 10px; color: var(--color-primary); font-weight: 700; }

.gantt-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.gantt-zoom, .gantt-pan {
  display: flex;
  gap: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 3px;
}
.gantt-range-label {
  font-size: 11px;
  color: var(--color-muted);
  font-family: monospace;
  margin-left: auto;
}

/* Inline estat selector a taules */
.inline-estat {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  background: var(--color-surface);
  cursor: pointer;
  transition: filter .15s;
}
.inline-estat:hover { filter: brightness(.97); }
.inline-estat.estat-pendent   { background: #f3ece5; color: var(--color-muted); }
.inline-estat.estat-en_curs   { background: #fde8d6; color: var(--color-primary-dark); }
.inline-estat.estat-acabat    { background: #e0f0e4; color: var(--color-success); }
.inline-estat.estat-cancel\2219at { background: #f7dada; color: var(--color-danger); }
.inline-estat.estat-error     { background: #f7dada; color: var(--color-danger); }

.row-actions { white-space: nowrap; }
.row-actions button { margin: 0 1px; }

/* ================== Impressores — card grid amb mini-gantt ================== */

.imp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.imp-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s, border-color .15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.imp-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--color-primary);
}
.imp-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.imp-card-title { font-size: 16px; font-weight: 700; }
.imp-card-sub   { font-size: 11px; color: var(--color-muted); margin-top: 2px; }

.imp-actual {
  background: #fff6ed;
  border-left: 3px solid var(--color-primary);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.imp-actual.idle {
  background: #f6f3ef;
  border-left-color: var(--color-border);
  color: var(--color-muted);
  font-style: italic;
}
.imp-actual-titol {
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: pulse 1.5s infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%     { opacity: .5; transform: scale(1.3); }
}

.imp-mini-gantt {
  position: relative;
  height: 46px;
  background: #faf7f3;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}
.mini-day {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: rgba(133,112,98,.15);
}
.mini-day.avui { background: var(--color-primary); width: 2px; opacity: .35; }
.mini-now {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--color-primary);
  z-index: 3;
  box-shadow: 0 0 4px rgba(192,79,44,.4);
}
.mini-bar {
  position: absolute;
  height: 10px;
  border-radius: 2px;
  z-index: 2;
  cursor: pointer;
  transition: filter .15s;
}
.mini-bar:hover { filter: brightness(1.2); }
.mini-bar.pendent { top: 6px;  background: var(--color-muted); }
.mini-bar.en_curs { top: 18px; background: var(--color-primary); }
.mini-bar.acabat  { top: 30px; background: var(--color-success); }
.mini-bar.cancel\2219at, .mini-bar.error { background: var(--color-danger); top: 30px; }

.imp-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.imp-stat {
  background: #faf7f3;
  border-radius: 4px;
  padding: 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.imp-stat-val { font-size: 16px; font-weight: 700; }
.imp-stat-lbl { font-size: 10px; color: var(--color-muted); text-transform: uppercase; letter-spacing: .5px; }

.imp-alerta {
  background: #fde8d6;
  color: var(--color-warning);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
}

/* Progrés producció 3D */
.prod-progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
}
.prod-label { color: var(--color-muted); }
.prod-val { font-weight: 600; }
.progress-bar {
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-success), var(--color-accent));
  transition: width .4s;
}
.progress-fill.over { background: linear-gradient(90deg, var(--color-warning), var(--color-danger)); }

/* Kanban card — job info */
.kc-impressora {
  font-size: 11px;
  background: #fff6ed;
  border-left: 3px solid var(--color-primary);
  padding: 4px 8px;
  border-radius: 3px;
  margin: 6px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kc-jobs {
  margin: 6px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kc-jobs-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}
.kc-job-chip {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 700;
}
.kc-job-chip.pendent { background: #f3ece5; color: var(--color-muted); }
.kc-job-chip.en_curs { background: #fde8d6; color: var(--color-primary-dark); }
.kc-job-chip.acabat  { background: #e0f0e4; color: var(--color-success); }
.kc-parts {
  font-size: 10px;
  color: var(--color-muted);
  margin-left: auto;
}

/* ================== Reports ================== */

.reports-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 4px;
}
.reports-toolbar select {
  border: none;
  background: transparent;
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
}
.reports-toolbar select:hover { background: var(--color-border); border-radius: 4px; }

.report-anual-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  padding: 12px 4px;
}
.report-mes-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background .15s;
}
.report-mes-col:hover { background: #faf7f3; }
.report-mes-col.active {
  background: #fff6ed;
  outline: 2px solid var(--color-primary);
}
.report-mes-bar-wrap {
  width: 100%;
  height: 140px;
  display: flex;
  flex-direction: column-reverse;
  align-items: stretch;
  border-bottom: 1px solid var(--color-border);
}
.report-mes-bar {
  width: 100%;
  min-height: 2px;
  margin-bottom: 1px;
  border-radius: 2px 2px 0 0;
  transition: filter .15s;
}
.report-mes-bar:hover { filter: brightness(1.15); }
.report-mes-label { font-size: 11px; font-weight: 600; color: var(--color-muted); }
.report-mes-total { font-size: 10px; color: var(--color-muted); font-family: monospace; }

.report-legend {
  display: flex;
  gap: 14px;
  justify-content: center;
  padding: 8px;
  border-top: 1px solid var(--color-border);
  margin-top: 8px;
  flex-wrap: wrap;
}
.report-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--color-muted);
}
.swatch {
  width: 14px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
tr.active-row { background: #fff6ed; }
tr.active-row td { font-weight: 600; }

/* ================== Alert panel ================== */
.alert-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-warning);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.alert-panel.ok {
  border-left-color: var(--color-success);
  background: #f4f9f5;
}
.alert-head {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 12px;
}
.alert-panel.ok .alert-head { color: var(--color-success); }
.alert-sub { font-size: 12px; color: var(--color-muted); }

.alert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.alert-group {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fafaf8;
}
.alert-group.danger { border-left: 3px solid var(--color-danger); background: #fbf0f0; }
.alert-group.warn   { border-left: 3px solid var(--color-warning); background: #fdf6ed; }
.alert-group.info   { border-left: 3px solid var(--color-accent); background: #fcf6ef; }

.alert-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}
.alert-icon { font-size: 14px; }
.alert-title { flex: 1; }
.alert-count {
  background: var(--color-primary);
  color: white;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
}
.alert-group.danger .alert-count { background: var(--color-danger); }
.alert-group.warn .alert-count   { background: var(--color-warning); }
.alert-group.info .alert-count   { background: var(--color-accent); }

.alert-list {
  list-style: none;
  padding: 0;
  margin: 0 0 6px 0;
  font-size: 11px;
  line-height: 1.6;
}
.alert-list li {
  padding: 3px 0;
  border-bottom: 1px dashed var(--color-border);
}
.alert-list li:last-child { border-bottom: none; }
.alert-list li:hover { background: rgba(192,79,44,0.04); }
.alert-value {
  font-family: monospace;
  font-weight: 600;
  color: var(--color-text);
}
.alert-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}
.alert-link:hover { text-decoration: underline; }

/* iCal modal */
.ical-has, .ical-none {
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
}
.ical-has  { background: #f4f9f5; color: var(--color-success); border: 1px solid #d0e6d4; }
.ical-none { background: #f6f3ef; color: var(--color-muted); border: 1px solid var(--color-border); }
.ical-state-label { font-weight: 700; font-size: 13px; }

/* Inline edit inputs (factura lines) */
.line-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  font-size: 12px;
  border-radius: 3px;
  font-family: inherit;
}
.line-input.num { text-align: right; font-family: monospace; }
.line-input.short { max-width: 80px; }
.line-input:hover { border-color: var(--color-border); background: #faf7f3; }
.line-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: white;
  box-shadow: 0 0 0 2px rgba(192,79,44,0.12);
}
tr.line-new { background: #fff6ed; }
tr.line-new td { padding: 6px; }

/* ================== Global search ================== */
.search-wrap {
  position: relative;
  width: 380px;
  max-width: 100%;
}
.search-wrap input {
  width: 100%;
}
.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 480px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 100;
}
.sr-inner { padding: 4px; }
.sr-empty, .search-empty {
  padding: 20px;
  text-align: center;
  color: var(--color-muted);
  font-size: 13px;
}
.sr-section { margin-bottom: 4px; }
.sr-section-head {
  padding: 6px 10px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #faf7f3;
  border-radius: 4px;
}
.sr-count {
  background: var(--color-primary);
  color: white;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 10px;
  margin-left: auto;
}
.sr-item {
  padding: 7px 10px;
  cursor: pointer;
  border-radius: 4px;
  transition: background .12s;
}
.sr-item:hover { background: #fff6ed; }
.sr-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}
.sr-meta {
  font-size: 11px;
  color: var(--color-muted);
}
.sr-foot {
  padding: 8px 10px;
  border-top: 1px solid var(--color-border);
  font-size: 10px;
  color: var(--color-muted);
  text-align: center;
}

/* Audit log */
.audit-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.audit-toolbar label {
  font-size: 11px;
  color: var(--color-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.audit-toolbar select, .audit-toolbar input {
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  font-size: 12px;
}
.audit-toolbar .spacer { flex: 1; }
.audit-method {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  color: white;
  font-family: monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.audit-table td { padding: 6px 8px; font-size: 12px; }

/* Catàleg · toggle visibilitat web */
.card.card-hidden { opacity: 0.55; border-style: dashed; }
.card.card-hidden .title::before { content: '🚫 '; }
.cataleg-actions { margin-top: 8px; display: flex; gap: 6px; }
.cataleg-toggle {
  flex: 1;
  padding: 4px 8px !important;
  font-size: 11px !important;
  border-radius: 3px;
}
.cataleg-toggle.on { background: #e0f0e4; color: var(--color-success); }
.cataleg-toggle.off { background: #f7dada; color: var(--color-danger); }
.cataleg-toggle:hover { filter: brightness(.97); }
