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

:root {
  --ghq-purple-950: #25043f;
  --ghq-purple-900: #34105a;
  --ghq-purple-800: #451579;
  --ghq-purple-700: #5a22a6;
  --ghq-purple-600: #6f35d0;
  --ghq-purple-500: #7c43df;
  --ghq-purple-300: #c9b0ef;
  --ghq-purple-200: #ded0f5;
  --ghq-purple-100: #eee7fb;
  --ghq-purple-050: #f8f5fd;

  --ghq-green-700: #16844d;
  --ghq-green-600: #22a865;
  --ghq-green-100: #e9f8f0;

  --ghq-red-700: #b33636;
  --ghq-red-600: #d64d4d;
  --ghq-red-100: #fff0f0;

  --ghq-orange-600: #d38a15;
  --ghq-orange-100: #fff5df;

  --ghq-bg: #f5f3f8;
  --ghq-panel: #ffffff;
  --ghq-text: #21192c;
  --ghq-text-soft: #706879;
  --ghq-line: #e4deeb;
  --ghq-line-strong: #d6cbe2;
  --ghq-shadow: 0 14px 36px rgba(61, 28, 98, 0.08);
  --ghq-shadow-soft: 0 8px 22px rgba(61, 28, 98, 0.05);
  --ghq-radius-lg: 18px;
  --ghq-radius-md: 13px;
  --ghq-radius-sm: 10px;
}

html {
  min-height: 100%;
  background: var(--ghq-bg);
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  color: var(--ghq-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--ghq-bg);
  color: var(--ghq-text);
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

img {
  max-width: 100%;
}

/* =========================================================
   APP SHELL
   ========================================================= */

.app-shell {
  min-height: 100vh;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto auto;
  align-items: center;
  gap: 22px;
  padding: 18px 28px;
  color: #fff;
  background:
    linear-gradient(
      110deg,
      var(--ghq-purple-950) 0%,
      var(--ghq-purple-800) 46%,
      var(--ghq-purple-600) 100%
    );
  box-shadow: 0 10px 30px rgba(45, 8, 76, 0.2);
  position: relative;
  z-index: 10;
}

.app-header__brand {
  min-width: 0;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  text-decoration: none;
}

.app-brand__logo {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 16px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.22), transparent 35%),
    linear-gradient(145deg, #211037, #5a22a6);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.app-brand__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-brand__text strong {
  font-size: 23px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.app-brand__text span {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.76);
}

.app-header__market {
  display: flex;
  align-items: center;
  gap: 12px;
}

.market-widget {
  min-width: 152px;
  padding: 11px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.13);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(7px);
}

.market-widget__label {
  display: block;
  color: rgba(255, 255, 255, 0.7);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.market-widget__price {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: -0.015em;
}

.market-widget__change {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 800;
  color: #d6ffe6;
}

.market-widget__change.is-down {
  color: #ffd4d4;
}

.app-header__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.market-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.market-status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #41dd87;
  box-shadow: 0 0 0 4px rgba(65, 221, 135, 0.12);
}

.app-header__user {
  display: flex;
  justify-content: flex-end;
}

.user-menu {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  font-size: 12px;
}

.user-menu__name {
  font-weight: 800;
  color: #fff;
}

.user-menu__logout {
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
}

.user-menu__logout:hover {
  color: #fff;
  text-decoration: underline;
}

/* =========================================================
   BUTTONS
   ========================================================= */

.button,
button,
.primary,
.secondary,
.danger {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 11px 15px;
  font-weight: 850;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease,
    opacity 0.16s ease;
}

.button:hover,
button:hover,
.primary:hover,
.secondary:hover,
.danger:hover {
  transform: translateY(-1px);
}

.button:active,
button:active,
.primary:active,
.secondary:active,
.danger:active {
  transform: translateY(0);
}

.button--ghost {
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
}

.button--ghost:hover {
  background: rgba(255, 255, 255, 0.2);
}

.primary {
  color: #fff;
  background:
    linear-gradient(135deg, var(--ghq-purple-700), var(--ghq-purple-500));
  box-shadow: 0 8px 18px rgba(111, 53, 208, 0.22);
}

.secondary {
  color: var(--ghq-purple-900);
  background: var(--ghq-purple-100);
}

.danger {
  color: var(--ghq-red-700);
  background: var(--ghq-red-100);
}

