:root {
  /* ==========================================================================
     Material Design 3 Expressive (M3) Design System
     Palette: Contemporary Oceanic Slate with authentic M3 dynamic tone scales
     ========================================================================== */

  /* Primary Tonal Palette */
  --md-sys-color-primary: #0061a4;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d1e4ff;
  --md-sys-color-on-primary-container: #001d36;
  --md-sys-color-primary-hover: #005088;

  /* Secondary Tonal Palette */
  --md-sys-color-secondary: #535f70;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #d7e3f7;
  --md-sys-color-on-secondary-container: #101c2b;

  /* Tertiary Tonal Palette */
  --md-sys-color-tertiary: #6b5778;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #f2daff;
  --md-sys-color-on-tertiary-container: #251431;

  /* Error & Destructive Palette */
  --md-sys-color-error: #ba1a1a;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #410002;
  --md-sys-color-error-hover: #93000a;

  /* Success & Verified Palette */
  --md-sys-color-success: #0b6b3e;
  --md-sys-color-on-success: #ffffff;
  --md-sys-color-success-container: #c4f3d2;
  --md-sys-color-on-success-container: #00210f;

  /* Neutral Surface Roles (Expressive Elevation hierarchy) */
  --md-sys-color-surface: #f8f9fe;
  --md-sys-color-on-surface: #191c20;
  --md-sys-color-surface-variant: #dfe2eb;
  --md-sys-color-on-surface-variant: #43474e;
  
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f2f3f9;
  --md-sys-color-surface-container: #ecedf3;
  --md-sys-color-surface-container-high: #e6e8ee;
  --md-sys-color-surface-container-highest: #e0e2e8;

  /* Outlines & Dividers */
  --md-sys-color-outline: #73777f;
  --md-sys-color-outline-variant: #c3c7d0;
  --md-sys-color-outline-subtle: #e2e5ec;

  /* Typography Scale */
  --md-sys-font-headline: 'Plus Jakarta Sans', 'Google Sans', system-ui, sans-serif;
  --md-sys-font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --md-sys-font-bengali: 'Noto Sans Bengali', 'Inter', system-ui, sans-serif;

  /* Expressive Shapes */
  --md-shape-xs: 6px;
  --md-shape-sm: 8px;
  --md-shape-md: 12px;
  --md-shape-lg: 18px;
  --md-shape-xl: 24px;
  --md-shape-full: 9999px;

  /* Elevation Shadows (Layered ambient + key shadows) */
  --md-elevation-0: none;
  --md-elevation-1: 0 1px 2px rgba(25, 28, 32, 0.05), 0 1px 3px 1px rgba(25, 28, 32, 0.04);
  --md-elevation-2: 0 2px 6px 1px rgba(25, 28, 32, 0.06), 0 1px 2px rgba(25, 28, 32, 0.08);
  --md-elevation-3: 0 6px 16px 2px rgba(25, 28, 32, 0.08), 0 2px 4px rgba(25, 28, 32, 0.06);
  --md-elevation-4: 0 12px 28px 4px rgba(25, 28, 32, 0.10), 0 4px 8px rgba(25, 28, 32, 0.07);

  /* Motion & Timing */
  --md-easing-standard: cubic-bezier(0.2, 0, 0, 1);
  --md-easing-emphasized: cubic-bezier(0.05, 0.7, 0.1, 1);
  --md-duration-short: 150ms;
  --md-duration-medium: 250ms;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-sys-font-body);
  line-height: 1.5;
  padding: 32px 16px 96px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.lang-bn {
  font-family: var(--md-sys-font-bengali);
}

.app-container {
  max-width: 960px;
  margin: 0 auto;
}

/* ==========================================================================
   Header Bar
   ========================================================================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-avatar {
  width: 46px;
  height: 46px;
  border-radius: var(--md-shape-lg);
  background: linear-gradient(135deg, var(--md-sys-color-primary), #004578);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 97, 164, 0.25);
}

.brand-avatar svg {
  width: 22px;
  height: 22px;
}

.brand-text h1 {
  font-family: var(--md-sys-font-headline);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--md-sys-color-on-surface);
}

.brand-text p {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 1px;
}

/* Language Segmented Button */
.m3-segmented-control {
  display: inline-flex;
  background-color: var(--md-sys-color-surface-container-high);
  padding: 3px;
  border-radius: var(--md-shape-full);
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}

