* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #ffffff;
    color: #222;
}

button {
    font-family: inherit;
}

.hidden {
    display: none !important;
}


/* =========================
   APP BAR
========================= */

.appbar {
    height: 58px;
    background: #1565c0;
    color: white;

    display: flex;
    align-items: center;

    padding: 0 18px;

    font-size: 19px;
    font-weight: 600;
}


/* =========================
   LOGIN
========================= */
.page-background {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    to bottom,
    rgb(240, 247, 232),
    rgb(243, 245, 219),
    #b8e5ff,
    #76c9f8
  );
}

.page {
  min-height: 100vh;
  padding: 28px 20px 45px;
}

.portal-header,
.auth-section {
  width: min(100%, 470px);
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.portal-header {
  padding-top: 5px;
}

.logo,
.logo-fallback {
  width: 105px;
  height: 105px;
  object-fit: contain;
  margin: 0 auto 20px;
}

.logo-fallback {
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #1565c0;
  color: white;
  font-weight: bold;
  font-size: 18px;
}

.portal-header h1 {
  margin: 0;
  color: #0d47a1;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 1px;
}

.subtitle {
  margin: 9px 0 20px;
  color: #666;
  font-size: 15px;
}

.auth-section h2 {
  margin: 0;
  font-size: 24px;
}

.auth-section > p {
  margin: 5px 0 15px;
  color: #777;
  font-size: 14px;
}

.auth-card {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  padding: 20px;
  background: rgba(255,255,255,.95);
  border-radius: 24px;
  box-shadow: 0 12px 25px rgba(0,0,0,.08);
  text-align: left;
}

.input-group {
  margin-bottom: 18px;
}

.input-group label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 600;
  color: #444;
}

.input-wrap {
  display: flex;
  align-items: center;
  min-height: 58px;
  background: #f7fbff;
  border: 1px solid #eef8d5;
  /*border-radius: 14px;*/
  transition: border .15s, box-shadow .15s;
}

.input-wrap:focus-within {
  border: 2px solid #1565c0;
  box-shadow: 0 0 0 2px rgba(61, 192, 21, 0.08);
}

.input-icon {
  width: 43px;
  text-align: center;
  color: #1565c0;
  font-size: 17px;
}

.input-wrap input {
  min-width: 0;
  flex: 1;
  height: 55px;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0 8px;
  font-size: 15px;
}

.eye-button {
  width: 42px;
  height: 45px;
  border: 0;
  background: transparent;
  color: #1565c0;
  cursor: pointer;
  font-size: 16px;
}

.primary-button {
  width: 100%;
  height: 55px;
  margin-top: 2px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(90deg, #42a5f5, #1565c0);
  color: white;
  font-size: 17px;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 5px 10px rgba(21,101,192,.20);
}

.primary-button:hover {
  filter: brightness(1.04);
}

.terms-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 5px 0 14px;
  font-size: 13px;
  line-height: 1.45;
}

.terms-row input {
  margin-top: 3px;
  accent-color: #1565c0;
}

.link-button,
.forgot-button,
.toggle-button {
  border: 0;
  background: none;
  color: #1565c0;
  font-weight: 700;
  cursor: pointer;
}

.link-button {
  padding: 0;
  text-decoration: underline;
  font-size: inherit;
}

.account-toggle {
  margin-top: 30px;
  color: #666;
  font-weight: 500;
}

.toggle-button {
  padding: 4px;
  font-size: 16px;
}

