:root {
  --blue-1: #3c6fb8;
  --blue-2: #2f5ea1;
  --blue-3: #eaf0fa;
  --ink: #22252b;
  --muted: #6a707d;
  --line: #d8dde6;
  --panel: #ffffff;
  --sidebar: #262838;
  --sidebar-2: #323545;
  --ok: #2f8b66;
  --warn: #9b8045;
  --danger: #9f4f4f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Pretendard", "Noto Sans KR", sans-serif;
  background: #f2f4f8;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

.global-header {
  height: 52px;
  background: linear-gradient(90deg, var(--blue-1), var(--blue-2));
  color: #fff;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.global-brand {
  font-weight: 700;
  font-size: 1.15rem;
}

.global-menu {
  display: flex;
  align-items: center;
  gap: 0.34rem;
  overflow-x: auto;
}

.global-btn {
  border: 0;
  background: transparent;
  color: #e8efff;
  padding: 0.34rem 0.62rem;
  border-radius: 6px;
  white-space: nowrap;
  cursor: pointer;
}

.global-btn.active,
.global-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.global-right {
  font-size: 0.84rem;
  color: #e4ebfb;
  background: rgba(255, 255, 255, 0.14);
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  font-size: 1.16rem;
}

.topbar p {
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.toolbar,
.toolbar-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.session-box {
  display: flex;
  align-items: center;
  gap: 0.34rem;
  padding: 0.28rem 0.4rem;
  background: var(--blue-3);
  border: 1px solid #ccd8f0;
  border-radius: 8px;
}

.session-box.wide {
  max-width: 100%;
}

.session-box label {
  color: #49618b;
  font-size: 0.78rem;
}

.session-box select {
  width: 110px;
}

#apiBaseInput {
  width: 200px;
}

#loginUsername,
#loginPassword {
  width: 94px;
}

button,
.file-btn {
  border: 1px solid #c8cfdd;
  background: #f8fafe;
  color: #2f4569;
  border-radius: 6px;
  padding: 0.38rem 0.66rem;
  cursor: pointer;
  font-weight: 600;
}

button:hover,
.file-btn:hover {
  background: #edf3ff;
}

.global-menu .global-btn {
  border: 0;
  background: transparent;
  color: #e8efff;
  padding: 0.34rem 0.62rem;
}

.global-menu .global-btn.active,
.global-menu .global-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

button.secondary {
  background: var(--blue-1);
  color: #fff;
  border-color: var(--blue-1);
}

button.secondary:hover {
  background: #2f5ea1;
}

button[disabled] {
  opacity: 0.58;
  cursor: not-allowed;
}

.file-btn {
  display: inline-flex;
}

.layout {
  min-height: calc(100vh - 104px);
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  background: var(--sidebar);
  color: #d7deef;
  border-right: 1px solid #1e2230;
  padding: 0.9rem 0.68rem;
  display: grid;
  gap: 0.38rem;
  align-content: start;
}

.sidebar-title {
  color: #aeb9d4;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem 0.35rem;
}

#sidebarMenu {
  display: grid;
  gap: 0.38rem;
}

.tab-btn {
  border: 1px solid #393d4d;
  background: var(--sidebar-2);
  color: #e2e8f8;
  text-align: left;
  border-radius: 7px;
  padding: 0.46rem 0.56rem;
}

.tab-btn:hover {
  background: #3a3f51;
}

.tab-btn.active {
  background: #4b6ca8;
  border-color: #6286cb;
  color: #fff;
}

.content {
  padding: 0.9rem;
}

.tab-panel {
  display: none;
  gap: 0.72rem;
}

.tab-panel.active {
  display: grid;
}

.tab-panel > h2 {
  font-size: 1.1rem;
}

.kpi-grid,
.report-grid,
.split-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}

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

.kpi-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.78rem;
}

.compact-panel {
  display: grid;
  gap: 0.5rem;
}

.inline-fields {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.38rem;
}

.inline-fields label {
  font-size: 0.82rem;
  color: var(--muted);
}

.inline-fields input {
  width: 180px;
}

.kpi-card h3 {
  font-size: 0.8rem;
  color: #657086;
}

.kpi-card p {
  margin-top: 0.2rem;
  font-size: 1.24rem;
  font-weight: 700;
}

.form-grid {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.72rem;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

#purchaseForm,
#saleForm {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

input,
select {
  width: 100%;
  border: 1px solid #ced5e2;
  border-radius: 6px;
  padding: 0.44rem 0.5rem;
  background: #fff;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 0.36rem;
  border: 1px solid #d4dae6;
  background: #f7f9fc;
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
}

.checkbox-inline input {
  width: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
}

th,
td {
  text-align: left;
  padding: 0.44rem;
  border-bottom: 1px solid #e7ebf1;
}

thead th {
  background: #edf1f7;
  color: #566177;
  font-size: 0.79rem;
  font-weight: 700;
}

.report-chart {
  width: 100%;
  height: 270px;
  display: block;
  margin-top: 0.55rem;
  border: 1px solid #dfe4ed;
  border-radius: 8px;
  background: #fff;
}

.mini-btn {
  border-radius: 6px;
  font-size: 0.75rem;
  padding: 0.28rem 0.52rem;
}

.badge {
  border-radius: 999px;
  padding: 0.16rem 0.42rem;
  font-size: 0.74rem;
  color: #fff;
}

.badge.success {
  background: var(--ok);
}

.badge.pending {
  background: var(--warn);
}

.badge.danger {
  background: var(--danger);
}

.badge.info {
  background: #416790;
}

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

  .sidebar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-right: 0;
    border-bottom: 1px solid #1d212e;
  }

  .sidebar-title {
    grid-column: 1 / -1;
  }

  .form-grid,
  #purchaseForm,
  #saleForm {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 740px) {
  .global-header,
  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar,
  .report-grid,
  .split-grid,
  .form-grid,
  #purchaseForm,
  #saleForm,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .session-box,
  .inline-fields,
  .session-box.wide {
    display: grid;
    align-items: stretch;
  }

  .session-box select,
  #apiBaseInput,
  #loginUsername,
  #loginPassword,
  .inline-fields input {
    width: 100%;
  }

  .global-right {
    justify-self: start;
  }
}
