/* ================= Voyeza ERP — Zoho-inspired theme ================= */
:root {
  --topbar: #21263c;
  --accent: #408dfb;
  --accent-dark: #2f7ae5;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e3e6ec;
  --text: #21263c;
  --muted: #7c8194;
  --green: #1a9f6c; --red: #d9484a; --orange: #e8871e; --purple: #8256d0;
  --sidebar-w: 232px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(33,38,60,.08);
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", Arial, sans-serif;
       background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); }
a { color: var(--accent); text-decoration: none; }

/* ================= login ================= */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #21263c 0%, #2c3352 60%, #40509b 100%); padding: 16px; }
.login-card { background: #fff; border-radius: 14px; padding: 36px 32px; width: 100%; max-width: 380px;
  box-shadow: 0 18px 60px rgba(0,0,0,.35); text-align: center; }
.login-logo-img { max-width: 230px; width: 80%; margin: 0 auto 6px; display: block; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 22px; }
.login-card form { text-align: left; }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(64,141,251,.15); }
.login-error { background: #fdecec; color: var(--red); border-radius: 6px; padding: 8px 10px; font-size: 12.5px; margin-top: 12px; white-space: pre-wrap; }

/* ================= topbar ================= */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 60;
  background: var(--topbar); color: #fff; display: flex; align-items: center; gap: 10px; padding: 0 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand-logo { width: 34px; height: 30px; border-radius: 7px; background: #fff; display: inline-flex;
  align-items: center; justify-content: center; overflow: hidden; }
.brand-logo img { width: 30px; height: auto; display: block; }
.icon-btn { background: rgba(255,255,255,.08); color: #fff; border: none; border-radius: 8px;
  width: 34px; height: 34px; font-size: 17px; line-height: 1; }
.icon-btn:hover { background: rgba(255,255,255,.18); }
.menu-toggle { display: none; }
.top-search { flex: 1; max-width: 480px; margin: 0 8px; }
.top-search input { width: 100%; padding: 8px 14px; border-radius: 8px; border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.1); color: #fff; }
.top-search input::placeholder { color: rgba(255,255,255,.55); }
.top-search input:focus { outline: none; background: rgba(255,255,255,.16); }
.top-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.company-switch { position: relative; }
.company-btn { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px; padding: 7px 12px; font-weight: 600; max-width: 220px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.company-menu { position: absolute; right: 0; top: 42px; background: #fff; color: var(--text); min-width: 260px;
  border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.25); padding: 8px; z-index: 70; }
.company-menu .cm-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 6px 10px; }
.company-menu button { display: flex; width: 100%; text-align: left; background: none; border: none;
  padding: 9px 10px; border-radius: 8px; gap: 8px; align-items: center; }
.company-menu button:hover { background: #eef4ff; }
.company-menu button.active { background: #e7f0ff; font-weight: 700; }
.company-menu .co-dot { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }
.user-chip { position: relative; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--purple); color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 13px; }
.user-menu { position: absolute; right: 0; top: 42px; background: #fff; color: var(--text); min-width: 200px;
  border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.25); padding: 8px; z-index: 70; }
