* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background: #f5f6f8;
  margin: 0;
  color: #222;
}

body.auth-loading .page {
  visibility: hidden;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px;
}

header {
  margin-bottom: 24px;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  font-weight: bold;
}

.logout-btn {
  padding: 8px 12px;
  font-size: 14px;
}

header h1 {
  margin: 0 0 6px;
  font-size: 34px;
}

header p {
  margin: 0;
  color: #666;
}

.layout {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 24px;
  align-items: start;
}

.right-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: white;
  padding: 24px;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.form-card {
  position: sticky;
  top: 24px;
}

h2 {
  margin-top: 0;
}

.form-section-title {
  font-size: 16px;
  margin: 0 0 6px;
}

.section-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 18px 0 14px;
}

label {
  display: block;
  margin-top: 14px;
  margin-bottom: 6px;
  font-weight: bold;
}

input, select {
  width: 100%;
  padding: 11px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 15px;
  background: white;
}

input[readonly] {
  background: #f3f4f6;
  color: #555;
}

.checkbox-row {
  margin-top: 14px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  text-align: left;
}

.checkbox-row .checkbox-label {
  display: grid;
  grid-template-columns: 18px 1fr;
  column-gap: 10px;
  align-items: start;
  width: 100%;
  margin: 0;
  font-weight: bold;
  line-height: 1.4;
  text-align: left;
}

.checkbox-row .checkbox-label input#full_sheet_mode {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px;
  max-width: 18px;
  margin: 4px 0 0 0 !important;
  padding: 0 !important;
  display: block;
}

.checkbox-row .checkbox-label span {
  display: block;
  text-align: left;
}

.checkbox-row small {
  display: block;
  margin-top: 6px;
  margin-left: 28px;
  color: #777;
  line-height: 1.4;
  text-align: left;
}

small {
  display: block;
  margin-top: 6px;
  color: #777;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.buttons {
  margin-top: 22px;
  display: flex;
  gap: 12px;
}

button {
  padding: 11px 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #ddd;
  font-size: 15px;
}

button.primary {
  background: #1f6feb;
  color: white;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  background: #e5e7eb;
  border-radius: 10px 10px 0 0;
  padding: 12px 18px;
  font-weight: bold;
}

.tab-btn.active {
  background: #1f6feb;
  color: white;
}

.tab-content {
  display: none;
  border-top-left-radius: 0;
}

.tab-content.active {
  display: block;
}

.empty {
  color: #666;
}

.success {
  color: #137333;
  font-weight: bold;
}

.error {
  color: #b00020;
  font-weight: bold;
}

.success {
  color: #137333;
  font-weight: bold;
}

.error {
  color: #b00020;
  font-weight: bold;
}

.notice-box {
  background: #fff7e6;
  border: 1px solid #f0c36d;
  color: #6b4700;
  border-radius: 10px;
  padding: 16px;
  line-height: 1.6;
  margin-bottom: 16px;
}

.hidden {
  display: none !important;
}

.tax-register-card {
  max-width: 520px;
  margin-bottom: 24px;
}

.summary {
  line-height: 1.7;
  margin-bottom: 18px;
}

.quote-box {
  background: #eef6ff;
  border: 1px solid #b8dcff;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
}

.quote-box a {
  color: #1f6feb;
  font-weight: bold;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
}

th, td {
  border: 1px solid #ccc;
  padding: 10px;
  text-align: right;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  background: #eee;
}

.cost-details {
  margin-top: 18px;
}

.cost-note {
  margin: 10px 0;
  color: #555;
  font-size: 14px;
}

.cost-details summary {
  cursor: pointer;
  font-weight: bold;
  color: #1f6feb;
}

.history-toolbar {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 14px;
  margin-bottom: 14px;
}

.history-toolbar label {
  margin-top: 0;
}

.history-table td,
.history-table th {
  vertical-align: top;
}

.history-main-row {
  cursor: pointer;
}

.history-main-row:hover {
  background: #f8fafc;
}

.expand-cell {
  background: #fafafa;
  padding: 16px;
}

.history-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.detail-box {
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 12px;
  background: white;
}

.detail-box h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.spec-list {
  line-height: 1.8;
}

.rate-table {
  margin-top: 0;
}

.pdf-link {
  color: #1f6feb;
  font-weight: bold;
  text-decoration: none;
}

.pdf-link:hover {
  text-decoration: underline;
}

.pagination {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
}

.pagination button {
  padding: 8px 14px;
}

.template-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #b8dcff;
  background: #eef6ff;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.template-box p {
  margin: 4px 0 0;
  font-size: 13px;
  color: #555;
  line-height: 1.4;
}

.template-download-btn {
  white-space: nowrap;
  background: #1f6feb;
  color: white;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 14px;
}

.template-download-btn:hover {
  background: #185abc;
}

@media (max-width: 600px) {
  .template-box {
    flex-direction: column;
    align-items: flex-start;
  }

  .template-download-btn {
    width: 100%;
    text-align: center;
  }
}

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

  .form-card {
    position: static;
  }

  .history-detail {
    grid-template-columns: 1fr;
  }

  .history-toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 16px;
  }

  header h1 {
    font-size: 26px;
  }

  .top-header {
    flex-direction: column;
  }

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

  .tabs {
    overflow-x: auto;
  }

  table {
    font-size: 13px;
  }

  .template-box {
    flex-direction: column;
    align-items: flex-start;
  }

  .template-download-btn {
    width: 100%;
    text-align: center;
  }
}

/* Force full sheet checkbox alignment */
.checkbox-row {
  margin-top: 14px !important;
  padding: 12px !important;
  background: #f8fafc !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 10px !important;
  text-align: left !important;
}

.checkbox-row label.checkbox-label {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  gap: 10px !important;
  width: 100% !important;
  margin: 0 !important;
  text-align: left !important;
}

.checkbox-row label.checkbox-label input#full_sheet_mode {
  appearance: auto !important;
  -webkit-appearance: checkbox !important;
  display: inline-block !important;
  width: 18px !important;
  height: 18px !important;
  min-width: 18px !important;
  max-width: 18px !important;
  margin: 4px 0 0 0 !important;
  padding: 0 !important;
  flex: 0 0 18px !important;
}

.checkbox-row label.checkbox-label span {
  display: inline-block !important;
  flex: 1 !important;
  text-align: left !important;
}

.checkbox-row small {
  display: block !important;
  margin-top: 6px !important;
  margin-left: 28px !important;
  color: #777 !important;
  line-height: 1.4 !important;
  text-align: left !important;
}