/* =========================================================
   BTB Helper – Clean Professional Light Theme (FINAL)
   CLEANED: no overlapping/duplicate blocks for bulkRow
========================================================= */

* { box-sizing: border-box; }

:root{
  --bg:#f7f9fc;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e6eaf2;

  --accent:#16a34a;
  --accent-dark:#15803d;
  --accent-soft: rgba(22, 163, 74, 0.10);

  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 10px 26px rgba(15, 23, 42, 0.06);

  --radius:16px;
}

/* =========================================================
   BASE
========================================================= */

html, body{
  margin:0; padding:0; height:100%;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, "Noto Sans", sans-serif;
  background:var(--bg);
  color:var(--text);
}

/* Subtle background effect */
body{
  background-image:
    radial-gradient(circle at 25% 10%, rgba(22, 163, 74, 0.06), transparent 40%),
    radial-gradient(circle at 85% 25%, rgba(22, 163, 74, 0.05), transparent 45%);
}

/* =========================================================
   GLOBAL BUTTON
========================================================= */

.btn{
  padding:10px 14px;
  border-radius:12px;
  border:1px solid #cbd5e1;
  background:#fff;
  cursor:pointer;
  font-weight:600;
  transition:0.15s ease;
}
.btn:hover{ background:#f8fafc; transform: translateY(-1px); }
.btn:disabled{ opacity:.55; cursor:not-allowed; }

/* =========================================================
   LOGIN
========================================================= */

.login-wrapper{
  min-height:100vh;
  display:flex;
  justify-content:center;
  align-items:center;
  padding:28px 18px;
}

.login-box{
  width:420px;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:40px;
}

.login-box h2{
  margin:0 0 26px 0;
  text-align:center;
}

.login-box input{
  width:100%;
  padding:12px 14px;
  margin-bottom:14px;
  border-radius:12px;
  border:1px solid var(--border);
}

.login-box input:focus{
  outline:none;
  border-color: rgba(22, 163, 74, 0.55);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.login-box button{
  width:100%;
  padding:12px;
  border-radius:12px;
  border:none;
  background:var(--accent);
  color:#fff;
  font-weight:700;
  cursor:pointer;
}

.login-box button:hover{ background:var(--accent-dark); }

.login-error{
  color:#b91c1c;
  background: rgba(220, 38, 38, 0.06);
  border:1px solid rgba(220, 38, 38, 0.16);
  padding:10px 12px;
  border-radius:12px;
  margin-bottom:14px;
  text-align:center;
}

/* =========================================================
   DASHBOARD
========================================================= */

.container{
  max-width:980px;
  margin:0 auto;
  padding:110px 18px 50px;
  text-align:center;
}

.menu{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:16px;
}

.menu a{
  text-decoration:none;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  padding:18px;
  box-shadow:var(--shadow-soft);
  color:var(--text);
  font-weight:700;
  transition:0.15s ease;
}

.menu a:hover{
  transform: translateY(-2px);
  border-color: rgba(22, 163, 74, 0.35);
}

.menu a::after{
  content:"→";
  float:right;
  color:var(--accent);
  font-weight:900;
}

/* =========================================================
   LOGO
========================================================= */

.brand-logo{
  display:flex;
  justify-content:center;
  margin-bottom:16px;
}

.brand-logo img{ height:48px; }
.brand-logo.large img{ height:64px; }

/* =========================================================
   GLOBAL TOPBAR (Back | Logo | Refresh)
========================================================= */

.page-topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin:0 0 10px 0;
}

.page-topbar .top-left,
.page-topbar .top-right{
  min-width:150px;
  display:flex;
  align-items:center;
}

.page-topbar .top-right{ justify-content:flex-end; }

.page-topbar .top-center{
  flex:1;
  display:flex;
  justify-content:center;
}

.page-topbar a.logoLink{
  display:flex;
  align-items:center;
  justify-content:center;
  text-decoration:none;
}

.page-topbar a.logoLink img{
  max-height:46px;
  cursor:pointer;
}

/* Topbar buttons */
.page-topbar .navBtn{
  padding:8px 14px;
  border-radius:12px;
  border:1px solid #cbd5e1;
  background:#fff;
  cursor:pointer;
  font-size:13px;
  font-weight:700;
  transition:0.15s ease;
}

.page-topbar .navBtn:hover{
  background:#f1f5f9;
  transform: translateY(-1px);
}

/* =========================================================
   TYPO TIGHTENING
========================================================= */

h1,h2,h3{ margin:6px 0; }

.muted{
  color:var(--muted);
  font-size:13px;
  margin:0;
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width:860px){
  .menu{ grid-template-columns:1fr; }
}

@media (max-width:900px){
  .page-topbar .top-left,
  .page-topbar .top-right{ min-width:110px; }
}

.footer-actions{ margin-top:30px; }

/* =========================================================
   CLIENT LIST COMPACT — SCOPED (only on body.page-clients)
========================================================= */

body.page-clients .wrap{ max-width:none; width:100%; margin:0; padding:20px 18px 28px; }
@media (min-width:1400px){
  body.page-clients .wrap{ padding-left:36px; padding-right:36px; }
}

body.page-clients .row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:flex-end;
  margin:10px 0;
}

