/* EZ Access CRM — brand: teal #1E5B52, terracotta #D9703C, sand #F7F0E6, ink #1F2A28 */
:root {
  --teal: #1E5B52; --teal-dark: #164640; --teal-soft: #E2EDEA;
  --terra: #D9703C; --terra-dark: #B85A2B; --terra-soft: #FBE9DE;
  --sand: #F7F0E6; --sand-2: #EFE5D5;
  --ink: #1F2A28; --muted: #5E6966; --line: #E4DDD2;
  --white: #fff; --danger: #B3261E; --danger-soft: #FCE8E6;
  --radius: 14px; --radius-sm: 9px;
  --shadow: 0 4px 16px rgba(22, 70, 64, .07);
  --font: "Nunito", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--sand); }
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--terra-dark); }
h1 { font-size: 1.6rem; margin: 0; font-weight: 800; }
h2 { font-size: 1.15rem; margin: 0; font-weight: 800; }
button, input, select, textarea { font: inherit; color: inherit; }

/* top bar */
.topbar { background: var(--teal); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 20px; height: 60px; display: flex; align-items: center; gap: 26px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { color: #fff; }
.brand strong { font-weight: 800; font-size: 1.1rem; }
.brand em { font-style: normal; font-weight: 700; font-size: .8rem; background: var(--terra); padding: 2px 7px; border-radius: 6px; margin-left: 2px; }
.brand img { border-radius: 9px; background: var(--sand); }
.mainnav { display: flex; gap: 4px; }
.mainnav a { color: #D5E5E1; padding: 6px 12px; border-radius: 8px; font-weight: 700; }
.mainnav a:hover, .mainnav a.active { background: rgba(255,255,255,.12); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.me { color: #BFD6D0; font-size: .85rem; }
.lang { background: transparent; border: 1.5px solid rgba(255,255,255,.5); color: #fff; border-radius: 999px; padding: 3px 12px; font-weight: 800; font-size: .85rem; cursor: pointer; }
.lang:hover { background: #fff; color: var(--teal); }

/* layout */
.page { max-width: 1240px; margin: 0 auto; padding: 26px 20px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 8px; }
.crumbs a { font-weight: 700; }
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 860px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.7rem; font-weight: 800; color: var(--teal); margin-top: 2px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: .92rem; border: 1.5px solid transparent; cursor: pointer; background: transparent; white-space: nowrap; }
.btn.primary { background: var(--terra); color: #fff; }
.btn.primary:hover { background: var(--terra-dark); }
.btn.teal { background: var(--teal); color: #fff; }
.btn.teal:hover { background: var(--teal-dark); }
.btn.ghost { border-color: var(--line); color: var(--ink); background: #fff; }
.btn.ghost:hover { border-color: var(--teal); color: var(--teal); }
.btn.danger { color: var(--danger); border-color: #EFC6C2; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 4px 11px; font-size: .82rem; }
.btn[disabled] { opacity: .6; cursor: wait; }
.link-btn { background: none; border: 0; padding: 0; color: var(--teal); font-weight: 700; cursor: pointer; font-size: .88rem; }
.link-btn:hover { color: var(--terra-dark); }
.link-btn.danger { color: var(--danger); }

/* search */
.search { position: relative; flex: 1; max-width: 420px; }
.search input { width: 100%; padding: 9px 14px 9px 38px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; }
.search input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.search::before { content: ""; position: absolute; left: 14px; top: 50%; width: 14px; height: 14px; transform: translateY(-50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235E6966' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.5' y2='16.5'/%3E%3C/svg%3E") center/contain no-repeat; }

/* filter bar */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters select { padding: 7px 10px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; font-size: .9rem; }
.filters select:focus { outline: none; border-color: var(--teal); }
.filters .search { min-width: 200px; }
.seg { display: inline-flex; background: var(--sand); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 5px 14px; border-radius: 999px; font-weight: 700; font-size: .88rem; cursor: pointer; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--teal); color: #fff; }
a.link-btn { margin-left: 12px; }
td.name-cell { min-width: 130px; }
td .badge, td.num { white-space: nowrap; }
@media (max-width: 1100px) { .hide-md { display: none; } }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -6px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid #F0EBE3; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #FBF8F3; }
td.num, th.num { text-align: right; white-space: nowrap; }
td .muted, .muted { color: var(--muted); font-size: .88rem; }
.actions { white-space: nowrap; text-align: right; }
.actions .link-btn + .link-btn { margin-left: 12px; }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--sand-2); color: var(--muted); white-space: nowrap; }
.badge.teal { background: var(--teal-soft); color: var(--teal-dark); }
.badge.terra { background: var(--terra-soft); color: var(--terra-dark); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.grey { background: #EEECE8; color: #7A7672; }
.badge.warn { background: #FBEFC5; color: #7A5900; }

/* telecom header: payment alerts (notice = yellow, suspend = orange, cancel = red) */
.stats.tel-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tel-stats .alert-card { grid-column: span 2; }
@media (max-width: 1100px) { .stats.tel-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.alert-card .label strong { color: var(--ink); font-size: 1rem; margin-left: 4px; }
.alert-card.has-alerts { box-shadow: 0 0 0 2px #F3C9B0 inset, var(--shadow); }
.alert-lvls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.alert-lvl { border: 0; border-radius: 10px; padding: 8px 10px; text-align: left; cursor: pointer; font: inherit; display: flex; flex-direction: column; line-height: 1.25; }
.alert-lvl .n { font-size: 1.45rem; font-weight: 800; }
.alert-lvl .l { font-weight: 800; font-size: .82rem; }
.alert-lvl .d { font-size: .72rem; opacity: .85; }
.alert-lvl.notice { background: #FBEFC5; color: #7A5900; }
.alert-lvl.suspend { background: #F9D9C2; color: #9A4316; }
.alert-lvl.cancel { background: #F6D2CE; color: #9B1C15; }
.alert-lvl:hover { filter: brightness(.96); }

/* customer page: clickable telecom counts and service list */
a.tel-pill.link { color: inherit; transition: background .15s, box-shadow .15s; }
a.tel-pill.link:hover { background: #CFE3DE; box-shadow: 0 0 0 2px var(--teal) inset; }
a.tel-pill.link.alert { background: #F9D9C2; }
a.tel-pill.link.alert .n, a.tel-pill.link.alert .l { color: #9A4316; }
.tel-list { list-style: none; margin: 4px 0 0; padding: 0; }
.tel-list li a { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 9px; color: var(--ink); }
.tel-list li + li a { border-top: 1px solid #F0EBE3; }
.tel-list li a:hover { background: #F6FAF9; color: var(--ink); }
.tel-list .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tel-list .right { white-space: nowrap; color: var(--muted); }
.tel-card.flash { animation: flash 2s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 3px var(--terra); } 100% { box-shadow: 0 0 0 0 transparent; } }

.tel-card-foot { align-items: center; flex-wrap: wrap; }
.tel-card-foot .spacer { flex: 1; }

/* read-only popup (payment history) */
dialog.viewer { width: min(760px, calc(100vw - 32px)); padding: 22px 24px 24px; }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.viewer-head h2 { margin: 0; }
#viewer-body { max-height: calc(100vh - 160px); overflow-y: auto; }
#viewer-body .table-wrap { margin: 0; }
#viewer-body th, #viewer-body td { padding: 9px 8px; }
.field.note .note-text { margin: 0; padding: 8px 11px; background: var(--teal-soft); color: var(--teal-dark); border-radius: var(--radius-sm); font-weight: 700; font-size: .9rem; }

/* customer info */
.info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin: 0; }
.info div { min-width: 0; }
.info dt { font-size: .78rem; color: var(--muted); font-weight: 700; }
.info dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.info .full { grid-column: 1 / -1; }
.info .pre { white-space: pre-wrap; }

/* telecom */
.tel-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.tel-pill { background: var(--teal-soft); border-radius: var(--radius-sm); padding: 10px 14px; min-width: 120px; }
.tel-pill .n { font-size: 1.35rem; font-weight: 800; color: var(--teal-dark); }
.tel-pill .l { font-size: .8rem; color: var(--teal-dark); }
.tel-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.tel-card { border: 1.5px solid var(--line); border-radius: var(--radius); padding: 16px 18px; background: #fff; }
.tel-card.inactive { background: #FAF8F5; }
.tel-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.tel-card .big { font-size: 1.15rem; font-weight: 800; overflow-wrap: anywhere; }
.tel-card .provider { color: var(--muted); font-weight: 700; font-size: .9rem; }
.tel-card .info { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tel-card-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid #F0EBE3; display: flex; justify-content: flex-end; gap: 14px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 26px 0 12px; }
.section-title h2 { font-size: 1.05rem; }

/* files */
.upload { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px; border: 1.5px dashed var(--line); border-radius: var(--radius-sm); margin-bottom: 12px; background: #FDFBF8; }
.upload select, .upload input[type=file] { font-size: .88rem; }
.upload select { padding: 6px 8px; border-radius: 8px; border: 1.5px solid var(--line); background: #fff; }

/* activity */
.activity { list-style: none; margin: 0; padding: 0; font-size: .86rem; }
.activity li { padding: 7px 0; border-bottom: 1px solid #F0EBE3; display: flex; gap: 10px; }
.activity li:last-child { border-bottom: 0; }
.activity time { color: var(--muted); white-space: nowrap; min-width: 118px; }
.activity.scroll { max-height: 420px; overflow-y: auto; padding-right: 4px; }
.section-activity { margin-top: 26px; }
.head-actions { display: flex; align-items: center; gap: 14px; }

/* customer search-and-pick (used in add forms) */
.cust-picker input[type=search] { width: 100%; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.cust-picker input[type=search]:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.cust-results { margin-top: 6px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: #FDFBF8; max-height: 260px; overflow-y: auto; }
.cust-hint { padding: 8px 12px; font-size: .82rem; color: var(--muted); }
.cust-row { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; border: 0; border-top: 1px solid #F0EBE3; background: transparent; padding: 8px 12px; text-align: left; cursor: pointer; font: inherit; }
.cust-row:first-child { border-top: 0; }
.cust-row:hover, .cust-row:focus { background: var(--teal-soft); outline: none; }
.cust-row .muted { font-size: .82rem; }
.cust-chosen { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1.5px solid var(--teal); border-radius: var(--radius-sm); background: var(--teal-soft); }

/* 安家: checklist tiles, progress bars, price list */
.buy-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 18px; }
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.svc-tile { border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; background: #fff; }
.svc-tile.off { background: #FAF8F5; border-style: dashed; }
.svc-tile.off .svc-name { color: var(--muted); }
.svc-tile.on { border-color: #B9D6CF; }
.svc-tile.done { background: var(--teal-soft); }
.svc-name { font-weight: 700; font-size: .92rem; line-height: 1.35; }
.svc-meta { font-size: .85rem; }
.svc-tile .link-btn { align-self: flex-start; font-size: .82rem; }
.svc-line { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; font: inherit; font-size: .85rem; line-height: 1.8; }
.svc-line:hover .badge { filter: brightness(.95); text-decoration: underline; }
.svc-subhead { font-size: .95rem; margin: 18px 0 10px; }
.pbar { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.pbar-track { width: 70px; height: 7px; border-radius: 99px; background: #E9E3DA; overflow: hidden; display: inline-block; }
.pbar-fill { display: block; height: 100%; background: var(--teal); border-radius: 99px; }
.pbar-text { font-size: .82rem; color: var(--muted); font-weight: 700; }
.strike { text-decoration: line-through; }
tr.row-off td { opacity: .55; }
.pkg-items { display: flex; flex-wrap: wrap; gap: 6px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 4px 12px; max-height: 330px; overflow-y: auto; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: #FDFBF8; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: .88rem; padding: 4px 0; cursor: pointer; font-weight: 400 !important; margin: 0 !important; }
.check input { width: auto !important; margin-top: 3px; }

/* dialog */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(22, 70, 64, .25); color: var(--ink); }
dialog::backdrop { background: rgba(22, 46, 42, .45); }
dialog form { padding: 24px 26px 22px; max-height: calc(100vh - 60px); overflow-y: auto; }
dialog h2 { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.field label { display: block; font-weight: 700; font-size: .86rem; margin-bottom: 5px; }
.field label .req { color: var(--terra); }
.field input, .field select, .field textarea { width: 100%; padding: 8px 11px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: #FDFBF8; }
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--teal); background: #fff; box-shadow: 0 0 0 3px var(--teal-soft); }
.form-error { color: var(--danger); font-weight: 700; min-height: 1.4em; margin: 12px 0 0; font-size: .9rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

.loading { color: var(--muted); padding: 40px 0; text-align: center; }

.lang, .mainnav a { white-space: nowrap; }
@media (max-width: 700px) {
  .topbar-inner { gap: 10px; padding: 0 14px; }
  .me { display: none; }
  .brand span { display: none; }
  .hide-sm { display: none; }
  td.name-cell { min-width: 130px; }
  .page { padding: 18px 14px 50px; }
  h1 { font-size: 1.35rem; }
  .info { grid-template-columns: 1fr; }
  .tel-cards { grid-template-columns: 1fr; }
}
