:root { --green: #2E9B50; --green-d: #23793E; --green-l: #E8F5EC; --slate: #2D3E50; --grey: #4A5568; --line: #D9E0E7;
  --bg: #F4F6F8; --white: #fff; --red: #C0392B; --red-l: #FBEAE8; --amber: #B7791F; --amber-l: #FDF3DC; --brand: var(--green); }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Calibri, Carlito, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; font-size: 16px; line-height: 1.45;
  color: var(--grey); background: var(--bg); }
h1, h2, h3 { color: var(--slate); margin: 0; line-height: 1.2; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
a { color: var(--green-d); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.btn { background: var(--green); color: #fff; border: 1px solid var(--green); border-radius: 6px; padding: 9px 16px; font-weight: 700; }
.btn:hover { background: var(--green-d); }
a.btn { text-decoration: none; display: inline-block; }
.btn.second { background: #fff; color: var(--slate); border-color: var(--line); }
.btn.second:hover { background: var(--bg); }
.btn.danger { background: #fff; color: var(--red); border-color: #E3B8B2; }
.btn.small { padding: 5px 10px; font-size: .92rem; }
.btn:disabled { opacity: .55; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--green-d); text-decoration: underline; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid #B9C4CF; border-radius: 6px; background: #fff; color: var(--slate); }
textarea { min-height: 84px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #9AD3AC; outline-offset: 1px; }
input:disabled, select:disabled, textarea:disabled { background: #F1F4F7; color: var(--grey); }
label.f { display: block; margin: 0 0 14px; }
label.f > span, .flabel { display: block; font-weight: 700; color: var(--slate); margin-bottom: 4px; }
label.f .need { color: var(--red); font-weight: 400; }
.help { font-size: .9rem; margin: 2px 0 0; }
.checks { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; max-height: 190px; overflow: auto; background: #fff; }
.checks label { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; }
.checks input { margin-top: 4px; }

/* sign in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: 100%; max-width: 420px; }
.auth .logo { justify-content: center; margin-bottom: 6px; }
.auth .strap { text-align: center; margin: 0 0 22px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 22px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.6rem; color: var(--slate); text-decoration: none; }
.logo b { color: var(--green); font-weight: 700; }
.logo svg { width: 36px; height: 36px; flex: none; }
.err { background: var(--red-l); color: #8E241A; border-radius: 6px; padding: 9px 12px; margin: 0 0 14px; }
.note { background: var(--green-l); color: #1D5E32; border-radius: 6px; padding: 9px 12px; margin: 0 0 14px; }

/* shell */
.top { background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 10px 20px; position: sticky; top: 0; z-index: 5; }
.top .logo { font-size: 1.3rem; } .top .logo svg { width: 28px; height: 28px; }
.top .client { font-weight: 700; color: var(--slate); border-left: 1px solid var(--line); padding-left: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .space { flex: 1; }
.top .who { white-space: nowrap; }
.menu-btn { display: none; }
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 54px); }
.side { background: var(--slate); color: #CBD5E0; padding: 14px 0 30px; }
.side a { display: flex; justify-content: space-between; gap: 8px; color: #E2E8F0; text-decoration: none; padding: 7px 20px; border-left: 4px solid transparent; }
.side a:hover { background: #38495C; }
.side a.on { background: #38495C; border-left-color: var(--brand); color: #fff; font-weight: 700; }
.side .grp { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: #9FB0C2; padding: 16px 20px 4px; font-weight: 700; }
.side .badge { background: var(--red); color: #fff; border-radius: 10px; padding: 0 7px; font-size: .8rem; font-weight: 700; align-self: center; }
.main { padding: 24px 28px 60px; min-width: 0; }
.crumbs { font-size: .92rem; margin-bottom: 8px; }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.head p { margin: 4px 0 0; max-width: 70ch; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 26px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; border-top: 4px solid var(--line); }
.tile b { display: block; font-size: 2rem; color: var(--slate); line-height: 1.1; }
.tile.bad { border-top-color: var(--red); } .tile.bad b { color: var(--red); }
.tile.warn { border-top-color: var(--amber); } .tile.warn b { color: var(--amber); }
.tile.good { border-top-color: var(--green); }
.pdca { margin: 0 0 26px; }
.pdca > h2 { display: flex; align-items: baseline; gap: 10px; border-bottom: 2px solid var(--brand); padding-bottom: 6px; margin-bottom: 12px; }
.pdca > h2 small { font-size: .9rem; font-weight: 400; color: var(--grey); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.rcard { display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; text-decoration: none; color: var(--grey); }
.rcard:hover { border-color: var(--green); box-shadow: 0 1px 6px rgba(45, 62, 80, .12); }
.rcard .cl { font-size: .8rem; color: var(--green-d); font-weight: 700; }
.rcard h3 { margin: 2px 0 6px; }
.rcard .n { font-size: 1.5rem; font-weight: 700; color: var(--slate); }
.rcard .pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pill { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: .85rem; font-weight: 700; background: #E9EEF3; color: var(--slate); white-space: nowrap; }
.pill.red { background: var(--red-l); color: #8E241A; } .pill.amber { background: var(--amber-l); color: #7A5210; } .pill.green { background: var(--green-l); color: #1D5E32; }

/* tables */
.tools { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.tools input[type=search] { max-width: 300px; } .tools select { width: auto; }
.tablewrap { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid #E8EDF2; }
th { background: #F1F4F7; color: var(--slate); font-size: .9rem; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.go { cursor: pointer; } tbody tr.go:hover { background: #F7FAF8; }
td.ref { font-weight: 700; color: var(--slate); white-space: nowrap; }
td.clip { max-width: 380px; }
.empty { background: #fff; border: 1px dashed #B9C4CF; border-radius: 10px; padding: 26px; text-align: center; }
.empty p { margin: 0 0 12px; }

/* record */
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 18px; align-items: start; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid2 .wide { grid-column: 1 / -1; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.panel > h2 { margin-bottom: 12px; }
.ro { padding: 9px 10px; background: #F1F4F7; border-radius: 6px; min-height: 40px; color: var(--slate); }
.items td .link { margin-right: 10px; }
.hist { font-size: .93rem; } .hist li { margin-bottom: 8px; } .hist .ch { display: block; color: var(--grey); }
.savebar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); margin-top: 6px; }

/* modal and toast */
.modal { position: fixed; inset: 0; background: rgba(45, 62, 80, .55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal[hidden], .toast[hidden] { display: none; }
.modal .box { background: #fff; border-radius: 10px; padding: 22px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; }
.modal .box h2 { margin-bottom: 12px; }
.modal .row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.toast { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); background: var(--slate); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 30; max-width: 92vw; }
.toast.bad { background: var(--red); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--grey); border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--slate); font-weight: 700; border-bottom-color: var(--brand); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; } .side.open { display: block; }
  .menu-btn { display: inline-block; }
  .main { padding: 16px 14px 60px; }
  .cols, .grid2 { grid-template-columns: 1fr; }
  .top { padding: 8px 12px; gap: 10px; } .top .who .nm { display: none; }
  table.stack thead { display: none; }
  table.stack tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.stack td { display: flex; gap: 10px; border: 0; padding: 3px 12px; max-width: none; }
  table.stack td::before { content: attr(data-l); font-weight: 700; color: var(--slate); flex: 0 0 38%; }
}
@media print { .top, .side, .savebar, .actions, .tools { display: none !important; } .shell { display: block; } body { background: #fff; } }
