/* Bama Systems Management — one small stylesheet, no framework. */
:root {
  --navy: #1e3466; --navy-2: #172a54; --blue: #2f6fb5; --blue-2: #437ec0; --sky: #e8f1fb;
  --bg: #f3f7fd; --card: #fff; --line: #dbe5f3; --ink: #14213d; --ink-2: #4a5a78; --ink-3: #7385a3;
  --green: #12925a; --green-bg: #e1f6ec; --amber: #b86a00; --amber-bg: #fff1d6;
  --red: #c8322b; --red-bg: #fde8e6; --violet: #6a4fd0; --violet-bg: #eeeafd;
  --teal: #0a8a94; --teal-bg: #dcf5f6; --orange: #d96a12; --orange-bg: #ffeadb;
  --radius: 12px; --shadow: 0 1px 2px rgba(30, 52, 102, .06), 0 4px 14px rgba(30, 52, 102, .06);
  --side: 236px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Ethiopic", sans-serif;
  color: var(--ink); background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0 0 .7rem; }
h3 { font-size: .95rem; margin: 0 0 .4rem; }
p { margin: 0 0 .7rem; }
.muted { color: var(--ink-3); } .small { font-size: .85rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Layout */
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: linear-gradient(180deg, var(--navy), var(--navy-2));
  color: #dfe8f7; display: flex; flex-direction: column; overflow-y: auto; z-index: 30; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 1rem 1rem .8rem; color: #fff; font-weight: 700; line-height: 1.15; }
.brand img { width: 44px; height: auto; background: #fff; border-radius: 9px; padding: 4px; }
.brand small { display: block; font-weight: 400; color: #a9bfe3; font-size: .74rem; }
.nav { padding: .2rem .6rem 1rem; flex: 1; }
.nav h6 { margin: 1rem .6rem .25rem; font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; color: #8fa8d3; font-weight: 600; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .48rem .7rem; border-radius: 8px; color: #dfe8f7; }
.nav a:hover { background: rgba(255, 255, 255, .09); text-decoration: none; }
.nav a.on { background: var(--blue-2); color: #fff; font-weight: 600; }
.nav .count { background: #ff6b5e; color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 .45rem; font-weight: 700; }
.me { padding: .8rem 1rem 1rem; border-top: 1px solid rgba(255, 255, 255, .12); font-size: .85rem; }
.me strong { display: block; color: #fff; }
.me a, .me button { color: #bcd0ee; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.me .row { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin-top: .35rem; }
.main { margin-left: var(--side); padding: 1.4rem 1.6rem 3rem; max-width: 1280px; }
.topbar { display: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .7rem; margin-bottom: 1rem; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.crumb { font-size: .85rem; color: var(--ink-3); margin-bottom: .15rem; }

/* Cards and grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card > .card-head { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; margin-bottom: .6rem; }
.card.flush > .card-head { padding: .9rem 1.1rem 0; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 1rem; } .grid > .card { margin: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.grid + .grid, .grid + .card, .card + .grid, .stats + .grid, .stats + .card { margin-top: 1rem; }
.section-title { margin: 1.5rem 0 .6rem; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .8rem; }
.stat { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .8rem .95rem; border-top: 4px solid var(--blue-2); color: inherit; }
a.stat:hover { text-decoration: none; transform: translateY(-1px); }
.stat .label { font-size: .8rem; color: var(--ink-2); }
.stat .value { font-size: 1.55rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .value.money { font-size: 1.15rem; }
.stat .sub { font-size: .78rem; color: var(--ink-3); }
.stat.green { border-top-color: var(--green); } .stat.amber { border-top-color: #f0a51c; } .stat.red { border-top-color: var(--red); }
.stat.violet { border-top-color: var(--violet); } .stat.teal { border-top-color: var(--teal); } .stat.orange { border-top-color: var(--orange); }
.stat.alert { background: var(--red-bg); border-color: #f3b8b3; border-top-color: var(--red); }
.neg { color: var(--red); } .pos { color: var(--green); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .5rem .95rem; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; min-height: 40px; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--blue-2); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; } .btn.primary:hover { background: #275f9d; }
.btn.good { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { background: #fff; border-color: #eab0ab; color: var(--red); }
.btn.sm { padding: .25rem .6rem; min-height: 32px; font-size: .85rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

/* Forms */
label { font-weight: 600; font-size: .88rem; display: block; margin-bottom: .2rem; }
input[type=text], input[type=search], input[type=email], input[type=number], input[type=password], input[type=date], input[type=tel], input[type=url],
select, textarea { width: 100%; padding: .5rem .65rem; border: 1px solid #c3d2e8; border-radius: 9px; font: inherit; color: var(--ink); background: #fff; min-height: 40px; }
input[type=file] { width: 100%; font: inherit; }
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid rgba(67, 126, 192, .35); outline-offset: 1px; border-color: var(--blue-2); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem 1rem; }
.fields.one { grid-template-columns: 1fr; }
.field.wide { grid-column: 1 / -1; }
.field .help { font-size: .8rem; color: var(--ink-3); margin-top: .2rem; }
.field .err, .errorlist { color: var(--red); font-size: .84rem; font-weight: 600; margin: .2rem 0 0; padding: 0; list-style: none; }
.field.bad input, .field.bad select, .field.bad textarea { border-color: var(--red); background: #fffafa; }
.field .req { color: var(--red); }
.check { display: flex; gap: .5rem; align-items: flex-start; } .check input { width: 18px; height: 18px; margin-top: .15rem; } .check label { margin: 0; }
.field ul, .field > div > div { list-style: none; padding: 0; margin: 0; }
.field input[type=checkbox] + *, .field label input[type=checkbox] { font-weight: 400; }
.field div label { font-weight: 400; display: flex; gap: .45rem; align-items: center; padding: .15rem 0; }
.field div label input { width: 18px; height: 18px; }
.edate { display: grid; grid-template-columns: minmax(64px, 1fr) minmax(96px, 1.7fr) minmax(76px, 1.1fr); gap: .35rem; }
.period .edate { display: inline-grid; width: 300px; max-width: 100%; vertical-align: middle; } .period .edate select, .period .edate input { min-height: 34px; padding: .2rem .4rem; }
fieldset { border: 0; padding: 0; margin: 0 0 1.2rem; } legend { font-weight: 700; color: var(--navy); padding: 0; margin-bottom: .6rem; font-size: 1rem; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-bottom: .9rem; }
.filters > * { flex: 1 1 150px; min-width: 0; } .filters .grow { flex: 3 1 240px; } .filters .fixed { flex: 0 0 auto; }
.filters label { font-size: .75rem; color: var(--ink-2); font-weight: 600; }
.seg { display: inline-flex; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg a { padding: .3rem .7rem; border-radius: 7px; color: var(--ink-2); font-weight: 600; font-size: .86rem; }
.seg a.on { background: var(--blue); color: #fff; } .seg a:hover { text-decoration: none; }
.period { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.period form { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; } .period input[type=date] { width: auto; min-height: 34px; padding: .25rem .5rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .74rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); background: #f0f5fc; padding: .55rem .8rem; white-space: nowrap; }
td { padding: .6rem .8rem; border-top: 1px solid #e9eff8; vertical-align: top; }
tbody tr:hover { background: #f8fbff; }
tr.overdue td:first-child { box-shadow: inset 4px 0 0 var(--red); }
tr.dim td { color: var(--ink-3); } tr.dim .strike { text-decoration: line-through; }
td .sub { display: block; font-size: .82rem; color: var(--ink-3); }
.empty { padding: 1.6rem 1rem; text-align: center; color: var(--ink-3); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .7rem 1rem; border-top: 1px solid #e9eff8; font-size: .88rem; color: var(--ink-2); }
.pager .btns { display: flex; gap: .4rem; }
dl.info { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: .4rem .8rem; margin: 0; }
dl.info dt { color: var(--ink-3); font-size: .86rem; } dl.info dd { margin: 0; overflow-wrap: anywhere; }

/* Chips */
.chip { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--sky); color: var(--blue); white-space: nowrap; }
.chip-muted { background: #edf1f7; color: var(--ink-2); } .chip-info { background: var(--sky); color: var(--blue); }
.chip-warn { background: var(--amber-bg); color: var(--amber); } .chip-danger { background: var(--red-bg); color: var(--red); } .chip-good { background: var(--green-bg); color: var(--green); }
.st-new { background: var(--sky); color: var(--blue); } .st-contacted { background: #e6e9fb; color: #3b4bb5; }
.st-interested { background: var(--teal-bg); color: var(--teal); } .st-follow_up { background: var(--amber-bg); color: var(--amber); }
.st-demo { background: var(--violet-bg); color: var(--violet); } .st-proposal { background: #dff1fd; color: #0f6aa3; }
.st-negotiation { background: var(--orange-bg); color: #b4530b; } .st-won, .st-approved, .st-completed, .st-recorded { background: var(--green-bg); color: var(--green); }
.st-lost, .st-rejected, .st-blocked { background: var(--red-bg); color: var(--red); } .st-pending, .st-in_progress { background: var(--amber-bg); color: var(--amber); }
.st-cancelled, .st-voided, .st-todo { background: #edf1f7; color: var(--ink-2); }
select.status-select { width: auto; min-height: 32px; padding: .15rem 1.6rem .15rem .6rem; border-radius: 99px; font-weight: 700; font-size: .8rem; border-color: transparent; max-width: 100%; }
.prio-4 { color: var(--red); font-weight: 700; } .prio-3 { color: var(--orange); font-weight: 700; } .prio-1 { color: var(--ink-3); }

/* Messages */
.msgs { margin-bottom: 1rem; } .msg { padding: .65rem .9rem; border-radius: 10px; margin-bottom: .5rem; font-weight: 600; border: 1px solid; }
.msg.success { background: var(--green-bg); color: #0a6a40; border-color: #a9e2c6; } .msg.error { background: var(--red-bg); color: #9d241e; border-color: #f3b8b3; }
.msg.warning, .notice { background: var(--amber-bg); color: #7a4700; border-color: #f2d08f; } .msg.info { background: var(--sky); color: var(--navy); border-color: #bcd4f0; }
.notice { padding: .8rem 1rem; border-radius: 10px; border: 1px solid #f2d08f; margin-bottom: 1rem; }
.notice ul { margin: .4rem 0; padding-left: 1.2rem; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; } .list li { padding: .55rem 0; border-top: 1px solid #e9eff8; display: flex; justify-content: space-between; gap: .7rem; align-items: flex-start; }
.list li:first-child { border-top: 0; } .list .t { font-weight: 600; } .list .s { font-size: .83rem; color: var(--ink-3); display: block; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 .9rem .7rem; }
.timeline li::before { content: ""; position: absolute; left: -1.42rem; top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--blue-2); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .7rem; padding: 1rem; }
.mini { border: 1px solid var(--line); border-radius: 10px; padding: .65rem .8rem; background: #fff; } .mini.overdue { border-left: 4px solid var(--red); }

/* Charts (plain HTML, no library) */
.hbars { display: grid; gap: .55rem; }
.hbar .top { display: flex; justify-content: space-between; gap: .6rem; font-size: .88rem; }
.hbar .track { height: 10px; background: #edf2f9; border-radius: 4px; margin-top: .2rem; }
.hbar .fill { height: 100%; background: var(--blue); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .fill.alt { background: var(--orange); } .hbar .fill.green { background: var(--green); }
.progress { height: 12px; background: #e6edf7; border-radius: 99px; overflow: hidden; } .progress > span { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.progress.done > span { background: var(--green); }
.cols { display: flex; align-items: flex-end; gap: 4%; height: 170px; padding: 0 .2rem; border-bottom: 1px solid var(--line); }
.cols .grp { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; height: 100%; position: relative; }
.cols .bar { flex: 0 1 22px; border-radius: 4px 4px 0 0; min-height: 2px; background: var(--blue); }
.cols .bar.alt { background: var(--orange); }
.cols .grp .tip { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: .76rem; padding: .35rem .5rem; border-radius: 7px; white-space: nowrap; z-index: 5; line-height: 1.45; }
.cols .grp:hover .tip, .cols .grp:focus .tip { display: block; } .cols .grp:hover { background: #f3f7fd; }
.cols-x { display: flex; gap: 4%; padding: .3rem .2rem 0; } .cols-x span { flex: 1; text-align: center; font-size: .76rem; color: var(--ink-2); }
.legend { display: flex; gap: 1rem; font-size: .82rem; color: var(--ink-2); margin-bottom: .6rem; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; background: var(--blue); } .legend i.alt { background: var(--orange); }
details.data summary { cursor: pointer; font-size: .84rem; color: var(--blue); margin-top: .6rem; }

/* Login and errors */
.center { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: .8rem; padding: 1rem; background: linear-gradient(160deg, #e6f0fc, #f6f9fe 55%, #e9f7f1); }
.login { width: 100%; max-width: 380px; } .login .logo { display: block; width: 120px; margin: 0 auto .6rem; }
.login h1 { text-align: center; color: var(--navy); margin-bottom: .2rem; } .login p.muted { text-align: center; }

/* Phone and tablet */
@media (max-width: 900px) {
  .side { transform: translateX(-100%); transition: transform .18s; width: min(280px, 86vw); } body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(15, 25, 50, .45); }
  .topbar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; padding: .5rem .8rem; }
  .topbar .brandline { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: #fff; } .topbar img { width: 34px; background: #fff; border-radius: 7px; padding: 3px; }
  .topbar button { background: rgba(255, 255, 255, .14); color: #fff; border: 0; border-radius: 8px; padding: .45rem .8rem; font: inherit; font-weight: 600; min-height: 40px; }
  .main { margin-left: 0; padding: 1rem .8rem 3rem; }
  .g2, .g3, .g-main { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .fields { grid-template-columns: 1fr; } h1 { font-size: 1.25rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Tables marked .stack turn into one card per row. */
  table.stack thead { display: none; } table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: .6rem .9rem; border-top: 1px solid var(--line); } table.stack tr.overdue { box-shadow: inset 4px 0 0 var(--red); }
  table.stack td { border: 0; padding: .12rem 0; text-align: left; box-shadow: none !important; }
  table.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-3); font-size: .8rem; }
  table.stack td:first-child { font-weight: 600; font-size: 1rem; } table.stack td:first-child .sub { font-weight: 400; }
  .page-head .actions { width: 100%; } .page-head .actions .btn { flex: 1; }
}
@media print { .side, .topbar, .filters, .period, .btn, .pager { display: none !important; } .main { margin: 0; padding: 0; } .card { box-shadow: none; } }
