@font-face { font-family: "Gilroy"; src: url("/static/fonts/Gilroy-Light.ttf") format("truetype"); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: "Gilroy"; src: url("/static/fonts/Gilroy-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Gilroy"; src: url("/static/fonts/Gilroy-Medium.ttf") format("truetype"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Gilroy"; src: url("/static/fonts/Gilroy-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Gilroy"; src: url("/static/fonts/Gilroy-Heavy.ttf") format("truetype"); font-weight: 800; font-style: normal; font-display: swap; }

:root {
  --orange: #FA4C07;
  --orange-hover: #FF6326;
  --orange-press: #C93D05;
  --tint-50: #FFF4EE;
  --tint-100: #FFE3D6;

  --ink-900: #273037;
  --ink-800: #1C252C;
  --ink-700: #3A454E;
  --ink-600: #515E68;
  --ink-500: #6B7882;
  --ink-400: #8C99A3;
  --ink-300: #B0BBC3;
  --ink-200: #D4DBE0;
  --ink-100: #E8ECEF;
  --bg: #F4F6F8;
  --white: #FFFFFF;

  --border: #E1E6EA;
  --border-strong: #C9D1D7;

  --success-fg: #1F8A5B; --success-bg: #E6F4ED;
  --warning-fg: #E0951A; --warning-bg: #FCF1DD;
  --error-fg: #D8412F; --error-bg: #FBE7E4;
  --info-fg: #2A6FDB; --info-bg: #E5EEFB;
  --neutral-fg: #515E68; --neutral-bg: #E8ECEF;

  --shadow-sm: 0 1px 2px rgba(28,37,44,0.06), 0 1px 3px rgba(28,37,44,0.08);
  --shadow-md: 0 4px 12px rgba(28,37,44,0.08), 0 2px 4px rgba(28,37,44,0.06);
  --shadow-lg: 0 16px 40px rgba(28,37,44,0.12), 0 4px 12px rgba(28,37,44,0.08);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-family: "Gilroy", "Helvetica Neue", Arial, sans-serif; }
::selection { background: var(--tint-100); }
select { -webkit-appearance: none; appearance: none; }
a { color: inherit; }

.eyebrow { font-weight: 700; font-size: 12.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--orange); }
h1.page-title { font-weight: 800; font-size: 2.1rem; letter-spacing: -0.02em; color: var(--ink-900); margin: 8px 0 0; }

/* Login */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: var(--white); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 44px 36px; display: flex; flex-direction: column; gap: 20px; }
.login-card img.logo { height: 26px; width: auto; align-self: flex-start; }
.login-heading { font-weight: 800; font-size: 1.7rem; letter-spacing: -0.02em; color: var(--ink-900); margin: 8px 0 0; line-height: 1.1; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-600); }
.field select, .field input, .field textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 11px 12px;
  font-family: inherit; font-size: 14px; color: var(--ink-900); background: var(--white); width: 100%;
}
.field select:focus, .field input:focus, .field textarea:focus { border-color: var(--orange); outline: none; }
.error-banner { font-size: 13px; color: var(--error-fg); background: var(--error-bg); padding: 10px 12px; border-radius: 8px; }
.ok-banner { font-size: 13px; color: var(--success-fg); background: var(--success-bg); padding: 10px 12px; border-radius: 8px; }
.btn-primary {
  background: var(--orange); color: var(--white); border: none; border-radius: 8px; padding: 13px 20px;
  font-family: inherit; font-weight: 700; font-size: 14px; cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: var(--orange-hover); }
.btn-primary:active { background: var(--orange-press); transform: scale(.98); }
.btn-primary.small { padding: 11px 18px; }
.helper-center { font-size: 12px; color: var(--ink-400); text-align: center; }

