/* =========================================================
   Mail Console - Refined Corporate UI (v2)
   Goals: clarity on PC, comfortable touch targets on mobile,
          consistent spacing/typography, subtle motion.
   ========================================================= */

:root {
  /* ----- Color tokens (Black / Gold #c6a579 / White) ----- */
  --primary:        #c6a579;   /* gold */
  --primary-hover:  #b89160;
  --primary-active: #9a784c;
  --primary-light:  #faf6ef;
  --primary-border: #e6d6bd;
  --primary-strong: #9a784c;

  --gold:           #c6a579;
  --gold-soft:      #d9c19a;
  --gold-deep:      #9a784c;
  --ink:            #0a0a0a;   /* near black */
  --ink-soft:       #1f1f1f;

  --accent:         #c6a579;
  --accent-light:   #faf6ef;

  --bg:             #f4f6fb;   /* page background */
  --bg-deep:        #eef1f7;
  --surface:        #ffffff;
  --surface-2:      #f8fafc;
  --surface-3:      #f1f5f9;
  --sidebar-bg:     #ffffff;
  --topbar-bg:      #ffffff;

  --border:         #e5e7eb;
  --border-strong:  #d1d5db;
  --divider:        #eef0f4;

  --text-primary:   #0f172a;
  --text-secondary: #334155;
  --text-muted:     #64748b;
  --text-subtle:    #94a3b8;
  --text-on-primary:#ffffff;

  --success:    #047857;
  --success-bg: #ecfdf5;
  --success-bd: #a7f3d0;
  --warning:    #b45309;
  --warning-bg: #fffbeb;
  --warning-bd: #fde68a;
  --danger:     #b91c1c;
  --danger-bg:  #fef2f2;
  --danger-bd:  #fecaca;
  --info:       #9a784c;
  --info-bg:    #faf6ef;
  --info-bd:    #e6d6bd;

  /* ----- Shadows ----- */
  --shadow-xs: 0 1px 1px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow:    0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 8px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 12px 24px -8px rgba(15, 23, 42, 0.14), 0 4px 10px -4px rgba(15, 23, 42, 0.06);
  --shadow-focus: 0 0 0 3px rgba(198, 165, 121, 0.28);

  /* ----- Radii ----- */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius:    8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 9999px;

  /* ----- Spacing scale ----- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10:40px;

  /* ----- Motion ----- */
  --ease:     cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur:      180ms;
  --dur-slow: 260ms;

  /* ----- Layout ----- */
  --sidebar-w:     248px;
  --topbar-h:      60px;
  --footer-tab-h:  64px;
  --content-max:   1320px;
}

/* ============ Base reset / typography ============ */
* { box-sizing: border-box; }

body, p, h1, h2, h3, h4, h5, h6, div, span, a, button, input, textarea, select, label, li {
  font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { margin: 0; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}
a:hover { color: var(--primary-hover); }

button { font-family: inherit; }

:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}

/* selection */
::selection {
  background: var(--primary-light);
  color: var(--primary-strong);
}

/* ============ App layout ============ */
.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* ============ Sidebar ============ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  background: #0a0a0a;
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(198, 165, 121, 0.25);
  position: relative;
}
.sidebar-brand::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(198, 165, 121, 0.6), transparent);
}
.sidebar-brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  flex-shrink: 0;
  border: 1px solid rgba(198, 165, 121, 0.35);
}
.sidebar-brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.sidebar-brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #c6a579;
}
.sidebar-brand-sub {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 10px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 0 10px 6px;
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
}

.sidebar-link i {
  width: 18px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  transition: color var(--dur-fast) var(--ease);
}

.sidebar-link:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.sidebar-link:hover i { color: var(--text-primary); }

.sidebar-link.active {
  background: var(--primary-light);
  color: var(--primary-strong);
  font-weight: 600;
}
.sidebar-link.active i { color: var(--primary); }

/* Left accent indicator on active link */
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}

.sidebar-link-badge {
  margin-left: auto;
  font-size: 10.5px;
  background: var(--surface-3);
  color: var(--text-muted);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}
.sidebar-link.active .sidebar-link-badge {
  background: var(--primary);
  color: #fff;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--divider);
  font-size: 11px;
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-footer i { color: var(--success); font-size: 8px; }

/* ============ Main area ============ */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ============ Topbar ============ */
.topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 25;
  min-height: var(--topbar-h);
  backdrop-filter: saturate(180%) blur(8px);
  background: rgba(255, 255, 255, 0.92);
}

