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

html {
  background: #553716;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(
    105.74% 144.35% at 46.18% -1.59%,
    #8a7965 0%,
    #100f0f 84.16%
  );
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
}
/* body:after {
            content: "";
            background: url(./assets/dragon.png);
            position: absolute;
            inset: 0;
            content: "";
            z-index: 0;
            background-position: bottom 19px right;
            background-repeat: no-repeat;
            pointer-events: none;
        } */

.container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.header {
  background: radial-gradient(circle at 100% -4%, #8a7965 0%, #100f0f 84.16%);
  color: white;
  padding: 30px;
  text-align: center;
  position: relative;
}
/*.header::before {
            content: "";
            position: absolute;
            inset: 0;
            background-position: right top;
            background-repeat: no-repeat;
            background-image: url(./assets/priority-card-account-pattern.png);
            z-index: 0;
        }*/

.header h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
  font-weight: 700;
}

.header p {
  font-size: 1.1em;
  opacity: 0.9;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  padding: 30px;
  background: #f8f9fa;
}

.stat-card {
  padding: 25px;
  border-radius: 16px;
  text-align: center;
  background: rgba(167, 134, 86, 0.1);
}

.stat-card h3 {
  color: #666;
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.stat-card .value {
  font-size: 2em;
  font-weight: 700;
  color: black;
}

.stat-card .value.positive {
  color: #553716;
}

.stat-card .value.negative {
  color: #dc3545;
}

.content {
  background: rgba(167, 134, 86, 0.1);
  padding: 30px;
}

.error {
  background: #fee;
  color: #c33;
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 20px;
  border-left: 4px solid #c33;
}

.table-wrapper {
  overflow-x: auto;
  overflow-y: scroll;
  border-radius: 16px;
  max-height: calc(100vh - 560px);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

thead {
  background: radial-gradient(
    105.74% 244.35% at 46.18% -1.59%,
    #8a7965 0%,
    #100f0f 84.16%
  );
  color: white;
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  padding: 18px 15px;
  text-align: left;
  font-weight: 600;
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 30px;
}

th.sortable:hover {
  background: rgba(255, 255, 255, 0.1);
}

th.sortable::after {
  content: " ↕";
  position: absolute;
  right: 10px;
  opacity: 0.5;
}

th.sortable.asc::after {
  content: " ↑";
  opacity: 1;
}

th.sortable.desc::after {
  content: " ↓";
  opacity: 1;
}

tbody tr {
  border-bottom: 1px solid #e9ecef;
  transition: background-color 0.2s;
}

tbody tr:hover {
  background-color: #f8f9fa;
}

tbody tr:last-child {
  border-bottom: none;
}

td {
  padding: 15px;
  color: #333;
}

.account {
  font-family: "Courier New", monospace;
  font-weight: 600;
  color: #667eea;
}

.amount {
  font-weight: 600;
  font-size: 1.05em;
}

.amount.positive {
  color: #553716;
}

.amount.negative {
  color: #dc3545;
}

.amount-change {
  font-weight: 600;
}

.amount-change.positive {
  color: #553716;
}

.amount-change.negative {
  color: #dc3545;
}

.amount-change.positive::before {
  content: "+";
}

.datetime {
  color: #666;
  font-size: 0.95em;
}

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

th.text-right a {
  display: inline-block;
  text-align: right;
}

.no-data {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.no-data svg {
  width: 100px;
  height: 100px;
  margin-bottom: 20px;
  opacity: 0.3;
}

.refresh-btn {
  display: inline-block;
  margin-bottom: 20px;
  padding: 12px 24px;
  background: radial-gradient(
    105.74% 244.35% at 46.18% -1.59%,
    #8a7965 0%,
    #100f0f 84.16%
  );
  color: white;
  text-decoration: none;
  border-radius: 100px;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 15px #8a7965;
}
.refresh-btn span {
  position: relative;
  z-index: 1;
}

.refresh-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px #8a7965;
}

.col-change {
  width: 150px;
}
.col-datetime {
  width: 200px;
}
.col-ref {
  font-family: "Courier New", monospace;
  font-size: 0.85em;
  word-break: break-all;
}
.col-stt {
  width: 62px;
}
.text-center {
  text-align: center;
}

@media (max-width: 768px) {
  body {
    padding: 0;
  }
  .header h1 {
    font-size: 1.8em;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  table {
    font-size: 0.9em;
  }

  th,
  td {
    padding: 10px 8px;
  }

  .container {
    margin: 0;
    border-radius: 0;
  }
  .content,
  .stats {
    padding: 1rem;
  }
  .stat-card .value {
    font-size: 20px;
  }
  .col-change {
    width: 110px;
  }
  .col-datetime {
    width: 110px;
  }
  .table-wrapper {
    overflow-y: hidden;
    max-height: unset;
  }
  .col-ref-sp,
  .col-ref {
    display: none;
  }
}

/* Safe area support for notched devices */
@supports (padding: max(0px)) {
  .standalone-mode .header {
    padding-top: max(20px, env(safe-area-inset-top) + 20px) !important;
  }
}

/* Fallback for devices without safe-area support */
.standalone-mode .header {
  padding-top: 44px !important;
}

/* Ensure header stays at top in standalone mode */
.standalone-mode .header {
  position: relative;
  z-index: 10;
}

/* Pull-to-refresh indicator */
.pull-to-refresh-indicator {
  position: absolute;
  top: 0;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  pointer-events: none;
  color: #553716;
  width: 100%;
  padding-top: 10px;
}

.pull-to-refresh-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  margin-bottom: 8px;
}

.pull-to-refresh-text {
  font-size: 12px;
  color: #553716;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.9);
  padding: 4px 12px;
  border-radius: 12px;
  white-space: nowrap;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Footer link */
.footer-link {
  padding: 24px 20px 24px;
  text-align: center;
}

.footer-link p {
  margin: 0;
  font-size: 11px;
  color: #ddd;
  line-height: 1;
}

.footer-link a {
  color: #fff;
  text-decoration: none;
  font-weight: 500;
}

.footer-link a:hover {
  text-decoration: underline;
}

.version-text {
  display: inline-block;
  margin-left: 5px;
  color: #999;
}