/* Header / nav */
header.topnav {
  position: fixed; top: 0; left: 0; right: 0; height: 64px; background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; padding: 0 32px; z-index: 50;
}
header.topnav .left { display: flex; align-items: center; gap: 32px; }
header.topnav img.logo { height: 20px; }
header.topnav nav { display: flex; gap: 4px; }
header.topnav nav a {
  padding: 10px 14px; border-radius: 8px; border: none; background: transparent;
  font-family: inherit; font-weight: 500; font-size: 14px; cursor: pointer; color: var(--ink-600);
  text-decoration: none; display: inline-block;
}
header.topnav nav a.active { background: var(--tint-50); color: var(--orange); font-weight: 700; }
header.topnav .right { display: flex; align-items: center; gap: 16px; }
header.topnav .right .whoami { font-size: 13px; color: var(--ink-500); }
.btn-ghost {
  background: transparent; color: var(--ink-600); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; font-family: inherit; font-weight: 500; font-size: 13px; cursor: pointer;
}
.btn-ghost:hover { background: var(--bg); border-color: var(--border-strong); }

main { padding-top: 64px; }
.container { max-width: 1200px; margin: 0 auto; padding: 48px 32px; }
.container.narrow { max-width: 1100px; }
.page-header-row { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 16px; margin-top: 10px; }
.back-link { background: none; border: none; color: var(--ink-500); font-family: inherit; font-size: 13px; cursor: pointer; padding: 0; text-decoration: none; display: inline-block; }

/* Cards grid */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; margin-top: 32px; }
.grid-cards.narrow-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.client-card {
  text-align: left; background: var(--white); border: 1px solid var(--border); border-radius: 18px; padding: 24px;
  display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, border-color .2s; position: relative;
}
.client-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.client-card .icon-tile { width: 40px; height: 40px; border-radius: 8px; background: var(--tint-50); display: flex; align-items: center; justify-content: center; color: var(--orange); font-size: 18px; overflow: hidden; }
.client-card .icon-tile img { width: 100%; height: 100%; object-fit: contain; }
.client-card .name { font-weight: 700; font-size: 1.05rem; color: var(--ink-900); }
.client-card .caption { font-size: 13px; color: var(--ink-400); }
.client-card a.card-link { position: absolute; inset: 0; border-radius: 18px; }
.client-card .card-actions { position: relative; z-index: 2; align-self: flex-end; display: flex; gap: 4px; }
.client-card .card-actions .icon-btn { color: var(--ink-500); }
.client-card .card-actions .icon-btn.edit:hover { color: var(--orange); }
.client-card .card-actions .icon-btn.delete:hover { color: var(--error-fg); }

.add-client-form { display: flex; gap: 10px; margin-top: 32px; flex-wrap: wrap; align-items: flex-end; }
.add-client-form input[type="text"] { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-family: inherit; font-size: 14px; min-width: 220px; }
.logo-upload-label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-600); }
.logo-upload-label input[type="file"] { font-family: inherit; font-size: 13px; }

/* Filter bar */
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; margin: 28px 0 20px; }
.filter-bar select {
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-family: inherit;
  font-size: 13px; color: var(--ink-900); background: var(--white);
}

