
@import "tailwind/application.css";

/* Staff sidebar: a compact rail keeps the toggle available when collapsed. */
.admin-layout { --sidebar-width: 18rem; padding-left: var(--sidebar-width); }
.admin-layout.sidebar-collapsed { --sidebar-width: 5rem; }
.admin-nav { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); z-index: 50; background: var(--theme-surface, #fff); border-right: 1px solid var(--theme-border, #e2e8f0); }
.admin-nav-shell { display: flex; flex-direction: column; height: 100dvh; }
.admin-nav-bar { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; min-height: 5rem; padding: 1rem; border-bottom: 1px solid var(--theme-border, #e2e8f0); }
.admin-menu-toggle { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex-shrink: 0; border: 1px solid var(--theme-border-strong, #d1d5db); border-radius: .5rem; color: var(--theme-text-secondary, #475569); }
.admin-menu-toggle:hover { background: var(--theme-surface-muted, #f1f5f9); }
.admin-navigation { display: flex; flex: 1; min-height: 0; flex-direction: column; gap: 1.5rem; overflow-y: auto; padding: 1rem; }
.admin-nav-links { display: flex; flex-direction: column; gap: .25rem; }
.admin-nav-links > a, .admin-nav-group > button { display: flex; align-items: center; min-height: 44px; width: 100%; padding: .65rem .75rem; border-radius: .5rem; text-align: left; font-size: .875rem; }
.admin-nav-group > button { justify-content: space-between; }
.admin-nav-group > button:hover, .admin-nav-links > a:hover { background: var(--theme-surface-muted, #f1f5f9); }
.admin-nav-group > button[aria-expanded="true"] { color: #1d4ed8; background: var(--theme-blue-bg, #eff6ff); }
.admin-nav-group > button[aria-expanded="true"] svg { transform: rotate(180deg); }
.admin-nav-submenu { margin: .25rem 0 .5rem .75rem; padding-left: .5rem; border-left: 1px solid var(--theme-border, #e2e8f0); }
.admin-nav-submenu a { display: flex; align-items: center; min-height: 44px; border-radius: .375rem; }
.admin-nav-links a[aria-current="page"] { color: #1d4ed8; background: var(--theme-blue-bg, #eff6ff); font-weight: 600; }
.admin-nav-account { display: flex; flex-direction: column; align-items: stretch; gap: .75rem; margin-top: auto; border-top: 1px solid var(--theme-border, #e2e8f0); padding-top: 1rem; font-size: .875rem; }
.admin-nav-account > span { overflow-wrap: anywhere; color: var(--theme-text-muted, #64748b); }
.admin-nav-account input { width: 100%; min-width: 0; }
.admin-nav-account button { min-height: 44px; }
.admin-nav-account .button_to > button { width: 100%; }
.admin-nav :is(a, button, input):focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.sidebar-collapsed .admin-navigation { display: none; }
.sidebar-collapsed .admin-nav-bar { flex-direction: column; gap: 1rem; padding-inline: .5rem; border-bottom: 0; }
.admin-main { min-width: 0; padding-top: 1.5rem; }

/* Table contents scroll within their card instead of widening the page. */
.admin-main :is(div, turbo-frame):has(> table) { max-width: 100%; overflow-x: auto; }

@media (max-width: 1023px) {
  .admin-layout, .admin-layout.sidebar-collapsed { padding-left: 0; padding-top: 4rem; }
  .admin-nav { width: 100%; bottom: auto; border-right: 0; border-bottom: 1px solid var(--theme-border, #e2e8f0); }
  .admin-nav-shell { height: auto; max-height: calc(100dvh - 1px); }
  .admin-nav-bar, .sidebar-collapsed .admin-nav-bar { flex-direction: row; min-height: 4rem; padding: .5rem 1rem; border-bottom: 0; }
  .admin-navigation { flex: 0 1 auto; border-top: 1px solid var(--theme-border, #e2e8f0); }
}

@media (max-width: 639px) {
  .admin-main { padding-inline: .75rem; }
  .admin-main > .container { padding-inline: 0; }
  .admin-main .flex.justify-between { flex-wrap: wrap; gap: .75rem; }
  .admin-main .flex.justify-between > * { min-width: 0; }
  .admin-main h1 { overflow-wrap: anywhere; }
}

/* Customer workspace: compact overview with independently loaded sections. */
.customer-workspace { color: var(--theme-text, #172033); padding: 1rem 0 2rem; }
.customer-back { display: inline-flex; align-items: center; gap: .5rem; font-size: .75rem; color: var(--theme-text-muted, #64748b); margin-bottom: 1rem; }
.customer-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; }
.customer-identity { display: flex; gap: 1rem; min-width: 0; }
.customer-avatar { display: grid; place-items: center; flex-shrink: 0; width: 3.25rem; height: 3.25rem; background: var(--theme-indigo-bg, #e0e7ff); color: #1d4ed8; border-radius: 50%; font-size: 1.2rem; font-weight: 700; }
.customer-name { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.customer-name h1 { font-size: 1.5rem; font-weight: 700; overflow-wrap: anywhere; }
.customer-status, .customer-badge { background: var(--theme-surface-muted, #f1f5f9); border-radius: .25rem; padding: .2rem .45rem; font-size: .7rem; font-weight: 600; }
.customer-status { display: inline-flex; align-items: center; gap: .35rem; color: var(--theme-text-secondary, #475569); white-space: nowrap; }
.customer-status::before { content: ""; width: .45rem; height: .45rem; flex-shrink: 0; border-radius: 50%; background: currentColor; }
.customer-status[data-status="active"] { background: var(--theme-green-bg, #dcfce7); color: var(--theme-green-text, #166534); }
.customer-status[data-status="unpaid"] { background: var(--theme-amber-bg, #fef3c7); color: var(--theme-amber-text, #92400e); }
.customer-status[data-status="collection"] { background: var(--theme-orange-bg, #ffedd5); color: var(--theme-orange-text, #9a3412); }
.customer-status[data-status="terminated"] { background: var(--theme-red-bg, #fee2e2); color: var(--theme-red-text, #991b1b); }
.customer-status[data-status="write_off"] { background: var(--theme-purple-bg, #f3e8ff); color: var(--theme-purple-text, #6b21a8); }
.customer-status[data-status="inactive"] { background: var(--theme-border, #e2e8f0); color: var(--theme-text-secondary, #475569); }
.customer-index-row > td { color: var(--theme-text-secondary, #475569); }
.customer-index-row[data-status="active"] { background-color: var(--theme-green-bg, #f0fdf4); }
.customer-index-row[data-status="unpaid"] { background-color: var(--theme-amber-bg, #fffbeb); }
.customer-index-row[data-status="collection"] { background-color: var(--theme-orange-bg, #fff7ed); }
.customer-index-row[data-status="terminated"] { background-color: var(--theme-red-bg, #fef2f2); }
.customer-index-row[data-status="write_off"] { background-color: var(--theme-purple-bg, #faf5ff); }
.customer-index-row[data-status="inactive"] { background-color: var(--theme-canvas, #f8fafc); }
.customer-meta { display: flex; flex-wrap: wrap; gap: .35rem 1rem; color: var(--theme-text-muted, #64748b); font-size: .75rem; margin-top: .4rem; overflow-wrap: anywhere; }
.customer-header-actions, .customer-quick-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.customer-button { display: inline-flex; align-items: center; justify-content: center; padding: .5rem .8rem; border: 1px solid var(--theme-border, #dce2eb); border-radius: .3rem; background: var(--theme-surface, #fff); color: var(--theme-text-secondary, #334155); font-size: .75rem; font-weight: 500; min-height: 2.25rem; }
.customer-button:hover { background: var(--theme-surface-muted, #f1f5f9); }
.customer-button-primary { background: #2563eb; border-color: #2563eb; color: white; }
.customer-button-primary:hover { background: #1d4ed8; }
.customer-button-danger { color: var(--theme-red-text, #dc2626); border-color: var(--theme-red-border, #fecaca); }
.customer-header-quick-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.customer-header-quick-actions .customer-button { gap: .4rem; cursor: pointer; }
.customer-payment-actions { position: relative; }
.customer-payment-actions > summary { list-style: none; }
.customer-payment-actions > summary::-webkit-details-marker { display: none; }
.customer-payment-menu { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 30; display: flex; flex-direction: column; gap: .5rem; width: min(17rem, calc(100vw - 2rem)); padding: .75rem; border: 1px solid var(--theme-border, #dce2eb); border-radius: .5rem; background: var(--theme-surface, #fff); box-shadow: 0 8px 24px rgb(15 23 42 / .12); }
.customer-note-dialog { width: min(42rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); margin: auto; padding: 1.5rem; overflow-y: auto; border: 1px solid var(--theme-border, #dce2eb); border-radius: .75rem; background: var(--theme-surface, #fff); color: var(--theme-text, #0f172a); }
.customer-note-dialog::backdrop { background: rgb(15 23 42 / .45); }
.customer-note-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.customer-note-dialog-heading h2 { font-size: 1.25rem; font-weight: 600; }

.customer-tabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--theme-border, #dce2eb); margin-bottom: 1rem; gap: .25rem; }
.customer-tab { display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap; padding: .8rem .75rem; font-size: .75rem; color: var(--theme-text-secondary, #475569); border-bottom: 2px solid transparent; }
.customer-tab:hover, .customer-tab.is-active { color: #2563eb; }
.customer-tab.is-active { border-bottom-color: #2563eb; font-weight: 600; }
.customer-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin: 1rem 0; }
.customer-card { background: var(--theme-surface, #fff); border: 1px solid var(--theme-border, #e5e9f0); border-radius: .5rem; min-width: 0; overflow: hidden; }
.customer-stat { display: flex; gap: .9rem; padding: 1rem; }
.customer-stat > div { min-width: 0; }
.customer-stat h2 { font-size: .75rem; font-weight: 600; }
.customer-stat-icon { color: #2563eb; background: var(--theme-blue-bg, #eff6ff); padding: .6rem; border-radius: .6rem; align-self: flex-start; }
.customer-stat-value { font-size: 1.25rem; line-height: 1.4; font-weight: 700; margin: .35rem 0; overflow-wrap: anywhere; }
.customer-muted { font-size: .7rem; color: var(--theme-text-muted, #64748b); }
.customer-link { color: #2563eb; font-size: .75rem; }
.customer-link:hover { text-decoration: underline; }
.customer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 1rem; margin-bottom: 1rem; }
.customer-workspace turbo-frame { display: block; min-width: 0; }
.customer-card-heading { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .8rem 1rem; border-bottom: 1px solid var(--theme-surface-muted, #f1f5f9); }
.customer-card-heading h2 { font-size: .875rem; font-weight: 650; }
.customer-quick-actions { padding: .75rem 1rem; }
.customer-table-scroll { overflow-x: auto; padding: .5rem .75rem; }
.customer-table { width: 100%; white-space: nowrap; text-align: left; font-size: .7rem; }
.customer-table th { font-size: .65rem; color: var(--theme-text-muted, #64748b); font-weight: 500; background: var(--theme-canvas, #f8fafc); }
.customer-table :is(th, td) { padding: .6rem .5rem; border-bottom: 1px solid var(--theme-surface-muted, #f1f5f9); }
.customer-loading { min-height: 9rem; padding: 1rem; display: flex; flex-direction: column; justify-content: center; gap: .75rem; color: var(--theme-text-muted, #64748b); font-size: .8rem; }
.customer-empty { padding: 2rem 1rem; font-size: .8rem; color: var(--theme-text-muted, #64748b); }
.customer-workspace dl { gap: .8rem 1rem; }
.customer-workspace :is(dt, dd) { font-size: .75rem; overflow-wrap: anywhere; }
.customer-workspace :is(a, button, input, select):focus-visible { outline: 2px solid #2563eb; outline-offset: 3px; }
.customer-workspace turbo-frame > .shadow-md { box-shadow: none; border: 1px solid var(--theme-border, #e5e9f0); margin-top: 0; margin-bottom: 1rem; }
.customer-workspace turbo-frame h2.text-xl { font-size: 1rem; }
@media (max-width: 1100px) {
  .customer-header { flex-wrap: wrap; }
  .customer-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .customer-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 639px) {
  .customer-summary { grid-template-columns: minmax(0, 1fr); }
  .customer-avatar { width: 2.5rem; height: 2.5rem; }
  .customer-name h1 { font-size: 1.25rem; }
  .customer-button, .customer-tab { min-height: 44px; }
}
.customer-account-details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.customer-alert-loading { min-height: 0; padding: .5rem 1rem; margin-bottom: 1rem; flex-direction: row; justify-content: space-between; }
@media (max-width: 639px) {
  .customer-account-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 380px) {
  .customer-account-details { grid-template-columns: minmax(0, 1fr); }
}
.customer-usage-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; padding: 1rem; border-bottom: 1px solid var(--theme-surface-muted, #f1f5f9); }
.customer-allowances { padding: 1rem; }
.customer-allowances h3 { font-size: .75rem; font-weight: 600; margin-bottom: .75rem; }
.customer-allowance { margin-bottom: .75rem; font-size: .75rem; }
.customer-allowance-progress { appearance: none; width: 100%; height: .4rem; border: 0; border-radius: 1rem; display: block; margin-top: .5rem; }
.customer-allowance-progress::-webkit-progress-bar { background: var(--theme-surface-muted, #f1f5f9); border-radius: 1rem; }
.customer-allowance-progress::-webkit-progress-value { background: #a7f3d0; border-radius: 1rem; }
.customer-allowance-progress::-moz-progress-bar { background: #a7f3d0; border-radius: 1rem; }
body:has(.customer-workspace) { background: var(--theme-canvas, #f8fafc); }

/* Cards make the selected customer's services easier to scan. */
.service-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 1rem; }
.service-card { display: flex; flex-direction: column; min-width: 0; padding: 1.25rem; background: var(--theme-surface, #fff); border: 1px solid var(--theme-border, #e2e8f0); border-radius: .75rem; box-shadow: 0 1px 3px rgb(15 23 42 / .08); }
.service-card-header, .service-card-badges, .service-card-actions { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.service-card-badges { justify-content: flex-start; flex-wrap: wrap; margin-top: .75rem; }
.service-card-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 1.25rem 0; }
.service-card-details > div { min-width: 0; }
.service-card-details dt { font-size: .75rem; color: var(--theme-text-muted, #64748b); }
.service-card-details dd { margin-top: .2rem; font-size: .875rem; overflow-wrap: anywhere; }
.service-card-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--theme-border, #e2e8f0); font-size: .875rem; font-weight: 500; }
.service-card :is(a, button, input):focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

/* Compact service summaries in the customer's Services tab. */
.customer-service-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: .5rem; padding: .75rem; }
.customer-service-card { padding: .65rem .75rem; border-radius: .5rem; box-shadow: none; }
.customer-service-card:has(.customer-service-type--cc) { background: rgb(59 130 246 / .04); }
.customer-service-card:has(.customer-service-type--sd) { background: rgb(20 184 166 / .04); }
.customer-service-card:has(.customer-service-type--dd) { background: rgb(249 115 22 / .04); }
.customer-service-card:has(.customer-service-type--vn) { background: rgb(139 92 246 / .04); }
.customer-service-card .service-card-header { gap: .5rem; }
.customer-service-type { display: inline-flex; align-items: center; padding: .15rem .5rem; border-radius: .25rem; background: var(--theme-surface-muted, #f1f5f9); color: var(--theme-text-secondary, #334155); font-size: .75rem; font-weight: 700; }
.customer-service-type--cc { background: var(--theme-blue-bg, #dbeafe); color: var(--theme-blue-text, #1e40af); }
.customer-service-type--sd { background: var(--theme-teal-bg, #ccfbf1); color: var(--theme-teal-text, #115e59); }
.customer-service-type--dd { background: var(--theme-orange-bg, #ffedd5); color: var(--theme-orange-text, #9a3412); }
.customer-service-type--vn { background: var(--theme-violet-bg, #ede9fe); color: var(--theme-violet-text, #5b21b6); }
.customer-service-id { flex: 1; color: var(--theme-text-muted, #64748b); font-size: .7rem; }
.customer-service-card .service-card-details { grid-template-columns: minmax(0, 1fr); gap: .3rem; margin: .6rem 0; }
.customer-service-card .service-card-details > div { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: .5rem; align-items: baseline; }
.customer-service-card .service-card-details dt { font-size: .7rem; }
.customer-service-card .service-card-details dd { margin: 0; color: var(--theme-text, #0f172a); font-size: 1rem; line-height: 1.3; font-weight: 700; font-variant-numeric: tabular-nums; }
.customer-service-plan { display: flex; gap: .5rem; font-size: .7rem; line-height: 1.4; margin-bottom: .4rem; }
.customer-service-plan > :first-child { color: var(--theme-text-muted, #64748b); }
.customer-service-plan > :last-child { min-width: 0; overflow-wrap: anywhere; }
.customer-service-card .service-card-actions { gap: .75rem; padding-top: 0; font-size: .75rem; }
.customer-service-card .service-card-actions a { display: inline-flex; align-items: center; min-height: 40px; }
