:root {
  --ink: #1C1B1F;
  --ink-soft: #29282E;
  --paper: #F7F5F0;
  --surface: #FFFFFF;
  --surface-alt: #F0EDE4;
  --line: #E1DDD1;

  --text: #201F1C;
  --text-muted: #7C7669;

  --accent: #2F6F4E;
  --accent-ink: #16402A;
  --accent-soft: #E3EEE7;

  --warn: #B5482A;
  --warn-soft: #F6E3DA;

  --radius-s: 6px;
  --radius-m: 10px;

  --font-ui: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input { font-family: inherit; color: inherit; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- app shell ---------- */

.app {
  display: flex;
  min-height: 100vh;
}

.rail {
  width: 220px;
  flex-shrink: 0;
  background: var(--ink);
  color: #EDEAE2;
  display: flex;
  flex-direction: column;
}

.rail__brand {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.rail__mark {
  color: var(--accent);
  font-family: var(--font-mono);
}

.rail__nav {
  flex: 1;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail__link {
  text-decoration: none;
  color: #C9C4B8;
  padding: 10px 12px;
  border-radius: var(--radius-s);
  font-size: 0.92rem;
  font-weight: 500;
}
.rail__link:hover { background: rgba(255,255,255,0.07); color: #fff; }
.rail__link.active { background: var(--accent); color: #fff; }

.rail__foot {
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.rail__logout {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.16);
  color: #C9C4B8;
  padding: 9px;
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 0.85rem;
}
.rail__logout:hover { border-color: var(--warn); color: #fff; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar__search input {
  width: 340px;
  max-width: 40vw;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 9px 14px;
  border-radius: var(--radius-s);
  font-size: 0.9rem;
}
.topbar__search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.topbar__meta { display: flex; align-items: center; gap: 18px; }
.topbar__clock {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.topbar__user { text-align: right; line-height: 1.25; }
.topbar__user-name { display: block; font-weight: 600; font-size: 0.85rem; }
.topbar__till { display: block; font-size: 0.75rem; color: var(--text-muted); }

/* base.css */

/* 1. Lock html & body height */
html, body { 
  height: 100%; 
  overflow: hidden; /* Stop whole-page scrolling */
}

/* 2. Constrain the outer app wrapper */
.app {
  display: flex;
  height: 100vh; /* Changed from min-height: 100vh */
  overflow: hidden;
}

/* 3. Constrain main content area */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.content {
  flex: 1;
  padding: 24px;
  overflow: hidden;
  display: flex;
  min-height: 0;
}

/* ---------- shared components ---------- */

.btn {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-s);
  padding: 11px 18px;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--text-muted); }
.btn-warn { background: var(--warn-soft); color: var(--warn); }
.btn-warn:hover { background: var(--warn); color: #fff; }

/* torn-edge: signature "receipt tape" cut, sits on top of a --paper bg */
.torn-edge { position: relative; }
.torn-edge::before {
  content: "";
  position: absolute;
  top: -1px; left: 0; right: 0;
  height: 9px;
  background-image: radial-gradient(circle at 8px 0, var(--paper) 7px, transparent 7.5px);
  background-size: 16px 9px;
  background-repeat: repeat-x;
}

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .rail { width: 100%; flex-direction: row; align-items: center; }
  .rail__brand { border-bottom: none; padding: 14px 16px; }
  .rail__nav { flex-direction: row; overflow-x: auto; padding: 8px; }
  .rail__foot { padding: 8px 16px; border-top: none; }
  .topbar { flex-wrap: wrap; height: auto; padding: 12px 16px; }
  .topbar__search input { width: 100%; max-width: none; }
}