/* Zync Light - same palette and type as Zync One (public/styles.css there). */
:root {
  --black: #0e0a06; --charcoal: #1b1917; --grey: #282828; --muted: #716f6d; --line: #e8e5e2; --canvas: #fafafa; --white: #fff;
  --red: #ff2f2b; --red-dark: #d91f1b; --red-soft: #fff0ef; --green: #188454; --green-soft: #eaf7f0;
  /* Zync Light brand: deep green (Zync One is red). Red above is kept for errors and warnings only. */
  --brand-deep: #0b3d2a; --brand: #0f7a4f; --brand-dark: #0b5e3d; --brand-soft: #e6f4ec;
  --sidebar-text: #cfe3d8; --sidebar-muted: #8fb5a3; --sidebar-hover: rgba(255, 255, 255, .08); --sidebar-field: #12503a; --sidebar-field-border: #1d6b4f;
  --amber: #a96500; --amber-soft: #fff4dd; --blue: #2768c7; --blue-soft: #ecf3ff;
  --radius: 10px; --shadow: 0 1px 2px rgba(14, 10, 6, .05);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* Grid children may shrink below their content, so wide tables scroll inside .table-wrap instead of widening the page. */
.app > div, .entry-grid > *, .doc-footer > *, .pos > *, .form-grid > * { min-width: 0; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 Urbanist, system-ui, sans-serif; color: var(--black); background: var(--canvas); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--brand-deep); color: var(--sidebar-text); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 18px; }
.brand img { width: 30px; height: 30px; border-radius: 7px; object-fit: contain; }
/* The built-in Zync logo is red (Zync One); tint it green for Zync Light. A company's own logo is never tinted. */
.brand img.default-logo { filter: hue-rotate(150deg) saturate(.85) brightness(1.15); }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--sidebar-muted); letter-spacing: .04em; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; text-decoration: none; color: var(--sidebar-text); font-weight: 500; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: inset 3px 0 0 #7fd3a8; }
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: var(--sidebar-muted); padding: 10px; }
.sidebar-foot a { color: var(--sidebar-muted); }
.sidebar-foot label { color: var(--sidebar-muted); }
.sidebar-foot select { margin-top: 4px; background: var(--sidebar-field); color: #fff; border-color: var(--sidebar-field-border); }

/* Executive sidebar, as Zync One's (v0.69.8) but in Zync Light green: a glow fading to near-black, a faint ring
   pattern at the bottom, glass menu tiles with an icon square. Always the full window height; the menu scrolls
   inside it when the window is short, and the company card stays at the bottom. */
.sidebar {
  height: 100vh; height: 100dvh; overflow: hidden; padding: 22px 14px 16px; gap: 0;
  background:
    radial-gradient(ellipse 140% 55% at 15% 0%, #14583d 0, #0d3d2a 30%, rgba(6, 24, 16, 0) 70%),
    radial-gradient(ellipse 120% 40% at 90% 100%, rgba(20, 88, 61, .85) 0, rgba(6, 24, 16, 0) 70%),
    linear-gradient(180deg, #0a2a1d 0%, #071c13 50%, #04120c 100%);
}
.sidebar::after { content: ""; position: absolute; width: 300px; height: 300px; border: 1px solid rgba(76, 214, 150, .22); border-radius: 50%; left: -40px; bottom: -190px;
  box-shadow: 0 0 0 55px rgba(76, 214, 150, .04), 0 0 0 110px rgba(76, 214, 150, .025); pointer-events: none; }
.sidebar > * { position: relative; z-index: 1; }
.brand { padding: 0 6px 18px; }
.brand img { width: 36px; height: 36px; }
.brand-wordmark { display: block; font: 700 21px Urbanist, sans-serif; color: #fff; letter-spacing: -.3px; }
.brand-wordmark .light { font-weight: 300; letter-spacing: .5px; background: linear-gradient(100deg, #8ff0be 0%, #3ccb8a 55%, #17a568 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand small { color: #fff; font-weight: 700; letter-spacing: .02em; }
.nav { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; scrollbar-width: thin; scrollbar-color: rgba(76, 214, 150, .35) transparent; }
.nav::-webkit-scrollbar { width: 5px; } .nav::-webkit-scrollbar-thumb { background: rgba(76, 214, 150, .35); border-radius: 5px; }
.nav-section { padding: 10px 8px 0; font: 700 10px Urbanist, sans-serif; letter-spacing: .14em; color: #fff; }
.nav-item { background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .1); color: #e8f3ed; border-radius: 11px; padding: 6px 10px; font-weight: 600;
  transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.nav-item svg { width: 30px; height: 30px; padding: 7px; border-radius: 8px; background: rgba(60, 203, 138, .18); color: #fff; stroke-width: 1.9; }
.nav-item:hover { background: rgba(60, 203, 138, .12); border-color: rgba(60, 203, 138, .3); color: #fff; transform: translateY(-1px); }
.nav-item.active { background: linear-gradient(90deg, rgba(60, 203, 138, .30), rgba(60, 203, 138, .08)); border-color: rgba(60, 203, 138, .6); color: #fff; box-shadow: none; }
.nav-item.active svg { color: #8ff0be; }
.sidebar-foot { margin-top: 14px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 11px; background: rgba(255, 255, 255, .05); padding: 10px; color: #cfe3d8; }
.user-card { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid rgba(255, 255, 255, .1); }
.user-card b { color: #fff; display: block; } .user-card small { color: var(--sidebar-muted); display: block; margin-bottom: 4px; }
.user-card a { color: #8ff0be; }

/* ---------- sign-in ---------- */
#auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(ellipse 120% 60% at 20% 0%, #14583d 0, #0d3d2a 30%, rgba(6, 24, 16, 0) 70%), linear-gradient(180deg, #0a2a1d, #04120c); }
.auth-card { width: min(420px, 100%); background: var(--white); border-radius: 16px; padding: 28px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); }
.auth-card h2 { font-size: 22px; margin: 18px 0 6px; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand img { width: 40px; height: 40px; }
.auth-brand img.default-logo { filter: hue-rotate(150deg) saturate(.85) brightness(1.15); }
.auth-brand .brand-wordmark { color: var(--brand-deep); }
.auth-brand .brand-wordmark .light { background: linear-gradient(100deg, #17a568, #0f7a4f); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-brand small { display: block; color: var(--muted); font-weight: 600; }
.sidebar-foot .pill { margin-top: 6px; }
.main { min-width: 0; padding: 24px 28px 48px; }
.topbar-mobile { display: none; }

/* ---------- page head ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.module-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--brand); font-weight: 700; }
.page-head h1 { font-size: 26px; margin-top: 2px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- controls ---------- */
.primary-button, .secondary-button, .ghost-button, .danger-button {
  border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.primary-button { background: var(--brand-deep); color: #fff; }
.primary-button:hover { background: var(--brand-dark); }
/* The main call to action (Fiscalise & post, Open POS, Credit note). */
.primary-button.accent { background: var(--brand); } .primary-button.accent:hover { background: var(--brand-dark); }
.secondary-button { background: var(--white); border-color: #d6d2ce; }
.secondary-button:hover { border-color: var(--brand); color: var(--brand-dark); }
input:focus, select:focus, textarea:focus { outline-color: var(--brand); }
/* Location tick boxes in the user form. */
.loc-picks { display: flex; flex-wrap: wrap; gap: 4px 12px; min-width: 180px; }
label.check { flex-direction: row; align-items: center; gap: 5px; color: var(--black); font-weight: 500; font-size: 13px; }
/* Button with a line icon (e.g. the customer lookup). */
.icon-button { gap: 7px; color: var(--brand-deep); }
.icon-button svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--brand); stroke-width: 2.2; stroke-linecap: round; }
.icon-button:hover { background: var(--brand-soft); border-color: var(--brand); }
.ghost-button { background: transparent; color: var(--muted); padding: 6px 8px; }
.ghost-button:hover { color: var(--black); }
.danger-button { background: var(--white); color: var(--red-dark); border-color: #f2c2c0; }
button:disabled { opacity: .5; cursor: not-allowed; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
label small { font-weight: 500; }
input, select, textarea { border: 1px solid #d6d2ce; border-radius: 8px; padding: 8px 10px; background: var(--white); font-size: 14px; font-weight: 500; color: var(--black); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--black); outline-offset: -1px; }
input[readonly] { background: var(--canvas); }
textarea { min-height: 70px; resize: vertical; }
.search { min-width: 240px; }

/* ---------- cards, grids ---------- */
.entry-card, .panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.panel + .panel, .entry-card + .entry-card { margin-top: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h3 { font-size: 16px; } .panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: 10px; display: block; }
.entry-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat span { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat strong { display: block; font-size: 24px; margin-top: 4px; }
.stat small { color: var(--muted); }
.stat.alert strong { color: var(--red-dark); }
.profile { display: grid; gap: 2px; font-size: 13px; color: var(--grey); margin-top: 10px; }
.profile strong { font-size: 15px; color: var(--black); }
.strip { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 13px; }
.strip span { color: var(--muted); } .strip b { color: var(--black); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 12px; background: #f6f5f4; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: #fbfaf9; }
.number { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, monospace; font-size: 12px; }
td input, td select { padding: 6px 8px; font-size: 13px; }
td input.qty { width: 80px; text-align: right; } td input.price { width: 110px; text-align: right; } td input.disc { width: 70px; text-align: right; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: #f0eeec; color: var(--grey); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red { background: var(--red-soft); color: var(--red-dark); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }

/* ---------- document screen (Zync One Sales Quote layout) ---------- */
.doc-footer { display: grid; grid-template-columns: 1fr 340px; gap: 14px; margin-top: 14px; align-items: start; }
.total-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.total-card div { display: flex; justify-content: space-between; padding: 4px 0; }
.total-card .grand { border-top: 2px solid var(--black); margin-top: 6px; padding-top: 8px; font-size: 18px; font-weight: 700; }
.bottom-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; }
.banner.amber { background: var(--amber-soft); color: var(--amber); }
.banner.red { background: var(--red-soft); color: var(--red-dark); }
.banner.green { background: var(--green-soft); color: var(--green); }
.banner.blue { background: var(--blue-soft); color: var(--blue); }
.steps { display: flex; gap: 0; margin: 4px 0 14px; flex-wrap: wrap; }
.step { flex: 1; min-width: 150px; padding: 10px 12px; border-top: 3px solid var(--line); color: var(--muted); font-size: 13px; }
.step b { display: block; color: var(--black); font-size: 14px; }
.step.done { border-color: var(--green); } .step.now { border-color: var(--amber); } .step.bad { border-color: var(--red); }
.fiscal-block { display: flex; gap: 18px; align-items: flex-start; }
.fiscal-block dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.fiscal-block dt { color: var(--muted); } .fiscal-block dd { margin: 0; word-break: break-all; }
.qr { width: 120px; height: 120px; flex: none; }

/* ---------- picker modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(14, 10, 6, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; }
.modal { background: var(--white); border-radius: 12px; width: min(860px, 100%); max-height: 86vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 14px 18px; overflow: auto; }
.close-button { border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: 1fr 380px; gap: 14px; align-items: start; }
.pos-search { font-size: 18px; padding: 12px 14px; width: 100%; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 12px; }
.pos-tile { text-align: left; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-height: 104px; }
.pos-tile:hover { border-color: var(--black); }
.pos-tile b { font-size: 13px; line-height: 1.25; } .pos-tile .price { margin-top: auto; font-size: 16px; font-weight: 700; }
.pos-tile small { color: var(--muted); }
.pos-tile.blocked { opacity: .55; }
.cart { position: sticky; top: 16px; }
.cart-lines { max-height: 46vh; overflow: auto; margin: 10px -16px; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.cart-line .qtybox { display: flex; align-items: center; gap: 4px; }
.cart-line .qtybox button { width: 28px; height: 28px; border-radius: 6px; border: 1px solid #d6d2ce; background: var(--white); cursor: pointer; }
.tenders { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.tenders button { padding: 14px 6px; font-size: 15px; justify-content: center; }

/* ---------- toast ---------- */
.toast { position: fixed; right: 18px; bottom: 18px; max-width: 420px; background: var(--black); color: #fff; padding: 12px 16px; border-radius: 10px; z-index: 80; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.toast.error { background: var(--red-dark); }

/* ---------- small screens ---------- */
@media (max-width: 980px) {
  .pos { grid-template-columns: 1fr; }
  .cart { position: static; }
  .doc-footer { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .app.nav-open .sidebar { transform: none; }
  .topbar-mobile { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--brand-deep); color: #fff; position: sticky; top: 0; z-index: 40; }
  .topbar-mobile button { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }
  .main { padding: 16px 16px 40px; }
  .entry-grid, .form-grid { grid-template-columns: 1fr; }
  .search { min-width: 0; width: 100%; }
  .page-head h1 { font-size: 22px; }
}