/* only clients page inputs */
body.page-clients input,
body.page-clients textarea{
  padding:8px 10px;
  border:1px solid #cbd5e1;
  border-radius:10px;
}
body.page-clients input{ height:38px; }

body.page-clients .page-header{ margin:0 0 10px 0; }
body.page-clients .page-header-top{
  display:flex; align-items:center; justify-content:space-between;
  gap:10px; margin-bottom:8px;
}
body.page-clients .page-header-top .logoLink{
  display:inline-flex; align-items:center; justify-content:center;
  text-decoration:none; flex:1;
}
body.page-clients .page-header-top .logoLink img{
  max-height:40px; width:auto; display:block;
}
body.page-clients .page-header-top .navBtn{
  padding:8px 12px;
  border-radius:12px;
  border:1px solid #cbd5e1;
  background:#fff;
  cursor:pointer;
  font-size:12px;
  font-weight:700;
  color:#0f172a;
  box-shadow: 0 10px 18px rgba(15,23,42,0.06);
  transition:transform .12s ease, background .12s ease, border-color .12s ease;
  white-space:nowrap;
  min-width:108px;
}
body.page-clients .page-header-top .navBtn:hover{
  background:#f8fafc;
  border-color:#94a3b8;
  transform: translateY(-1px);
}
body.page-clients .page-title h2{
  margin:0 0 3px 0;
  font-size:18px;
}

/* table container */
body.page-clients .tableWrap{
  width:100%;
  background:#fff;
  border:1px solid #e2e8f0;
  border-radius:14px;
  overflow:auto;
}

/* table */
body.page-clients table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  min-width:1200px;
}
body.page-clients thead th{
  position:sticky;
  top:0;
  z-index:5;
  background:#f8fafc;
  border-bottom:1px solid #e2e8f0;
  font-weight:700;
}

/* TOP ALIGN */
body.page-clients th,
body.page-clients td{
  padding:4px 8px;
  border-bottom:1px solid #eef2f7;
  font-size:12px;
  line-height:1.15;
  vertical-align:top;
  white-space:nowrap;
}