.m3-segment-item {
  border: none;
  background: transparent;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--md-sys-color-on-surface-variant);
  border-radius: var(--md-shape-full);
  cursor: pointer;
  transition: all var(--md-duration-medium) var(--md-easing-standard);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.m3-segment-item.active {
  background-color: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.m3-segment-item:hover:not(.active) {
  color: var(--md-sys-color-on-surface);
}

/* ==========================================================================
   M3 Surface Cards
   ========================================================================== */
.m3-card {
  background-color: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-shape-xl);
  border: 1px solid var(--md-sys-color-outline-subtle);
  box-shadow: var(--md-elevation-1);
  transition: box-shadow var(--md-duration-medium) var(--md-easing-standard),
              border-color var(--md-duration-medium) var(--md-easing-standard),
              transform var(--md-duration-medium) var(--md-easing-standard);
}

/* Billing Settings Bar */
.config-card {
  padding: 22px 24px;
  margin-bottom: 24px;
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 16px;
}

@media (max-width: 560px) {
  .config-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

/* ==========================================================================
   M3 Outlined Input Fields
   ========================================================================== */
.m3-textfield {
  display: flex;
  flex-direction: column;
}

.m3-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}

.m3-input-box {
  position: relative;
  display: flex;
  align-items: center;
}

.m3-input {
  width: 100%;
  height: 44px;
  background-color: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-shape-md);
  padding: 0 14px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  outline: none;
  transition: border-color var(--md-duration-short) var(--md-easing-standard),
              box-shadow var(--md-duration-short) var(--md-easing-standard);
}

.m3-input:hover {
  border-color: var(--md-sys-color-outline);
}

.m3-input:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px rgba(0, 97, 164, 0.16);
}

.m3-input::placeholder {
  color: var(--md-sys-color-outline);
  font-weight: 400;
}

.has-trailing-btn .m3-input {
  padding-right: 44px;
}

/* Field Inner Copy Action */
.field-copy-action {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: var(--md-shape-full);
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--md-duration-short) var(--md-easing-standard);
}

.field-copy-action:hover {
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-primary);
}

.field-copy-action svg {
  width: 16px;
  height: 16px;
}

/* Checkbox Toggle */
.m3-checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  user-select: none;
}

.m3-checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--md-sys-color-primary);
  border-radius: var(--md-shape-xs);
  cursor: pointer;
}

/* ==========================================================================
   Submeter Grid & Cards
   ========================================================================== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

@media (max-width: 860px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }
}

/* Submeter Card */
.submeter-card {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  background-color: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-shape-xl);
}

.submeter-card:hover {
  border-color: var(--md-sys-color-outline-variant);
  box-shadow: var(--md-elevation-2);
}

/* Header & Inline Rename */
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 32px;
}

.badge-and-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.room-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  padding: 4px 10px;
  border-radius: var(--md-shape-full);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all var(--md-duration-short) var(--md-easing-standard);
  border: 1px solid transparent;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-badge:hover {
  background-color: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-outline-variant);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary);
  flex-shrink: 0;
}

.room-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Inline Edit Field */
.inline-rename-input {
  height: 28px;
  padding: 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--md-shape-sm);
  border: 1.5px solid var(--md-sys-color-primary);
  background: #ffffff;
  color: var(--md-sys-color-on-surface);
  outline: none;
  font-family: inherit;
  width: 120px;
}

.card-actions-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Micro Action Buttons */
.m3-icon-action {
  width: 28px;
  height: 28px;
  border-radius: var(--md-shape-full);
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--md-duration-short) var(--md-easing-standard);
}

.m3-icon-action:hover {
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
}

.m3-icon-action.delete-btn:hover {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-error);
}

.m3-icon-action svg {
  width: 14px;
  height: 14px;
}

/* Stat Rows */
.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background-color: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-shape-md);
  font-size: 13px;
}

.stat-item-label {
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 500;
}

.stat-item-val-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-number {
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  font-size: 14px;
}

.stat-item.total-highlight {
  background-color: var(--md-sys-color-primary-container);
}

.stat-item.total-highlight .stat-item-label {
  color: var(--md-sys-color-on-primary-container);
  font-weight: 600;
}

.stat-item.total-highlight .stat-number {
  color: var(--md-sys-color-on-primary-container);
  font-size: 15px;
}

/* Image Snapshot Dropzone */
.snapshot-box {
  border: 1.5px dashed var(--md-sys-color-outline-variant);
  background-color: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-shape-md);
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  outline: none;
  text-align: center;
  padding: 4px;
  transition: all var(--md-duration-short) var(--md-easing-standard);
}