.user-menu-name { font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-menu button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 9px 10px; border-radius: 8px; }
.user-menu button:hover { background: #eef4ff; }

/* ================= sidebar ================= */
.sidebar { position: fixed; top: 52px; left: 0; bottom: 0; width: var(--sidebar-w); background: #fbfbfd;
  border-right: 1px solid var(--border); z-index: 50; display: flex; flex-direction: column; }
.nav-scroll { overflow-y: auto; padding: 10px 8px 30px; flex: 1; }
.nav-group-title { display: flex; align-items: center; gap: 5px; width: 100%; border: none; background: none;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding: 14px 10px 4px; cursor: pointer; text-align: left; border-radius: 6px; }
.nav-group-title:hover { color: var(--text); }
.nav-group-title .ng-caret { width: 12px; font-size: 10px; flex: none; }
.nav-group.collapsed .nav-group-items { display: none; }
.nav-item { display: flex; align-items: center; gap: 9px; width: 100%; border: none; background: none;
  padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: 13.5px; text-align: left; margin: 1px 0; position: relative; }
.nav-item .ni-icon { width: 20px; text-align: center; font-size: 15px; flex: none; }
.nav-item .ni-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .ni-plus { flex: none; width: 22px; height: 22px; border-radius: 6px; background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 700; line-height: 22px; text-align: center; opacity: 0; transition: opacity .1s; }
.nav-item:hover .ni-plus { opacity: 1; }
.nav-item.active .ni-plus { background: rgba(255,255,255,.25); }
.nav-item .ni-plus:hover { background: var(--accent-dark); }
.nav-item:hover { background: #eef1f6; }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }
@media (hover: none) { .nav-item .ni-plus { opacity: 1; } }  /* always visible on touch devices */
.sidebar-backdrop { position: fixed; inset: 52px 0 0 0; background: rgba(0,0,0,.35); z-index: 45; }

/* ================= content ================= */
.content { margin: 52px 0 0 var(--sidebar-w); padding: 20px 22px 60px; min-height: calc(100vh - 52px); }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h2 { margin: 0; font-size: 19px; }
.page-head .spacer { flex: 1; }
.page-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .kpi-value { font-size: 21px; font-weight: 700; margin-top: 4px; }
.kpi .kpi-value.pos { color: var(--green); } .kpi .kpi-value.neg { color: var(--red); }
.kpi .kpi-foot { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 14.5px; }
.panel-body { padding: 14px 16px; }

/* buttons */
.btn { border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 8px;
  padding: 8px 14px; font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: #f2f5fa; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--red); border-color: #f2c6c6; }
.btn-danger:hover { background: #fdecec; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; margin-top: 18px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; padding: 9px 12px; background: #f7f8fa; color: var(--muted); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); white-space: nowrap;
  cursor: pointer; user-select: none; position: sticky; top: 0; }
table.data td { padding: 9px 12px; border-bottom: 1px solid #eef0f4; vertical-align: middle; }
table.data tbody tr:hover { background: #f6f9ff; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-link { color: var(--accent); font-weight: 600; cursor: pointer; }
.empty-state { text-align: center; color: var(--muted); padding: 34px 10px; font-size: 13px; }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.b-green { background: #e2f6ec; color: var(--green); }
.b-red { background: #fdecec; color: var(--red); }
.b-orange { background: #fdf1e2; color: var(--orange); }
.b-blue { background: #e7f0ff; color: var(--accent-dark); }
.b-gray { background: #eef0f4; color: var(--muted); }
.b-purple { background: #f1eafc; color: var(--purple); }

/* forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; }
.fg { display: flex; flex-direction: column; gap: 4px; }
.fg.full { grid-column: 1 / -1; }
.fg label { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.fg input, .fg select, .fg textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; background: #fff; width: 100%; }
.fg input:focus, .fg select:focus, .fg textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(64,141,251,.13); }
.fg .req::after { content: " *"; color: var(--red); }
.check-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; padding-top: 18px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; background: #fff; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(23,27,42,.5); z-index: 90;
  display: flex; align-items: flex-start; justify-content: center; padding: 4vh 14px; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 720px; box-shadow: 0 25px 80px rgba(0,0,0,.35);
  animation: modalIn .15s ease-out; margin-bottom: 4vh; }
.modal.modal-lg { max-width: 980px; }
.modal.modal-sm { max-width: 460px; }
@keyframes modalIn { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 15.5px; flex: 1; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--muted); }
.modal-body { padding: 16px 18px; max-height: 68vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }

/* line-item editor */
.lines-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.lines-table th { text-align: left; font-size: 11px; color: var(--muted); padding: 5px 6px; }
.lines-table td { padding: 3px 4px; }
.lines-table input, .lines-table select { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }
.lines-table .num input { text-align: right; }
.line-del { background: none; border: none; color: var(--red); font-size: 15px; }
.totals-box { margin-left: auto; max-width: 320px; font-size: 13px; margin-top: 12px; }
.totals-box .tr { display: flex; justify-content: space-between; padding: 3px 0; }
.totals-box .tr.grand { font-weight: 800; font-size: 15px; border-top: 1px solid var(--border); padding-top: 7px; margin-top: 5px; }

/* toast */
#toastRoot { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 120;
  display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #262b44; color: #fff; padding: 11px 20px; border-radius: 9px; font-size: 13px;
  box-shadow: 0 8px 30px rgba(0,0,0,.3); animation: modalIn .18s ease-out; max-width: 92vw; white-space: pre-wrap; }
.toast.err { background: var(--red); }
.toast.ok  { background: var(--green); }

/* dashboard extras */
.company-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.co-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  box-shadow: var(--shadow); cursor: pointer; transition: box-shadow .12s; }
.co-card:hover { box-shadow: 0 4px 16px rgba(33,38,60,.14); }
.co-card .co-head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.co-card .co-dot { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.co-card h4 { margin: 0; font-size: 14.5px; }
.co-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; font-size: 12.5px; }
.co-metrics .m b { display: block; font-size: 14px; }
.co-metrics .m span { color: var(--muted); font-size: 11px; }
.mini-bars { display: flex; align-items: flex-end; gap: 3px; height: 46px; margin-top: 10px; }
.mini-bars .bar { flex: 1; background: #dbe7fb; border-radius: 3px 3px 0 0; min-height: 2px; }
.mini-bars .bar.hi { background: var(--accent); }

/* shortage list */
.shortage { background: #fdf1e2; border: 1px solid #f4ddba; border-radius: 8px; padding: 10px 14px; margin: 10px 0; font-size: 12.5px; }
.shortage.ok { background: #e2f6ec; border-color: #bfe8d4; }
.shortage ul { margin: 6px 0 0; padding-left: 18px; }

/* progress */
.prog { background: #eef0f4; border-radius: 6px; height: 8px; overflow: hidden; min-width: 70px; }
.prog > div { height: 100%; background: var(--accent); border-radius: 6px; }
.prog.done > div { background: var(--green); }

/* ================= mobile ================= */
@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar { transform: translateX(-105%); transition: transform .18s ease-out; box-shadow: 4px 0 24px rgba(0,0,0,.12); }
  .sidebar.open { transform: none; }
  .content { margin-left: 0; padding: 14px 12px 70px; }
  .top-search { display: none; }
  .brand-name { display: none; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .kpi .kpi-value { font-size: 18px; }
  .modal { max-width: 100%; }
  .modal-body { max-height: 74vh; }
  table.data th, table.data td { padding: 8px 8px; }
  .company-btn { max-width: 130px; }
}
@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .fg.full { grid-column: 1 / -1; }
}
