/* SYSTEEL Sourcing — identidade forest + gold.
   Fontes de sistema (sem Google Fonts: bloqueado na China continental). */
:root {
  --forest: #105000;
  --forest-dark: #0b3a00;
  --forest-mid: #1e6b0e;
  --gold: #C4A35A;
  --gold-soft: #e6d9bd;
  --paper: #F5F5F0;
  --white: #ffffff;
  --ink: #23281f;
  --muted: #6b7263;
  --line: #dcded4;
  --bad: #a33327;
  --serif: Georgia, "Times New Roman", "Songti SC", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--sans); background: var(--paper); color: var(--ink); font-size: 15px; }
a { color: var(--forest); }
h1, h2, h3 { font-family: var(--serif); margin: 0 0 .4rem; }
code { font-family: var(--mono); background: #ecefe6; padding: 1px 5px; border-radius: 3px; font-size: .85em; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.content { flex: 1; padding: 1.5rem 2rem 3rem; max-width: 1200px; }

.sidebar {
  width: 232px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  background: linear-gradient(180deg, var(--forest-dark), var(--forest));
  color: #eef2e8; display: flex; flex-direction: column;
}
.brand { padding: 1.4rem 1.2rem 1rem; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand h1 { font-size: 1.7rem; color: var(--gold); margin: .1rem 0; }
.brand-kicker { font-family: var(--mono); font-size: .62rem; letter-spacing: .18em; text-transform: uppercase; opacity: .75; }
.brand-sub { font-size: .72rem; opacity: .7; }
.sidebar nav { flex: 1; padding: .8rem .6rem; display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: #d9e2cf; text-decoration: none; padding: .5rem .7rem; border-radius: 6px;
  font-size: .9rem; display: flex; align-items: center; gap: .5rem;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.active { background: rgba(196,163,90,.18); color: var(--gold); border-left: 3px solid var(--gold); padding-left: calc(.7rem - 3px); }
.badge { background: var(--gold); color: var(--forest-dark); font-size: .68rem; font-weight: 700; border-radius: 99px; padding: 1px 7px; margin-left: auto; }
.sidebar-foot { padding: .9rem 1.2rem; border-top: 1px solid rgba(255,255,255,.12); display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.user-email { font-family: var(--mono); font-size: .68rem; opacity: .75; overflow: hidden; text-overflow: ellipsis; }

/* ---------- páginas ---------- */
.page-head { margin-bottom: 1.2rem; }
.page-head h2 { font-size: 1.6rem; color: var(--forest-dark); }
.page-head .sub { margin: 0; color: var(--muted); font-size: .88rem; }
.crumb { font-size: .8rem; text-decoration: none; color: var(--muted); }

.panel { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.3rem; margin-bottom: 1.2rem; }
.panel h3 { font-size: 1.05rem; color: var(--forest-dark); margin-bottom: .8rem; }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.stat-card { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1rem; }
.stat-label { font-family: var(--mono); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); display: block; }
.stat-value { font-family: var(--serif); font-size: 1.9rem; font-weight: 700; color: var(--forest-dark); }
.stat-value.gold { color: var(--gold); }
.stat-value.bad { color: var(--bad); }

/* ---------- tabelas / listas ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; font-family: var(--mono); font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: .4rem .6rem; border-bottom: 2px solid var(--line); }
.table td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:hover td { background: #fafaf5; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .8rem; }
.muted { color: var(--muted); }
.clip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cn { font-family: var(--sans); }
.sm-text { font-size: .78rem; }
.empty { color: var(--muted); font-style: italic; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .7rem; font-weight: 600; text-transform: capitalize; }
.st-novo { background: #e8ecf5; color: #33507a; }
.st-contactado { background: #fdf3d7; color: #8a6d1a; }
.st-em_cotacao { background: #f5e8d0; color: #7a5a20; }
.st-amostras { background: #e5d9f2; color: #5b3b85; }
.st-qualificado { background: #ddecd4; color: var(--forest); }
.st-rejeitado { background: #f5dcd7; color: var(--bad); }
.tag { display: inline-block; background: #eef0e7; color: var(--muted); font-family: var(--mono); font-size: .66rem; padding: 1px 6px; border-radius: 4px; }

/* ---------- formulários ---------- */
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .5rem; }
input, select, textarea {
  width: 100%; padding: .48rem .6rem; margin-top: .2rem;
  border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: .88rem;
  background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-soft); border-color: var(--gold); }
.stack-form label { margin-bottom: .6rem; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem 1rem; }
.grid-form .form-actions { grid-column: 1 / -1; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; }
.inline-form input[type=search] { width: 300px; }
.inline-form select { width: auto; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--ink); }
.check input { width: auto; margin: 0; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
  border: 1px solid transparent; border-radius: 6px; font: inherit; font-size: .85rem; font-weight: 600;
  padding: .5rem 1rem; text-decoration: none; transition: background .15s;
}
.btn.primary { background: var(--forest); color: #fff; }
.btn.primary:hover { background: var(--forest-mid); }
.btn.secondary { background: var(--gold-soft); color: var(--forest-dark); border-color: var(--gold); }
.btn.secondary:hover { background: var(--gold); }
.btn.ghost { background: transparent; color: inherit; border-color: currentColor; opacity: .8; }
.btn.sm { padding: .3rem .7rem; font-size: .75rem; }
.btn.wide { width: 100%; justify-content: center; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.hidden { display: none; }

.flash { padding: .6rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .88rem; }
.flash.ok { background: #ddecd4; color: var(--forest-dark); border: 1px solid #b9d3a8; }
.flash.bad { background: #f5dcd7; color: var(--bad); border: 1px solid #e3b3aa; }

/* ---------- login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(160deg, var(--forest-dark), var(--forest) 70%); }
.login-card { background: var(--paper); border-radius: 14px; padding: 2.2rem 2.4rem; width: 340px; box-shadow: 0 18px 60px rgba(0,0,0,.35); }
.login-card h1 { color: var(--forest-dark); font-size: 2rem; margin: .2rem 0; }
.login-card form { margin-top: 1.2rem; }

/* ---------- detalhe fornecedor ---------- */
.two-col { display: grid; grid-template-columns: 340px 1fr; gap: 1.2rem; align-items: start; }
.col-side { min-width: 0; }
.col-main { min-width: 0; }
.person { padding: .5rem 0; border-bottom: 1px dashed var(--line); }
.ai-summary { white-space: pre-wrap; background: #f7f5ee; border-left: 3px solid var(--gold); padding: .7rem .9rem; border-radius: 0 8px 8px 0; font-size: .88rem; }

.timeline { display: flex; flex-direction: column; gap: .7rem; }
.bubble { max-width: 88%; background: #f2f4ec; border: 1px solid var(--line); border-radius: 10px; padding: .6rem .9rem; }
.bubble.out { align-self: flex-end; background: #eaf2e2; border-color: #cfe0c2; }
.bubble header { display: flex; gap: .5rem; align-items: baseline; font-size: .78rem; margin-bottom: .2rem; }
.bubble header time { margin-left: auto; color: var(--muted); font-size: .7rem; }
.bubble p { margin: .2rem 0; white-space: pre-wrap; word-break: break-word; }
.bubble .subject { font-weight: 700; font-size: .85rem; }
.bubble .orig summary { font-size: .7rem; color: var(--muted); cursor: pointer; }
.bubble .orig p { color: var(--muted); font-size: .85rem; }
.bubble-img { max-width: 260px; max-height: 220px; border-radius: 8px; display: block; margin-top: .3rem; }
.bubble-file { display: inline-flex; gap: .4rem; align-items: center; margin-top: .3rem; font-size: .85rem; }

/* ---------- ficheiros ---------- */
.file-strip { display: flex; flex-wrap: wrap; gap: .5rem; }
.file-chip { width: 86px; text-align: center; text-decoration: none; color: var(--ink); font-size: .66rem; }
.file-chip img { width: 86px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.file-icon { font-size: 1.6rem; display: block; }
.file-name { word-break: break-all; }

.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .9rem; }
.file-card { background: var(--white); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; text-decoration: none; color: var(--ink); }
.file-card img { width: 100%; height: 130px; object-fit: cover; display: block; }
.file-card-icon { height: 130px; display: flex; align-items: center; justify-content: center; font-size: 2.4rem; background: #f2f4ec; }
.file-card-meta { padding: .5rem .7rem; display: flex; flex-direction: column; gap: 2px; font-size: .8rem; }

/* ---------- inbox ---------- */
.sender-card .sender-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.preview-list { margin: .5rem 0; padding-left: 1.1rem; color: var(--muted); font-size: .85rem; }
.assign-form { display: flex; gap: .8rem; align-items: end; flex-wrap: wrap; border-top: 1px dashed var(--line); padding-top: .7rem; }
.assign-form label { margin: 0; }
.assign-form select, .assign-form input { width: 200px; }

/* ---------- whatsapp ---------- */
.qr { width: 260px; height: 260px; border: 1px solid var(--line); border-radius: 10px; background: #fff; display: block; margin: .6rem 0; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .two-col { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
}