.forgot-button {
  display: block;
  margin: 25px auto 0;
  font-size: 15px;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 20px;
  padding: 12px;
  border-radius: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.message.error {
  color: #8b0000;
  background: #fff0f0;
  border: 1px solid #e53935;
}

.message.success {
  color: #176b2c;
  background: #effaf1;
  border: 1px solid #2e7d32;
}



/* =========================
   ACCOUNT SCREEN
========================= */

.account-page {
    padding: 14px;

    max-width: 760px;

    margin: auto;

    padding-bottom: 90px;
}

.company-card {
    background: rgb(209,229,243);

    border-radius: 16px;

    padding: 10px 20px;

    text-align: center;

    box-shadow:
        0 2px 6px rgba(0,0,0,.08);
}

.company-logo {
    width: 70px;
    height: 70px;

    object-fit: contain;
}

.company-name {
    font-size: 20px;
    font-weight: bold;
}

.company-address,
.company-email {
    font-size: 13px;
    color: #555;

    margin-top: 3px;
}

.account-heading {
    margin-top: 10px;
}

.account-heading h1 {
    font-size: 21px;
    margin-bottom: 3px;
}

.account-heading p {
    font-size: 14px;
    color: #777;
    margin-top: 0;
}

.account-counter {
    font-size: 13px;
    color: #1565c0;

    font-weight: 500;

    margin-bottom: 5px;
}

.account-card {
    display: flex;

    align-items: center;

    gap: 15px;

    background: rgb(209,229,243);

    border-radius: 12px;

    margin: 7px 3px;

    padding: 15px 17px;

    box-shadow:
        0 3px 8px rgba(0,0,0,.14);

    cursor: pointer;

    transition:
        transform .12s ease;
}

.account-card:active {
    transform: scale(.98);
}

.account-icon {
    width: 54px;
    height: 54px;

    border-radius: 50%;

    background: #1565c0;

    color: white;

    display: grid;
    place-items: center;

    font-size: 27px;

    flex: none;
}

.account-information {
    flex: 1;

    min-width: 0;
}

.account-label {
    font-size: 11px;

    font-weight: bold;

    color: rgba(0,0,0,.54);

    letter-spacing: .8px;
}

.account-number {
    font-size: 20px;

    font-weight: bold;

    margin-top: 3px;
}

.account-name {
    font-size: 16px;

    margin-top: 3px;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}

.account-arrow {
    width: 32px;
    height: 32px;

    border-radius: 50%;

    background: rgba(255,255,255,.65);

    display: grid;
    place-items: center;

    font-size: 22px;
}

.no-account {
    text-align: center;

    padding: 70px 20px;

    color: #777;
}

.no-account-icon {
    font-size: 55px;
    color: #aaa;
}

.no-account h2 {
    color: #333;
}


/* =========================
   HOMEPAGE
========================= */

.home-page {
    max-width: 760px;

    margin: auto;

    padding:
        10px
        10px
        90px;
}

.balance-card {
    background: rgb(209,229,243);

    border-radius: 12px;

    padding:
        9px 18px;

    box-shadow:
        0 3px 8px rgba(0,0,0,.14);
}

.balance-card h2 {
    font-size: 18px;

    margin:
        0 0 5px;
}

.balance-card div {
    font-size: 16px;

    color: rgba(0,0,0,.58);

    line-height: 1.5;
}

.period-heading {
    display: flex;

    align-items: center;

    gap: 8px;

    padding:
        5px 8px;
}

.period-heading h2 {
    font-size: 18px;

    margin: 0;
}

.period-icon {
    color: #1565c0;

    font-size: 23px;
}

.billing-card {
    border-radius: 12px;

    margin:
        8px 4px;

    padding: 16px;

    box-shadow:
        0 3px 8px rgba(0,0,0,.14);
}

.billing-card.unread {
    background:
        rgb(175,211,253);
}

.billing-card.read {
    background:
        rgb(209,229,243);
}

.period-main {
    width: 100%;

    display: flex;

    align-items: center;

    gap: 18px;

    border: 0;

    background: transparent;

    text-align: left;

    padding: 0;

    cursor: pointer;
}

.calendar-avatar {
    width: 56px;
    height: 56px;

    border-radius: 50%;

    background: #1565c0;

    color: white;

    display: grid;

    place-items: center;

    font-size: 29px;

    flex: none;
}

.period-info {
    flex: 1;

    min-width: 0;

    display: flex;

    flex-direction: column;

    gap: 3px;
}

.period-info strong {
    font-size: 18px;
}

.period-amount {
    font-size: 18px;

    font-weight: 700;
}

.due-date {
    font-size: 18px;

    font-weight: 700;

    color: rgb(69,5,129);
}

.period-arrow {
    color: #777;

    font-size: 28px;
}

.download-bill {
    width: 100%;

    border: 0;

    border-radius: 7px;

    background: #1565c0;

    color: white;

    padding: 13px 12px;

    margin-top: 10px;

    font-size: 15px;

    cursor: pointer;
}


/* =========================
   BOTTOM NAVIGATION
========================= */

.bottom-nav {
    position: fixed;

    bottom: 0;
    left: 0;
    right: 0;

    height: 68px;

    background: white;

    border-top: 1px solid #ddd;

    display: flex;

    z-index: 20;
}

.bottom-nav button {
    flex: 1;

    border: none;

    background: transparent;

    color: #555;

    display: flex;

    flex-direction: column;

    justify-content: center;

    align-items: center;

    gap: 3px;

    cursor: pointer;
}

.bottom-nav button span {
    font-size: 23px;
}

.bottom-nav button small {
    font-size: 11px;
}

/* ================================
   TERMS & PRIVACY MODAL
   ================================ */

.legal-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;

    width: 100vw !important;
    height: 100vh !important;

    background: rgba(0, 0, 0, 0.55);

    display: flex !important;
    justify-content: center !important;
    align-items: center !important;

    padding: 20px;
    box-sizing: border-box;

    z-index: 99999;
}

