/* ==========================================================================
   Margin Mate — application stylesheet
   Brand: Navy #0F2540 · Teal #18B7A0 · Lime #A7C83B · Inter / Manrope
   ========================================================================== */

:root {
  --navy:  #0F2540;
  --navy-700: #18324f;
  --navy-600: #21406a;
  --teal:  #18B7A0;
  --teal-dark: #129683;
  --lime:  #A7C83B;
  --ink:   #1d2733;
  --muted: #6b7785;
  --line:  #e3e8ee;
  --bg:    #f5f7fa;
  --card:  #ffffff;
  --green: #2fae6b;
  --amber: #e6a020;
  --red:   #d6483f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15,37,64,.06), 0 4px 16px rgba(15,37,64,.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- App shell ---------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  background: var(--navy);
  color: #cdd7e3;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.sidebar .brand {
  padding: 20px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand img { width: 100%; max-width: 180px; display: block; }
.sidebar nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.sidebar nav .group {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: #6f8095; padding: 14px 12px 6px;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; margin: 1px 0;
  color: #cdd7e3; font-weight: 500; font-size: 13.5px;
}
.sidebar nav a:hover { background: var(--navy-700); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--navy-600); color: #fff; }
.sidebar nav a .accent { width: 3px; height: 16px; border-radius: 2px; background: var(--teal); }
.sidebar .who {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px; color: #9fb0c2;
}
.sidebar .who strong { color: #fff; display: block; font-size: 13px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 700; }
.content { padding: 24px; flex: 1; }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; font-size: 13px; cursor: pointer; font-family: inherit;
  background: var(--navy); color: #fff;
}
.btn:hover { background: var(--navy-700); text-decoration: none; }
.btn.teal { background: var(--teal); }
.btn.teal:hover { background: var(--teal-dark); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: #eef2f6; }
.btn.danger { background: transparent; color: var(--red); border-color: #f0c9c6; padding: 5px 10px; font-size: 12px; }
.btn.sm { padding: 5px 10px; font-size: 12px; }

/* ---- Cards & layout ----------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 700; display:flex; justify-content:space-between; align-items:center;}
.card .card-body { padding: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.stack > * + * { margin-top: 16px; }

/* ---- Tables ------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px;
     text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Forms -------------------------------------------------------------- */
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input, select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 13.5px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--teal); outline-offset: -1px; border-color: var(--teal); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 10px; align-items: end; }

/* ---- Margin summary (signature element) --------------------------------- */
.margin-hero {
  background: linear-gradient(150deg, var(--navy) 0%, var(--navy-600) 100%);
  color: #fff; border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.margin-hero .figure { font-size: 38px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.margin-hero .pct { font-size: 18px; font-weight: 700; margin-left: 8px; }
.margin-hero .caption { color: #9fb0c2; font-size: 12px; margin-top: 4px; }
.margin-hero .breakdown { margin-top: 18px; border-top: 1px solid rgba(255,255,255,.12); padding-top: 14px; }
.margin-hero .breakdown .line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; color: #cdd7e3; }
.margin-hero .breakdown .line.total { color: #fff; font-weight: 700; border-top: 1px solid rgba(255,255,255,.12); margin-top: 6px; padding-top: 10px; }
.status-pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-green { background: rgba(47,174,107,.16); color: #7fe6ab; }
.status-amber { background: rgba(230,160,32,.16); color: #f3c86b; }
.status-red   { background: rgba(214,72,63,.18);  color: #f3a39d; }
.status-unknown { background: rgba(255,255,255,.1); color: #cdd7e3; }

/* status pills on light bg (MI tables) */
.tag-green { color: var(--green); font-weight: 700; }
.tag-amber { color: var(--amber); font-weight: 700; }
.tag-red   { color: var(--red); font-weight: 700; }

/* ---- Flash messages ----------------------------------------------------- */
.flashes { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 8px; border: 1px solid; }
.flash.success { background: #eafaf2; border-color: #bce8d2; color: #1c7a4b; }
.flash.error   { background: #fdecea; border-color: #f5c6c2; color: #b33028; }
.flash.info    { background: #eaf3fb; border-color: #c6dcf0; color: #1f5d92; }

/* ---- Lock banner -------------------------------------------------------- */
.lock-banner { background: #fff8e9; border: 1px solid #f0d9a8; color: #8a6418;
  padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; font-weight: 600; }
.indicative { font-size: 11.5px; color: var(--muted); }

/* ---- Login -------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--navy); }
.login-card { background: #fff; border-radius: 14px; padding: 32px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card img { width: 220px; display: block; margin: 0 auto 22px; }
.login-card .strap { text-align: center; color: var(--muted); font-size: 12.5px; margin: -12px 0 22px; }
.login-card .hint { font-size: 11.5px; color: var(--muted); margin-top: 16px; text-align: center; }

/* ---- Misc --------------------------------------------------------------- */
.meta-row { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.meta-row b { color: var(--ink); font-weight: 600; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 10px; }
.empty { color: var(--muted); font-size: 13px; padding: 10px 0; }

/* Hamburger toggle (hidden on desktop) */
.nav-toggle { display: none; background: none; border: 0; cursor: pointer; padding: 8px;
  font-size: 22px; line-height: 1; color: var(--navy); }

@media (max-width: 880px) {
  /* Sidebar slides in from the left, toggled by the hamburger */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 2px 0 16px rgba(0,0,0,.25);
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  /* Dark overlay behind the open sidebar */
  .app.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40;
  }
  .nav-toggle { display: inline-block; }

  .grid-2 { grid-template-columns: 1fr; }

  /* Tables scroll sideways instead of overflowing the screen */
  .card .card-body { overflow-x: auto; }
  table { min-width: 520px; }

  /* Tighter page padding on small screens */
  .topbar { padding: 12px 14px; }
  .content { padding: 14px; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .login-card { width: 92%; max-width: 360px; padding: 24px; }
  .meta-row { gap: 10px; font-size: 12px; }
}

@media (max-width: 480px) {
  .field-row { grid-template-columns: 1fr; }
  h1, .topbar h1 { font-size: 20px; }
}