.topbar-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease);
}
.topbar-menu-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.topbar-menu-btn:active { background: var(--surface-3); }

.topbar-titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-title-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.topbar-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ============ Content area ============ */
.content {
  flex: 1;
  padding: 28px;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* ============ Panel / Card ============ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.panel-title i { color: var(--text-muted); }

.panel-body { padding: 18px; }

/* Legacy compat */
.glass-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

/* ============ Tiles (menu) ============ */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.menu-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  text-decoration: none;
  transition: transform var(--dur) var(--ease-out),
              border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  overflow: hidden;
}
.menu-tile::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 14px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--surface-3);
  transition: background var(--dur-fast) var(--ease);
}
.menu-tile:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  color: var(--text-primary);
}
.menu-tile:hover::after { background: var(--primary); }

.menu-tile-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 18px;
  transition: transform var(--dur) var(--ease-out);
}
.menu-tile:hover .menu-tile-icon { transform: scale(1.05); }

.menu-tile-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.menu-tile-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.menu-tile-arrow {
  margin-top: auto;
  font-size: 12px;
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
  font-weight: 500;
  transition: color var(--dur-fast) var(--ease), gap var(--dur-fast) var(--ease);
}
.menu-tile:hover .menu-tile-arrow {
  color: var(--primary);
  gap: 10px;
}

/* ============ Buttons ============ */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              transform 80ms var(--ease);
  border-radius: var(--radius);
  user-select: none;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.4;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  box-shadow: 0 1px 2px rgba(30, 64, 175, 0.25);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 12px -2px rgba(30, 64, 175, 0.35);
}
.btn-primary:active:not(:disabled) {
  background: var(--primary-active);
  border-color: var(--primary-active);
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(30, 64, 175, 0.2);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--text-subtle);
  color: var(--text-primary);
}
.btn-secondary:active:not(:disabled) {
  background: var(--surface-3);
  transform: translateY(1px);
}
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
  background: var(--surface);
  border: 1px solid var(--danger-bd);
  color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-bg);
  border-color: #fca5a5;
}
.btn-danger:active:not(:disabled) { transform: translateY(1px); }

.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text-primary);
}

/* Icon-only button */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
}

/* ============ Forms ============ */
.input-field,
input[type="text"].input-field,
input[type="email"].input-field,
input[type="password"].input-field,
input[type="number"].input-field,
textarea.input-field,
select.input-field {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
  border-radius: var(--radius);
  font-size: 13.5px;
}

.input-field:hover:not(:focus):not(:disabled) {
  border-color: var(--text-subtle);
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

.input-field::placeholder {
  color: var(--text-subtle);
}

.input-field:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}

textarea.input-field {
  line-height: 1.6;
  resize: vertical;
}

label { color: var(--text-secondary); }

/* Search input wrapper */
.input-search {
  position: relative;
}
.input-search > input {
  padding-left: 36px;
}
.input-search > i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  font-size: 13px;
  pointer-events: none;
}

/* ============ Checkbox (custom) ============ */
.custom-checkbox {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: all var(--dur-fast) var(--ease);
  flex-shrink: 0;
}
.custom-checkbox:hover:not(:disabled) {
  border-color: var(--primary);
}
.custom-checkbox:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.custom-checkbox:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
}
.custom-checkbox:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ Scrollbar ============ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border: 2px solid transparent;
  background-clip: content-box;
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
  background-clip: content-box;
}

/* ============ Badges ============ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
  white-space: nowrap;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

.badge-success { background: var(--success-bg); color: var(--success); border-color: var(--success-bd); }
.badge-pending { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-bd); }
.badge-failed  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-bd); }
.badge-info    { background: var(--info-bg);    color: var(--info);    border-color: var(--info-bd); }
.badge-neutral { background: var(--surface-3);  color: var(--text-secondary); border-color: var(--border); }

/* ============ Spinner ============ */
.spinner {
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Toast ============ */
.toast {
  animation: toast-in 0.22s var(--ease-out);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius);
}
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ============ Modal ============ */
.modal-overlay {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  animation: fade-in var(--dur) var(--ease-out);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  animation: modal-in var(--dur-slow) var(--ease-out);
  box-shadow: var(--shadow-lg) !important;
  border-radius: var(--radius-lg) !important;
}
@keyframes modal-in {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* ============ Tables ============ */
.data-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table th {
  background: var(--surface-2);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--divider);
  color: var(--text-primary);
  font-size: 13px;
}

