/* Lagmar — site ledger. Slate structure, one amber accent, numbers in tabular figures. */
:root {
  --ink: #1b2430; --ink-2: #4a5666; --ink-3: #7b8696;
  --line: #dfe3e8; --line-2: #eef0f3;
  --paper: #f5f6f8; --card: #ffffff;
  --side: #1a3458; --side-ink: #cdd8e6; --side-hover: #25446d;
  --accent: #d98a12; --accent-ink: #5b3a05; --accent-soft: #fdf3e0;
  --ok: #1d7a4c; --ok-soft: #e4f4ec; --bad: #b3261e; --bad-soft: #fbe9e7; --info-soft: #e8eef7;
  --radius: 8px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--paper); line-height: 1.45; }
a { color: inherit; }
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.muted { color: var(--ink-3); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 1.1rem 1.25rem; font-weight: 700; font-size: 1.15rem; color: #fff; letter-spacing: .04em; display: flex; align-items: center; gap: .6rem; }
.brand i { width: 10px; height: 22px; background: var(--accent); border-radius: 2px; display: block; }
.side nav { flex: 1; overflow-y: auto; padding: .25rem .6rem; }
.side nav a { display: block; padding: .55rem .7rem; border-radius: 6px; text-decoration: none; margin-bottom: 2px; }
.side nav a:hover { background: var(--side-hover); color: #fff; }
.side nav a.active { background: var(--side-hover); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.side nav .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: #6f7c8d; padding: 1rem .7rem .35rem; }
.side .who { padding: .9rem 1.25rem; border-top: 1px solid #2a3644; font-size: .9rem; }
.side .who form { display: inline; }
.side .who button { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; font: inherit; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 1rem; padding: .7rem 1.75rem; background: var(--card); border-bottom: 1px solid var(--line); }
.top form { display: flex; align-items: center; gap: .5rem; margin: 0; }
.top label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.top select { font-weight: 600; min-width: 220px; }
.page { padding: 1.5rem 1.75rem 3rem; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.head p { margin: .2rem 0 0; color: var(--ink-3); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* controls */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=search], input[type=email], select, textarea {
  border: 1px solid #c9cfd7; border-radius: 6px; padding: .42rem .6rem; background: #fff; width: 100%; min-height: 2.25rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .48rem .95rem; border-radius: 6px; border: 1px solid #c9cfd7; background: #fff; text-decoration: none; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(.94); }
.btn.danger { color: var(--bad); }
.btn.small { padding: .25rem .6rem; font-size: .88rem; font-weight: 500; }

/* cards, tables */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 1rem 1.25rem 0; }
.grid { display: grid; gap: 1.1rem; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; text-decoration: none; display: block; }
.stat b { display: block; font-size: 1.7rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat span { color: var(--ink-3); font-size: .88rem; }
a.stat:hover { border-color: var(--accent); }
.scroll { overflow-x: auto; }
.card.flush.scroll { overflow: auto; }            /* a wide table scrolls inside its card, it is never cut off */
.card.flush.linescard { overflow: visible; }      /* the block picker opens over the card edge */
.sheetwrap { max-height: calc(100vh - 215px); }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; padding: .6rem .75rem; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
td { padding: .5rem .75rem; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tbody tr:hover td { background: #fafbfc; }
tr.week td { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; font-size: .88rem; padding: .4rem .75rem; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); background: #fafbfc; }
td .sub { display: block; color: var(--ink-3); font-size: .85rem; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--ink-3); }
.tag { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.tag.MATERIAL { background: var(--info-soft); color: #2b4a78; }
.tag.EQUIPMENT { background: var(--accent-soft); color: var(--accent-ink); }
.tag.SERVICE { background: #efe9f7; color: #50357a; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }

/* filters and forms */
.filters { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters > div { min-width: 140px; }
.filters .grow { flex: 1; min-width: 200px; }
label, .label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: .25rem; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .9rem 1rem; }
.field.wide { grid-column: 1 / -1; }
.help { font-size: .82rem; color: var(--ink-3); margin-top: .2rem; }
.errorlist { list-style: none; margin: .25rem 0 0; padding: 0; color: var(--bad); font-size: .85rem; }
.checks { display: flex; flex-wrap: wrap; gap: .3rem .9rem; }
.checks label, label.inline { display: inline-flex; align-items: center; gap: .35rem; font-weight: 400; margin: 0; }
.checks > div { display: contents; }
.msg { padding: .65rem 1rem; border-radius: 6px; margin-bottom: 1rem; background: var(--ok-soft); color: var(--ok); }
.msg.error { background: var(--bad-soft); color: var(--bad); }
.msg.warning, .msg.info { background: var(--accent-soft); color: var(--accent-ink); }

/* receipt lines */
.lines td { padding: .35rem .4rem; }
.lines th { padding-left: .4rem; }
.lines .c-item { min-width: 260px; } .lines .c-qty { width: 110px; } .lines .c-unit { width: 90px; }
.lines .c-price { width: 110px; } .lines .c-blocks { width: 170px; } .lines .c-del { width: 40px; text-align: center; }
details.pick { position: relative; }
details.pick summary { list-style: none; border: 1px solid #c9cfd7; border-radius: 6px; padding: .42rem .6rem; min-height: 2.25rem; cursor: pointer; background: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
details.pick summary::-webkit-details-marker { display: none; }
details.pick[open] summary { outline: 2px solid var(--accent); }
details.pick .pop { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .7rem .8rem; width: 270px; box-shadow: 0 10px 30px rgba(20,30,45,.16); }

/* monthly write-off sheet */
/* toolbar above the sheet: search + which block columns are shown */
.sheetbar { display: flex; gap: .9rem 1.25rem; align-items: center; flex-wrap: wrap; padding: .7rem 1rem; margin-bottom: .7rem; }
.sheetbar input[type=search] { width: 230px; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; flex: 1; }
.chips .label { font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-right: .3rem; }
.chip { border: 1px solid #c9cfd7; background: #fff; border-radius: 999px; min-width: 2.1rem; padding: .22rem .6rem; cursor: pointer; font-size: .88rem; color: var(--ink-3); }
.chip:hover { border-color: var(--ink-3); }
.chip[aria-pressed=true] { background: var(--side); border-color: var(--side); color: #fff; font-weight: 600; }
.chip.locked { cursor: default; background: var(--accent); border-color: var(--accent); }
.chip.link { border-color: transparent; color: var(--ink-2); text-decoration: underline; padding-left: .4rem; padding-right: .4rem; }
.sheet .name a { text-decoration: none; }
.sheet .name a:hover { text-decoration: underline; }
.sheet th, .sheet td { padding: .3rem .4rem; }
.sheet thead th { position: sticky; top: 0; z-index: 3; text-align: right; }
.sheet .name { position: sticky; left: 0; z-index: 2; background: #fff; min-width: 270px; max-width: 320px; text-align: left; box-shadow: 1px 0 0 var(--line); }
.sheet thead .name { z-index: 4; background: #fafbfc; }
.sheet td.cell { padding: 2px; }
.sheet td.cell input { width: 62px; min-height: 1.9rem; padding: .2rem .35rem; text-align: right; border-color: var(--line); background: #fff; font-variant-numeric: tabular-nums; }
.sheet td.cell input:hover { border-color: #c9cfd7; background: #fff; }
.sheet td.cell input:focus { background: #fff; }
.sheet td.cell input.filled { background: var(--accent-soft); font-weight: 600; }
.sheet td.cell input.saved { background: var(--ok-soft); transition: background .2s; }
.sheet td.cell input:disabled { color: var(--ink-2); background: var(--paper); border-color: transparent; }
.sheet .zone { background: #fafbfc; }
.sheet .sum { background: #fafbfc; font-weight: 600; }
.sheet .closing { font-weight: 700; box-shadow: 1px 0 0 var(--line); }
.sheet .note input { min-width: 220px; border-color: transparent; background: transparent; min-height: 1.9rem; padding: .2rem .35rem; }
.sheet .note input:hover, .sheet .note input:focus { border-color: #c9cfd7; background: #fff; }
.sheet tr.cat td { background: var(--line-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); font-weight: 600; position: sticky; left: 0; }
#toast { position: fixed; right: 1.5rem; bottom: 1.5rem; background: var(--bad); color: #fff; padding: .8rem 1.1rem; border-radius: 8px; max-width: 420px; box-shadow: 0 10px 30px rgba(0,0,0,.25); display: none; z-index: 50; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--side); }
.login .card { width: min(380px, 92vw); padding: 2rem; }
.login .brand { color: var(--ink); padding: 0 0 1.25rem; }
.login .field { margin-bottom: .9rem; }
.login .btn { width: 100%; justify-content: center; margin-top: .4rem; }

.menu-btn, .backdrop, .rep, .um-inline, .filterbox > summary { display: none; }
.filterbox .filters { margin-bottom: 0; }
.searchrow, .exactrow { display: flex; gap: .4rem; align-items: flex-end; }
.filters details.exact { flex: 1 1 100%; }
.filters details.exact > summary { cursor: pointer; color: var(--ink-2); font-size: .88rem; width: max-content; }
.filters details.exact[open] > summary { margin-bottom: .5rem; }
.exactrow > div { width: 170px; }
.exactrow > div:last-child { width: auto; }
.del-text { display: none; }
.lines tr.removed td:not(.c-del) { opacity: .4; text-decoration: line-through; pointer-events: none; }
.lines .c-del .btn { min-width: 2.1rem; justify-content: center; }
.lines .c-del .btn:disabled { opacity: .35; cursor: default; }
.monthrow { display: flex; gap: .3rem; }
.monthrow select { min-width: 170px; }
.monthrow .btn { padding-left: .7rem; padding-right: .7rem; }

/* phone and small tablet: the menu becomes a drawer, lists become cards */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: min(280px, 84vw); height: auto;
          transform: translateX(-100%); transition: transform .2s ease; }
  .nav-open .side { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(15,22,30,.5); }
  .side nav a { padding: .8rem .8rem; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 2.75rem; height: 2.75rem; flex: none;
              border: 1px solid #c9cfd7; border-radius: 6px; background: #fff; font-size: 1.3rem; line-height: 1; cursor: pointer; }
  .top { position: sticky; top: 0; z-index: 20; padding: .5rem .75rem; gap: .6rem; }
  .top form { flex: 1; min-width: 0; }
  .top label { display: none; }
  .top select { min-width: 0; }
  .page { padding: 1rem .75rem 4rem; }

  /* comfortable touch targets; 16px stops iOS from zooming into fields */
  input[type=text], input[type=number], input[type=date], input[type=password], input[type=search], input[type=email], select, textarea {
    font-size: 16px; min-height: 2.75rem; }
  .btn { min-height: 2.75rem; justify-content: center; }
  .btn.small { min-height: 2.25rem; }
  h1 { font-size: 1.3rem; }
  .head { align-items: stretch; flex-direction: column; gap: .7rem; }
  .head .actions { width: 100%; }
  .head .actions > .btn, .head .actions > form { flex: 1 1 auto; }
  .head .actions > form .btn { width: 100%; }
  .head .actions input[type=search] { flex: 1; width: auto !important; }
  .filters { gap: .6rem; }
  .filterbox > summary { display: block; font-weight: 600; cursor: pointer; padding: .2rem 0; }
  .filterbox > summary::after { content: ' ▾'; color: var(--ink-3); }
  .filterbox[open] > summary { margin-bottom: .7rem; }
  .filters > div { flex: 1 1 calc(50% - .3rem); min-width: 0; }
  .filters .grow { flex-basis: 100%; }
  .filters .monthpick { flex-basis: 100%; }
  .monthrow select { min-width: 0; flex: 1; }
  .filters .btn { width: 100%; }
  .fields { grid-template-columns: 1fr; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .grid.cols-4 { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .stat { padding: .8rem .9rem; }
  .stat b { font-size: 1.3rem; }
  .card { padding: .9rem; }
  .card.flush > h2 { padding: .9rem .9rem 0; }
  .checks { gap: .6rem 1.1rem; }
  .checks label, label.inline { min-height: 2rem; }
  input[type=checkbox] { width: 1.15rem; height: 1.15rem; }
  #toast { left: .75rem; right: .75rem; bottom: .75rem; max-width: none; }

  /* tables marked .stack: one card per row, "label: value" pairs that wrap */
  table.stack, table.stack tbody { display: block; }
  table.stack thead { display: none; }
  table.stack tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .9rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
  table.stack tbody tr:hover td { background: none; }
  table.stack td { display: block; padding: 0; border: 0; text-align: left; white-space: normal; min-width: 0; }
  table.stack td:empty { display: none; }
  table.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-3); font-size: .82rem; }
  table.stack td.main { order: -1; flex: 1 1 100%; font-weight: 600; margin-bottom: .1rem; }
  table.stack td.main .sub { font-weight: 400; }
  table.stack td.empty, table.stack tr.week td, table.stack tr.total td { flex: 1 1 100%; }
  table.stack tr.week { padding: .4rem .9rem; background: var(--accent-soft); }
  table.stack tr.week td { background: none; padding: 0; }
  table.stack td:has(> .btn.small) { flex: 1 1 100%; text-align: right; margin-top: .3rem; }
  .rep { display: inline; }

  /* receipt lines: each line is a small form of its own */
  table.lines.stack tr { gap: .6rem; padding: .9rem; align-items: flex-start; }
  table.lines.stack td { flex: 1 1 100%; }
  table.lines.stack td[data-label]::before { content: attr(data-label); display: block; font-weight: 600; color: var(--ink-2); margin-bottom: .2rem; }
  table.lines.stack td.c-qty, table.lines.stack td.c-unit, table.lines.stack td.c-price { flex: 1 1 28%; width: auto; }
  table.lines.stack td.c-blocks, table.lines.stack td.c-item { width: auto; min-width: 0; }
  table.lines.stack td.c-del { flex: 1 1 100%; width: auto; text-align: right; }
  details.pick .pop { width: min(300px, 86vw); }

  /* monthly sheet: one card per material, with a labelled box per shown block */
  .sheetbar { padding: .7rem; gap: .6rem; }
  .sheetbar input[type=search] { width: 100%; }
  .chip { min-width: 2.6rem; min-height: 2.2rem; }
  .sheetwrap { max-height: none; overflow: visible; background: none; border: 0; }
  table.sheet, table.sheet tbody { display: block; }
  table.sheet thead, .sheet tr.item td.um { display: none; }
  .um-inline { display: inline; font-size: .82rem; font-weight: 400; }
  .sheet tr.cat { display: block; margin: .9rem 0 .4rem; }
  .sheet tr.cat td { display: block; background: none; padding: 0 .2rem; position: static; }
  .sheet tr.item { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; background: var(--card);
                   border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; margin-bottom: .6rem; }
  .sheet tr.item[hidden], .sheet tr.cat[hidden] { display: none; }
  .sheet tr.item td { display: block; padding: 0; border: 0; background: none; box-shadow: none; text-align: left; min-width: 0; }
  .sheet tr.item:hover td { background: none; }
  .sheet tr.item td.name { grid-column: 1 / -1; position: static; max-width: none; font-size: 1rem; font-weight: 600; }
  .sheet td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; text-transform: uppercase;
                                  letter-spacing: .05em; color: var(--ink-3); font-weight: 600; }
  .sheet td.st { font-size: 1.05rem; font-variant-numeric: tabular-nums; padding-bottom: .5rem !important; border-bottom: 1px solid var(--line-2) !important; }
  .sheet td.cell[data-label]::before { text-align: center; text-transform: none; font-size: .85rem; color: var(--ink-2); margin-bottom: .15rem; }
  .sheet td.cell input { width: 100%; min-height: 2.75rem; font-size: 16px; text-align: center; border-color: #c9cfd7; background: #fff; }
  .sheet td.cell input:disabled { background: var(--paper); }
  .sheet td.note { grid-column: 1 / -1; }
  .sheet .note input { width: 100%; min-width: 0; min-height: 2.6rem; font-size: 16px; border-color: #c9cfd7; background: #fff; }

  .exactrow { flex-wrap: wrap; }
  .exactrow > div { flex: 1 1 calc(50% - .2rem); width: auto; }
  .exactrow > div:last-child { flex-basis: 100%; }
  .exactrow .btn, .searchrow .btn { width: auto; }
  .searchrow input { flex: 1; }
  .del-text { display: inline; }
}
@media (max-width: 380px) { .grid.cols-4 { grid-template-columns: 1fr; } }
@media print { .side, .top, .actions, .filters { display: none; } .shell { display: block; } .page { padding: 0; } }

/* monthly sheet on a wide screen: a real grid, every row and column ruled like a spreadsheet */
@media (min-width: 861px) {
  table.sheet { border-collapse: separate; border-spacing: 0; }
  .sheet th, .sheet td { border-right: 1px solid #cfd5dd; border-bottom: 1px solid #cfd5dd; }
  .sheet thead th { background: #e3e8ee; color: var(--ink); border-bottom: 2px solid #9aa5b3; padding-top: .55rem; padding-bottom: .55rem; }
  .sheet thead .name { background: #e3e8ee; }
  .sheet thead th.zone { background: #d9dfe7; }
  .sheet tbody tr.item:nth-of-type(even) td { background: #f7f9fb; }
  .sheet tbody tr.item:nth-of-type(even) td.name { background: #f7f9fb; }
  .sheet tbody tr.item:hover td, .sheet tbody tr.item:hover td.name { background: #eef3f9; }
  .sheet .name { box-shadow: none; border-right: 2px solid #9aa5b3; }
  .sheet .sum, .sheet tbody tr.item td.sum { background: #eef1f5; }
  .sheet .closing, .sheet tbody tr.item td.closing { background: #e6ebf1; border-right: 2px solid #9aa5b3; box-shadow: none; }
  .sheet tr.cat td { background: #d9dfe7; color: var(--ink); border-bottom: 1px solid #9aa5b3; border-top: 1px solid #9aa5b3; }
  /* the cell itself is the box: the input fills it and has no frame of its own */
  .sheet td.cell { padding: 0; }
  .sheet td.cell input { display: block; width: 100%; min-width: 66px; min-height: 2.2rem; border: 0; border-radius: 0; background: transparent; padding: .2rem .5rem; }
  .sheet td.cell input:hover { background: #fff; box-shadow: inset 0 0 0 1px #9aa5b3; }
  .sheet td.cell input:focus { outline: none; background: #fff; box-shadow: inset 0 0 0 2px var(--accent); }
  .sheet td.cell input.filled { background: var(--accent-soft); }
  .sheet td.cell input.saved { background: var(--ok-soft); }
  .sheet td.cell input:disabled { background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(0,0,0,.035) 6px 7px); }
  .sheet td.note { padding: 0; }
  .sheet .note input { display: block; width: 100%; min-height: 2.2rem; border: 0; border-radius: 0; background: transparent; padding: .2rem .6rem; }
  .sheet .note input:focus { outline: none; background: #fff; box-shadow: inset 0 0 0 2px var(--accent); }
}

/* monthly sheet on a phone: the same emphasis, as clearer card edges */
@media (max-width: 860px) {
  .sheet tr.item { border-color: #b9c2cd; box-shadow: 0 1px 2px rgba(20, 30, 45, .06); }
  .sheet tr.cat td { color: var(--ink); font-size: .82rem; border-bottom: 2px solid #9aa5b3; padding-bottom: .25rem; }
  .sheet td.cell input { border-color: #9aa5b3; }
}

/* month calendar in the filter bar */
.filters .label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: .25rem; }
.monthcal summary { min-width: 190px; font-weight: 600; display: flex; align-items: center; gap: .45rem; }
.monthcal .calicon { color: var(--accent); font-size: 1.05rem; line-height: 1; }
.monthcal .pop { width: 280px; padding: .8rem; }
.calhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.calhead .calyear { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.calhead .btn { min-width: 2.2rem; justify-content: center; }
.calgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; }
.calgrid a { position: relative; text-align: center; padding: .55rem 0; border-radius: 6px; text-decoration: none; border: 1px solid transparent; color: var(--ink-3); }
.calgrid a.has { color: var(--ink); font-weight: 600; }
.calgrid a.has::after, .calfoot .dot { content: ''; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
.calgrid a:hover { background: var(--line-2); }
.calgrid a.today { border-color: #c9cfd7; }
.calgrid a.selected { background: var(--side); color: #fff; font-weight: 600; }
.calfoot { display: flex; justify-content: space-between; align-items: center; margin-top: .6rem; padding-top: .55rem; border-top: 1px solid var(--line-2); font-size: .85rem; }
.calfoot .dot { position: static; display: inline-block; margin: 0 .2rem .1rem 0; vertical-align: middle; }
@media (max-width: 860px) {
  .monthcal { flex: 1; }
  .monthcal summary { min-width: 0; min-height: 2.75rem; }
  .monthcal .pop { width: min(300px, 86vw); }
  .calgrid a { padding: .8rem 0; }
}
@media (max-width: 860px) {
  .monthrow { position: relative; }
  .monthrow > .btn, .calhead .btn { width: auto !important; flex: none; min-width: 2.75rem; }
  details.monthcal { position: static; }           /* the calendar opens across the whole row, never off-screen */
  .monthcal .pop { left: 0; right: 0; width: auto; top: calc(100% + 4px); }
}

/* company logo */
.logo { display: block; width: 34px; height: 34px; flex: none; }
.brand { font-weight: 500; letter-spacing: .22em; gap: .7rem; }
.side .who { border-top-color: #2c4a72; }
.side nav .group { color: #8fa5c0; }
.toplogo { display: none; color: var(--side); }
.login .card { text-align: center; }
.login .brand { flex-direction: column; gap: .5rem; color: var(--side); font-size: 1.5rem; padding-bottom: .9rem; }
.login .brand .logo { width: 68px; height: 68px; }
.login .field { text-align: left; }
@media (max-width: 860px) { .toplogo { display: block; } .toplogo .logo { width: 32px; height: 32px; } }

/* Detaliat / Pe furnizori */
.tabs { display: flex; gap: .25rem; margin: 0 0 .8rem; border-bottom: 2px solid var(--line); }
.tabs a { padding: .55rem 1.1rem; text-decoration: none; font-weight: 600; color: var(--ink-3); border-bottom: 3px solid transparent; margin-bottom: -2px; border-radius: 6px 6px 0 0; }
.tabs a:hover { color: var(--ink); background: var(--line-2); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
table.grouped tr.week td { font-size: .95rem; }
table.grouped tr.week .sum { float: right; font-variant-numeric: tabular-nums; }
table.grouped td.product { padding-left: 1.75rem; }
@media (max-width: 860px) {
  .tabs a { flex: 1; text-align: center; padding: .7rem .5rem; }
  table.grouped td.product { padding-left: 0; }
}

/* signature preview: on "paper", so the transparent image reads as ink */
.sigpreview { background: #fff; border: 1px dashed #c9cfd7; border-radius: 8px; padding: 1rem; text-align: center; }
.sigpreview img { max-width: 100%; max-height: 130px; }
.sigpreview.empty { color: var(--ink-3); font-size: .9rem; }
input[type=file] { width: 100%; padding: .4rem 0; }
.side .who a { color: #fff; text-decoration: none; }
.side .who a:hover { text-decoration: underline; }

/* Lună / Perioadă switch above the period control */
.modeswitch { display: inline-flex; margin-bottom: .25rem; border: 1px solid #c9cfd7; border-radius: 999px; overflow: hidden; font-size: .78rem; font-weight: 600; }
.modeswitch a { padding: .08rem .7rem; text-decoration: none; color: var(--ink-3); }
.modeswitch a:hover { background: var(--line-2); }
.modeswitch a.active { background: var(--side); color: #fff; }
.rangerow { display: flex; align-items: center; gap: .35rem; }
.rangerow input[type=date] { width: 150px; }
@media (max-width: 860px) {
  .modeswitch a { padding: .35rem 1rem; font-size: .88rem; }
  .rangerow input[type=date] { width: auto; flex: 1; min-width: 0; }
}

/* dialog (change password) */
dialog.modal { border: 0; border-radius: 10px; padding: 1.4rem 1.5rem; width: min(420px, 92vw); box-shadow: 0 20px 60px rgba(15, 25, 40, .35); color: var(--ink); }
dialog.modal::backdrop { background: rgba(15, 25, 40, .55); }
dialog.modal h2 { margin-bottom: 1rem; }
dialog.modal .field { margin-bottom: .8rem; }
dialog.modal .actions { justify-content: flex-end; margin-top: 1rem; }

/* lists of receipts and equipment hours: columns ruled a little, cells that open on click */
tr.open { cursor: pointer; }
.lines tr.target td { background: var(--accent-soft); }
@media (min-width: 861px) {
  table.ruled th, table.ruled td { border-right: 1px solid var(--line); }
  table.ruled th:last-child, table.ruled td:last-child { border-right: 0; }
  table.ruled thead th { background: #eef1f5; color: var(--ink-2); border-bottom: 2px solid #c3cad3; }
  table.ruled tbody tr:not(.week) td { border-bottom-color: var(--line); }
  table.ruled td.num { background: #fafbfc; font-weight: 600; }
  table.ruled tr.week td { border-right: 0; }
  table.ruled tr.open td[data-f]:hover { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
}
@media (max-width: 860px) { tr.open td[data-f]:active { background: var(--accent-soft); } }

/* nomenclature icon before a product name: fixed box, never taller than the text line */
.ico { display: inline-block; width: 1.45em; margin-right: .15em; font-size: .92em; line-height: 1; text-align: center;
       vertical-align: -0.05em; font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
h1 .ico { font-size: .85em; }
select#id_icon { font-family: "Segoe UI", "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
