/* Kro brand. Sources: brand/reference.jpeg. Fonts are self-hosted (OFL, see static/fonts). */
@font-face { font-family: "Plus Jakarta Sans"; src: url("../fonts/plus-jakarta-sans.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-semibold.woff2") format("woff2"); font-weight: 600 700; font-display: swap; }

:root {
  --navy: #0e1726;
  --cyan: #06b6d4;
  --blue: #0284c7;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0e1726;
  --muted: #5b6b82;      /* slate grey, a step darker so small text stays readable */
  --border: #e2e8f0;
  --primary: #0369a1;    /* maintenance blue, a step darker: 4.5:1 or more on white */
  --primary-text: #ffffff;
  --chrome: var(--navy); /* top bar */
  --chrome-text: #f8fafc;
  --ok: #1b7f4b;
  --warn: #a15c00;
  --danger: #b42318;
  --radius: 10px;
  --sidebar: 240px;
  --font-heading: "Plus Jakarta Sans", system-ui, sans-serif;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1726; --surface: #162236; --text: #f8fafc; --muted: #94a3b8;
  --border: #28374f; --primary: #06b6d4; --primary-text: #0e1726;
  --chrome: #0a111d; --ok: #4cc38a; --warn: #f0a742; --danger: #f97066;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1726; --surface: #162236; --text: #f8fafc; --muted: #94a3b8;
    --border: #28374f; --primary: #06b6d4; --primary-text: #0e1726;
    --chrome: #0a111d; --ok: #4cc38a; --warn: #f0a742; --danger: #f97066;
  }
}
.theme-toggle { background: none; border: 0; color: inherit; font-size: 1.2rem; cursor: pointer; min-height: 44px; min-width: 44px; padding: 0 .5rem; }
.theme-toggle-floating { position: fixed; top: .5rem; right: .5rem; color: var(--text); z-index: 30; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--primary); }
h1, h2, h3, .brand, .kpi-value { font-family: var(--font-heading); }
h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 1.1rem; font-weight: 700; margin: 1.2rem 0 .4rem; }
code { font-size: .9em; }
.muted { color: var(--muted); }
.error { color: var(--danger); display: block; }
.help { color: var(--muted); display: block; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem;
  height: 52px; padding: 0 1rem; background: var(--chrome); color: var(--chrome-text);
  box-shadow: inset 0 -2px 0 var(--cyan);
}
.topbar a, .topbar .link { color: var(--chrome-text); text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.15rem; letter-spacing: .02em; }
.brand img { height: 28px; width: auto; }
.brand small { font-weight: 500; font-size: .8rem; opacity: .75; letter-spacing: 0; }