button:disabled,
.button:disabled,
.primary:disabled,
.secondary:disabled,
.danger:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

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

.app-tabs {
  background: #fff;
  border-bottom: 1px solid var(--ghq-line);
  position: sticky;
  top: 0;
  z-index: 9;
}

.app-tabs__inner {
  display: flex;
  gap: 7px;
  padding: 0 28px;
  overflow-x: auto;
  scrollbar-width: none;
}

.app-tabs__inner::-webkit-scrollbar {
  display: none;
}

.app-tab {
  flex: 0 0 auto;
  padding: 18px 15px 14px;
  color: var(--ghq-text-soft);
  border-bottom: 3px solid transparent;
  text-decoration: none;
  font-size: 15px;
  font-weight: 850;
  white-space: nowrap;
  transition:
    color 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.app-tab:hover {
  color: var(--ghq-purple-700);
}

.app-tab.is-active {
  color: var(--ghq-purple-700);
  border-bottom-color: var(--ghq-purple-600);
}

.app-subbar {
  background: #f1ebf9;
  border-bottom: 1px solid #e4daf1;
}

.app-subbar__inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 28px;
  color: #675d72;
  font-size: 11px;
}

.app-main {
  padding: 30px;
}

/* =========================================================
   TYPOGRAPHY AND LAYOUT
   ========================================================= */

.panel {
  max-width: 1440px;
  margin: 0 auto;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.panel-head h2,
h2 {
  margin: 0;
  font-size: 29px;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.panel-head p,
.muted {
  margin: 7px 0 0;
  color: var(--ghq-text-soft);
  line-height: 1.45;
}

h1,
h2,
h3,
h4 {
  color: var(--ghq-text);
}

/* =========================================================
   CARDS / DASHBOARD
   ========================================================= */

.summary-bar,
.market-import-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 0 0 20px;
}

.summary-bar > div,
.market-import-summary > div {
  padding: 16px 18px;
  background: var(--ghq-panel);
  border: 1px solid var(--ghq-line);
  border-radius: var(--ghq-radius-md);
  box-shadow: var(--ghq-shadow-soft);
}

.summary-bar span,
.market-import-summary span {
  display: block;
  margin-bottom: 6px;
  color: var(--ghq-text-soft);
  font-size: 12px;
}

.summary-bar strong,
.market-import-summary strong {
  display: block;
  color: var(--ghq-purple-900);
  font-size: 22px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--ghq-text-soft);
  background: var(--ghq-panel);
  border: 1px dashed var(--ghq-line-strong);
  border-radius: var(--ghq-radius-lg);
}

/* =========================================================
   ALERTS
   ========================================================= */

.alert {
  margin: 0 0 18px;
  padding: 13px 15px;
  border-radius: 11px;
  font-size: 13px;
  line-height: 1.45;
}

.alert-success {
  color: var(--ghq-green-700);
  background: var(--ghq-green-100);
  border: 1px solid #bce5cd;
}

.alert-error {
  color: var(--ghq-red-700);
  background: var(--ghq-red-100);
  border: 1px solid #efc2c2;
}

/* =========================================================
   FORMS
   ========================================================= */

input,
select,
textarea {
  width: 100%;
  color: var(--ghq-text);
  background: #fff;
  border: 1px solid var(--ghq-line-strong);
  border-radius: 11px;
  outline: 0;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

input,
select {
  min-height: 42px;
  padding: 10px 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ghq-purple-500);
  box-shadow: 0 0 0 4px rgba(111, 53, 208, 0.11);
}

label {
  color: var(--ghq-text-soft);
  font-size: 12px;
  font-weight: 750;
}

/* =========================================================
   MARKET UPLOAD
   ========================================================= */

.market-upload-card {
  margin-bottom: 20px;
  padding: 18px;
  background: var(--ghq-panel);
  border: 1px solid var(--ghq-line);
  border-radius: var(--ghq-radius-lg);
  box-shadow: var(--ghq-shadow-soft);
}

.market-drop-zone {
  min-height: 158px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  background: #faf8fd;
  border: 2px dashed #cdbbe4;
  border-radius: 15px;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    transform 0.16s ease;
}

.market-drop-zone:hover {
  background: var(--ghq-purple-050);
  border-color: var(--ghq-purple-500);
  transform: translateY(-1px);
}

.market-drop-zone input {
  display: none;
}