.data-table tbody tr {
  transition: background var(--dur-fast) var(--ease);
}
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ============ Variable chips ============ */
.var-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  margin: 1px 2px;
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  color: var(--primary-strong);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-family: 'JetBrains Mono', 'Menlo', monospace;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  user-select: none;
}
.var-chip:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  transform: translateY(-1px);
}
.var-chip:active { transform: translateY(0); }

/* ============ File items ============ */
.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
  border: 1px solid transparent;
}
.file-item:hover { background: var(--surface-2); }
.file-item.selected {
  background: var(--primary-light);
  border-color: var(--primary-border);
}

/* ============ Section header ============ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 400;
}

/* ============ Form group ============ */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-help {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============ Stat cards ============ */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform var(--dur) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: #d4dbe6;
}
.stat-card-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.stat-card-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-card-icon.green  { background: var(--success-bg);   color: var(--success); }
.stat-card-icon.amber  { background: var(--warning-bg);   color: var(--warning); }
.stat-card-icon.sky    { background: var(--accent-light); color: var(--accent); }
.stat-card-icon.red    { background: var(--danger-bg);    color: var(--danger);  }

.stat-card-body { min-width: 0; flex: 1; }
.stat-label {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  line-height: 1.4;
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.stat-value.text-small { font-size: 13px; padding-top: 6px; }

/* ============ Empty state ============ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 36px;
  color: var(--text-subtle);
  margin-bottom: 12px;
  opacity: 0.6;
}
.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.empty-state-desc {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 360px;
  margin: 0 auto;
}

/* ============ Avatar ============ */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }

/* ============ Compose page layout ============ */
.compose-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: start;
}

.compose-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.contact-list-scroll {
  max-height: calc(100vh - 320px);
  min-height: 280px;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

/* Compose contact row */
.compose-contact {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
  border: 1px solid transparent;
}
.compose-contact:hover { background: var(--surface-2); }
.compose-contact.selected {
  background: var(--primary-light);
  border-color: var(--primary-border);
}

/* Mobile tabs */
.compose-mobile-tabs {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 14px;
  gap: 4px;
}

.compose-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
}
.compose-tab i { font-size: 13px; }
.compose-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px -2px rgba(30, 64, 175, 0.4);
}
.compose-tab.active i { color: #fff; }

.compose-tab-badge {
  background: var(--surface-3);
  color: var(--text-secondary);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
}
.compose-tab.active .compose-tab-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* Compose action bar */
.compose-action-bar {
  position: sticky;
  bottom: 12px;
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-md);
  z-index: 10;
}

/* Per-contact attachment row */
.per-contact-att-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

/* ============ Footer Tab Bar (Mobile) - FAB style ============ */
.footer-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #ffffff;
  border-top: 1px solid var(--border);
  z-index: 45;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  align-items: center;
  justify-content: space-between;
}

/* 左右のサイド(各2アイテム) */
.footer-tab-side {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-around;
}

.footer-tab-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  min-width: 54px;
  height: 48px;
  border-radius: 10px;
  transition:
    color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.footer-tab-item i {
  font-size: 18px;
  line-height: 1;
  transition: transform var(--dur) var(--ease-out);
}
.footer-tab-item span {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0.85;
}

.footer-tab-item:active {
  transform: scale(0.94);
  background: rgba(30, 64, 175, 0.06);
}

.footer-tab-item.active {
  color: var(--primary);
}
.footer-tab-item.active i {
  color: var(--primary);
}
.footer-tab-item.active span {
  opacity: 1;
}

/* 中央のFAB(作成) - バー内に収まるフラット円形 */
.footer-tab-fab {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  flex-shrink: 0;
  margin: 0 8px;
  transition:
    transform var(--dur) var(--ease-out),
    background var(--dur) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.footer-tab-fab i {
  font-size: 18px;
  color: #fff;
  transition: transform var(--dur) var(--ease-out);
}
.footer-tab-fab:hover {
  background: var(--primary-strong);
  color: #fff;
}
.footer-tab-fab:active {
  transform: scale(0.95);
}
.footer-tab-fab:active i {
  transform: rotate(-10deg);
}
.footer-tab-fab.active {
  background: var(--primary-strong);
}

/* ============ More menu sheet ============ */
.more-menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 60;
  backdrop-filter: blur(3px);
  animation: fade-in var(--dur) var(--ease-out);
}
.more-menu-backdrop.open { display: block; }

