/* ========== index.html (layout: login/register) ========== */
:root {
  --w: 1500px;
  --bg-dark: #b8a9c9;
  --bg-darker: #8b7a9e;
  --accent: #c9b8d4;
  --muted: #faf6f8;
  --card-width: 360px;
  --rose: #d4a5b0;
  --rose-deep: #c4909a;
  --blush: #f5eef1;
  --text-soft: #5a4d5c;
  --border-soft: #e8dde5;
  /* Universal buttons: same as chart-card-actions */
  --btn-padding: 0.4rem 0.75rem;
  --btn-padding-x: 0.75rem;
  --btn-font-size: 0.85rem;
  --btn-radius: 6px;
  --btn-primary-bg: var(--bg-dark);
  --btn-muted-bg: var(--border-soft);
  --btn-muted-color: var(--text-soft);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body.layout-index {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  justify-content: space-between;
  background: linear-gradient(
    160deg,
    var(--muted) 0%,
    #f0e9ed 50%,
    var(--muted) 100%
  );
  font-family:
    Raleway,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}

/* header / nav */
body.layout-index header {
  position: relative;
  background: var(--bg-darker);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

body.layout-index .header-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

/* Rotated 90deg: img height (before rotation) = visible width; use 100% of header width via vw so full image width is shown */
body.layout-index .header-bg img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100vw;
  height: auto;
  max-width: none;
  object-fit: contain;
  transform: translate(-50%, -50%);
  filter: brightness(0.55);
}

body.layout-index nav {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--w);
  background-color: transparent;
  display: flex;
  flex-direction: column;
}

body.layout-index .login {
  align-self: flex-end;
  padding: var(--btn-padding);
  width: fit-content;
  background: var(--btn-primary-bg);
  border: none;
  border-radius: var(--btn-radius);
  color: #fff;
  font-size: var(--btn-font-size);
  transition: opacity 0.2s;
}
body.layout-index .login:hover {
  opacity: 0.9;
  cursor: pointer;
  color: #fff;
}

body.layout-index .logo {
  color: #fff;
  text-align: center;
  height: 100px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}
body.layout-index .logo img {
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: grayscale(100%);
  opacity: 0.5;
  display: block;
}

body.layout-index .tabs {
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 0 16px 12px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 12px 12px 0 0;
}

body.layout-index .tabs .nav-button {
  flex: 1;
  border: none;
  padding: var(--btn-padding-x);
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  font-size: var(--btn-font-size);
  font-weight: 500;
  border-radius: var(--btn-radius);
  transition:
    background 0.2s,
    color 0.2s;
}

body.layout-index .tabs .nav-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
}

body.layout-index .tabs .active-tab {
  background: var(--btn-primary-bg);
  color: #fff;
}

/* Prosty nagłówek na stronach auth (forgot_password, reset_password, verify) */
body.layout-index .header-auth {
  background: var(--bg-darker);
}
body.layout-index .header-auth .nav-auth {
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background: none;
  background-image: none;
  filter: none;
  max-width: none;
}
body.layout-index .nav-auth a {
  color: rgba(255, 255, 255, 0.95);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  transition:
    background 0.2s,
    color 0.2s;
}
body.layout-index .nav-auth a:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}
body.layout-index .nav-auth a + a {
  margin-left: 0.5rem;
}
body.layout-index .nav-auth-back .fa {
  margin-right: 0.35rem;
}

body.layout-index section[id] {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px 20px;
  gap: 16px;
}

body.layout-index .form-error {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(196, 144, 154, 0.2);
  border: 1px solid var(--rose-deep);
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.4;
  margin-bottom: 16px;
  box-sizing: border-box;
}
body.layout-index .form-error:empty {
  display: none;
}
body.layout-index .form-info {
  background: rgba(139, 122, 158, 0.15);
  border-color: var(--lavender);
  color: var(--text-soft);
}

body.layout-index .login-section {
  background: var(--blush);
  padding: 32px 28px;
  border-radius: 16px;
  box-shadow:
    0 8px 32px rgba(139, 122, 158, 0.18),
    0 2px 8px rgba(139, 122, 158, 0.08);
  width: 100%;
  max-width: var(--card-width);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border-soft);
}

body.layout-index .hidden {
  display: none !important;
}

body.layout-index .form-icon-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.form-icon-wrap img {
  background-color: #fff;
}

body.layout-index .form-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--rose);
  box-shadow: 0 2px 12px rgba(212, 165, 176, 0.3);
}

