/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #2563eb;
  --blue-light: #eff6ff;
  --green: #16a34a;
  --red: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --radius: 12px;
  --header-height: 56px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  color: var(--gray-800);
  background: var(--gray-100);
  -webkit-font-smoothing: antialiased;
}

/* Screens */
.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* Auth */
.auth-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 48px 24px 32px;
}
.auth-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 4px;
}
.auth-subtitle {
  color: var(--gray-400);
  margin-bottom: 32px;
}

/* Header */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  max-width: 480px;
  margin: 0 auto;
}
.header-title {
  font-weight: 600;
  font-size: 1.1rem;
}

/* Main content */
.app-main {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(var(--header-height) + 12px) 16px 24px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: none;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s, background .15s;
}
.btn:active { opacity: .8; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-ghost { background: var(--gray-100); color: var(--gray-600); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 0.85rem; border-radius: 8px; }
.btn-full { width: 100%; }
.btn:disabled { background: var(--gray-200); color: var(--gray-400); cursor: not-allowed; pointer-events: none; }
.btn-icon {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  color: var(--gray-600);
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:active { background: var(--gray-100); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 6px;
}
.form-input {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  font-size: 16px;
  color: var(--gray-800);
  background: #fff;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--blue);
}
select.form-input {
  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='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.error-msg {
  color: var(--red);
  font-size: 0.85rem;
  padding: 8px 12px;
  background: #fef2f2;
  border-radius: 8px;
  margin-bottom: 8px;
}

.success-msg {
  color: var(--green);
  font-size: 0.85rem;
  padding: 8px 12px;
  background: #f0fdf4;
  border-radius: 8px;
  margin-bottom: 8px;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  text-align: center;
  padding: 32px;
  color: var(--gray-400);
}

/* Filter bar */
.filter-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.action-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* Logs table */
.logs-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 12px;
}
.logs-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.logs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: fixed;
}
.logs-table th {
  background: var(--gray-50);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.logs-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  color: var(--gray-800);
}
.logs-table tr:last-child td {
  border-bottom: none;
}
.logs-table tbody tr:hover td {
  background: var(--gray-50);
}
.col-time {
  white-space: nowrap;
  width: 45px;
  font-variant-numeric: tabular-nums;
  color: var(--gray-600);
}
.col-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col-phone {
  white-space: nowrap;
  width: 180px;
  font-variant-numeric: tabular-nums;
}
.phone-link {
  color: inherit;
  text-decoration: none;
}
.phone-link:hover {
  text-decoration: underline;
}
.copy-btn {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 2px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  border-radius: 3px;
  vertical-align: middle;
}
.copy-btn:hover {
  color: var(--gray-700);
  background: var(--gray-100);
}
.date-separator td {
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  border-bottom: 1px solid var(--gray-200);
}
.logs-empty {
  text-align: center;
  color: var(--gray-400);
  padding: 32px !important;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}
.page-info {
  font-size: 0.82rem;
  color: var(--gray-600);
}
.pagination-btns {
  display: flex;
  gap: 6px;
}
