:root {
  --green: #52b788;
  --green-light: #a3f7bf;
  --green-pale: #d4fdbc;
  --green-btn-disabled: #cce8d9;
  --dark: #343a40;
  --red: #e60000;
  --maroon: #7e1d1d;
  --text: #333;
  --muted: #6c757d;
  --page-bg: #f5f7f7;
  --border: #dee2e6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Poppins", sans-serif; color: var(--text); background: #fff; font-size: 14px; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
.hidden { display: none !important; }

/* ---------------- login ---------------- */
.login-page { min-height: 100vh; background: var(--green-pale); display: flex; justify-content: center;
  align-items: flex-start; padding: 64px 16px 32px; font-family: "Montserrat", sans-serif; }
.login-card { background: #fff; width: 460px; max-width: 100%; padding: 40px 24px 32px; border-radius: 4px;
  box-shadow: 0 10px 30px rgba(0,0,0,.05); }
.login-card .logo { display: block; margin: 0 auto 30px; width: 104px; }
.login-card h1 { text-align: center; font-weight: 500; font-size: 21px; letter-spacing: .5px; margin: 0 0 22px; }
.login-card label { display: block; font-size: 14px; color: #444; margin: 0 0 8px; }
.login-card input { width: 100%; height: 40px; border: 1px solid #c7cfe2; background: #e8f0fe; border-radius: 4px;
  padding: 0 12px; font-size: 14px; margin-bottom: 20px; outline: none; font-family: "Montserrat", sans-serif; }
.login-card input:focus { border-color: var(--green); }
.login-card .btn-login { width: 100%; height: 40px; margin-top: 18px; background: var(--green-pale);
  border: 1px solid #4caf50; border-radius: 4px; font-size: 14px; font-family: "Montserrat", sans-serif; color: #222; }
.login-card .btn-login:hover { background: #c3f5a6; }
.login-error { color: var(--red); text-align: center; min-height: 20px; margin-top: 10px; font-size: 13px; }

/* ---------------- shell ---------------- */
.topbar { height: 64px; background: #fff; display: flex; align-items: center; padding: 0 28px 0 22px;
  position: sticky; top: 0; z-index: 20; }
.topbar .logo { width: 28px; }
.topbar .burger { background: none; border: 0; margin-left: 34px; padding: 4px; }
.topbar .burger span { display: block; width: 22px; height: 2px; background: #333; margin: 5px 0; }
.topbar .user { margin-left: auto; position: relative; }
.topbar .user button { background: none; border: 0; font-size: 15px; color: #444; display: flex; gap: 14px; align-items: center; }
.topbar .user .menu { position: absolute; right: 0; top: 34px; background: #fff; border: 1px solid var(--border);
  border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.08); min-width: 140px; }
.topbar .user .menu a { display: block; padding: 10px 16px; color: #333; text-decoration: none; font-size: 14px; }
.topbar .user .menu a:hover { background: var(--page-bg); }
.shell { display: flex; min-height: calc(100vh - 64px); }
.sidebar { width: 72px; background: #fff; padding-top: 18px; display: flex; flex-direction: column; align-items: center; gap: 30px;
  transition: width .2s; flex-shrink: 0; }
.sidebar a { color: #555; display: flex; align-items: center; gap: 12px; text-decoration: none; font-size: 14px; }
.sidebar a.active { color: #4caf50; }
.sidebar a svg { width: 24px; height: 24px; flex-shrink: 0; }
.sidebar .label { display: none; }
.sidebar.open { width: 180px; align-items: flex-start; padding-left: 24px; }
.sidebar.open .label { display: inline; }
.main { flex: 1; background: var(--page-bg); padding: 24px 24px 32px; min-width: 0; }

/* ---------------- dashboard ---------------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .3px; }
.range { position: relative; }
.range button { background: #fff; border: 1px solid var(--border); border-radius: 3px; padding: 8px 14px; font-size: 14px; color: #333; }
.range .menu { position: absolute; right: 0; top: 40px; background: #fff; border: 1px solid var(--border); border-radius: 4px;
  box-shadow: 0 6px 20px rgba(0,0,0,.08); z-index: 5; min-width: 140px; }
.range .menu a { display: block; padding: 8px 14px; color: #333; text-decoration: none; }
.range .menu a:hover { background: var(--page-bg); }
.grid-top { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.card { background: #fff; border-radius: 4px; padding: 20px; min-width: 0; }
.card h3 { margin: 0 0 16px; font-size: 16px; font-weight: 600; color: #333; }
.pies { display: flex; justify-content: space-around; flex-wrap: wrap; gap: 16px; }
.pie-box { text-align: center; }
.pie-box .pie-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.pie-box svg { width: 170px; height: 170px; }
.pie-box .no-data { width: 170px; height: 170px; border-radius: 50%; border: 2px dashed #cfd8dc; display: flex; align-items: center;
  justify-content: center; text-align: center; color: var(--muted); font-size: 12px; padding: 20px; margin: 0 auto; }
.legend { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; margin: 14px auto 0; width: max-content; color: #555; font-size: 13px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.legend b { font-weight: 600; color: #333; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 17px; font-weight: 600; color: #2d6a4f; margin-top: 2px; }
.desc .note { font-size: 12px; color: var(--muted); margin: 12px 0 0; line-height: 1.5; }
table.dark { width: 100%; border-collapse: collapse; }
table.dark th { background: var(--dark); color: #fff; text-align: left; padding: 11px 12px; font-size: 13px; font-weight: 600; }
table.dark td { padding: 9px 12px; border-bottom: 1px solid #eee; font-size: 13px; }
table.dark td a { color: var(--green); text-decoration: none; }
table.dark td.none { color: var(--muted); text-align: center; padding: 18px; }

/* ---------------- upload ---------------- */
.upload-card { background: #fff; border-radius: 4px; padding: 26px 24px 30px; }
.upload-card h1 { font-size: 30px; font-weight: 600; margin: 0; line-height: 1.15; color: #000; }
.upload-card .sub { margin: 2px 0 20px; font-size: 14px; color: #333; }
.drop { border: 2px dashed #c9c9c9; border-radius: 24px; height: 260px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; cursor: pointer; transition: background .15s;
  font-family: "Times New Roman", serif; }
.drop.over { background: #f1fbf5; border-color: var(--green); }
.drop .icon { width: 68px; height: 68px; border: 1px solid #ddd; border-radius: 8px; display: flex; align-items: center;
  justify-content: center; margin-bottom: 18px; background: #fff; }
.drop .icon svg { width: 40px; height: 46px; }
.drop .hint { color: #888; font-size: 15px; line-height: 1.5; }
.drop .hint b { color: #2d8a5f; font-weight: 400; }
.drop .file { margin-top: 10px; font-family: "Poppins", sans-serif; font-size: 13px; color: #333; }
.btn-upload { width: 100%; height: 46px; margin-top: 22px; border: 0; border-radius: 23px; background: var(--green);
  color: #fff; font-size: 16px; font-weight: 700; font-family: "Times New Roman", serif; }
.btn-upload:disabled { background: var(--green-btn-disabled); cursor: default; }
.upload-msg { margin-top: 12px; text-align: center; font-size: 14px; min-height: 22px; }
.upload-msg.err { color: var(--red); }
.spinner { display: inline-block; width: 15px; height: 15px; border: 3px solid #cde; border-top-color: var(--green);
  border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -3px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- pdf list ---------------- */
.list-head, .list-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) 96px 48px 72px 220px; align-items: center;
  column-gap: 12px; padding: 0 20px; }
.list-head { background: var(--green); color: #fff; border-radius: 10px; height: 46px; font-size: 15px; font-weight: 600; }
.list-head .csv-all, .list-row .csv { width: 24px; height: 28px; border: 0; background: none; padding: 0; }
.list-head .c, .list-row .c { text-align: center; }
.list-row { background: #fff; border-radius: 10px; min-height: 60px; margin-top: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.03); font-size: 14px; }
.list-row .visit { width: 20px; height: 20px; display: block; }
.list-row .title { font-weight: 600; color: var(--red); text-decoration: none; overflow-wrap: anywhere; padding: 8px 0; }
.list-row .title.done { color: #2d8a5f; }
.list-row .rev { font-size: 20px; font-weight: 700; color: var(--red); }
.list-row .rev.done { color: #2d8a5f; }
.list-row .date, .list-head .date-h { text-align: right; white-space: nowrap; }
.list-row .date { color: #555; font-size: 13px; }
.cost-btn { background: #fff; border: 1px solid var(--green); color: #2d8a5f; border-radius: 14px; padding: 3px 10px; font-size: 12px; }
.cost-btn:hover { background: #ecf8f1; }
.cost-pop { position: absolute; z-index: 30; background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 12px 14px; font-size: 13px; min-width: 210px; }
.cost-pop .row { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; }
.cost-pop .row b { color: #2d6a4f; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; background: #fff; border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; }
.filters input, .filters select { height: 34px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; font-size: 13px; }
.filters input { flex: 1; min-width: 180px; }
.empty { text-align: center; color: var(--muted); padding: 36px; }
.icon-btn { background: none; border: 0; padding: 0; }

/* ---------------- review ---------------- */
.review { display: flex; height: 100vh; overflow: hidden; background: #3a3a3a; }
.review .left { width: 48%; min-width: 440px; background: #fff; display: flex; flex-direction: column; }
.review .bar { background: #000; height: 64px; display: flex; align-items: center; padding: 0 18px; flex-shrink: 0; gap: 14px; }
.review .bar .back { background: none; border: 0; padding: 0; display: flex; }
.review .bar .back svg { width: 24px; height: 24px; }
.review .bar .doc-title { color: #e0e0e0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.review .bar .cost-btn { background: transparent; color: #b7e4c7; border-color: #52b788; flex-shrink: 0; }
.review .bar .btn-final { margin-left: auto; background: var(--maroon); color: #fff; border: 1px solid #fff; border-radius: 24px;
  padding: 9px 18px; font-family: "Times New Roman", serif; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.review .bar .btn-final:disabled { opacity: .6; }
.review .form { flex: 1; overflow-y: auto; font-family: "Montserrat", sans-serif; }
.review .frow { display: grid; grid-template-columns: 170px 1fr; align-items: center; border-bottom: 1px solid #e5e5e5;
  padding: 7px 0; min-height: 52px; }
.review .frow label { font-size: 15px; color: #555; padding-left: 12px; }
.review input.fi { height: 38px; border: 1px solid #b7e4c7; border-radius: 5px; padding: 0 10px; font-size: 14px;
  font-family: "Montserrat", sans-serif; width: 100%; max-width: 420px; outline: none; color: #111; }
.review input.fi:focus, .review input.ci:focus { border-color: var(--green); box-shadow: 0 0 0 2px #d8f3dc; }
.review .addr-head, .review .addr-row { display: grid; grid-template-columns: 96px repeat(5, minmax(0, 1fr)); align-items: center; }
.review .addr-head { margin-top: 18px; background: #111; color: #fff; font-weight: 600; font-size: 14px; text-align: center;
  min-height: 52px; font-family: "Poppins", sans-serif; line-height: 1.25; }
.review .addr-row { border-bottom: 1px solid #e5e5e5; padding: 10px 0; }
.review .addr-row label { font-size: 15px; color: #555; padding-left: 12px; line-height: 1.3; }
.review input.ci { height: 38px; border: 1px solid #b7e4c7; border-radius: 5px; padding: 0 8px; font-size: 14px;
  font-family: "Montserrat", sans-serif; width: calc(100% - 10px); margin: 0 5px; outline: none; color: #111; min-width: 0; }
.review .items-head, .review .item-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.4fr 32px; align-items: center; }
.review .items-head { margin-top: 18px; background: #111; color: #fff; font-weight: 600; font-size: 14px; min-height: 44px;
  padding-left: 7px; font-family: "Poppins", sans-serif; }
.review .item-row { padding: 8px 0; border-bottom: 1px solid #e5e5e5; }
.review .item-row .del { background: none; border: 0; color: #c00; font-size: 20px; }
.review .add-line { margin: 12px 10px 28px; background: #fff; border: 1px dashed var(--green); color: #2d8a5f; border-radius: 6px; padding: 7px 14px; font-size: 13px; }
.review .po-switch { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px; background: #f1fbf5;
  border-bottom: 1px solid #b7e4c7; padding: 8px 12px; font-family: "Poppins", sans-serif; }
.review .po-switch .nav { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--green); background: #fff;
  color: #2d6a4f; font-size: 20px; line-height: 1; padding: 0; }
.review .po-switch .nav:disabled { opacity: .35; cursor: default; }
.review .po-switch .po-info { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; color: #333; }
.review .po-switch .po-info b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review .po-switch .po-info span { color: var(--muted); font-size: 12px; }
.review .po-switch .ok { color: #2d8a5f; font-weight: 600; }
.review .po-switch .todo { color: #c00; font-weight: 600; }
.review .po-switch .save-po { background: var(--green); color: #fff; border: 0; border-radius: 16px; padding: 7px 14px; font-size: 13px; flex-shrink: 0; }
.list-row .po-badge { display: inline-block; font-size: 11px; font-weight: 600; color: #2d6a4f; background: #e3f5ea;
  border: 1px solid #b7e4c7; border-radius: 10px; padding: 1px 8px; vertical-align: 2px; margin-left: 6px; }
.list-row .rev .part { font-size: 13px; color: #b26a00; font-weight: 600; }
.review .right { flex: 1; display: flex; }
.review .right iframe { border: 0; width: 100%; height: 100%; background: #525659; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #2d6a4f; color: #fff; padding: 10px 18px;
  border-radius: 6px; z-index: 50; font-size: 14px; }
.toast.err { background: #b00020; }

@media (max-width: 1000px) {
  .grid-top, .grid-bottom { grid-template-columns: 1fr; }
  .list-head, .list-row { grid-template-columns: 40px minmax(0, 1fr) 70px 36px 64px 150px; padding: 0 12px; column-gap: 8px; }
  .list-row .date { font-size: 12px; }
  .review { flex-direction: column; height: auto; }
  .review .left { width: 100%; min-width: 0; }
  .review .right { height: 80vh; }
}