/* Hide modal */
.legal-modal.hidden {
    display: none !important;
}

/* White modal box */
.legal-modal-content {
    width: 100%;
    max-width: 700px;

    max-height: 85vh;

    background: #ffffff;

    border-radius: 12px;

    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.30);

    overflow: hidden;

    display: flex;
    flex-direction: column;
}

/* Header */
.legal-modal-header {
    flex-shrink: 0;

    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 16px 20px;

    border-bottom: 1px solid #ddd;
}

.legal-modal-header h2 {
    margin: 0;

    font-size: 20px;
    font-weight: 600;
}

/* Close button */
.legal-close {
    border: none;
    background: transparent;

    font-size: 30px;
    line-height: 1;

    cursor: pointer;

    padding: 0 5px;

    color: #555;
}

.legal-close:hover {
    color: #000;
}

/* Legal text */
.legal-body {
    padding: 20px;

    overflow-y: auto;

    line-height: 1.6;

    font-size: 14px;

    color: #333;
}

/* Terms / Privacy clickable links */
.link-button {
    border: none;
    background: none;

    padding: 0;
    margin: 0;

    color: #1976d2;

    text-decoration: underline;

    font: inherit;

    cursor: pointer;
}

.link-button:hover {
    color: #0d47a1;
}

/* =========================
   MODALS
========================= */

.modal-backdrop {
    position: fixed;

    inset: 0;

    background:
        rgba(0,0,0,.45);

    display: flex;

    justify-content: center;

    align-items: flex-end;

    z-index: 100;
}

.modal {
    width: 100%;

    max-width: 600px;

    background: white;

    border-radius:
        18px
        18px
        0
        0;

    padding: 22px;

    max-height: 85vh;

    overflow-y: auto;
}

.modal h2 {
    margin-top: 0;
}

.modal-input {
    width: 100%;

    padding: 13px;

    margin:
        7px 0;

    border:
        1px solid #ccc;

    border-radius: 8px;

    font-size: 15px;
}

.modal-actions {
    display: flex;

    justify-content: flex-end;

    gap: 10px;

    margin-top: 18px;
}

.primary,
.secondary {
    border: none;

    padding:
        10px 18px;

    border-radius: 7px;

    cursor: pointer;
}

.primary {
    background: #1565c0;

    color: white;
}

.secondary {
    background: #eee;

    color: #333;
}

.menu-item {
    width: 100%;

    display: flex;

    align-items: center;

    gap: 15px;

    padding: 15px;

    border: none;

    border-bottom:
        1px solid #eee;

    background: white;

    text-align: left;

    font-size: 15px;

    cursor: pointer;
}


/* =========================
   PAYMENT HISTORY
========================= */

.payment-history-body {
    max-height: 400px;

    overflow-y: auto;

    border-top:
        1px solid #ddd;
}

.payment-row {
    display: grid;

    grid-template-columns:
        3fr 2fr 2fr;

    gap: 8px;

    padding: 10px 2px;

    border-bottom:
        1px solid #ddd;

    font-size: 14px;
}

.payment-header {
    border-bottom:
        2px solid #ccc;
}

.payment-row .right {
    text-align: right;
}


/* =========================
   LOADING
========================= */

.loading-overlay {
    position: fixed;

    inset: 0;

    z-index: 200;

    background:
        rgba(0,0,0,.35);

    display: flex;

    justify-content: center;

    align-items: center;
}

.loading-box {
    background: white;

    border-radius: 16px;

    padding:
        28px;

    text-align: center;

    box-shadow:
        0 5px 20px rgba(0,0,0,.2);
}

.spinner {
    width: 42px;
    height: 42px;

    border:
        4px solid #ddd;

    border-top-color:
        #1565c0;

    border-radius: 50%;

    margin:
        0 auto 18px;

    animation:
        spin .8s linear infinite;
}

@keyframes spin {

    to {
        transform:
            rotate(360deg);
    }

}

.center-message {
    min-height: 100px;

    display: grid;

    place-items: center;

    text-align: center;

    color: #666;
}


/* =========================
   MOBILE
========================= */

@media (max-width: 520px) {

    .account-page {
        padding-left: 10px;
        padding-right: 10px;
    }

    .period-main {
        gap: 12px;
    }

    .calendar-avatar {
        width: 52px;
        height: 52px;
    }

    .period-info strong,
    .period-amount,
    .due-date {
        font-size: 16px;
    }

    .payment-row {
        font-size: 13px;
    }

}