.more-menu-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 12px 20px 24px;
  box-shadow: var(--shadow-lg);
  z-index: 61;
  transform: translateY(100%);
  transition: transform var(--dur-slow) var(--ease-out);
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
}
.more-menu-sheet.open { transform: translateY(0); }

.more-menu-handle {
  width: 40px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 0 auto 14px;
}
.more-menu-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  text-align: center;
  letter-spacing: -0.01em;
}
.more-menu-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.more-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all var(--dur-fast) var(--ease);
}
.more-menu-item:active {
  transform: scale(0.97);
}
.more-menu-item:hover,
.more-menu-item.active {
  border-color: var(--primary-border);
  background: var(--primary-light);
  color: var(--primary-strong);
}
.more-menu-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
  transition: all var(--dur-fast) var(--ease);
}
.more-menu-item:hover .more-menu-icon,
.more-menu-item.active .more-menu-icon {
  background: #fff;
  color: var(--primary);
}
.more-menu-label {
  font-size: 12px;
  font-weight: 600;
}
.more-menu-close {
  width: 100%;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.more-menu-close:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}

/* ============ Sidebar backdrop ============ */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 40;
  animation: fade-in var(--dur) var(--ease-out);
}

/* ============ Sticky footer (page actions) ============ */
.page-action-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.04);
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

/* ============ Utility ============ */
.divider { border-top: 1px solid var(--divider); }
.text-muted-app { color: var(--text-muted); }
.gradient-text { color: var(--text-primary); }

.kbd {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
}

/* ============ Responsive ============ */
@media (max-width: 1024px) {
  .content { padding: 22px; }
  .hero { padding: 24px; }
  .hero-title { font-size: 20px; }
}

@media (max-width: 768px) {
  :root {
    --sidebar-w: 280px;
  }
  .sidebar {
    position: fixed;
    left: calc(var(--sidebar-w) * -1 - 8px);
    top: 0;
    width: var(--sidebar-w);
    transition: left var(--dur-slow) var(--ease-out);
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .sidebar-backdrop.open { display: block; }

  .topbar {
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.96);
  }
  .topbar-menu-btn { display: inline-flex; }
  .topbar-title { font-size: 16px; }
  .topbar-subtitle { font-size: 11.5px; }

  .content {
    /* フッタータブ(固定型:height 60px)+余白で被り防止 */
    padding: 16px 14px 76px;
  }

  .footer-tab-bar { display: flex; }

  /* Tiles */
  .tile-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .menu-tile { padding: 14px; gap: 8px; }
  .menu-tile-title { font-size: 13.5px; }
  .menu-tile-desc { font-size: 11.5px; -webkit-line-clamp: 2; }
  .menu-tile-icon { width: 36px; height: 36px; font-size: 16px; }

  /* Stats */
  .stat-card { padding: 14px; gap: 10px; }
  .stat-card-icon { width: 38px; height: 38px; font-size: 16px; }
  .stat-value { font-size: 19px; }

  /* Larger touch targets */
  .btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
    min-height: 40px;
  }
  .input-field {
    min-height: 42px;
  }
  .panel-header { padding: 12px 14px; }
  .panel-body { padding: 14px; }

  /* Tables become cards (optional class) */
  .data-table.responsive thead { display: none; }
  .data-table.responsive tr {
    display: block;
    border-bottom: 1px solid var(--divider);
    padding: 10px 0;
  }
  .data-table.responsive td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
    padding: 6px 14px;
    font-size: 13px;
  }
  .data-table.responsive td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .section-header { gap: 8px; }
  .section-title { font-size: 14.5px; }

  /* Compose: switch to single-column tabs */
  .compose-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .compose-right { gap: 0; }
  .compose-mobile-tabs { display: flex; }
  /* デフォルト: 宛先のみ表示。JS で .pane-active を切り替え */
  .compose-pane { display: none; }
  #pane-recipients { display: block; }  /* 初期表示 */
  .compose-pane.pane-active { display: block; }
  /* 別ペインが active になったら recipients を隠す */
  body:has(.compose-pane.pane-active) #pane-recipients:not(.pane-active) { display: none; }

  .contact-list-scroll { max-height: 60vh; }

  .compose-action-bar {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: 92px;  /* フッタータブ(浮遊型)の上に配置 */
    margin-top: 0;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
  }
  .compose-action-bar > div:first-child { font-size: 12.5px; }
}

