:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --success: #15803d;
  --text: #172033;
  --muted: #667085;
  --border: #dce2ec;
  --background: #f4f7fb;
  --surface: #ffffff;
  --shadow: 0 8px 24px rgba(26, 43, 74, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Kaku Gothic ProN",
    "Hiragino Sans",
    "Yu Gothic",
    "Meiryo",
    sans-serif;
  line-height: 1.6;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 16px;
  color: #ffffff;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
}

.app-kicker {
  margin: 0 0 2px;
  color: #bfdbfe;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.app-header h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  color: #dbeafe;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.main-content {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: 16px;
}

.intro-card,
.form-card,
.list-section {
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.intro-card {
  border-left: 5px solid var(--primary);
}

.intro-card h2,
.form-card h2,
.list-section h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.4;
}

.intro-card p,
.section-heading p,
.list-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.section-heading {
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 7px;
  font-size: 14px;
  font-weight: 700;
}

.required {
  margin-left: 4px;
  color: var(--danger);
  font-size: 12px;
}

.form-group input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--text);
  border: 1px solid #c8d1df;
  border-radius: 10px;
  outline: none;
  background: #ffffff;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.primary-button,
.secondary-button,
.icon-button,
.edit-button,
.delete-button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

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

.primary-button:disabled,
.secondary-button:disabled,
.icon-button:disabled,
.edit-button:disabled,
.delete-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.primary-button {
  flex: 1;
  min-width: 180px;
  padding: 10px 16px;
  color: #ffffff;
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  padding: 10px 16px;
  color: #344054;
  background: #edf1f7;
}

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

.icon-button {
  display: grid;
  width: 42px;
  min-width: 42px;
  place-items: center;
  padding: 0;
  color: var(--primary);
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  font-size: 23px;
}

.message-area {
  min-height: 0;
}

.message {
  margin: 0 0 14px;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

.message.success {
  color: #166534;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
}

.message.error {
  color: #991b1b;
  border: 1px solid #fecaca;
  background: #fef2f2;
}

.message.info {
  color: #1e40af;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
}

.loading-area,
.empty-area {
  padding: 32px 16px;
  text-align: center;
}

.loading-area p,
.empty-area p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.empty-area h3 {
  margin: 6px 0 0;
  font-size: 17px;
}

.empty-icon {
  font-size: 34px;
}

.spinner {
  width: 30px;
  height: 30px;
  margin: 0 auto;
  border: 4px solid #dbeafe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: rotate 0.8s linear infinite;
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

.application-list {
  display: grid;
  gap: 12px;
}

.application-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #ffffff;
}

.application-card-main {
  padding: 16px;
}

.application-date {
  display: inline-block;
  margin-bottom: 10px;
  padding: 3px 9px;
  color: #1d4ed8;
  border-radius: 999px;
  background: var(--primary-light);
  font-size: 13px;
  font-weight: 800;
}

.application-key {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
}

.application-borrower {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.application-admin-user {
  margin: 8px 0 0;
  color: #7c3aed;
  font-size: 12px;
  word-break: break-all;
}

.application-card-actions {
  display: flex;
  border-top: 1px solid var(--border);
}

.edit-button,
.delete-button {
  flex: 1;
  min-height: 42px;
  border-radius: 0;
  background: #ffffff;
  font-size: 14px;
}

.edit-button {
  color: var(--primary);
  border-right: 1px solid var(--border);
}

.delete-button {
  color: var(--danger);
}

.delete-button:hover {
  color: #ffffff;
  background: var(--danger);
}

.hidden {
  display: none !important;
}

.app-footer {
  padding: 16px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.app-footer p {
  margin: 0;
}

@media (min-width: 640px) {
  .app-header {
    padding: 24px max(24px, calc((100% - 828px) / 2));
  }

  .app-header h1 {
       font-size: 26px;
  }

  .main-content {
    padding: 24px 16px;
  }

  .intro-card,
  .form-card,
  .list-section {
    padding: 24px;
  }

  .application-card {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
  }

  .application-card-main {
    flex: 1;
  }

  .application-card-actions {
    flex-direction: column;
    min-width: 100px;
    border-top: 0;
    border-left: 1px solid var(--border);
  }

  .edit-button,
  .delete-button {
    min-height: 50%;
  }

  .edit-button {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}