/* Sign-in: the full logo above the form. */
.brand-panel { display: flex; align-items: center; justify-content: center; gap: .9rem; margin-bottom: 1rem; padding: 1.4rem 1rem; background: var(--chrome); color: #fff; border-radius: var(--radius); border: 1px solid var(--border); border-bottom: 3px solid var(--cyan); }
.brand-panel img { height: 64px; width: auto; }
.brand-panel strong { display: block; font-family: var(--font-heading); font-weight: 800; font-size: 2rem; line-height: 1; letter-spacing: .02em; }
.brand-panel span { display: block; margin-top: .3rem; font-size: .68rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.powered { margin-top: 1.5rem; text-align: center; font-size: .8rem; color: var(--muted); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.topbar-user form { margin: 0; }
.menu-toggle { display: none; background: none; border: 0; color: inherit; font-size: 1.4rem; cursor: pointer; }
.layout { display: flex; min-height: calc(100vh - 52px); }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: .75rem .5rem; overflow-y: auto;
}
.sidebar a { display: block; padding: .45rem .75rem; border-radius: 6px; color: var(--text); text-decoration: none; }
.sidebar a:hover { background: var(--bg); }
.sidebar a.active { background: var(--primary); color: var(--primary-text); }
.nav-module summary { padding: .5rem .75rem; cursor: pointer; font-weight: 600; list-style: none; }
.nav-module summary::-webkit-details-marker { display: none; }
.nav-module a { padding-left: 2rem; }
.content { flex: 1; min-width: 0; padding: 1.25rem; max-width: 1200px; margin-inline: auto; }
.content-narrow { max-width: 420px; margin: 8vh auto; }

/* Components */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.form { max-width: 760px; }
.field { margin-bottom: .9rem; }
.field label { display: block; font-weight: 600; margin-bottom: .25rem; }
.check-label { display: flex !important; align-items: center; gap: .5rem; font-weight: 500 !important; }
.input {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
.input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.has-error .input { border-color: var(--danger); }
ul[id$="roles"], div[id$="roles"] { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .5rem .9rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
  font: inherit; text-decoration: none; cursor: pointer; min-height: 40px;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-block { width: 100%; }
.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.search { display: flex; gap: .5rem; margin-bottom: 1rem; max-width: 520px; }
.date-filter { display: flex; flex-direction: column; gap: .15rem; }
.small { font-size: .85rem; }
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.msg { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .5rem; background: var(--surface); border: 1px solid var(--border); }
.msg-success { border-left: 4px solid var(--ok); }
.msg-error { border-left: 4px solid var(--danger); }
.msg-warning { border-left: 4px solid var(--warn); }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .8rem; border: 1px solid var(--border); }
.badge-ok { color: var(--ok); border-color: var(--ok); }
.badge-warn { color: var(--warn); border-color: var(--warn); }
.badge-danger { color: var(--danger); border-color: var(--danger); }
[data-show-when-checked][hidden] { display: none; }
.btn.disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; cursor: not-allowed; }
.span-all { grid-column: 1 / -1; }
tr[data-removed] { display: none !important; }
[data-show-when-empty][hidden] { display: none; }
/* Menu search (side menu and "¿Qué querés hacer?" on the home page). */
.sidebar a[hidden], .sidebar details[hidden], .find-results a[hidden], [data-search-empty][hidden] { display: none; }
.nav-search { margin: 0 0 .5rem; }
.nav-empty { padding: .25rem .75rem; font-size: .9rem; }
.find { margin: 1rem 0; }
.find label { display: block; font-weight: 600; margin-bottom: .4rem; }
.find-results { display: flex; flex-direction: column; margin-top: .4rem; }
.find-results a { padding: .5rem .25rem; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.find-results a:hover, .find-results a:focus { background: var(--bg); }
.find-results p { margin: .5rem 0 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; margin: 1rem 0; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 1.1rem; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; font-weight: 600;
}
.tile-icon { font-size: 1.8rem; color: var(--primary); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
a.kpi { color: var(--text); text-decoration: none; }
.kpi-value { font-size: 1.35rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-label { color: var(--muted); font-size: .85rem; }
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 1rem; }
.chart-box { position: relative; height: 280px; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .85rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: color-mix(in srgb, var(--primary) 6%, transparent); }
.row-actions { white-space: nowrap; text-align: right; }
.table td.row-actions { width: 1%; }
.row-actions a { margin-left: .6rem; }
.danger { color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 1.5rem; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; }
.lines .input { min-width: 90px; }
.totals { margin-left: auto; max-width: 320px; }
.totals div { display: flex; justify-content: space-between; padding: .2rem 0; }
.totals .grand { font-weight: 700; font-size: 1.15rem; border-top: 1px solid var(--border); padding-top: .4rem; }
.notice { padding: .7rem 1rem; border-radius: 8px; border: 1px dashed var(--warn); color: var(--warn); margin-bottom: 1rem; }
.login h1 { margin-bottom: 1rem; }
.login label { display: block; font-weight: 600; margin-bottom: .8rem; }

/* Mobile */
.menu-backdrop { display: none; }
@media (max-width: 800px) {
  /* Notch and home-indicator areas (viewport-fit=cover). */
  .topbar {
    height: calc(52px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
    padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(.5rem, env(safe-area-inset-right));
    gap: .5rem;
  }
  .topbar-user { gap: .25rem; }
  .topbar-user > a, .topbar-user .link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .4rem; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; margin-left: -.6rem; }

  /* Side menu as a drawer over a dimmed page; tapping outside or Escape closes it. */
  .sidebar {
    position: fixed; top: calc(52px + env(safe-area-inset-top)); bottom: 0; left: 0; z-index: 15;
    width: min(85vw, 300px); transform: translateX(-100%); visibility: hidden;
    transition: transform .2s ease, visibility .2s; box-shadow: 0 0 24px rgba(0,0,0,.25);
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
  .sidebar.open { transform: translateX(0); visibility: visible; }
  .sidebar a { padding: .7rem .75rem; }
  .nav-module summary { padding: .75rem; }
  .menu-backdrop { display: block; position: fixed; inset: 0; z-index: 14; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.menu-open .menu-backdrop { opacity: 1; pointer-events: auto; }
  body.menu-open { overflow: hidden; }

  .content { padding: 1rem max(1rem, env(safe-area-inset-right)) calc(1.5rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
  h1 { font-size: 1.25rem; }
  .card { padding: 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .charts { grid-template-columns: 1fr; }
  .chart-box { height: 240px; }

  /* Touch targets of at least 44px, and 16px text in fields so iOS does not zoom on focus. */
  .btn { min-height: 44px; }
  .input, select, textarea { font-size: 16px; }
  .input { min-height: 44px; }
  .check-label { min-height: 44px; }

  /* Filter rows wrap instead of squeezing or overflowing. */
  .search { flex-wrap: wrap; max-width: none; }
  .search > * { flex: 1 1 auto; min-width: 0; }
  .search > input[type="search"] { flex: 1 1 12rem; }
  .search > select { width: auto; flex: 1 1 9rem; }
  .search > label { display: flex; flex-direction: column; gap: .2rem; flex: 1 1 140px; }
  .search > .btn { flex: 0 0 auto; }

  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .kpi { padding: .75rem; }
  .kpi-value { font-size: 1.1rem; }
  .kpi-label { font-size: .8rem; }

  /* Tables read as cards: the first cell is the title, the rest label/value rows. */
  .table.stack thead { display: none; }
  .table.stack tr { display: block; border-bottom: 1px solid var(--border); padding: .6rem 0; }
  .table.stack tr:last-child { border-bottom: 0; }
  .table.stack td { display: block; border: 0; padding: .25rem .9rem; text-align: right; }
  .table.stack td::before { content: attr(data-label); float: left; margin-right: 1rem; font-weight: 600; color: var(--muted); text-align: left; }
  .table.stack td::after { content: ""; display: table; clear: both; }
  .table.stack:not(.lines) td:first-of-type { font-size: 1.05rem; font-weight: 700; text-align: left; padding-bottom: .4rem; }
  .table.stack:not(.lines) td:first-of-type::before { content: none; }
  .table.stack td.stack-hide:first-of-type + td { font-size: 1.05rem; font-weight: 700; text-align: left; padding-bottom: .4rem; }
  .table.stack td.stack-hide:first-of-type + td::before { content: none; }
  .table.stack td.empty { text-align: center; }
  .table.stack td.empty::before, .table.stack td.row-actions::before { content: none; }
  .table.stack .stack-hide { display: none; }
  .table.stack td.row-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .5rem; padding-top: .5rem; white-space: normal; width: auto; }
  .table.stack td.row-actions::after { content: none; }
  .table.stack .row-actions > a, .table.stack .row-actions summary {
    display: inline-flex; align-items: center; min-height: 44px; margin: 0; padding: 0 1rem;
    border: 1px solid var(--border); border-radius: 8px; text-decoration: none;
  }
  .table.stack .row-actions summary { cursor: pointer; list-style: none; }
  .table.stack .row-actions details { width: 100%; text-align: right; }
  .table.stack .row-actions details[open] summary { margin-bottom: .25rem; }

  /* Document lines (invoice, order, recipe): a small form per line, labels above the fields. */
  .table.stack.lines tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: .25rem .75rem; padding: .75rem .9rem; }
  .table.stack.lines td { display: block; padding: 0; text-align: left; }
  .table.stack.lines td::before { display: block; float: none; margin: 0 0 .2rem; font-size: .85rem; }
  .table.stack.lines td:first-of-type { grid-column: 1 / -1; }
  .table.stack.lines td:last-of-type { grid-column: 1 / -1; display: flex; align-items: center; gap: .5rem; }
  .table.stack.lines td:last-of-type::before { content: none; }  /* the button already says "Quitar" */
  .table.stack.lines td:last-of-type { justify-content: flex-end; }
  .lines .input { min-width: 0; }

  /* The save bar of long forms stays at hand. */
  form.card > .actions:last-child {
    position: sticky; bottom: 0; z-index: 5; margin: 1rem -1rem -1rem; padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  }
}

/* Print: documents (invoices, orders) print without the app chrome */
@media print {
  .topbar, .sidebar, .actions, .messages, .no-print { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
  body { background: #fff; color: #000; }
}

.inline-form { display: inline; }

.code { white-space: pre-wrap; word-break: break-word; margin: 0; font-size: .85rem; }

.product-photo { display: block; max-width: min(100%, 320px); height: auto; border-radius: 8px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; }
.shop-item { display: flex; flex-direction: column; gap: .5rem; margin: 0; }
.shop-item h2, .shop-item p { margin: 0; }
.shop-item form { margin-top: auto; }
.shop-item img, .shop-nophoto { width: 100%; aspect-ratio: 1; object-fit: contain; }
.shop-nophoto { display: grid; place-items: center; font-size: 3rem; background: var(--bg); }
.shop-qty { display: flex; gap: .35rem; flex-wrap: wrap; }
.shop-qty .input { width: 6rem; }

/* Notifications */
.bell { position: relative; }
/* Line icons from static/brand/icons.svg: they take the size and color of the text. */
.ico { width: 1.15em; height: 1.15em; vertical-align: -.22em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.bell-count { position: absolute; top: -.5rem; right: -.7rem; min-width: 1.15rem; padding: 0 .25rem; border-radius: 99px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; text-align: center; }
.notification { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1rem; margin-bottom: .5rem; }
.notification.unread { border-left: 4px solid var(--primary); }
.notification form { margin: 0; }