@media (max-width: 480px) {
  .tile-grid { grid-template-columns: 1fr; }
  .menu-tile {
    flex-direction: row;
    align-items: center;
    padding: 14px;
  }
  .menu-tile-icon { width: 40px; height: 40px; }
  .menu-tile-arrow {
    margin-top: 0;
    margin-left: auto;
    padding-top: 0;
  }
  .menu-tile-body { flex: 1; min-width: 0; }

  .footer-tab-item span { font-size: 10px; }
  .footer-tab-item i { font-size: 17px; }
}

/* ============ Reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
 * 連絡先フォーム (不動産業向け詳細フォーム)
 * ============================================ */

/* タブ */
.contact-form-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.cf-tab {
  flex-shrink: 0;
  padding: 9px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease);
}
.cf-tab:hover {
  color: var(--text-secondary);
  background: var(--surface-soft);
}
.cf-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.contact-form-body {
  min-height: 280px;
}
.cf-pane {
  display: none;
}
.cf-pane.active {
  display: block;
  animation: fade-in var(--dur) var(--ease-out);
}

/* レイアウト */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.cf-pane .form-group {
  margin-bottom: 14px;
}
.cf-pane .input-field {
  width: 100%;
  padding: 8px 11px;
  font-size: 13.5px;
  border-radius: 6px;
}
.cf-pane select.input-field {
  cursor: pointer;
}

/* 電話3ボックス */
.phone-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.phone-box {
  width: 90px !important;
  text-align: center;
  letter-spacing: 0.05em;
}
.phone-sep {
  color: var(--text-muted);
  font-weight: 600;
}

/* 郵便番号検索 */
.zip-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.zip-box {
  width: 160px !important;
  letter-spacing: 0.05em;
}
.zip-btn {
  padding: 7px 14px;
  font-size: 12.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* レンジ入力 (平米数・金額) */
.range-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.range-row .input-field {
  width: auto !important;
  flex: 1;
  min-width: 100px;
}
.range-sep {
  color: var(--text-muted);
  font-weight: 600;
  padding: 0 4px;
}
.unit {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}
.unit-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.unit-row .input-field {
  flex: 1;
}

/* スイッチ */
.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  background: var(--surface-soft);
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.switch-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* 間取りチップ */
.layout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 6px;
}
.layout-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  user-select: none;
}
.layout-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.layout-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.layout-chip input[type="checkbox"] {
  display: none;
}

/* 希望エリア (動的追加リスト) */
.pref-city-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.pref-city-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px;
  align-items: center;
}
.pc-del {
  padding: 6px 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 4px;
}
.pc-del:hover {
  background: rgba(220,38,38,0.08);
}

/* タグ入力 (希望駅) */
.tag-input-area {
  min-height: 36px;
  padding: 6px 8px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tag-input-row {
  display: flex;
  gap: 6px;
}
.tag-input-row .input-field {
  flex: 1;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 10px;
  background: var(--primary);
  color: #fff;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
}
.tag-del {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 10px;
}
.tag-del:hover {
  color: #fff;
}
.empty-inline {
  font-size: 12.5px;
  color: var(--text-subtle);
  font-style: italic;
}

/* ボタン: small variant */
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 4px;
}

/* モバイル */
@media (max-width: 640px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
  .phone-box {
    width: 70px !important;
  }
  .pref-city-row {
    grid-template-columns: 1fr 1fr auto;
  }
  .range-row {
    flex-wrap: wrap;
  }
  .layout-grid {
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  }
  .zip-box {
    width: 120px !important;
  }
}

/* ============================================
 * 連絡先カードUI (テーブル代替)
 * ============================================ */
