:root{
  --bg:#0b1016;
  --card:#111827;
  --muted:#94a3b8;
  --text:#e5e7eb;
  --accent:#06b6d4;
  --accent-2:#22c55e;
  --shadow:0 8px 20px rgba(0,0,0,.25);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Inter,Ubuntu,"Helvetica Neue",Arial,sans-serif;
  background:linear-gradient(160deg,#0b1016, #0e1420 40%, #121a28);
  color:var(--text);
}

.app-header{
  position:sticky; top:0; z-index:20;
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 16px; background:rgba(11,16,22,.85); backdrop-filter: blur(8px);
  border-bottom:1px solid #1f2937;
}
.brand{display:flex; align-items:center; gap:10px; font-weight:700; letter-spacing:.3px;}
.brand-icon{width:28px; height:28px; border-radius:8px}

.header-actions{display:flex; align-items:center; gap:8px}
button, .ghost{
  background:transparent; border:1px solid #334155; color:var(--text);
  padding:8px 12px; border-radius:10px; cursor:pointer;
}
button:hover,.ghost:hover{border-color:#475569}

.container{max-width:1100px; margin:0 auto; padding:18px}

.controls{
  display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; margin-bottom:12px;
}
.range-tabs{display:flex; gap:8px; flex-wrap:wrap}
.tab{
  border:1px solid #334155; border-radius:999px; padding:8px 12px; background:#0f1623; color:var(--text);
}
.tab.active{border-color:var(--accent); box-shadow:0 0 0 2px rgba(6,182,212,.2) inset}

.status{display:flex; align-items:center; gap:10px}
.badge{padding:4px 8px; border-radius:999px; border:1px solid #334155}
.badge.online{border-color:var(--accent); color:var(--accent)}
.badge.offline{border-color:#ef4444; color:#ef4444}

.grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap:14px;
}
.card{
  background:var(--card); border:1px solid #1f2937; border-radius:16px; padding:18px; box-shadow:var(--shadow);
}
.metric h3{margin:0 0 6px; color:#9ca3af; font-weight:600}
.metric-value{
  font-size: clamp(24px, 6vw, 40px);
  font-weight:800; letter-spacing:.3px;
  background:linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip:text; background-clip:text; color:transparent;
}
.metric-sub{color:var(--muted); font-size:14px; margin-top:6px}

.footnote{opacity:.85; margin-top:8px}
.muted{color:var(--muted)}

.centered{
  display:grid; place-items:center; min-height:100dvh;
  padding:20px;
}
.auth-card{max-width:420px; width:100%}
.form{display:grid; gap:10px}
.form input{
  padding:10px 12px; border-radius:10px; border:1px solid #334155; background:#0f1623; color:var(--text)
}
.form button{background:var(--accent); border-color:transparent; color:#012b33; font-weight:700}
.alert{background:#1f2937; border:1px solid #f59e0b; color:#fbbf24; padding:10px; border-radius:10px; margin-bottom:8px}
.inline{display:inline}

/* Payments / Invoice breakdown list */
.metric-value.small {
  font-size: 15px;
  font-weight: 500;
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  color: var(--text);
  line-height: 1.5;
  display: block;
  margin-top: 6px;
}

.payment-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  white-space: nowrap;
  font-size: 14px;
  margin-top: 3px;
}

.payment-line .method {
  color: var(--text);
  text-overflow: ellipsis;
  overflow: hidden;
}

.payment-line .amount {
  color: var(--accent);
  font-weight: 600;
}

/* Toggle link */
.show-toggle {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  text-align: right;
  user-select: none;
}
.show-toggle:hover {
  text-decoration: underline;
}

/* Invoice Due list same as payment list */
#invoiceDue .payment-line .amount {
  color: var(--accent-2);
}

/* Stock values container (purchase vs sale) */
.stock-values {
  margin-top: 8px;
}
.stock-values .payment-line .amount {
  color: var(--accent);
}
/* Special card highlights */
.card.metric.highlight-invoice {
  border-left: 4px solid #22c55e; /* green stripe */
}
.card.metric.highlight-stock {
  border-left: 4px solid #06b6d4; /* cyan stripe */
}
.card.metric.highlight-payments {
  border-left: 4px solid #f59e0b; /* amber stripe */
}

/* Adjust small metric values */
.metric-value.small {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.metric-value.small .amount {
  font-size: 15px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
}
/* Totals inside small metric sections */
.metric-value.small .total {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--accent-2); /* green by default */
}

/* Differentiate by section if needed */
.highlight-payments .total {
  color: var(--accent-2); /* green */
}
.highlight-invoice .total {
  color: #ef4444; /* red for due */
}
.highlight-stock .total {
  color: var(--accent); /* cyan */
}
