* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: #F2F3F5; color: #111827; font-size: 15px;
}
.boot { padding: 3rem; color: #6B7280; }

/* Top bar */
.topbar {
    display: flex; align-items: center; gap: 1.25rem;
    background: #512BD4; color: #fff; padding: 0 1.25rem; height: 52px;
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; margin-right: .5rem; }
.topbar a { color: #DDD3F9; text-decoration: none; padding: .35rem .6rem; border-radius: 8px; }
.topbar a:hover { background: rgba(255,255,255,.12); color: #fff; }
.topbar a.active { background: rgba(255,255,255,.18); color: #fff; }
.topbar .spacer { flex: 1; }
.topbar .user { color: #DDD3F9; font-size: .85rem; }
.topbar button {
    background: transparent; color: #DDD3F9; border: 1px solid rgba(255,255,255,.35);
    border-radius: 8px; padding: .3rem .7rem; cursor: pointer;
}
.topbar button:hover { color: #fff; border-color: #fff; }

.page { padding: 1.25rem; max-width: 1400px; margin: 0 auto; }

/* Cards & forms */
.card {
    background: #fff; border-radius: 14px; padding: 1.1rem 1.25rem;
    box-shadow: 0 1px 2px rgba(17,24,39,.06);
}
.field { margin-bottom: .8rem; }
.field label { display: block; font-size: .78rem; font-weight: 600; color: #9CA3AF; margin-bottom: .25rem; }
.field input, .field select, .field textarea {
    width: 100%; padding: .5rem .65rem; border: 1px solid #E5E7EB; border-radius: 8px;
    font: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid #512BD4; outline-offset: 0; border-color: transparent;
}
.row { display: flex; gap: .8rem; }
.row > * { flex: 1; }

.btn {
    display: inline-block; border: none; border-radius: 9px; cursor: pointer;
    padding: .55rem 1.1rem; font: inherit; font-weight: 600;
}
.btn-primary { background: #512BD4; color: #fff; }
.btn-primary:hover { background: #4423b8; }
.btn-primary:disabled { background: #B7A8EA; cursor: default; }
.btn-quiet { background: #EEF2FF; color: #3730A3; }
.btn-quiet:hover { background: #e2e8fd; }

.error { color: #DC2626; font-size: .9rem; margin: .5rem 0; }
.hint { color: #6B7280; font-size: .85rem; }

/* Suggestions (GHL matches / addresses) */
.suggest { border: 1px solid #E5E7EB; border-radius: 8px; margin-top: .25rem; overflow: hidden; }
.suggest div { padding: .5rem .7rem; cursor: pointer; background: #F9FAFB; }
.suggest div:hover { background: #EEF2FF; }

/* Week schedule */
.weekbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.weekbar h2 { font-size: 1.1rem; }
.weekbar button { border: none; background: #fff; border-radius: 8px; width: 34px; height: 34px;
    font-size: 1.2rem; cursor: pointer; box-shadow: 0 1px 2px rgba(17,24,39,.08); }
.weekgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: .6rem; }
.daycol { background: #fff; border-radius: 12px; padding: .6rem; min-height: 320px;
    display: flex; flex-direction: column; gap: .5rem; }
.daycol .dayhead { text-align: center; font-size: .8rem; color: #6B7280; padding-bottom: .3rem;
    border-bottom: 1px solid #F3F4F6; }
.daycol .dayhead b { display: block; font-size: 1.05rem; color: #111827; }
.daycol.today .dayhead b { color: #512BD4; }
.addslot { border: 1px dashed #D1D5DB; background: none; color: #9CA3AF; border-radius: 8px;
    padding: .3rem; cursor: pointer; font: inherit; font-size: .85rem; }
.addslot:hover { border-color: #512BD4; color: #512BD4; }

.jobcard { border-radius: 10px; padding: .5rem .6rem; border-left: 4px solid; cursor: default; }
.jobcard .t { font-size: .78rem; font-weight: 700; color: #374151; }
.jobcard .n { font-weight: 700; margin: .1rem 0; }
.jobcard .m { font-size: .78rem; color: #6B7280; }
.jobcard .urgent { color: #DC2626; font-size: .72rem; font-weight: 700; }

.s-open        { background: #EFEAFB; border-color: #7C3AED; }
.s-ontheway    { background: #E1EFFE; border-color: #2563EB; }
.s-inprogress  { background: #FBF1DD; border-color: #D97706; }
.s-quotegiven  { background: #DBF0ED; border-color: #0D9488; }
.s-completed   { background: #E6F4EC; border-color: #16A34A; }
.s-cancelled   { background: #FCE8E8; border-color: #DC2626; }

/* Hour-grid week view (parity with the Windows app's week grid) */
.hgrid-wrap { background: #fff; border-radius: 12px; overflow: hidden;
    box-shadow: 0 1px 2px rgba(17,24,39,.06); }
.hgrid-days { display: grid; grid-template-columns: 48px repeat(7, 1fr); background: #fff;
    border-bottom: 1px solid #E5E7EB; }
.hgrid-days .dhead { text-align: center; padding: .45rem 0 .4rem; font-size: .78rem; color: #6B7280; }
.hgrid-days .dhead b { display: block; font-size: 1.05rem; color: #111827; }
.hgrid-days .dhead.today b { color: #512BD4; }
.hgrid-scroll { overflow-y: auto; height: calc(100vh - 210px); user-select: none; }
.hgrid-body { display: grid; grid-template-columns: 48px repeat(7, 1fr); }
.hgrid-axis { position: relative; }
.hgrid-axis div { height: 48px; font-size: .68rem; color: #9CA3AF; text-align: center;
    transform: translateY(-.55em); }
.hgrid-col { position: relative; border-left: 1px solid #F3F4F6; height: 1152px; /* 24 × 48px */
    background: repeating-linear-gradient(to bottom, transparent 0 47px, #F3F4F6 47px 48px);
    cursor: crosshair; }
.hjob { position: absolute; left: 3px; right: 3px; border-radius: 8px; border-left: 4px solid;
    padding: .2rem .4rem; overflow: hidden; z-index: 2; cursor: default; font-size: .74rem; }
.hjob .t { font-weight: 700; color: #374151; }
/* Name on the left, assigned-tech badge pinned right on the same line. */
.hjob .n { font-weight: 700; color: #111827; display: flex; align-items: center;
    justify-content: space-between; gap: .25rem; }
.hjob .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hjob .m { color: #6B7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hjob .urgent { color: #DC2626; font-size: .66rem; font-weight: 700; }
.hsel { position: absolute; left: 3px; right: 3px; background: rgba(81,43,212,.25);
    border: 2px solid #512BD4; border-radius: 6px; z-index: 3; pointer-events: none; }

/* Assigned-tech initials avatar on schedule blocks */
.tech-badge { display: inline-flex; align-items: center; justify-content: center;
    width: 15px; height: 15px; border-radius: 50%; background: #512BD4; color: #fff;
    font-size: .56rem; font-weight: 700; vertical-align: -2px; flex: none; }

/* Custom status dropdown (color dot on the button and on every option) */
.status-btn { display: flex; align-items: center; gap: .5rem; width: 100%;
    padding: .5rem .65rem; border: 1px solid #E5E7EB; border-radius: 8px;
    background: #fff; font: inherit; cursor: pointer; }
.status-btn:focus { outline: 2px solid #512BD4; border-color: transparent; }
.status-menu { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff;
    border: 1px solid #E5E7EB; border-radius: 8px; box-shadow: 0 10px 24px rgba(17,24,39,.12);
    z-index: 30; overflow: hidden; }
.status-item { display: flex; align-items: center; gap: .5rem; width: 100%;
    padding: .5rem .65rem; border: none; background: #fff; font: inherit; cursor: pointer;
    text-align: left; }
.status-item:hover { background: #F3F4F6; }
.status-dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.menu-backdrop { position: fixed; inset: 0; z-index: 29; }

/* Custom time picker (Firefox has no native time popup) */
.tf-input { width: 100%; padding: .5rem .65rem; border: 1px solid #E5E7EB; border-radius: 8px;
    font: inherit; background: #fff; }
.tf-input:focus { outline: 2px solid #512BD4; border-color: transparent; }
.tf-menu { max-height: 238px; overflow-y: auto; }
.tf-sel { background: #EEF2FF; font-weight: 600; }

/* Account dropdown in the top bar */
.topbar .account-menu { position: absolute; right: 0; top: calc(100% + 8px); background: #fff;
    border-radius: 10px; box-shadow: 0 10px 30px rgba(17,24,39,.25); min-width: 180px;
    z-index: 40; display: flex; flex-direction: column; padding: .3rem; }
.topbar .account-menu a, .topbar .account-menu button { color: #111827; background: none;
    border: none; text-align: left; padding: .5rem .7rem; border-radius: 8px; font: inherit;
    cursor: pointer; text-decoration: none; }
.topbar .account-menu a:hover, .topbar .account-menu button:hover { background: #F3F4F6; color: #111827; }

/* List rows (messages, phone, employees, dump sites) */
.listrow { display: flex; justify-content: space-between; align-items: center; gap: .8rem;
    padding: .6rem .2rem; border-bottom: 1px solid #F3F4F6; cursor: pointer; }
.listrow:hover { background: #F9FAFB; }
.listrow .hint { font-size: .8rem; }

/* Messages: two-pane inbox */
.msg-wrap { display: grid; grid-template-columns: 330px 1fr; gap: 1rem;
    height: calc(100vh - 100px); }
.msg-list { background: #fff; border-radius: 14px; overflow-y: auto;
    box-shadow: 0 1px 2px rgba(17,24,39,.06); }
.msg-list-head { padding: .95rem 1.1rem; border-bottom: 1px solid #F3F4F6;
    position: sticky; top: 0; background: #fff; z-index: 1; }
.msg-row { display: flex; align-items: center; gap: .7rem; padding: .7rem 1rem;
    cursor: pointer; border-bottom: 1px solid #F7F8F9; }
.msg-row:hover { background: #FAFAFB; }
.msg-row.active { background: #F3EFFD; box-shadow: inset 3px 0 0 #512BD4; }
.msg-row-text { min-width: 0; flex: 1; }
.msg-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.msg-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-time { color: #9CA3AF; font-size: .72rem; flex: none; }
.msg-preview { color: #6B7280; font-size: .82rem; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; margin-top: .1rem; }
.msg-avatar { width: 34px; height: 34px; border-radius: 50%; background: #512BD4; color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: .78rem;
    font-weight: 700; flex: none; }
.msg-avatar.big { width: 38px; height: 38px; font-size: .85rem; }

.msg-thread { background: #fff; border-radius: 14px; display: flex; flex-direction: column;
    overflow: hidden; box-shadow: 0 1px 2px rgba(17,24,39,.06); }
.msg-empty { margin: auto; text-align: center; color: #9CA3AF; }
.msg-head { display: flex; align-items: center; gap: .7rem; padding: .8rem 1.1rem;
    border-bottom: 1px solid #F3F4F6; }
.msg-back { display: none; border: none; background: none; font-size: 1.5rem; color: #512BD4;
    cursor: pointer; padding: 0 .3rem; }
.msg-body { flex: 1; overflow-y: auto; padding: 1.1rem; display: flex; flex-direction: column;
    gap: .45rem; background: #FBFBFC; }
.msg-compose { display: flex; gap: .5rem; padding: .75rem 1rem; border-top: 1px solid #F3F4F6; }
.msg-compose input { flex: 1; padding: .6rem .9rem; border: 1px solid #E5E7EB;
    border-radius: 22px; font: inherit; }
.msg-compose input:focus { outline: 2px solid #512BD4; border-color: transparent; }

/* Chat bubbles */
.bubble { max-width: 72%; padding: .5rem .75rem; border-radius: 16px; font-size: .92rem;
    line-height: 1.35; box-shadow: 0 1px 1px rgba(17,24,39,.05); word-break: break-word; }
.bubble.in { background: #fff; border: 1px solid #EFEFF2; align-self: flex-start;
    border-bottom-left-radius: 5px; }
.bubble.out { background: #512BD4; color: #fff; align-self: flex-end;
    border-bottom-right-radius: 5px; }
.bubble .stamp { font-size: .67rem; margin-top: .2rem; text-align: right; }
.bubble.in .stamp { color: #9CA3AF; }
.bubble.out .stamp { color: rgba(255,255,255,.75); }

/* One pane at a time on small screens */
@media (max-width: 820px) {
    .msg-wrap { grid-template-columns: 1fr; height: calc(100vh - 90px); }
    .msg-wrap .msg-thread { display: none; }
    .msg-wrap.showing-thread .msg-list { display: none; }
    .msg-wrap.showing-thread .msg-thread { display: flex; }
    .msg-back { display: block; }
}

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 380px; }
.login-card h1 { color: #512BD4; font-size: 1.5rem; margin-bottom: 1rem; }
