:root {
  --white: #ffffff;
  --beige: #706259;
  --navy: #1f355e;
  --bg: #f6f4f1;
  --border: #d8d0c9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--navy);
  overflow-x: hidden;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--navy);
}

.brand__title {
  font-weight: 700;
}

.brand__subtitle {
  font-size: 12px;
  color: var(--beige);
}

.container {
  max-width: 1200px;
  margin: 24px auto 80px;
  padding: 0 16px;
  display: grid;
  gap: 20px;
  width: 100%;
  box-sizing: border-box;
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: nowrap;
}

.card__header h2 {
  margin: 0;
  min-width: 0;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid--3 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.login-row .btn {
  width: 100%;
}

.grid--4 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.grid button[type="submit"] {
  max-width: 200px;
}

@media (max-width: 768px) {
  .card__header {
    flex-wrap: wrap;
  }

  .actions {
    flex-wrap: wrap;
  }

  .actions .input--sm {
    flex: 1 1 auto;
  }

  .grid--4 {
    grid-template-columns: 1fr;
  }

  .grid--3 {
    grid-template-columns: 1fr;
  }
  
  .grid button[type="submit"] {
    max-width: 100%;
  }
}

.field {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--navy);
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.input--sm {
  padding: 8px 10px;
  font-size: 13px;
}

.btn {
  border: none;
  background: var(--navy);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn[data-tooltip] {
  position: relative;
}

.btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f1d36;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 30;
}

.btn[data-tooltip]:hover::after,
.btn[data-tooltip]:focus-visible::after {
  opacity: 1;
}

.btn[data-tooltip]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #0f1d36;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.btn[data-tooltip]:hover::before,
.btn[data-tooltip]:focus-visible::before {
  opacity: 1;
}

.btn--outline {
  background: transparent;
  border: 1px solid var(--navy);
  color: var(--navy);
}

.btn--ghost {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
}

.btn--success {
  background: #1f6f4a;
  border: 1px solid #1f6f4a;
  color: #fff;
}

.btn--warning {
  background: #b07d1c;
  border: 1px solid #b07d1c;
  color: #fff;
}

.btn--danger {
  background: #a62c2b;
  border: 1px solid #a62c2b;
  color: #fff;
}

.btn--info {
  background: #1f4a7a;
  border: 1px solid #1f4a7a;
  color: #fff;
}

.btn--outline.btn--danger,
.btn--ghost.btn--danger {
  color: #fff;
  border-color: #a62c2b;
  background: #a62c2b;
}

.btn--outline.btn--info,
.btn--ghost.btn--info {
  color: #fff;
  border-color: #1f4a7a;
  background: #1f4a7a;
}

.btn--outline.btn--success,
.btn--ghost.btn--success {
  color: #fff;
  border-color: #1f6f4a;
  background: #1f6f4a;
}

.btn--outline.btn--warning,
.btn--ghost.btn--warning {
  color: #fff;
  border-color: #b07d1c;
  background: #b07d1c;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
}

.actions .input,
.actions .btn {
  min-width: 0;
}

.actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  min-width: 38px;
  height: auto;
  flex-shrink: 0;
}

.actions .input--sm {
  flex: 0 0 220px;
  min-width: 0;
}

.card__header .actions {
  max-width: 100%;
}

.card__header .actions .input--sm {
  flex: 1 1 auto;
  max-width: 260px;
}

.nav {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.nav .btn {
  white-space: nowrap;
}

.table-wrap {
  margin-top: 16px;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th,
.table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.table th {
  background: #f3f0ed;
  color: var(--beige);
}

.hint {
  color: var(--beige);
  font-size: 13px;
  margin-top: 8px;
}

.code {
  background: #0f1d36;
  color: #dfe6ff;
  padding: 16px;
  border-radius: 8px;
  max-height: 360px;
  overflow: auto;
}

.result-view {
  display: grid;
  gap: 16px;
  margin-top: 8px;
}

.result-section {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--section-bg, #fbfaf8);
  margin-top: 12px;
}

.result-section.group-0.level-0 {
  --section-bg: #f7f3ef;
}

.result-section.group-0 {
  --section-bg: #f7f3ef;
}

.result-section.group-1.level-0 {
  --section-bg: #fbfaf8;
}

.result-section.group-1 {
  --section-bg: #fbfaf8;
}

.result-section.group-2.level-0 {
  --section-bg: #f3efe9;
}

.result-section.group-2 {
  --section-bg: #f3efe9;
}

.result-section.group-3.level-0 {
  --section-bg: #f9f5f1;
}

.result-section.group-3 {
  --section-bg: #f9f5f1;
}

.result-title {
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  text-transform: capitalize;
}

.result-row {
  display: grid;
  grid-template-columns: minmax(160px, 260px) 1fr;
  gap: 8px;
  align-items: start;
  padding: 6px 0;
  border-bottom: 1px dashed #e6dfd8;
}

.result-key {
  font-weight: 600;
  color: #5b4f47;
}

.result-value {
  color: var(--navy);
  word-break: break-word;
}

.result-row:nth-child(odd) {
  background: rgba(250, 248, 245, 0.6);
}

.result-row:last-child {
  border-bottom: none;
}

.result-raw {
  margin-top: 12px;
}

@media (max-width: 768px) {
  .result-row {
    grid-template-columns: 1fr;
  }
}

.is-hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 29, 54, 0.4);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 20;
}

.modal.is-hidden {
  display: none;
}

.modal__card {
  width: calc(100% - 32px);
  max-width: 1200px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: grid;
  gap: 16px;
  box-sizing: border-box;
  margin: auto;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

@media (max-width: 480px) {
  .modal {
    padding: 8px;
  }
  
  .modal__card {
    width: 100%;
    padding: 16px;
  }
}

.date-picker {
  position: relative;
}

.date-picker__calendar {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10;
  min-width: 280px;
  max-width: 100vw;
  box-sizing: border-box;
}

@media (max-width: 400px) {
  .date-picker__calendar {
    left: -16px;
    right: -16px;
    min-width: auto;
  }
}

.date-picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.date-picker__nav {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--navy);
  font-size: 16px;
}

.date-picker__nav:hover {
  background: var(--bg);
  border-radius: 4px;
}

.date-picker__month-year {
  font-weight: 600;
  font-size: 14px;
}

.date-picker__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.date-picker__weekday {
  text-align: center;
  font-size: 11px;
  color: var(--beige);
  font-weight: 600;
  padding: 4px;
}

.date-picker__days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.date-picker__day {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  border-radius: 4px;
  color: var(--navy);
}

.date-picker__day:hover {
  background: var(--bg);
}

.date-picker__day--other-month {
  color: var(--border);
}

.date-picker__day--selected {
  background: var(--navy);
  color: #fff;
}

.date-picker__day--today {
  font-weight: 700;
  border: 1px solid var(--navy);
}

@media (max-width: 480px) {
  .topbar {
    padding: 12px 16px;
  }
  
  .brand__title {
    font-size: 14px;
  }
  
  .brand__subtitle {
    font-size: 11px;
  }
  
  .card {
    padding: 16px;
  }
  
  .card__header h2 {
    font-size: 18px;
  }
  
  .table {
    font-size: 12px;
  }
  
  .table th,
  .table td {
    padding: 8px 6px;
  }
  
  .btn {
    padding: 8px 12px;
    font-size: 13px;
  }
}