body.layout-index .form-title {
  margin: 0 0 6px 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-soft);
  text-align: center;
}

body.layout-index .form-desc {
  margin: 0 0 24px 0;
  font-size: 0.9rem;
  color: var(--bg-darker);
  text-align: center;
  line-height: 1.4;
}

body.layout-index .form-group {
  width: 100%;
  margin-bottom: 18px;
}

body.layout-index .form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-soft);
  margin-bottom: 6px;
}

body.layout-index .login-section input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: #fff;
  font-size: 1rem;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
body.layout-index .login-section input::placeholder {
  color: #b0a5b5;
}
body.layout-index .login-section input:focus {
  outline: none;
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(212, 165, 176, 0.2);
}

body.layout-index .form-link {
  align-self: flex-end;
  margin: -6px 0 20px 0;
  color: var(--bg-darker);
  font-size: 0.85rem;
  text-decoration: none;
  transition: color 0.2s;
}
body.layout-index .form-link:hover {
  color: var(--rose-deep);
  text-decoration: underline;
}

body.layout-index .btn-submit,
body.layout-index .login-section button[type="submit"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: var(--btn-primary-bg);
  color: #fff;
  cursor: pointer;
  border-radius: var(--btn-radius);
  font-size: var(--btn-font-size);
  font-weight: 500;
  transition:
    opacity 0.2s,
    transform 0.15s;
}
body.layout-index a.btn-submit {
  display: block;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}
body.layout-index a.btn-submit:hover {
  color: #fff;
}
body.layout-index .auth-success-actions {
  margin-top: 1.25rem;
  margin-bottom: 0;
  max-width: var(--card-width);
  width: 100%;
}
body.layout-index .btn-submit:hover,
body.layout-index .login-section button[type="submit"]:hover {
  opacity: 0.94;
}
body.layout-index .btn-submit:active,
body.layout-index .login-section button[type="submit"]:active {
  transform: scale(0.99);
}

body.layout-index footer {
  background: var(--bg-darker);
  color: rgba(255, 255, 255, 0.95);
  text-align: center;
  padding: 16px;
  margin-top: auto;
  font-size: 0.875rem;
}
body.layout-index footer .copyright {
  margin: 0;
}

body.layout-index span {
  white-space: nowrap;
}

