:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dde3ec;
  --text: #1c2430;
  --muted: #64748b;
  --primary: #1f5eff;
  --primary-dark: #1747c2;
  --danger: #d92d20;
  --ok: #067647;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: min(880px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  background: #101828;
  color: #fff;
  padding: 14px 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.nav-user {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #cbd5e1;
  font-size: 0.9rem;
}

main.container {
  flex: 1;
  padding: 28px 0 48px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

.card.narrow {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.center { text-align: center; }
.spacer { flex: 1; }

h1 {
  font-size: 1.25rem;
  margin: 0 0 12px;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 10px;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.alert {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.92rem;
  margin: 10px 0;
}

.alert.error {
  background: #fef3f2;
  border: 1px solid #fecdca;
  color: #b42318;
}

.alert.success {
  background: #ecfdf3;
  border: 1px solid #abefc6;
  color: #067647;
}

.button {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.button:hover:not(:disabled) {
  background: #f2f4f7;
}

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

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

.button.danger {
  background: #fff;
  border-color: #fda29b;
  color: var(--danger);
}

.button.danger:hover:not(:disabled) {
  background: #fef3f2;
}

.button.small {
  padding: 5px 10px;
  font-size: 0.82rem;
}

.button.wide {
  width: 100%;
  margin-top: 14px;
}

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

.link-button {
  appearance: none;
  background: none;
  border: none;
  color: #93c5fd;
  cursor: pointer;
  font-size: inherit;
  padding: 0;
}

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

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--muted);
  font-weight: 600;
}

.tab.active {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.form-grid label {
  display: block;
  margin-bottom: 14px;
}

.form-grid span {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

input[type="text"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(31, 94, 255, 0.35);
  outline-offset: 0;
  border-color: var(--primary);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.issue-result .url-row {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.url-box {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85rem;
}

.history-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
}

.history-header h2 {
  margin: 0;
}

.request-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.9rem;
}

.request-table th,
.request-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.request-table thead th {
  background: #f8fafc;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.purpose-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions-cell {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-waiting { background: #eff4ff; color: #175cd3; }
.status-uploaded { background: #ecfdf3; color: #067647; }
.status-revoked { background: #fef3f2; color: #b42318; }
.status-expired { background: #fffaeb; color: #b54708; }

.detail-row td {
  background: #fafbfd;
  font-size: 0.82rem;
}

.detail-info {
  padding-top: 0 !important;
}

.info-list {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 14px;
  margin: 14px 0;
}

.info-list dt {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
}

.info-list dd {
  margin: 0;
  word-break: break-word;
}

.upload-form .file-input-wrap input[type="file"] {
  width: 100%;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 16px 0;
  color: var(--muted);
  font-size: 0.8rem;
  background: var(--surface);
}

@media (max-width: 640px) {
  .url-row { flex-direction: column; }
  .request-table thead { display: none; }
  .request-table tr {
    display: block;
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }
  .request-table td {
    display: block;
    border-bottom: none;
    padding: 4px 14px;
  }
}