.contact-cards {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.contact-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--divider);
  align-items: flex-start;
  transition: background 0.12s;
}
.contact-card:hover {
  background: var(--surface-2);
}
.contact-card:last-child {
  border-bottom: none;
}
.contact-card-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  margin-top: 2px;
}
.contact-card-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.contact-card-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.contact-card-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.cc-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}
.cc-kana {
  font-size: 11px;
  color: var(--text-muted);
}
.contact-card-company {
  font-size: 12px;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.contact-card-company .fas {
  color: var(--text-subtle);
  font-size: 11px;
}
.contact-card-contact {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.cc-email, .cc-phone {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.cc-email .fas, .cc-phone .fas {
  color: var(--text-subtle);
  font-size: 11px;
}
.contact-card-wishes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.wish-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  line-height: 1.5;
}
.wish-chip .fas {
  font-size: 10px;
  opacity: 0.7;
}
.wish-chip.wish-area    { background: #faf6ef; border-color: #e6d6bd; color: #9a784c; }
.wish-chip.wish-station { background: #f4ece0; border-color: #d9c19a; color: #6f5230; }
.wish-chip.wish-layout  { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.wish-chip.wish-price   { background: #fefce8; border-color: #fde047; color: #854d0e; }
.wish-chip.wish-age     { background: #faf5ff; border-color: #e9d5ff; color: #6b21a8; }
.wish-chip.wish-sqm     { background: #f1f5f9; border-color: #cbd5e1; color: #334155; }
.wish-chip.wish-sublease{ background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.contact-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.contact-card-actions {
  display: flex;
  gap: 2px;
  align-items: center;
}
.contact-card-actions .btn-ghost {
  padding: 6px 9px;
  border-radius: 4px;
  font-size: 12px;
}

/* モバイル */
@media (max-width: 640px) {
  .contact-card {
    grid-template-columns: 36px 1fr;
    gap: 10px;
    padding: 12px 14px;
  }
  .contact-card-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    margin-top: 4px;
  }
  .contact-card-head {
    gap: 8px;
  }
  .contact-card-contact {
    gap: 10px;
  }
}

/* ============================================
 * 送信前プレビューモーダル
 * ============================================ */
.preview-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 12px;
  padding-bottom: 0;
}
.preview-tab {
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
}
.preview-tab:hover {
  color: var(--text-primary);
  background: var(--surface-2);
}
.preview-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.preview-content {
  padding: 4px 0;
}
.preview-meta {
  background: var(--surface-2);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}
.preview-meta-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 4px;
}
.preview-meta-row:last-child { margin-bottom: 0; }
.preview-meta-label {
  color: var(--text-muted);
  font-size: 11px;
  min-width: 60px;
}
.preview-meta-value {
  color: var(--text-primary);
  font-weight: 500;
  flex: 1;
}
.preview-subject {
  font-size: 14px;
  font-weight: 600;
  padding: 10px 14px;
  background: var(--primary-light);
  color: var(--primary-strong);
  border-radius: 6px 6px 0 0;
  border: 1px solid var(--primary);
  border-bottom: none;
}
.preview-body {
  padding: 14px;
  background: white;
  border: 1px solid var(--primary);
  border-radius: 0 0 6px 6px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text-primary);
  font-family: inherit;
}
.preview-attachments {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}
.preview-attachments-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 11px;
}

/* テンプレートプレビューも同じスタイル */

/* ============================================
 * 送信画面 - 希望条件フィルタ
 * ============================================ */
.compose-filter-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}
.compose-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.compose-filter-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.compose-filter-toggle .fas {
  transition: transform 0.18s;
}
.compose-filter-panel.collapsed .compose-filter-toggle .fas {
  transform: rotate(-90deg);
}
.compose-filter-panel.collapsed .compose-filter-body {
  display: none;
}
.compose-filter-body {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cf-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cf-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.cf-chip {
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11.5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s;
}
.cf-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.cf-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.cf-range {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
}
.cf-range input {
  width: 80px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
}
.cf-filter-summary {
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 6px 0;
}
.cf-filter-clear {
  font-size: 11px;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  background: transparent;
  border: none;
  padding: 0;
}

/* ============================================
 * 送信画面 - 連絡先表示拡張(最終送信日時等)
 * ============================================ */
.compose-contact-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-subtle);
  margin-top: 2px;
}
.compose-contact-last-sent {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.compose-contact-last-sent .fas {
  font-size: 9px;
}
.compose-contact-detail-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.12s;
}
.compose-contact-detail-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* 連絡先詳細モーダル */
.cd-section {
  margin-bottom: 14px;
}
.cd-section:last-child { margin-bottom: 0; }
.cd-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--divider);
}
.cd-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px;
  padding: 4px 0;
  font-size: 12.5px;
}
.cd-label {
  color: var(--text-muted);
  font-size: 11.5px;
}
.cd-value {
  color: var(--text-primary);
}

