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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 24px;
  color: #333;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
}

/* Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  padding: 16px 24px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  margin-bottom: 20px;
}

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

.header-icon { font-size: 28px; }

.header-title {
  font-size: 22px;
  font-weight: 700;
  color: #333;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-info {
  font-size: 13px;
  color: #888;
}

.btn-logout {
  padding: 8px 16px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  color: #666;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  border-color: #e74c3c;
  color: #e74c3c;
}

/* Error */
.error-box {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
}

/* Grid */
.main-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
}

@media (max-width: 860px) {
  .main-grid { grid-template-columns: 1fr; }
}

/* Card */
.card {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  color: #333;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f0;
}

/* Form */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e8e8e8;
  border-radius: 10px;
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: #667eea;
}

.apps-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f5f5f5;
  border: 2px solid #e8e8e8;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}

.app-chip input {
  display: none;
}

.app-chip.checked {
  background: #e8ecff;
  border-color: #667eea;
  color: #5464c8;
  font-weight: 600;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  margin-top: 4px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.45);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.msg {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
}

.msg.error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.msg.success {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

/* User List */
.user-list {
  max-height: 640px;
  overflow-y: auto;
  padding-right: 4px;
}

.loading {
  color: #aaa;
  text-align: center;
  padding: 30px 0;
}

.user-row {
  border: 1px solid #ececec;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: border-color 0.2s;
}

.user-row:hover {
  border-color: #d0d5ff;
}

.user-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.user-phone {
  font-size: 15px;
  font-weight: 700;
  color: #333;
}

.user-role {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  background: #eef2ff;
  color: #5464c8;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.user-role.admin-tag {
  background: #fff7e6;
  color: #d46b08;
}

.user-created {
  font-size: 12px;
  color: #aaa;
}

.user-row-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.user-apps-box {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.btn-save {
  padding: 6px 14px;
  background: #667eea;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-save:hover:not(:disabled) {
  background: #5464c8;
}

.btn-save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.row-msg {
  font-size: 12px;
  margin-left: 8px;
}

.row-msg.ok { color: #16a34a; }
.row-msg.err { color: #dc2626; }
