@import url('/fonts/fonts.css');

/* Monate CI: charcoal #4A4A4D + greys, tan #AC8A69 and rose #C27B6F as accents (tan text uses #82613D on light). */
:root {
  --ink: #4A4A4D;
  --ink-deep: #3B3B3E;
  --text: #2E2E31;
  --muted: #6E6A66;
  --grey: #CCCCCC;
  --grey-2: #B3B3B3;
  --bg: #F6F4F1;
  --card: #FFFFFF;
  --line: #E4DFD8;
  --line-strong: #CFC8BE;
  --tan: #AC8A69;
  --tan-ink: #82613D;
  --tan-soft: #F3ECE3;
  --rose: #C27B6F;
  --rose-ink: #9A4E43;
  --good: #2E6B47;
  --bad: #A1392E;
  --warn-ink: #7A5200;
  --warn-bg: #FFF4DB;
  --error-bg: #FBEDEB;
  --focus: #AC8A69;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(46, 46, 49, .06), 0 2px 10px rgba(46, 46, 49, .05);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 1rem/1.5 'Lato', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: 'Playfair Display SC', Georgia, serif; font-weight: 700; color: var(--ink); line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.75rem; letter-spacing: .01em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
a { color: var(--tan-ink); }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- shell */
.topbar { background: var(--ink-deep); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; gap: 1.25rem; padding: .55rem 1.25rem; }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: #fff; flex-shrink: 0; }
.brand img { height: 40px; width: auto; display: block; }
.brand span { font: 700 .72rem/1.1 'Lato', sans-serif; letter-spacing: .14em; text-transform: uppercase; color: var(--grey); border-left: 1px solid rgba(255,255,255,.25); padding-left: .75rem; }
.nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #E9E6E1; text-decoration: none; padding: .5rem .75rem; border-radius: 6px; font-weight: 700; font-size: .92rem; white-space: nowrap; position: relative; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { color: #fff; }
.nav a.active::after { content: ''; position: absolute; left: .75rem; right: .75rem; bottom: .15rem; height: 2px; background: var(--tan); }
.badge-count { display: inline-block; min-width: 1.4em; padding: 0 .4em; margin-left: .35em; border-radius: 999px; background: var(--rose); color: #fff; font-size: .72rem; line-height: 1.5; text-align: center; }
.usermenu { position: relative; flex-shrink: 0; }
.usermenu > button { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 999px; padding: .35rem .85rem; font: 700 .85rem 'Lato', sans-serif; cursor: pointer; }
.usermenu .menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.18); min-width: 200px; padding: .35rem; }
.usermenu .menu a, .usermenu .menu button { display: block; width: 100%; text-align: left; padding: .55rem .75rem; color: var(--text); text-decoration: none; border: 0; background: none; font: inherit; border-radius: 6px; cursor: pointer; }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--tan-soft); }
.usermenu .menu .who { padding: .5rem .75rem; font-size: .82rem; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: .25rem; }

main { max-width: 1400px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: .25rem; }