/* ========== Auth: Login Screen ========== */
.login-body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at 0% 0%, rgba(198, 165, 121, 0.22), transparent 45%),
    radial-gradient(circle at 100% 100%, rgba(198, 165, 121, 0.10), transparent 45%),
    linear-gradient(135deg, #0a0a0a 0%, #1f1f1f 60%, #0a0a0a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-shell { width: 100%; max-width: 420px; }
.login-card {
  background: #ffffff;
  border: 1px solid #ece5d8;
  border-radius: 18px;
  padding: 36px 32px;
  box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.55), 0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(198, 165, 121, 0.18);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.login-brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #0a0a0a;
  color: #c6a579;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px;
  box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.4);
}
.login-brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.login-brand-title { font-size: 15px; font-weight: 700; color: #0f172a; }
.login-brand-sub { font-size: 11px; color: #64748b; font-weight: 500; }
.login-title {
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}
.login-desc { font-size: 13px; color: #64748b; margin: 0 0 24px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 6px;
}
.login-label i { color: #94a3b8; font-size: 11px; }
.login-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  background: #f8fafc;
  color: #0f172a;
  transition: all 0.15s;
  font-family: inherit;
}
.login-input:focus {
  outline: none;
  border-color: #c6a579;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(198, 165, 121, 0.22);
}
.login-password-wrap { position: relative; }
.login-password-wrap .login-input { padding-right: 42px; }
.login-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: 8px;
  font-size: 13px;
  border-radius: 6px;
  transition: background 0.15s;
}
.login-eye:hover { background: #f1f5f9; color: #475569; }
.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
}
.login-submit {
  width: 100%;
  background: linear-gradient(135deg, #0a0a0a 0%, #1f1f1f 100%);
  color: #c6a579;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  padding: 12px 16px;
  border: 1px solid #c6a579;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: 0 6px 16px -4px rgba(0, 0, 0, 0.45);
  transition: all 0.15s;
}
.login-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #1f1f1f 0%, #0a0a0a 100%);
  box-shadow: 0 10px 22px -4px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(198, 165, 121, 0.4);
}
.login-submit:disabled { opacity: 0.7; cursor: not-allowed; }
.login-footer {
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
  margin-top: 22px;
  letter-spacing: 0.04em;
}

/* Login modal */
.login-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-modal-card {
  background: #fff;
  border-radius: 16px;
  max-width: 460px;
  width: 100%;
  padding: 28px;
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.4);
  animation: lmFadeIn 0.2s ease-out;
}
@keyframes lmFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.login-modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fffbeb;
  color: #d97706;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 16px;
}
.login-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  text-align: center;
  margin: 0 0 10px;
}
.login-modal-desc {
  font-size: 13.5px;
  color: #475569;
  text-align: center;
  line-height: 1.6;
  margin: 0 0 16px;
}
.login-modal-info {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login-modal-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
}
.login-modal-info-label { color: #64748b; font-weight: 500; }
.login-modal-info-value { color: #0f172a; font-weight: 600; }
.login-modal-actions { display: flex; gap: 8px; }
.login-modal-btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}
.login-modal-btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.login-modal-btn-secondary:hover { background: #e2e8f0; }
.login-modal-btn-primary {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  box-shadow: 0 4px 12px -2px rgba(239, 68, 68, 0.4);
}
.login-modal-btn-primary:hover { transform: translateY(-1px); }

/* ========== Sidebar User Block ========== */
.sidebar-user {
  border-top: 1px solid var(--divider, #e2e8f0);
  padding: 14px 16px 10px;
  margin-top: 8px;
}
.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #0a0a0a;
  color: #c6a579;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid rgba(198, 165, 121, 0.35);
}
.sidebar-user-meta { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
  margin-top: 2px;
}
.sidebar-role-badge.admin {
  background: #0a0a0a;
  color: #c6a579;
  border: 1px solid #c6a579;
}
.sidebar-role-badge.user {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.sidebar-logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #475569;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.sidebar-logout-btn:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

/* ========== Users Management ========== */
.user-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
  transition: all 0.15s;
}
.user-card:hover { border-color: #cbd5e1; box-shadow: 0 4px 12px -4px rgba(15, 23, 42, 0.08); }
.user-card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #f1f5f9;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.user-card-avatar.admin {
  background: #0a0a0a;
  color: #c6a579;
  border: 1px solid rgba(198, 165, 121, 0.4);
}
.user-card-main { flex: 1; min-width: 0; }
.user-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.user-card-name {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
}
.user-card-me {
  background: #faf6ef;
  color: #9a784c;
  border: 1px solid #e6d6bd;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}
.user-card-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: #64748b;
}
.user-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.role-badge.admin {
  background: #0a0a0a;
  color: #c6a579;
  border: 1px solid #c6a579;
}
.role-badge.user {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.user-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.user-status-badge.on { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.user-status-badge.on i { font-size: 7px; color: #10b981; }
.user-status-badge.idle { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }
.user-status-badge.off { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* Role radios (edit modal) */
.user-role-radios { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.user-role-radio { cursor: pointer; }
.user-role-radio input { display: none; }
.user-role-radio-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  transition: all 0.15s;
}
.user-role-radio input:checked + .user-role-radio-card {
  border-color: #c6a579;
  background: #faf6ef;
  box-shadow: 0 0 0 3px rgba(198, 165, 121, 0.18);
}
.user-role-radio input:disabled + .user-role-radio-card {
  opacity: 0.5;
  cursor: not-allowed;
}
.user-role-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-role-icon.user { background: #f1f5f9; color: #64748b; }
.user-role-icon.admin { background: #0a0a0a; color: #c6a579; border: 1px solid rgba(198, 165, 121, 0.4); }
.user-role-name { display: block; font-size: 12.5px; font-weight: 600; color: #0f172a; }
.user-role-desc { display: block; font-size: 10.5px; color: #64748b; margin-top: 1px; }
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #0f172a;
  cursor: pointer;
}

@media (max-width: 640px) {
  .user-card { flex-wrap: wrap; }
  .user-card-actions { width: 100%; justify-content: flex-end; margin-top: 4px; }
  .user-role-radios { grid-template-columns: 1fr; }
}

/* ========================================================
   Send History (Hybrid: Rich Table on PC / Cards on Mobile)
   ======================================================== */

/* Toolbar */
.history-toolbar {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--divider);
  align-items: center;
  flex-wrap: wrap;
}
.history-search {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.history-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  font-size: 12px;
  pointer-events: none;
}
.history-search-input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface-2);
  color: var(--text-primary);
  transition: all 0.15s;
  font-family: inherit;
}
.history-search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: var(--shadow-focus);
}
.history-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.history-select {
  padding: 8px 30px 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2010%206%22%3E%3Cpath%20d%3D%22M1%201l4%204%204-4%22%20stroke%3D%22%23718096%22%20stroke-width%3D%221.5%22%20fill%3D%22none%22%20stroke-linecap%3D%22round%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 9px;
  appearance: none;
}
.history-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}
.history-meta {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--divider);
}
.history-meta strong { color: var(--text-primary); font-weight: 700; }

/* Table (PC) */
.history-table-wrap { overflow-x: auto; }
.history-table .history-row { transition: background 0.1s; }
.history-table .history-row:hover { background: var(--surface-2); }
.history-subject {
  font-weight: 500;
  color: var(--text-primary);
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-id {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'SFMono-Regular', Consolas, monospace;
  margin-top: 2px;
}
.history-rate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.history-rate-num { font-size: 12.5px; font-weight: 700; }
.history-rate-bar {
  width: 56px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}
.history-rate-fill { height: 100%; border-radius: 2px; transition: width 0.3s ease; }

/* Cards (Mobile) */
.history-cards { display: none; padding: 12px; flex-direction: column; gap: 10px; }
.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  transition: all 0.15s;
}
.history-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.history-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
}
.history-card-title { flex: 1; min-width: 0; }
.history-card-subject {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.history-card-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.history-card-meta i { font-size: 10px; }
.history-card-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.history-card-stat {
  text-align: center;
  padding: 8px 4px;
  background: var(--surface-2);
  border-radius: 8px;
}
.history-card-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}
.history-card-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.history-card-bar {
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 10px;
}
.history-card-bar-fill { height: 100%; border-radius: 2px; transition: width 0.3s ease; }
.history-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* Detail modal */
.history-detail-table-wrap {
  max-height: 40vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Responsive switch */
@media (max-width: 768px) {
  .history-table-wrap { display: none; }
  .history-cards { display: flex; }
  .history-toolbar { padding: 12px 12px; }
  .history-meta { padding: 8px 12px; }
}
