/* ServoPOS portal — no framework. Brand: navy #14142B, orange #FF6B35. */

:root {
  --navy: #14142b;
  --navy-deep: #0d0d1c;
  --navy-soft: #3a3a5c;
  --orange: #ff6b35;
  --orange-dark: #e2551f;
  --orange-wash: #fff1eb;
  --accent: var(--orange);

  --bg: #eeeef3;
  --surface: #ffffff;
  --surface-alt: #f4f4f8;
  --border: #e4e4ec;
  --text: #14142b;
  --muted: #6b6b80;

  --ok: #14714f;
  --ok-bg: #e5f4ed;
  --warn: #9a6a12;
  --warn-bg: #fbf1dc;
  --bad: #b92a1f;
  --bad-bg: #fbe7e5;
  --info: #0f6b62;
  --info-bg: #e2f2f0;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 43, .06), 0 1px 1px rgba(20, 20, 43, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--orange-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
code, .mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.wrap { word-break: break-word; }

/* ---------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: 0 0 248px; background: var(--navy); color: #fff;
  display: flex; flex-direction: column; padding: 18px 14px; gap: 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand img { height: 34px; display: block; margin: 2px 6px 6px; }
.tenant-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius); background: rgba(255,255,255,.06); }
.tenant-card img { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; background: #fff; }
.tenant-name { font-weight: 600; }
.tenant-meta { font-size: .8rem; color: #a9a9c0; }
.nav-heading { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #8a8aa0; padding: 6px 10px 0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: #d6d6e4; padding: 8px 10px; border-radius: 8px; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav a.active { background: var(--orange); color: #fff; font-weight: 600; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.me { display: flex; gap: 10px; align-items: center; color: #fff; padding: 6px; border-radius: 8px; }
.me:hover, .me.active { background: rgba(255,255,255,.07); text-decoration: none; }
.me small { display: block; color: #a9a9c0; font-size: .75rem; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-soft); display: grid; place-items: center; font-weight: 700; flex: none; }
.sidebar .link { color: #a9a9c0; padding: 4px 8px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px 6px; }
.topbar h1 { margin: 0; }
.menu-btn { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--text); padding: 4px 8px; }
.content { padding: 12px 28px 40px; display: flex; flex-direction: column; gap: 18px; max-width: 1280px; width: 100%; }

/* ---------------------------------------------------------------- cards + grid */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card.narrow { max-width: 620px; }
.card-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.card-link { margin-left: auto; font-size: .9rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.empty { padding: 12px 0; }

/* ---------------------------------------------------------------- tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.tile { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.tile-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tile-value { font-size: 1.55rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile-sub { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.tiles.small .tile-value { font-size: 1.15rem; }
.delta { font-size: .78rem; font-weight: 600; padding: 1px 6px; border-radius: 99px; white-space: nowrap; }
.delta.up { color: var(--ok); background: var(--ok-bg); }
.delta.down { color: var(--bad); background: var(--bad-bg); }
.delta.flat { color: var(--muted); background: var(--surface-alt); }

/* ---------------------------------------------------------------- charts */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--accent); }
.chart .hit { fill: transparent; }
.chart g:hover .bar { fill: var(--orange-dark); }
.chart g:hover .hit { fill: var(--surface-alt); }
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hbar-head { display: flex; justify-content: space-between; gap: 12px; font-size: .92rem; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-value { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.hbar-track { height: 8px; background: var(--surface-alt); border-radius: 99px; margin-top: 4px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--accent); border-radius: 99px; }
.hbar-sub { font-size: .78rem; margin-top: 2px; }

/* ---------------------------------------------------------------- tables + lists */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.archived td { opacity: .6; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-alt); }
td.actions { text-align: right; white-space: nowrap; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0 0 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.roles { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 14px 0 0; }
.roles dt { font-weight: 600; }
.roles dd { margin: 0; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 12px; }

/* ---------------------------------------------------------------- badges + dots */
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; vertical-align: middle; white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.muted { color: var(--muted); background: var(--surface-alt); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }
.dot.on { background: #22a06b; box-shadow: 0 0 0 3px rgba(34,160,107,.18); }
.dot.idle { background: #e0a526; }
.dot.off { background: #b7b7c6; }

/* ---------------------------------------------------------------- banners + flashes */
.banner, .flash { border-radius: var(--radius); padding: 11px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.main > .banner, .main > .flash { margin: 6px 28px 0; }
.banner.info { background: var(--info-bg); color: var(--info); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.danger { background: var(--bad-bg); color: var(--bad); }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.auth-card .flash { margin-bottom: 14px; }

/* ---------------------------------------------------------------- forms + buttons */
.form { display: flex; flex-direction: column; gap: 12px; }
.form.compact { gap: 8px; margin-top: 10px; text-align: left; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: .88rem; flex: 1; min-width: 0; }
label .muted, label small { font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: #fff; border: 1px solid #cfcfdc; border-radius: 8px;
  padding: 8px 10px; min-height: 38px; width: 100%; min-width: 0;
}
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--orange); }
input[type=color] { padding: 2px; width: 46px; flex: none; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; }
input:disabled { background: var(--surface-alt); color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > form { display: inline; }
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; background: var(--surface); padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.filters label { flex: 0 1 200px; }
.filters .custom-dates { display: flex; gap: 12px; }
.filters .push, .push { margin-left: auto; }
.range-label { align-self: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: .9rem;
  padding: 8px 14px; min-height: 38px; border-radius: 8px; border: 1px solid #cfcfdc; background: #fff; color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); }
.btn.danger { color: var(--bad); border-color: #e9b8b3; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: .82rem; }
.btn.block { width: 100%; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--orange-dark); cursor: pointer; }
.link:hover { text-decoration: underline; }
details.inline-edit { display: inline-block; text-align: left; }
details.inline-edit summary { list-style: none; }
details.inline-edit summary::-webkit-details-marker { display: none; }
details.inline-edit[open] { display: block; min-width: 260px; }
details.inline-edit[open] summary { margin-left: auto; }
.copy-row { display: flex; gap: 8px; margin: 8px 0; }

/* ---------------------------------------------------------------- branding preview */
.brand-preview { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.brand-preview-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--navy); color: #fff; }
.brand-preview-head img { width: 34px; height: 34px; object-fit: contain; background: #fff; border-radius: 6px; }
.brand-preview-body { padding: 14px; display: flex; flex-wrap: wrap; gap: 8px; background: var(--surface-alt); }
.brand-preview-pill { padding: 14px 18px; background: #fff; border-radius: 8px; border-left: 4px solid var(--preview-accent); font-weight: 600; }
.brand-preview-pay { flex-basis: 100%; text-align: center; padding: 12px; background: var(--preview-accent); color: #fff; border-radius: 8px; font-weight: 700; }

/* ---------------------------------------------------------------- auth pages */
body.auth { background: var(--navy); min-height: 100vh; }
.auth-wrap { max-width: 420px; margin: 0 auto; padding: 48px 16px; }
.auth-brand img { height: 40px; display: block; margin: 0 auto 24px; }
.auth-card { background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.auth-card .card { box-shadow: none; padding: 0; }
.auth-foot { color: #8a8aa0; text-align: center; font-size: .85rem; margin-top: 18px; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.nav-open .sidebar { transform: none; }
  .menu-btn { display: inline-block; }
  .topbar { padding: 14px 16px 4px; }
  .content { padding: 10px 16px 32px; }
  .main > .banner, .main > .flash { margin: 6px 16px 0; }
  .filters label { flex: 1 1 140px; }
}
@media (max-width: 480px) {
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .tile-value { font-size: 1.3rem; }
  .card { padding: 14px; }
  .auth-card { padding: 20px; }
}
@media print {
  .sidebar, .topbar .menu-btn, .filters button, .banner form { display: none; }
  body { background: #fff; }
  .card, .tile { box-shadow: none; border: 1px solid var(--border); }
}
