:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --text: #22252a;
  --muted: #68707d;
  --line: #d9dedb;
  --primary: #166a5f;
  --primary-strong: #0f5149;
  --blue: #285f9e;
  --danger: #a33838;
  --success: #1f7a4d;
  --warning-bg: #fff4d8;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
}

.app-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.header-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.role-badge,
.status-badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 7px 10px;
  white-space: nowrap;
}

.role-badge {
  background: #e9efe9;
  color: #334039;
}

.page {
  margin: 0 auto;
  max-width: 960px;
  padding: 24px 20px 48px;
}

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

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.35;
}

.button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

.button-primary {
  background: var(--primary);
  color: #fff;
}

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

.button-secondary {
  background: #eef3f7;
  border-color: #d4dee8;
  color: #1f354d;
}

.button-success {
  background: var(--success);
  color: #fff;
}

.button-danger {
  background: #fff0f0;
  border-color: #efc9c9;
  color: var(--danger);
}

.button-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.button-wide {
  width: 100%;
}

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.flash,
.error-list {
  border-radius: var(--radius);
  padding: 12px 14px;
}

.flash-success {
  background: #e9f5ed;
  color: #185737;
}

.flash-error,
.error-list {
  background: #fff0f0;
  color: var(--danger);
}

.error-list {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.auth-panel,
.form-panel,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 32px auto 0;
  max-width: 480px;
  padding: 24px;
}

.auth-subtitle {
  color: var(--muted);
  margin-top: 6px;
}

.login-link-grid {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.login-link {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 6px;
  padding: 18px;
  text-decoration: none;
}

.login-link span {
  color: var(--muted);
  font-size: 14px;
}

.login-link strong {
  font-size: 20px;
}

.login-link-miki {
  border-left: 5px solid var(--primary);
}

.login-link-eichi {
  border-left: 5px solid var(--blue);
}

.form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: #424953;
  font-size: 14px;
  font-weight: 700;
}

input,
textarea {
  background: #fff;
  border: 1px solid #cdd4d7;
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}

textarea {
  resize: vertical;
}

.current-receipt {
  background: #f6f8f9;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
  padding: 12px;
}

.current-receipt > span {
  color: #424953;
  font-size: 14px;
  font-weight: 700;
}

.current-receipt a,
.receipt-link {
  color: var(--blue);
  font-weight: 700;
}

.checkbox-field {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 8px;
  font-size: 14px;
}

.checkbox-field input {
  min-height: auto;
  width: auto;
}

.toolbar,
.form-heading {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.summary {
  color: var(--muted);
  margin-top: 8px;
}

.summary strong {
  color: var(--text);
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 20px 0;
  overflow-x: auto;
}

.tab {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 700;
  min-width: 82px;
  padding: 10px 12px;
  text-align: center;
  text-decoration: none;
}

.tab.active {
  background: #24313b;
  border-color: #24313b;
  color: #fff;
}

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

.request-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius);
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr auto;
  padding: 18px;
}

.request-item.paid {
  border-left-color: #8c969f;
}

.request-title-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-pending {
  background: var(--warning-bg);
  color: #7a5100;
}

.status-paid {
  background: #e8eef3;
  color: #43515d;
}

.amount {
  font-size: 26px;
  font-weight: 800;
  margin-top: 10px;
}

.note {
  color: #39424c;
  margin-top: 10px;
  white-space: pre-wrap;
}

.meta-grid {
  display: grid;
  gap: 10px 16px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 16px;
}

.meta-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.meta-grid dd {
  font-size: 14px;
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.request-actions {
  align-content: start;
  display: grid;
  gap: 8px;
  min-width: 92px;
}

.request-actions form {
  display: contents;
}

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

@media (max-width: 720px) {
  .app-header {
    padding: 0 14px;
  }

  .page {
    padding: 18px 14px 40px;
  }

  .toolbar,
  .form-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .request-item {
    grid-template-columns: 1fr;
  }

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

  .request-actions .button {
    width: 100%;
  }

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

@media (max-width: 420px) {
  .header-actions {
    gap: 6px;
  }

  .button {
    padding: 0 10px;
  }

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