body.page-clients tbody tr{ height:34px; }
body.page-clients tbody tr.changed{ background:#ffe4e6; }
body.page-clients tbody tr:hover{ background:#f8fafc; }

/* columns */
body.page-clients th.col-status, body.page-clients td.col-status{ width:70px; }
body.page-clients th.col-reg,    body.page-clients td.col-reg{ width:110px; }
body.page-clients th.col-type,   body.page-clients td.col-type{ width:70px; }
body.page-clients th.col-date,   body.page-clients td.col-date{ width:90px; }
body.page-clients th.col-term,   body.page-clients td.col-term{ width:70px; }
body.page-clients th.col-vplg,   body.page-clients td.col-vplg{ width:120px; }

body.page-clients th.col-name, body.page-clients td.col-name{ min-width:220px; }
body.page-clients th.col-addr, body.page-clients td.col-addr{ width:180px; }

body.page-clients th.col-k, body.page-clients td.col-k{ width:170px; }
body.page-clients th.col-actions, body.page-clients td.col-actions{ width:56px; text-align:center; }

/* Right sticky save column */
body.page-clients th.col-actions,
body.page-clients td.col-actions{
  position:sticky;
  right:0;
  z-index:6;
  background:#fff;
  border-left:1px solid #eef2f7;
}
body.page-clients thead th.col-actions{
  background:#f8fafc;
  z-index:7;
}

/* pills */
body.page-clients .pill{
  display:inline-block;
  padding:2px 8px;
  border:1px solid #cbd5e1;
  border-radius:999px;
  font-size:11px;
  line-height:1.1;
}
body.page-clients .pill.ok{ border-color:#86efac; }
body.page-clients .pill.bad{ border-color:#fda4af; background:#ffe4e6; }
body.page-clients .link{ color:#2563eb; cursor:pointer; text-decoration:underline; }

/* name + addr ellipsis/wrap */
body.page-clients .cellEllip{
  display:block;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
body.page-clients .cellEllip.name{ max-width:280px; }
body.page-clients .cellWrap{
  display:block;
  white-space:normal;
  word-break:break-word;
  line-height:1.25;
  max-width:180px;
}

/* 1-line comment preview input */
body.page-clients .commentCell{
  width:100%;
  height:24px;
  padding:3px 8px;
  border:1px solid #cbd5e1;
  border-radius:10px;
  font-size:12px;
  line-height:18px;
  background:#fff;
  cursor:pointer;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
body.page-clients .commentCell::placeholder{ color:#94a3b8; }

/* save icon button */
body.page-clients .iconBtn{
  width:28px; height:28px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid #cbd5e1;
  background:#fff;
  border-radius:10px;
  cursor:pointer;
  font-size:14px;
}
body.page-clients .iconBtn:hover{ background:#f8fafc; transform: translateY(-1px); }
body.page-clients .iconBtn:disabled{ opacity:.55; cursor:not-allowed; transform:none; }

/* modals */
body.page-clients .modal{
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-start;
  justify-content: center;
  background: rgba(15,23,42,.55);
  padding: 18px 14px;
  z-index: 1000;
}
body.page-clients .modal.open{ display:flex; }
body.page-clients .modalCard{
  width: 96vw;
  max-width: 1200px;
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid #e2e8f0;
  max-height: 92vh;
  overflow: auto;
  box-shadow: 0 20px 50px rgba(15,23,42,0.12);
}
body.page-clients .modalHead{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:12px;
}
body.page-clients .grid2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:14px;
}
body.page-clients .box{
  border:1px solid #e2e8f0;
  border-radius:12px;
  padding:12px;
  background:#fafcff;
}
body.page-clients .box h4{ margin:0 0 10px 0; font-size:13px; }
body.page-clients .list{ white-space: pre-wrap; font-size: 13px; line-height: 1.4; }

@media (max-width: 900px){
  body.page-clients .modal{ padding: 0; }
  body.page-clients .modalCard{
    width:100vw; max-width:100vw;
    height:100vh; max-height:100vh;
    border-radius:0;
  }
  body.page-clients .grid2{ grid-template-columns: 1fr; }
}

/* COMMENT MODAL: editor full width */
body.page-clients #commentModal .box{ width: 100%; }

body.page-clients #commentModal #cEditor{
  display:block;
  width:100% !important;
  max-width:100% !important;
  min-width:100% !important;
  min-height:55vh;
  height:55vh;
  padding:12px 14px;
  resize:vertical;
  white-space:pre-wrap;
  overflow:auto;
  box-sizing:border-box;
}

/* =========================================================
   SYNC ALL progress box (scoped clean)
========================================================= */

body.page-clients .syncBox{
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,.70);
}

body.page-clients .syncTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  margin-bottom: 10px;
}

body.page-clients .syncTitle{
  font-weight: 800;
  margin-bottom: 2px;
}

body.page-clients .progressOuter{
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(15,23,42,0.10);
  overflow: hidden;
}

body.page-clients .progressInner{
  height: 100%;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.55);
  width: 0%;
  transition: width 160ms linear;
}

body.page-clients .syncMeta{
  display:flex;
  justify-content:space-between;
  gap: 12px;
  margin-top: 8px;
}

/* =========================================================
   BULK ROW (FINAL, single source of truth — no overlaps)
   Goal:
   - bulk textarea left
   - button immediately to the right of textarea (not centered on page)
   - button top aligned with textarea top (skip label height)
========================================================= */

body.page-clients .row.bulkRow{
  display:flex;
  flex-wrap:nowrap;
  align-items:flex-start;
  justify-content:flex-start;
  gap:16px;
}

body.page-clients .bulkLeft{
  /* controls how far the button is from the left side of the screen */
  flex: 0 1 720px;        /* change 720px if you want shorter/longer textarea */
  max-width: 720px;
}

body.page-clients .bulkLeft textarea{
  width:100%;
  min-height:74px;
}

body.page-clients .bulkRight{
  width: 240px;
  display:flex;
  flex-direction:column;
  gap:10px;

  /* align button top with textarea top (label height compensation) */
  padding-top: 20px;      /* tune 18–24px */
}

body.page-clients .bulkInfo{
  font-size:12px;
  line-height:1.3;
}

/* Mobile: stack */
@media (max-width: 900px){
  body.page-clients .row.bulkRow{
    flex-wrap:wrap;
  }
  body.page-clients .bulkLeft{
    flex:1 1 100%;
    max-width:none;
  }
  body.page-clients .bulkRight{
    width:100%;
    padding-top:0;
  }
}

/* =========================================================
   BUTTON VARIANT
========================================================= */

.btnPrimary{
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btnPrimary:hover{
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

/* =========================================================
   LOGIN REMEMBER ROW
========================================================= */

.login-box .rememberRow{
  display:flex;
  align-items:center;
  gap:10px;
  margin:4px 0 16px 0;
  font-size:14px;
  color:var(--text);
  cursor:pointer;
}

.login-box .rememberRow input[type="checkbox"]{
  width:16px;
  height:16px;
  margin:0;
  padding:0;
  border-radius:4px;
  accent-color: var(--accent);
  flex:0 0 auto;
}

.login-box .rememberRow span{
  line-height:1.2;
}

/* =========================================================
   USERS PAGE
========================================================= */

body.page-users .usersWrap{
  max-width:1100px;
  margin:0 auto;
  padding:42px 18px 48px;
}

body.page-users .usersTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  margin-bottom:22px;
}

body.page-users .usersTop h2{
  margin:0;
  font-size:36px;
  font-weight:800;
  letter-spacing:-0.02em;
}

body.page-users .usersTopActions{
  display:flex;
  align-items:center;
  gap:14px;
}

body.page-users .usersTopActions a{
  color:var(--text);
  text-decoration:none;
  font-weight:600;
}

body.page-users .usersTopActions a:hover{
  text-decoration:underline;
}

body.page-users .usersCard{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow:var(--shadow-soft);
  padding:22px;
  margin-bottom:22px;
}

body.page-users .usersCard h3{
  margin:0 0 18px 0;
  text-align:center;
  font-size:20px;
}

body.page-users .usersAlert{
  margin-bottom:16px;
  padding:12px 14px;
  border-radius:12px;
  font-size:14px;
  font-weight:600;
}

body.page-users .usersAlertOk{
  color:#166534;
  background:#ecfdf3;
  border:1px solid #bbf7d0;
}

body.page-users .usersAlertErr{
  color:#991b1b;
  background:#fef2f2;
  border:1px solid #fecaca;
}

body.page-users .usersForm{
  width:100%;
}

body.page-users .usersGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
}

body.page-users .usersGrid input{
  width:100%;
  height:44px;
  padding:10px 14px;
  border:1px solid var(--border);
  border-radius:12px;
  background:#fff;
}

body.page-users .usersGrid input:focus{
  outline:none;
  border-color: rgba(22, 163, 74, 0.55);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

body.page-users .usersCheck{
  display:flex;
  align-items:center;
  gap:10px;
  height:44px;
  padding:0 4px;
  font-weight:600;
  cursor:pointer;
}

body.page-users .usersCheck input[type="checkbox"]{
  width:16px;
  height:16px;
  margin:0;
  accent-color: var(--accent);
}

body.page-users .usersFormActions{
  display:flex;
  justify-content:center;
  margin-top:16px;
}

body.page-users .usersTableWrap{
  overflow:auto;
}

body.page-users .usersTable{
  width:100%;
  border-collapse:collapse;
}

body.page-users .usersTable th,
body.page-users .usersTable td{
  text-align:left;
  padding:14px 10px;
  border-bottom:1px solid #edf2f7;
  vertical-align:middle;
}

body.page-users .usersTable th{
  font-size:14px;
  font-weight:800;
  color:var(--text);
  background:transparent;
}

body.page-users .usersTable td{
  font-size:15px;
}

body.page-users .usersTable tr:hover{
  background:#fafcff;
}

body.page-users .usersTableAction{
  width:120px;
}

body.page-users .usersTableAction form{
  margin:0;
}

@media (max-width: 760px){
  body.page-users .usersTop{
    flex-direction:column;
    align-items:flex-start;
  }

  body.page-users .usersGrid{
    grid-template-columns:1fr;
  }

  body.page-users .usersTop h2{
    font-size:28px;
  }
}

.commentCellBtn{
  display:block;
  width:100%;
  min-height:32px;
  padding:6px 8px;
  border:1px solid #d0d7de;
  border-radius:6px;
  background:#fff;
  text-align:left;
  cursor:pointer;
  overflow:hidden;
  white-space:nowrap;
  text-overflow:ellipsis;
}

.commentCellBtn:hover{
  background:#f6f8fa;
}

.commentCellBtn:focus{
  outline:2px solid #2563eb;
  outline-offset:1px;
}