.market-drop-title {
  color: var(--ghq-purple-900);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.015em;
}

.market-drop-help {
  color: var(--ghq-text-soft);
  font-size: 12px;
}

.market-upload-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.market-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.market-preview-card {
  overflow: hidden;
  background: var(--ghq-panel);
  border: 1px solid var(--ghq-line);
  border-radius: 14px;
  box-shadow: var(--ghq-shadow-soft);
}

.market-preview-card img {
  display: block;
  width: 100%;
  height: 165px;
  object-fit: cover;
  object-position: top;
  background: #f2eef7;
}

.market-preview-details {
  padding: 11px 12px 12px;
}

.market-preview-details strong {
  display: block;
  color: var(--ghq-purple-900);
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-preview-details span {
  display: block;
  margin-top: 5px;
  color: var(--ghq-text-soft);
  font-size: 10px;
}

/* =========================================================
   TABLES
   ========================================================= */

.table-card {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--ghq-line);
  border-radius: var(--ghq-radius-lg);
  box-shadow: var(--ghq-shadow-soft);
}

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

thead th {
  padding: 13px 14px;
  color: #746b7e;
  background: #faf8fc;
  border-bottom: 1px solid var(--ghq-line);
  text-align: left;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid #eee9f2;
  font-size: 13px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

/* =========================================================
   LOGIN / INSTALL
   ========================================================= */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 80% 20%, rgba(141, 76, 227, 0.45), transparent 34%),
    linear-gradient(135deg, #2c084a 0%, #4a197e 46%, #6f35d0 100%);
}

.login-card {
  width: min(440px, 100%);
  padding: 34px;
  text-align: center;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 26px 80px rgba(28, 8, 49, 0.34);
}

.login-logo {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  color: #fff;
  background: linear-gradient(145deg, var(--ghq-purple-900), var(--ghq-purple-500));
  border-radius: 20px;
  font-size: 21px;
  font-weight: 950;
}

.login-card h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.04em;
}

.login-card > p {
  margin: 10px 0 0;
  color: var(--ghq-text-soft);
}

.login-form {
  display: grid;
  gap: 15px;
  margin-top: 26px;
  text-align: left;
}

.login-form label {
  display: block;
}

.login-form input {
  margin-top: 7px;
}

.login-form .primary {
  width: 100%;
  margin-top: 4px;
}

/* =========================================================
   UTILITIES
   ========================================================= */

.hidden {
  display: none !important;
}

.text-success {
  color: var(--ghq-green-600) !important;
}

.text-danger {
  color: var(--ghq-red-600) !important;
}

.text-muted {
  color: var(--ghq-text-soft) !important;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1180px) {
  .app-header {
    grid-template-columns: 1fr auto;
  }

  .app-header__market {
    order: 3;
    grid-column: 1 / -1;
    width: 100%;
  }

  .app-header__user {
    grid-column: 2;
    grid-row: 1;
  }

  .app-header__actions {
    margin-left: auto;
  }
}

@media (max-width: 900px) {
  .app-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .app-header__user {
    justify-content: flex-start;
  }

  .user-menu {
    align-items: flex-start;
  }

  .app-header__market {
    flex-wrap: wrap;
  }

  .market-widget {
    flex: 1 1 180px;
  }

  .app-header__actions {
    width: 100%;
    margin-left: 0;
  }

  .summary-bar,
  .market-import-summary {
    grid-template-columns: 1fr;
  }

  .market-preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 650px) {
  .app-header {
    padding: 16px 18px;
  }

  .app-brand__logo {
    width: 50px;
    height: 50px;
    border-radius: 14px;
  }

  .app-brand__text strong {
    font-size: 20px;
  }

  .app-tabs__inner {
    padding: 0 12px;
  }

  .app-tab {
    padding-left: 11px;
    padding-right: 11px;
    font-size: 14px;
  }

  .app-subbar__inner {
    padding: 9px 18px;
    flex-direction: column;
    gap: 3px;
  }

  .app-main {
    padding: 20px 16px;
  }

  .panel-head {
    flex-direction: column;
  }

  .market-preview-grid {
    grid-template-columns: 1fr;
  }

  .market-upload-actions {
    flex-direction: column;
  }

  .market-upload-actions button {
    width: 100%;
  }

  .login-card {
    padding: 27px 22px;
    border-radius: 18px;
  }
}