.snapshot-box:hover,
.snapshot-box:focus {
  border-color: var(--md-sys-color-primary);
  background-color: var(--md-sys-color-surface-container);
}

.snapshot-box img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.snapshot-copy-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--md-shape-full);
  background-color: rgba(25, 28, 32, 0.78);
  backdrop-filter: blur(4px);
  border: none;
  cursor: pointer;
  color: #ffffff;
  transition: all var(--md-duration-short) var(--md-easing-standard);
}

.snapshot-copy-btn.show {
  display: flex;
}

.snapshot-copy-btn:hover {
  background-color: rgba(25, 28, 32, 0.95);
}

.snapshot-copy-btn svg {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   Add Submeter Bar
   ========================================================================== */
.add-submeter-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  margin-bottom: 24px;
  align-items: end;
}

.m3-filled-btn {
  height: 44px;
  padding: 0 22px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  border: none;
  border-radius: var(--md-shape-full);
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-elevation-1);
  transition: all var(--md-duration-medium) var(--md-easing-standard);
}

.m3-filled-btn:hover {
  background-color: var(--md-sys-color-primary-hover);
  box-shadow: var(--md-elevation-2);
}

.m3-filled-btn svg {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
   Grand Total Banner
   ========================================================================== */
.grand-summary-card {
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, var(--md-sys-color-success-container), #d9f7e3);
  border-color: rgba(11, 107, 62, 0.25);
  box-shadow: var(--md-elevation-2);
}

.grand-label-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.grand-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--md-shape-full);
  background-color: var(--md-sys-color-success);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(11, 107, 62, 0.25);
}

.grand-avatar svg {
  width: 20px;
  height: 20px;
}

.grand-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--md-sys-color-on-success-container);
  letter-spacing: 0.1px;
}

.grand-val-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.grand-total-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--md-sys-color-on-success-container);
  letter-spacing: -0.5px;
}

.grand-copy-btn {
  background-color: rgba(0, 0, 0, 0.06);
  color: var(--md-sys-color-on-success-container);
}

.grand-copy-btn:hover {
  background-color: rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   M3 Dialog / Modal (Confirm Delete & Rename)
   ========================================================================== */
.m3-dialog-scrim {
  position: fixed;
  inset: 0;
  background-color: rgba(25, 28, 32, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--md-duration-medium) var(--md-easing-standard),
              visibility var(--md-duration-medium) var(--md-easing-standard);
  padding: 16px;
}

.m3-dialog-scrim.open {
  opacity: 1;
  visibility: visible;
}

.m3-dialog {
  background-color: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-shape-xl);
  max-width: 400px;
  width: 100%;
  padding: 24px;
  box-shadow: var(--md-elevation-4);
  transform: scale(0.92);
  transition: transform var(--md-duration-medium) var(--md-easing-emphasized);
}

.m3-dialog-scrim.open .m3-dialog {
  transform: scale(1);
}

.m3-dialog-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--md-shape-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.m3-dialog-icon.danger {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-error);
}

.m3-dialog-icon svg {
  width: 20px;
  height: 20px;
}

.m3-dialog-title {
  font-family: var(--md-sys-font-headline);
  font-size: 18px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 8px;
}

.m3-dialog-desc {
  font-size: 13.5px;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.5;
  margin-bottom: 24px;
}

.m3-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.m3-text-btn {
  background: transparent;
  border: none;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  padding: 8px 16px;
  border-radius: var(--md-shape-full);
  color: var(--md-sys-color-primary);
  cursor: pointer;
  transition: background-color var(--md-duration-short) var(--md-easing-standard);
}

.m3-text-btn:hover {
  background-color: var(--md-sys-color-surface-container-high);
}

.m3-danger-btn {
  background-color: var(--md-sys-color-error);
  color: var(--md-sys-color-on-error);
  border: none;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  padding: 8px 18px;
  border-radius: var(--md-shape-full);
  cursor: pointer;
  transition: all var(--md-duration-short) var(--md-easing-standard);
  box-shadow: var(--md-elevation-1);
}

.m3-danger-btn:hover {
  background-color: var(--md-sys-color-error-hover);
  box-shadow: var(--md-elevation-2);
}

/* ==========================================================================
   Copy Feedback State
   ========================================================================== */
.copied-success {
  color: var(--md-sys-color-success) !important;
  background-color: var(--md-sys-color-success-container) !important;
}
