* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: #172033;
  background: #f4f7fb;
}

a {
  color: #0b5cad;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

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

.workspace {
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 100vh;
  padding: 22px 16px;
  background: #111827;
  color: #dbe7f3;
}

.sidebar-brand {
  padding: 0 10px;
  color: #ffffff;
  font-size: 20px;
  font-weight: 800;
  text-decoration: none;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 10px;
  color: #bcccdc;
  text-decoration: none;
  border-radius: 8px;
}

.sidebar-link:hover,
.sidebar-link.active {
  color: #ffffff;
  background: #1f3a5f;
}

.icon {
  flex: 0 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 24px;
  background: #ffffff;
  border-bottom: 1px solid #d9e2ec;
}

.brand {
  font-weight: 700;
  text-decoration: none;
  color: #111827;
}

.account {
  display: flex;
  gap: 16px;
  color: #52606d;
  font-size: 14px;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 28px 48px;
}

.auth-panel,
.message-panel {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px;
  background: #ffffff;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-header h1 {
  margin: 4px 0 4px;
  font-size: 28px;
  line-height: 1.2;
}

.page-header p {
  margin: 0;
}

.panel,
.empty-state {
  padding: 20px;
  background: #ffffff;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
}

.panel + .panel,
.panel + .empty-state,
.empty-state + .panel {
  margin-top: 16px;
}

.table-panel {
  padding: 0;
  overflow: auto;
}

[hidden] {
  display: none !important;
}

label {
  display: block;
  margin: 16px 0;
  font-weight: 600;
}

fieldset {
  margin: 20px 0;
  padding: 16px;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
}

legend {
  padding: 0 6px;
  color: #334e68;
  font-weight: 800;
}

input,
textarea,
select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #bcccdc;
  border-radius: 6px;
  font: inherit;
  color: #172033;
  background: #ffffff;
}

.form-field--error input,
.form-field--error textarea,
.form-field--error select,
.form-input--error {
  border-color: #c53030;
  background: #fffafa;
}

.field-error {
  display: block;
  margin-top: 6px;
  color: #9b1c1c;
  font-size: 13px;
  font-weight: 700;
}

.form-hint {
  display: block;
  margin-top: 6px;
  color: #627d98;
  font-size: 13px;
  font-weight: 500;
}

textarea {
  resize: vertical;
}

select {
  min-height: 40px;
}

button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 0;
  border-radius: 6px;
  background: #0b5cad;
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

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

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid #bcccdc;
  border-radius: 6px;
  color: #334e68;
  background: #ffffff;
  text-decoration: none;
  font-weight: 700;
}

.link-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}

.back-link {
  color: #52606d;
  text-decoration: none;
  font-size: 14px;
}

.muted {
  color: #627d98;
}

.error {
  padding: 10px 12px;
  border-radius: 6px;
  color: #8a1f11;
  background: #ffebe6;
}

.success {
  padding: 10px 12px;
  border-radius: 6px;
  color: #1f6f43;
  background: #e3fcef;
}

.summary {
  display: grid;
  gap: 12px;
}

.summary div {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 0;
  border-bottom: 1px solid #edf2f7;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.kpi-card {
  min-height: 132px;
  padding: 18px;
  background: #ffffff;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
}

.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #52606d;
  font-size: 13px;
  font-weight: 700;
}

.kpi-card strong {
  display: block;
  margin-top: 18px;
  color: #111827;
  font-size: 30px;
  line-height: 1;
}

.kpi-card p {
  margin: 10px 0 0;
  color: #627d98;
  font-size: 13px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.dashboard-card {
  margin: 0;
}

.dashboard-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.dashboard-card-header h2 {
  margin: 0;
  font-size: 18px;
}

.dashboard-list {
  display: grid;
  gap: 0;
  padding: 0;
  margin: 0;
  list-style: none;
}

.dashboard-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-top: 1px solid #edf2f7;
}

.dashboard-list-item:first-child {
  border-top: 0;
}

.dashboard-list-item a {
  font-weight: 700;
  text-decoration: none;
}

.dashboard-list-item p {
  margin: 4px 0 0;
  color: #627d98;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.dashboard-list-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
  min-width: 120px;
  color: #52606d;
  font-size: 13px;
  white-space: nowrap;
}

.quick-actions {
  display: grid;
  gap: 10px;
}

.empty-state.compact {
  padding: 16px;
}

.empty-state.compact h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.empty-state.compact p {
  margin: 0 0 12px;
}

.empty-state.compact p:last-child {
  margin-bottom: 0;
}

.stack {
  overflow: auto;
  padding: 12px;
  background: #111827;
  color: #f9fafb;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.filter-form {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(180px, 240px) auto auto;
  gap: 10px;
  align-items: end;
}

.filter-form label {
  margin: 0;
}

.search-label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #52606d;
}

.search-label input {
  margin-top: 0;
}

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

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  vertical-align: top;
}

th {
  color: #52606d;
  background: #f8fafc;
  font-size: 13px;
  font-weight: 700;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: #e0f2fe;
  color: #075985;
}

.status-confirmed,
.status-completed {
  background: #dcfce7;
  color: #166534;
}

.status-in_progress,
.status-no_show {
  background: #fef3c7;
  color: #92400e;
}

.status-cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.danger-button {
  background: #b91c1c;
}

.empty-state {
  display: grid;
  gap: 10px;
  justify-items: start;
}

.empty-state.compact {
  margin: 14px 0;
}

.empty-state h2 {
  margin: 0;
}

.empty-state p {
  margin: 0;
  color: #627d98;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.detail-full {
  grid-column: 1 / -1;
}

.detail-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf2f7;
}

.detail-list dt {
  color: #627d98;
}

.detail-list dd {
  margin: 0;
  text-align: right;
}

.plain-text {
  white-space: pre-wrap;
  line-height: 1.5;
}

.locked-context-field {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid #d9e2ec;
  border-radius: 6px;
  background: #f8fafc;
  color: #334e68;
}

.locked-context-label {
  color: #52606d;
  font-size: 13px;
  font-weight: 700;
}

.locked-context-value {
  font-weight: 700;
}

.locked-context-help {
  margin: 0;
  color: #627d98;
  font-size: 13px;
  line-height: 1.4;
}

.form-panel {
  max-width: 680px;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
}

.notice-banner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
  color: #1e3a8a;
}

.notice-banner p {
  margin: 4px 0 0;
  color: #334e68;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

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

  .page-header,
  .search-form,
  .filter-form,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    display: grid;
  }

  .notice-banner {
    align-items: stretch;
    flex-direction: column;
  }
}