/* ---------------------------------------------------------------- cards, banners */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 1.25rem; }
.card h2 { margin-bottom: .85rem; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.banner { border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid; }
.banner.warn { background: var(--warn-bg); border-color: #F1D99A; color: var(--warn-ink); }
.banner.error { background: var(--error-bg); border-color: #EDC4BD; color: var(--bad); }
.banner.info { background: var(--tan-soft); border-color: #E2D3C1; color: var(--tan-ink); }
.banner ul { margin: .35rem 0 0 1.1rem; padding: 0; }

/* ---------------------------------------------------------------- buttons, inputs */
.btn { display: inline-flex; align-items: center; gap: .4rem; border-radius: 8px; border: 1px solid var(--ink); background: var(--ink); color: #fff;
  padding: .55rem 1rem; font: 700 .92rem 'Lato', sans-serif; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--ink-deep); color: #fff; }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { border-color: var(--ink); color: var(--ink); }
.btn.danger { background: #fff; color: var(--bad); border-color: #E2B3AC; }
.btn.danger:hover { background: var(--error-bg); }
.btn.small { padding: .35rem .7rem; font-size: .82rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

label.field, .field { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 700; color: var(--ink); }
.field .hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select, textarea {
  font: 400 .95rem 'Lato', sans-serif; color: var(--text); background: #fff; border: 1px solid var(--line-strong); border-radius: 7px;
  padding: .5rem .6rem; width: 100%; min-height: 2.4rem;
}
textarea { min-height: 5.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--tan); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--bad); background: #FFFAF9; }
.field .err { color: var(--bad); font-weight: 700; font-size: .8rem; }
.field .wrn { color: var(--warn-ink); font-weight: 700; font-size: .8rem; }
.field .calc { font-weight: 400; color: var(--muted); font-size: .8rem; }
.req::after { content: ' *'; color: var(--rose-ink); }

.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.toolbar .field { min-width: 150px; }
.toolbar .grow { flex: 1; min-width: 220px; }
.check { display: inline-flex; align-items: center; gap: .45rem; font-weight: 700; font-size: .9rem; color: var(--ink); }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--ink); }

/* ---------------------------------------------------------------- form layout */
.form-section { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1rem; }
.form-section:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.form-section h3 { color: var(--tan-ink); margin-bottom: .75rem; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem 1rem; }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: 1 / -1; }
.form-actions { position: sticky; bottom: 0; background: rgba(246, 244, 241, .96); border-top: 1px solid var(--line); margin: 1.25rem -1.25rem -1.1rem; padding: .85rem 1.25rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; border-radius: 0 0 var(--radius) var(--radius); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .5rem .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { background: var(--ink); color: #fff; font-weight: 700; font-size: .8rem; letter-spacing: .02em; position: sticky; top: 0; white-space: nowrap; }
thead th.num { text-align: right; }
tbody tr:nth-child(even) td { background: #FBFAF8; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--tan-soft); }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); background: #fff !important; }
tr.section td { background: var(--tan-soft) !important; color: var(--tan-ink); font-weight: 700; font-size: .78rem; letter-spacing: .05em; text-transform: uppercase; }
tr.dim td { color: var(--grey-2); }
.pos { color: var(--good); font-weight: 700; }
.neg { color: var(--bad); font-weight: 700; }

.status { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; border: 1px solid; }
.status.enquiry { color: #3E5C76; background: #EEF3F7; border-color: #C9D6E2; }
.status.tentative { color: var(--tan-ink); background: var(--tan-soft); border-color: #E2D3C1; }
.status.definite { color: var(--good); background: #EAF4EE; border-color: #BCD9C7; }
.status.lost { color: var(--rose-ink); background: #FAEEEC; border-color: #EBC9C3; }
.status.cna { color: #5E5A57; background: #F0EEEC; border-color: #D8D3CE; }
.flag { display: inline-block; padding: .05rem .45rem; border-radius: 4px; font-size: .72rem; font-weight: 700; background: var(--warn-bg); color: var(--warn-ink); border: 1px solid #F1D99A; }
.flag.hold { background: var(--error-bg); color: var(--bad); border-color: #EDC4BD; }

.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: .75rem; }

/* ---------------------------------------------------------------- dashboard */
.selectors { display: flex; flex-wrap: wrap; gap: .9rem; align-items: flex-end; }
.selectors .field { min-width: 170px; }
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1rem; margin: 1.25rem 0; }
.tile { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--tan); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.tile .label { font-size: .78rem; font-weight: 700; color: var(--tan-ink); text-transform: uppercase; letter-spacing: .06em; }
.tile .value { font: 700 1.55rem/1.2 'Lato', sans-serif; color: var(--ink); margin: .3rem 0 .15rem; font-variant-numeric: tabular-nums; }
.tile .cmp { font-size: .85rem; color: var(--muted); }
.chart-card > svg { width: 100%; height: auto; display: block; }
.legend .swatch { width: 12px; height: 12px; display: inline-block; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .82rem; color: var(--muted); margin-top: .4rem; }
.legend i { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: .9rem; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: .55rem .9rem; font: 700 .9rem 'Lato', sans-serif; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--tan); }

/* ---------------------------------------------------------------- month view */
.fourfields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.fourfields .tile .value { font-size: 1.35rem; }

/* ---------------------------------------------------------------- detail view */
.dl { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem 1.25rem; margin: 0; }
.dl div { min-width: 0; }
.dl dt { font-size: .76rem; font-weight: 700; color: var(--tan-ink); text-transform: uppercase; letter-spacing: .05em; }
.dl dd { margin: .1rem 0 0; overflow-wrap: anywhere; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { border-left: 3px solid var(--line-strong); padding: .35rem 0 .6rem .8rem; }
.history li .when { font-size: .8rem; color: var(--muted); }
.history .chg { font-size: .85rem; margin-top: .2rem; }
.history .chg span { color: var(--muted); }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--bg); }
.login-card { width: min(420px, 100%); background: #fff; border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 10px 40px rgba(46,46,49,.1); padding: 2rem; }
.login-card img { width: 220px; height: auto; display: block; margin: 0 auto 1.25rem; }
.login-card h1 { text-align: center; font-size: 1.35rem; }
.login-card form { display: grid; gap: .9rem; margin-top: 1rem; }

/* ---------------------------------------------------------------- toast + modal */
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--ink-deep); color: #fff; padding: .7rem 1.1rem; border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 60; max-width: calc(100% - 2rem); }
.toast.error { background: var(--bad); }
.modal-back { position: fixed; inset: 0; background: rgba(30, 30, 32, .45); z-index: 50; display: grid; place-items: center; padding: 1rem; }
.modal { background: #fff; border-radius: 12px; width: min(520px, 100%); padding: 1.4rem; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal .btn-row { margin-top: 1rem; justify-content: flex-end; }
.secret { font: 700 1.2rem/1.4 ui-monospace, Consolas, monospace; background: var(--tan-soft); border: 1px dashed var(--tan); border-radius: 8px; padding: .6rem .8rem; user-select: all; overflow-wrap: anywhere; }

.loading { color: var(--muted); padding: 2rem 0; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .topbar-inner { flex-wrap: wrap; gap: .5rem; padding: .5rem 1rem; }
  .brand img { height: 32px; }
  .brand span { display: none; }
  .nav { order: 3; flex-basis: 100%; }
  main { padding: 1rem 1rem 3rem; }
  h1 { font-size: 1.4rem; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
  .tile .value { font-size: 1.2rem; }
  .fourfields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .dl { grid-template-columns: 1fr; }
  .form-actions { margin: 1rem -1.25rem -1.1rem; }
}
.legend .swatch { margin-right: .35rem; vertical-align: -1px; }
details.card > summary { cursor: pointer; font-weight: 700; color: var(--ink); }
details.card[open] > summary { margin-bottom: .75rem; }
.toolbar form, form.toolbar { margin: 0; }
.grid > *, .tiles > *, .fourfields > *, .form-grid > *, .dl > * { min-width: 0; }
