:root {
  --primary: #1a2f5a;
  --primary-light: #243c73;
  --accent: #3b7dd8;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e0e4ef;
  --text: #1c1e26;
  --text-muted: #6b7280;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(26,47,90,0.1);

  /* メモタイプカラー */
  --c-help: #e53935;
  --c-share: #00acc1;
  --c-issue: #f9a825;
  --c-order: #43a047;
  --c-lost: #757575;
  --c-nego: #8e6bbf;
  --c-other: #90a4ae;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Hiragino Sans', 'Noto Sans JP', 'Meiryo', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ─────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  text-decoration: none;
}
.sidebar-logo span { color: #7eb3ff; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  border-radius: 0;
  transition: background 0.15s;
  font-size: 13.5px;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: var(--primary-light);
  color: #fff;
}
.sidebar-nav a .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-user {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}
.sidebar-user strong { display: block; color: #fff; font-size: 13px; margin-bottom: 2px; }

.main-content {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.page-header h1 { font-size: 18px; font-weight: 700; color: var(--primary); }

.page-body { padding: 24px 28px; flex: 1; }

/* ─── Cards & Surfaces ───────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 20px; }

/* ─── Buttons ────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-dark { background: var(--primary); color: #fff; }
.btn-ghost { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-danger { background: #e53935; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ─── Forms ──────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 5px; color: var(--primary); font-size: 13px; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--accent); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

/* ─── Table ──────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: #f8faff; }
tr.selected td { background: #eef4ff; }
th.sort-asc::after { content: ' ▲'; font-size: 10px; }
th.sort-desc::after { content: ' ▼'; font-size: 10px; }
th[data-sort] { cursor: pointer; }
th[data-sort]:hover { color: var(--accent); }

/* ─── Badges & Tags ──────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  min-width: 22px;
}
.badge-memo { background: var(--accent); color: #fff; }
.badge-new  { background: #e53935; color: #fff; animation: pulse 1.5s infinite; }
.badge-zero { background: #e5e7eb; color: var(--text-muted); }

@keyframes pulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}
.tag-admin { background: var(--primary); }
.tag-sales { background: #64748b; }

/* ─── Search Bar ─────────────────────── */
.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.search-input-wrap { position: relative; flex: 1; min-width: 200px; }
.search-input-wrap input { padding-left: 36px; }
.search-input-wrap::before {
  content: '🔍';
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.5;
}

/* ─── Modal ──────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--primary);
}
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Tabs ───────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s;
}
.tab-btn.active { color: var(--accent); border-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Memo Board ─────────────────────── */
.memo-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  align-items: start;
}

.memo-stack {
  position: relative;
}

/* スタック時の背景カード表示 */
.memo-stack-peek {
  position: relative;
  margin-bottom: 0;
}
.memo-stack-peek .peek-card {
  position: absolute;
  bottom: -8px;
  left: 6px;
  right: 6px;
  height: 40px;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  z-index: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.08);
}
.memo-stack-peek .peek-card:hover { opacity: 0.9; }

.memo-card {
  position: relative;
  z-index: 1;
  border-radius: 8px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.1);
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.06);
}
.memo-card-header {
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.memo-card-type {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
}
.memo-card-date {
  font-size: 11px;
  color: rgba(255,255,255,0.85);
  font-weight: 500;
}
.memo-card-body {
  padding: 10px 12px;
  background: #fff;
}
.memo-card-author {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.memo-card-content {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 36px;
  max-height: 120px;
  overflow-y: auto;
}
.memo-card-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  background: #fafbfe;
}
.memo-card-attach {
  font-size: 11.5px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 3px;
}
.memo-card-actions { display: flex; gap: 4px; }

/* メモタイプ別カラー */
.memo-type-HELP   .memo-card-header { background: var(--c-help); }
.memo-type-share  .memo-card-header { background: var(--c-share); }
.memo-type-issue  .memo-card-header { background: var(--c-issue); }
.memo-type-issue  .memo-card-type,
.memo-type-issue  .memo-card-date   { color: rgba(0,0,0,0.7); }
.memo-type-order  .memo-card-header { background: var(--c-order); }
.memo-type-lost   .memo-card-header { background: var(--c-lost); }
.memo-type-nego   .memo-card-header { background: var(--c-nego); }
.memo-type-other  .memo-card-header { background: #eceff1; }
.memo-type-other  .memo-card-type,
.memo-type-other  .memo-card-date   { color: #546e7a; }
.memo-type-other  .memo-card        { border: 1px solid #cfd8dc; }

/* ─── Login Page ─────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #2d5faa 100%);
}
.login-box {
  background: #fff;
  border-radius: 14px;
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-logo {
  text-align: center;
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--primary);
  margin-bottom: 4px;
}
.login-logo span { color: var(--accent); }
.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 32px;
}
.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: 7px;
  margin-bottom: 16px;
  font-size: 13px;
  display: none;
}

/* ─── Customer Info Panel ────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 20px;
}
.info-item label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; margin-bottom: 2px; display: block; }
.info-item span { font-size: 14px; color: var(--text); }

/* ─── Contact Table ──────────────────── */
.contact-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f0f4ff;
  border: 1px solid #c7d6f5;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--primary);
  margin: 2px;
}

/* ─── Misc Utilities ─────────────────── */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.text-center { text-align: center; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; display: none; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert.show { display: block; }

.checkbox-wrap { display: flex; align-items: center; gap: 6px; }
input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }

/* Spinner */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid rgba(59,125,216,0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* File upload zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); color: var(--accent); }
.drop-zone input[type=file] { display: none; }