/* Task table */
.task-card { background: var(--white); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-sm); }
.task-head, .task-row {
  display: grid; gap: 12px; padding: 16px 24px; align-items: center; border-bottom: 1px solid var(--border);
}
.task-head { padding: 14px 24px; background: var(--bg); font-size: 12px; font-weight: 700; color: var(--ink-500); text-transform: uppercase; letter-spacing: 0.04em; }
.task-row:last-child { border-bottom: none; }
.cols-7 { grid-template-columns: 2.2fr 1.2fr 1fr 0.9fr 0.9fr 0.7fr 0.8fr; }
.cols-8 { grid-template-columns: 2fr 1.3fr 1.1fr 0.9fr 0.9fr 0.9fr 0.7fr 0.8fr; }
.task-title { font-weight: 700; font-size: 14px; color: var(--ink-900); }
.task-notes { font-size: 12.5px; color: var(--ink-400); margin-top: 2px; }
.task-meta { font-size: 13px; color: var(--ink-600); }
.pill { display: inline-flex; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.task-actions { display: flex; gap: 6px; }
.icon-btn { background: none; border: none; cursor: pointer; padding: 4px; color: var(--ink-500); font-size: 15px; }
.icon-btn:hover.edit { color: var(--orange); }
.icon-btn:hover.delete { color: var(--error-fg); }
.empty-state { padding: 40px 24px; text-align: center; color: var(--ink-400); font-size: 14px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(28,37,44,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px; }
.modal-card { background: var(--white); border-radius: 18px; max-width: 480px; width: 100%; padding: 32px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow-lg); max-height: 88vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-weight: 700; font-size: 1.3rem; color: var(--ink-900); margin: 0; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--ink-500); padding: 4px; font-size: 18px; text-decoration: none; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; margin-top: 6px; }
.btn-cancel {
  background: transparent; color: var(--ink-600); border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 18px; font-family: inherit; font-weight: 500; font-size: 14px; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn-cancel:hover { background: var(--bg); border-color: var(--border-strong); }

/* Resum per treballador */
.worker-card { background: var(--white); border: 1px solid var(--border); border-radius: 18px; padding: 24px; box-shadow: var(--shadow-sm); }
.worker-card .top-row { display: flex; justify-content: space-between; align-items: center; }
.worker-card .name { font-weight: 700; font-size: 1.05rem; color: var(--ink-900); }
.worker-card .role { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-400); }
.worker-card .big-stat { font-weight: 800; font-size: 2rem; letter-spacing: -0.02em; color: var(--orange); margin-top: 16px; }
.worker-card .stat-caption { font-size: 12.5px; color: var(--ink-400); margin-top: 2px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.counts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 13px; color: var(--ink-600); }
.counts-grid b { color: var(--ink-900); }

/* Preus */
.total-banner { margin-top: 16px; background: var(--ink-800); border-radius: 18px; padding: 24px 28px; display: flex; justify-content: space-between; align-items: center; }
.total-banner .label { color: var(--ink-300); font-size: 13px; }
.total-banner .amount { color: var(--white); font-weight: 800; font-size: 1.8rem; letter-spacing: -0.01em; }
.billing-card { background: var(--white); border: 1px solid var(--border); border-radius: 18px; padding: 24px 28px; margin-top: 20px; box-shadow: var(--shadow-sm); }
.billing-card .header-row { display: flex; justify-content: space-between; align-items: center; }
.billing-card .client-name { font-weight: 700; font-size: 1.1rem; color: var(--ink-900); }
.billing-card .client-total { font-weight: 800; font-size: 1.15rem; color: var(--orange); }
.billing-row { display: grid; grid-template-columns: 2fr 1fr 1fr 0.9fr; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.billing-row .btitle { font-size: 13.5px; color: var(--ink-900); font-weight: 500; }
.billing-row .bmeta { font-size: 12.5px; color: var(--ink-400); }
.price-input-wrap { display: flex; align-items: center; gap: 4px; justify-self: end; }
.price-input-wrap span { color: var(--ink-400); font-size: 13px; }
.price-input-wrap input { width: 80px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font-family: inherit; font-size: 13px; color: var(--ink-900); text-align: right; }
.price-input-wrap input:focus { border-color: var(--orange); outline: none; }
.no-tasks-note { font-size: 13px; color: var(--ink-400); padding: 8px 0; }

/* Usuaris */
.users-table { background: var(--white); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-sm); margin-top: 24px; }
.user-row { display: grid; grid-template-columns: 1.6fr 1fr 2fr 0.6fr; gap: 12px; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-row form.inline-password { display: flex; gap: 8px; align-items: center; }
.user-row form.inline-password input { border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-family: inherit; font-size: 13px; width: 100%; }
.user-row .btn-small { background: var(--ink-100); color: var(--ink-700); border: none; border-radius: 8px; padding: 7px 12px; font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.user-row .btn-small:hover { background: var(--border-strong); }
.add-user-card { background: var(--white); border: 1px solid var(--border); border-radius: 18px; padding: 24px; margin-top: 24px; display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.add-user-card .field { min-width: 200px; }