/* ========== dashboard ========== */
body.layout-dashboard {
  font-family: Raleway, "Segoe UI", system-ui, sans-serif;
  margin: 0;
  min-height: 100vh;
  background: var(--muted, #faf6f8);
  color: var(--text-soft, #5a4d5c);
  display: flex;
  flex-direction: column;
}
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--blush, #f5eef1);
  border-bottom: 1px solid var(--border-soft, #e8dde5);
}
.dashboard-header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-soft, #5a4d5c);
}
.dashboard-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.dashboard-nav .user-email {
  font-size: 0.875rem;
  color: var(--text-soft, #5a4d5c);
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-add-chart {
  display: inline-block;
  padding: var(--btn-padding);
  background: var(--btn-primary-bg);
  color: #fff;
  text-decoration: none;
  border-radius: var(--btn-radius);
  font-size: var(--btn-font-size);
  font-weight: 500;
  transition: opacity 0.2s;
}
.btn-add-chart:hover {
  opacity: 0.9;
  color: #fff;
}
.dashboard-nav .logout-link {
  font-size: 0.875rem;
  color: var(--text-soft, #5a4d5c);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  transition:
    background 0.2s,
    color 0.2s;
}
.dashboard-nav .logout-link:hover {
  background: var(--border-soft, #e8dde5);
  color: var(--bg-dark, #8b7a9e);
}
.dashboard-main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}
.dashboard-empty {
  text-align: center;
  color: var(--text-soft, #5a4d5c);
  margin: 2rem 0;
}
.dashboard-empty a {
  color: var(--bg-darker, #8b7a9e);
  text-decoration: none;
}
.dashboard-empty a:hover {
  text-decoration: underline;
  color: var(--rose-deep, #c4909a);
}
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}
.chart-card {
  background: var(--blush, #f5eef1);
  border: 1px solid var(--border-soft, #e8dde5);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(139, 122, 158, 0.1);
  transition: box-shadow 0.2s;
}
.chart-card:hover {
  box-shadow: 0 4px 20px rgba(139, 122, 158, 0.15);
}
.chart-card-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.chart-card-img {
  display: block;
  max-width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  object-fit: contain;
  background: #fff;
  /* Rendered at thumb_display_w × thumb_display_h so browser scales down the larger generated image */
}
.chart-card-label {
  display: block;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-soft, #5a4d5c);
}
.chart-card-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1rem 1rem;
  border-top: 1px solid var(--border-soft, #e8dde5);
  margin-top: -1px;
}
.btn-edit {
  padding: var(--btn-padding);
  font-size: var(--btn-font-size);
  background: var(--btn-primary-bg);
  color: #fff;
  text-decoration: none;
  border-radius: var(--btn-radius);
  transition: opacity 0.2s;
}
.btn-edit:hover {
  opacity: 0.9;
  color: #fff;
}
.btn-pdf {
  padding: var(--btn-padding);
  font-size: var(--btn-font-size);
  background: var(--btn-muted-bg);
  color: var(--btn-muted-color);
  text-decoration: none;
  border-radius: var(--btn-radius);
  transition:
    background 0.2s,
    color 0.2s;
}
.btn-pdf:hover {
  background: var(--btn-primary-bg);
  color: #fff;
}
.chart-card-delete-form {
  margin: 0;
}
.btn-delete {
  padding: var(--btn-padding);
  font-size: var(--btn-font-size);
  background: transparent;
  color: var(--rose-deep);
  border: 1px solid var(--rose-deep);
  border-radius: var(--btn-radius);
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s;
}
.btn-delete:hover {
  background: rgba(196, 144, 154, 0.15);
}

/* Ustawienia cyklu na karcie wykresu */
.chart-card-cycle-settings {
  padding: 0 1rem;
  border-top: 1px solid var(--border-soft, #e8dde5);
  margin-top: -1px;
}
.chart-card-cycle-settings summary {
  padding: 0.5rem 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--bg-darker, #8b7a9e);
  cursor: pointer;
  list-style: none;
  -webkit-user-select: none;
  user-select: none;
}
.chart-card-cycle-settings summary::-webkit-details-marker {
  display: none;
}
.chart-card-cycle-settings summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.2s;
}
.chart-card-cycle-settings[open] summary::before {
  transform: rotate(90deg);
}
.cycle-settings-form {
  padding: 0.75rem 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.cycle-settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.cycle-settings-row label {
  font-size: 0.85rem;
  color: var(--text-soft, #5a4d5c);
  min-width: 10rem;
}
.cycle-settings-row input[type="number"],
.cycle-settings-row input[type="date"] {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border-soft, #e8dde5);
  border-radius: 6px;
  font-size: 0.9rem;
  max-width: 10rem;
}
.btn-cycle-save {
  align-self: flex-start;
  padding: var(--btn-padding);
  font-size: var(--btn-font-size);
  background: var(--btn-primary-bg);
  color: #fff;
  border: none;
  border-radius: var(--btn-radius);
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-cycle-save:hover {
  opacity: 0.9;
}

/* Ustawienia cyklu na stronie wykresu (chart.php) – zawsze widoczne */
.chart-page-cycle-settings {
  padding: 0 0 0.5rem 0;
  margin-top: 1rem;
  margin-bottom: 0;
}
.chart-page-cycle-settings-title {
  margin: 0 0 0.5rem 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--bg-darker, #8b7a9e);
}

/* Wykres i tabela obok siebie */
.chart-and-table-row {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  flex-wrap: wrap;
  width: 100%;
}
.chart-image-wrap {
  flex: 1 1 400px;
  min-width: 0;
  overflow-x: auto;
}
.chart-image-wrap #chart {
  display: block;
  min-width: 800px;
  width: auto;
  height: auto;
  max-width: none;
  background: var(--blush, #f5eef1);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(139, 122, 158, 0.12);
  border: 1px solid var(--border-soft, #e8dde5);
}

/* Tabela pomiarów – obok wykresu, mniejsza */
.chart-measurements-section {
  flex: 0 0 auto;
  margin-top: 0;
}
.chart-measurements-title {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-soft, #5a4d5c);
  text-align: center;
}
.chart-measurements-wrapper {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.chart-measurements-table {
  width: auto;
  max-width: 260px;
  border-collapse: collapse;
  font-size: 0.9rem;
  border: 1px solid var(--border-soft, #e8dde5);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(139, 122, 158, 0.08);
}
.chart-measurements-table th {
  background: rgb(200, 185, 210);
  color: var(--text-soft, #5a4d5c);
  font-weight: 600;
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border-soft, #e8dde5);
}
.chart-measurements-table th:first-child {
  text-align: center;
  width: 2.5rem;
}
.chart-measurements-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border-soft, #e8dde5);
}
.chart-measurements-table td:first-child {
  text-align: center;
}
.chart-measurements-table td:nth-child(3) {
  white-space: nowrap;
}
.chart-measurements-table tbody tr:nth-child(even) {
  background: rgb(245, 238, 241);
}
.chart-measurements-table tbody tr:nth-child(odd) {
  background: transparent;
}
.chart-measurements-table tbody tr:last-child td {
  border-bottom: none;
}
.chart-measurements-edit-th {
  width: 1.75rem;
  padding: 0.25rem;
  border: none;
  background: rgb(200, 185, 210);
}
.chart-measurements-edit-cell {
  width: 1.75rem;
  padding: 0.25rem 0.35rem;
  border-bottom: 1px solid var(--border-soft, #e8dde5);
  vertical-align: middle;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.chart-measurements-table tbody tr:hover .chart-measurements-edit-cell {
  opacity: 1;
}
.chart-measurements-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--bg-darker, #8b7a9e);
  cursor: pointer;
  border-radius: 4px;
  transition:
    background 0.15s,
    color 0.15s;
}
.chart-measurements-edit:hover {
  background: rgba(139, 122, 158, 0.2);
  color: var(--rose-deep, #c4909a);
}
.chart-measurements-edit .fa {
  font-size: 0.85rem;
}

.dashboard-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-soft, #e8dde5);
  font-size: 0.875rem;
}
.dashboard-footer a {
  color: var(--bg-darker, #8b7a9e);
  text-decoration: none;
}
.dashboard-footer a:hover {
  color: var(--rose-deep, #c4909a);
  text-decoration: underline;
}
.dashboard-main .form-error {
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(196, 144, 154, 0.2);
  border: 1px solid var(--rose-deep, #c4909a);
  color: var(--text-soft, #5a4d5c);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.dashboard-main .form-success {
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(139, 122, 158, 0.15);
  border: 1px solid var(--bg-dark, #b8a9c9);
  color: var(--text-soft, #5a4d5c);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ========== chart.php / modify (chart + edit dialog) – uses .dashboard-header + .dashboard-main ========== */
.dashboard-link,
.pdf-link,
.logout-link {
  font-size: 0.875rem;
  color: var(--text-soft, #5a4d5c);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  transition:
    background 0.2s,
    color 0.2s;
}
.dashboard-link:hover,
.pdf-link:hover,
.logout-link:hover {
  background: var(--border-soft, #e8dde5);
  color: var(--rose-deep, #c4909a);
}
#chart {
  display: block;
  min-width: 800px;
  width: auto;
  height: auto;
  max-width: none;
  background: var(--blush, #f5eef1);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(139, 122, 158, 0.12);
  border: 1px solid var(--border-soft, #e8dde5);
}

/* Modal overlay */
.dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(90, 77, 92, 0.35);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.dialog-overlay.is-open {
  display: flex;
}
.dialog {
  background: var(--blush, #f5eef1);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(139, 122, 158, 0.2);
  width: 100%;
  max-width: 340px;
  padding: 1.5rem;
  border: 1px solid var(--border-soft, #e8dde5);
}
.dialog-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
  color: var(--text-soft, #5a4d5c);
}
.dialog-field {
  margin-bottom: 1rem;
}
.dialog-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-soft, #5a4d5c);
  margin-bottom: 0.35rem;
}
.dialog-field input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border-soft, #e8dde5);
  border-radius: 8px;
  background: #fff;
}
.dialog-field input:focus {
  outline: none;
  border-color: var(--rose, #d4a5b0);
  box-shadow: 0 0 0 3px rgba(212, 165, 176, 0.25);
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
.dialog-actions button {
  padding: var(--btn-padding);
  font-size: var(--btn-font-size);
  font-weight: 500;
  border: none;
  border-radius: var(--btn-radius);
  cursor: pointer;
  transition:
    opacity 0.2s,
    background 0.2s,
    color 0.2s;
}
.btn-save {
  background: var(--btn-primary-bg);
  color: #fff;
}
.btn-save:hover {
  opacity: 0.9;
  color: #fff;
}
.btn-period,
.btn-no-measure {
  background: var(--btn-primary-bg);
  color: #fff;
}
.btn-period:hover,
.btn-no-measure:hover {
  opacity: 0.9;
  color: #fff;
}
.btn-cancel {
  background: var(--btn-muted-bg);
  color: var(--btn-muted-color);
}
.btn-cancel:hover {
  background: var(--btn-primary-bg);
  color: #fff;
}

/* ========== Responsive (all pages) ========== */
html {
  overflow-x: hidden;
}
body {
  overflow-x: hidden;
}

/* Layout index: login/register, forgot/reset/verify */
@media (max-width: 768px) {
  body.layout-index section[id] {
    padding: 20px 12px;
  }
  body.layout-index .login-section {
    padding: 24px 20px;
  }
  body.layout-index .form-title {
    font-size: 1.35rem;
  }
  body.layout-index .logo {
    height: 72px;
    font-size: 1.25rem;
  }
  body.layout-index .tabs {
    max-width: 100%;
    padding: 0 12px 10px;
  }
  body.layout-index .tabs .nav-button {
    padding: 10px 12px;
    font-size: 0.9rem;
  }
  body.layout-index nav {
    padding: 0;
  }
  body.layout-index .login {
    padding: 10px 12px;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  body.layout-index section[id] {
    padding: 16px 10px;
  }
  body.layout-index .login-section {
    padding: 20px 16px;
    border-radius: 12px;
  }
  body.layout-index .form-title {
    font-size: 1.2rem;
  }
  body.layout-index .form-desc {
    font-size: 0.85rem;
    margin-bottom: 18px;
  }
  body.layout-index .form-icon {
    width: 56px;
    height: 56px;
  }
  body.layout-index .login-section input {
    padding: 10px 12px;
    font-size: 0.95rem;
  }
  body.layout-index .btn-submit,
  body.layout-index .login-section button[type="submit"] {
    padding: 12px;
    font-size: 0.95rem;
  }
  body.layout-index .form-link {
    margin: -4px 0 16px 0;
    font-size: 0.8rem;
  }
  body.layout-index .logo {
    height: 60px;
    font-size: 1.1rem;
  }
  body.layout-index .tabs .nav-button {
    padding: 8px 10px;
    font-size: 0.85rem;
  }
  body.layout-index footer {
    padding: 12px 10px;
    font-size: 0.8rem;
  }
}

/* Standalone auth pages (forgot_password, reset_password, verify) use layout-index; main has inline max-width */
@media (max-width: 480px) {
  body.layout-index main {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

/* Dashboard */
@media (max-width: 768px) {
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
  }
  .dashboard-header h1 {
    font-size: 1.2rem;
  }
  .dashboard-nav {
    width: 100%;
    flex-wrap: wrap;
  }
  .dashboard-nav .user-email {
    max-width: 100%;
  }
  .dashboard-main {
    padding: 1rem;
  }
  .charts-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .chart-card-actions {
    flex-wrap: wrap;
  }
  .chart-card-actions .btn-edit,
  .chart-card-actions .btn-pdf,
  .chart-card-actions .btn-delete {
    min-height: 44px;
  }
  .cycle-settings-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .cycle-settings-row label {
    min-width: 0;
  }
  .cycle-settings-row input[type="number"],
  .cycle-settings-row input[type="date"] {
    max-width: 100%;
    width: 100%;
  }
  .dashboard-footer {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .dashboard-header {
    padding: 0.75rem 1rem;
  }
  .dashboard-header h1 {
    font-size: 1.1rem;
  }
  .dashboard-nav {
    gap: 0.5rem;
  }
  .btn-add-chart {
    padding: 0.5rem 0.85rem;
    font-size: 0.85rem;
  }
  .dashboard-main {
    padding: 0.75rem;
  }
  .charts-grid {
    gap: 1rem;
  }
  .chart-card-label {
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
  }
  .chart-card-actions {
    padding: 0.5rem 0.75rem 0.75rem;
  }
  .chart-card-cycle-settings {
    padding: 0 0.75rem;
  }
  .chart-card-cycle-settings summary {
    font-size: 0.8rem;
  }
}

/* Chart edit page: dialog + chart image responsive (chart keeps min-width: 800px, wrap scrolls) */
@media (max-width: 768px) {
  .dialog-overlay {
    padding: 0.75rem;
  }
  .dialog {
    max-width: 100%;
    padding: 1.25rem;
  }
  .dialog-title {
    font-size: 1rem;
  }
  .dialog-actions button {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .dialog {
    padding: 1rem;
  }
  .dialog-field input {
    padding: 0.5rem 0.65rem;
    font-size: 0.95rem;
  }
}
