:root {
  --bg: #f6f7fb; --card: #fff; --text: #1d2433; --muted: #6b7385; --line: #e5e8ef;
  --brand: #2f5bea; --brand-d: #2347c2; --green: #138a4b; --green-bg: #e5f6ec;
  --red: #c4362b; --red-bg: #fdecea; --blue-bg: #e8eefe; --grey-bg: #eef0f4; --amber: #b86e00; --amber-bg: #fff4e0;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { margin: 0 0 .4rem; }
.container { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.container.narrow { max-width: 640px; }
.muted { color: var(--muted); }
.small, small { font-size: .85rem; }
.center { text-align: center; }
.upper { text-transform: uppercase; }

/* top bar */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav.right { margin-left: auto; align-items: center; gap: 16px; }
.topbar nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.topbar nav a.active, .topbar nav a:hover { background: var(--grey-bg); color: var(--text); text-decoration: none; }
.topbar nav a.btn { color: #fff; background: var(--brand); }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .9rem; }
.who form { margin: 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; background: var(--brand); color: #fff;
  padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--brand-d); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--grey-bg); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.big { padding: 14px 26px; font-size: 1.05rem; }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.whatsapp { background: #1fa855; }
.btn.whatsapp:hover { background: #178a45; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; font-size: .85rem; }
.linkbtn.muted { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

/* layout */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.crumbs { margin: 0 0 4px; font-size: .9rem; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.empty { color: var(--muted); padding: 20px 0; text-align: center; margin: 0; }
.callout { background: var(--blue-bg); border-radius: 8px; padding: 12px 14px; margin: 0 0 16px; }

/* flash */
.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash.ok { background: var(--green-bg); color: var(--green); }
.flash.err { background: var(--red-bg); color: var(--red); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--muted); box-shadow: var(--shadow); }
.stat span { display: block; font-size: 1.9rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat.warn span { color: var(--red); }
.stat.info span { color: var(--brand); }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #fafbfd; }
.overdue { color: var(--red); font-weight: 600; }
.card > .table { margin: -8px 0; }
@media (max-width: 700px) { .card:has(> .table) { overflow-x: auto; } }

/* badges & progress */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.grey { background: var(--grey-bg); color: var(--muted); }
.badge.blue { background: var(--blue-bg); color: var(--brand); }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.progress { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.progress .bar { flex: 1; height: 8px; background: var(--grey-bg); border-radius: 99px; overflow: hidden; display: flex; }
.progress .ok { background: var(--green); }
.progress .sub { background: #8aa6f5; }
.progress small { color: var(--muted); }

/* tabs & chips */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 6px 14px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--text); font-weight: 500; }
.tab.active { background: var(--text); color: #fff; border-color: var(--text); }
.tab:hover { text-decoration: none; }
.tab small { opacity: .6; margin-left: 4px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); background: #fff; font: inherit; cursor: pointer; }
.chip.active { border-color: var(--brand); background: var(--blue-bg); color: var(--brand); font-weight: 600; }

/* forms */
label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; font-weight: 500; }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid #d3d8e2; border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 91, 234, .25); border-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 12px; }
.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; cursor: pointer; }
.check input { width: auto; margin-top: 4px; }
.check.inline { align-items: center; white-space: nowrap; }
.check.inline input { margin: 0; }
.search input { min-width: 260px; }
.checklist { list-style: none; padding: 0; margin: 0 0 8px; border: 1px solid var(--line); border-radius: 8px; }
.checklist li { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
form.card > label { margin-bottom: 16px; }

/* request detail */
.share { display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; }
@media (max-width: 800px) { .share { grid-template-columns: 1fr; } }
.share h2 { margin-bottom: 2px; }
.share p { margin: 0 0 10px; }
.copyrow { display: flex; gap: 8px; }
.copyrow input { font-family: ui-monospace, Menlo, monospace; font-size: .82rem; background: var(--bg); }
.items, .portal-items { list-style: none; padding: 0; margin: 0; }
.item { border: 1px solid var(--line); border-left: 4px solid #cfd5e1; border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.item.submitted { border-left-color: #8aa6f5; }
.item.approved { border-left-color: var(--green); }
.item.rejected { border-left-color: var(--red); }
.item-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.item-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.item-actions form { margin: 0; }
.item-actions details { position: relative; }
.item-actions summary { list-style: none; }
.item-actions summary::-webkit-details-marker { display: none; }
.reject { display: flex; gap: 6px; margin-top: 8px; min-width: min(340px, 90vw); }
.note { background: var(--amber-bg); color: var(--amber); padding: 8px 10px; border-radius: 6px; margin: 8px 0 0; font-size: .9rem; }
.files { list-style: none; padding: 0; margin: 8px 0 0; font-size: .9rem; }
.files li { padding: 3px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
form.inline { display: inline; margin: 0; }
.add-item { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.feed li:last-child { border-bottom: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--muted); }
.dot.client { background: var(--green); }
.dot.firm { background: var(--brand); }

/* auth */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 32px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.auth-card .brand { margin-bottom: 20px; }
.auth-card h1 { font-size: 1.35rem; margin-bottom: 16px; }

/* portal */
body.portal { background: #f2f4f8; }
.portal-head { background: var(--text); color: #fff; }
.portal-head .container { padding: 22px 20px; }
.portal-head p { margin: 0; color: #aab2c5; }
.portal-head h1 { margin: 0; font-size: 1.4rem; }
.portal .card { padding: 18px; }
.portal .item { background: #fff; }
.upload { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.filepick { flex: 1; min-width: 200px; position: relative; border: 2px dashed #c9d0dd; border-radius: 8px; padding: 10px 12px; cursor: pointer; text-align: center; color: var(--brand); font-weight: 600; }
.filepick:hover { border-color: var(--brand); background: var(--blue-bg); }
.filepick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.filepick.has-files { border-style: solid; border-color: var(--brand); background: var(--blue-bg); }

/* landing */
.landing .hero { background: linear-gradient(180deg, #fff, var(--bg)); text-align: center; }
.landing .hero .container { max-width: 760px; padding: 72px 20px 48px; }
.landing .hero h1 { font-size: 2.6rem; line-height: 1.15; margin-bottom: 16px; }
.lead { font-size: 1.15rem; color: var(--muted); margin: 0 0 28px; }
.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .features, .plans { grid-template-columns: 1fr 1fr !important; } .landing .hero h1 { font-size: 2rem; } }
.feature, .plan { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.feature p, .plan p { color: var(--muted); margin: 0; }
.pricing { text-align: center; }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; text-align: left; }
.plan.featured { border: 2px solid var(--brand); }
.price { font-size: 1.8rem; font-weight: 700; color: var(--text) !important; }
.price span { font-size: .9rem; font-weight: 400; color: var(--muted); }

/* ---------- v2: services, accept/decline, rearranging, client side ---------- */
.nowrap { white-space: nowrap; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--amber); color: #fff; font-size: .75rem; font-weight: 700; text-align: center; line-height: 20px; }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.stat.amber span { color: var(--amber); }
.sharebox { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; background: #fff; border: 1px dashed #b9c6f3; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; }
.sharebox .copyrow { flex: 1; min-width: min(320px, 100%); max-width: 560px; }
.incoming { border-color: #f1c98a; background: #fffbf3; }
.incoming h2 { display: flex; align-items: center; gap: 8px; }
.incoming-list { list-style: none; margin: 0; padding: 0; }
.incoming-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid #f3e2c4; flex-wrap: wrap; }
.accept-box { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; border: 2px solid #f1c98a; background: #fffbf3; }
@media (max-width: 800px) { .accept-box { grid-template-columns: 1fr; } }
.accept-actions { display: flex; flex-direction: column; gap: 10px; }
.accept-actions summary { list-style: none; width: 100%; }
.accept-actions summary::-webkit-details-marker { display: none; }
.iconbtn { width: 28px; height: 28px; display: inline-grid; place-items: center; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font: inherit; color: var(--muted); padding: 0; list-style: none; }
.iconbtn:hover:not([disabled]) { background: var(--grey-bg); color: var(--text); }
.iconbtn[disabled] { opacity: .35; cursor: default; }
summary.iconbtn::-webkit-details-marker { display: none; }
.order { display: flex; flex-direction: column; gap: 2px; }
.order form { margin: 0; }
td.order { flex-direction: row; display: table-cell; white-space: nowrap; }
td.order form { display: inline; }
.item-head .grow { flex: 1; }
.item-head { align-items: flex-start; }
.rename { display: inline; }
.rename summary { display: inline; cursor: pointer; list-style: none; }
.rename summary::-webkit-details-marker { display: none; }
.edit-hint { color: var(--muted); font-size: .8rem; opacity: 0; }
.rename summary:hover .edit-hint { opacity: 1; }
.inline-form { display: flex; gap: 6px; margin: 6px 0; }
.inline-form input, .inline-form select { padding: 5px 8px; font-size: .88rem; }
.file-menu { position: relative; }
.file-menu .menu { position: absolute; right: 0; top: 32px; z-index: 3; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(16,24,40,.12); padding: 10px; width: min(340px, 90vw); }
.file-menu .menu form { margin: 0 0 6px; }
tr.inactive td { opacity: .5; }

/* client side */
.client-nav { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-top: 14px !important; padding-bottom: 14px !important; flex-wrap: wrap; }
.client-nav p { margin: 0; color: #aab2c5; }
.firmname { color: #fff; font-size: 1.3rem; font-weight: 700; }
.client-nav nav { display: flex; gap: 18px; align-items: center; }
.client-nav nav a:not(.btn) { color: #dfe4ef; }
.client-nav nav form { margin: 0; }
.linkbtn.light { color: #aab2c5; }
.portal-head .back { color: #dfe4ef; display: inline-block; margin-top: 8px; font-size: .9rem; }
.store-hero { text-align: center; padding: 24px 0 28px; }
.store-hero .lead { max-width: 620px; margin: 8px auto 12px; }
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 18px; margin-bottom: 28px; }
.service-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
.service-card p { margin: 0; }
.service-card details { margin: 4px 0 10px; color: var(--muted); }
.service-card summary { cursor: pointer; }
.service-card ul { padding-left: 18px; margin: 6px 0 0; }
.service-card .btn { margin-top: auto; }
.price { font-size: 1.5rem; font-weight: 700; color: var(--text); margin: 4px 0; }
.price span { font-size: .85rem; font-weight: 400; color: var(--muted); }
.price.big { font-size: 1.9rem; }
.btn.full { width: 100%; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; text-align: center; color: var(--muted); }
.steps strong { display: grid; place-items: center; width: 32px; height: 32px; margin: 0 auto 6px; border-radius: 50%; background: var(--blue-bg); color: var(--brand); }
.auth-card.centered { margin: 20px auto; }
.portal form.card > label { margin-bottom: 14px; }
@media (max-width: 760px) {
  .topbar-in { flex-wrap: wrap; gap: 8px 16px; }
  .topbar nav:not(.right) { order: 3; width: 100%; overflow-x: auto; }
  .topbar nav a { white-space: nowrap; }
}
